mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Added all missing use statements from global functions and constants
This commit is contained in:
parent
77d810b735
commit
025135b8c6
36 changed files with 67 additions and 6 deletions
|
@ -50,7 +50,7 @@
|
|||
"infection/infection": "^0.9.0",
|
||||
"phpstan/phpstan": "^0.10.0",
|
||||
"phpunit/phpcov": "^5.0",
|
||||
"phpunit/phpunit": "^7.0",
|
||||
"phpunit/phpunit": "^7.3",
|
||||
"slevomat/coding-standard": "^4.0",
|
||||
"squizlabs/php_codesniffer": "^3.2.3",
|
||||
"symfony/dotenv": "^4.0",
|
||||
|
@ -101,15 +101,15 @@
|
|||
"@test:unit",
|
||||
"@test:func"
|
||||
],
|
||||
"test:unit": "phpunit --coverage-php build/coverage-unit.cov",
|
||||
"test:func": "phpunit -c phpunit-func.xml --coverage-php build/coverage-func.cov",
|
||||
"test:unit": "phpunit --coverage-php build/coverage-unit.cov --order-by=random",
|
||||
"test:func": "phpunit -c phpunit-func.xml --coverage-php build/coverage-func.cov --order-by=random",
|
||||
|
||||
"test:pretty": [
|
||||
"@test:unit",
|
||||
"@test:func",
|
||||
"phpcov merge build --html build/html"
|
||||
],
|
||||
"test:unit:pretty": "phpunit --coverage-html build/coverage",
|
||||
"test:unit:pretty": "phpunit --coverage-html build/coverage --order-by=random",
|
||||
|
||||
"infect": "infection --threads=4 --min-msi=60 --only-covered --log-verbosity=2",
|
||||
"infect:show": "infection --threads=4 --min-msi=60 --only-covered --log-verbosity=2 --show-mutations"
|
||||
|
|
|
@ -8,6 +8,9 @@ use Shlinkio\Shlink\CLI\Command\Config\GenerateCharsetCommand;
|
|||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use function implode;
|
||||
use function sort;
|
||||
use function str_split;
|
||||
|
||||
class GenerateCharsetCommandTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -16,6 +16,8 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||
use Zend\I18n\Translator\Translator;
|
||||
use Zend\Paginator\Adapter\ArrayAdapter;
|
||||
use Zend\Paginator\Paginator;
|
||||
use function count;
|
||||
use function substr_count;
|
||||
|
||||
class GeneratePreviewCommandTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\Service\UrlShortener;
|
|||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use function strpos;
|
||||
|
||||
class GenerateShortcodeCommandTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\Service\UrlShortener;
|
|||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use const PHP_EOL;
|
||||
|
||||
class ResolveUrlCommandTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ use Symfony\Component\Console\Application;
|
|||
use Symfony\Component\Console\Command\Command;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use Zend\ServiceManager\ServiceManager;
|
||||
use function array_merge;
|
||||
|
||||
class ApplicationFactoryTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ use function in_array;
|
|||
use function json_decode as spl_json_decode;
|
||||
use function json_last_error;
|
||||
use function json_last_error_msg;
|
||||
use function sprintf;
|
||||
use function strtolower;
|
||||
use function trim;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shlinkio\Shlink\Common\Exception;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class PreviewGenerationException extends RuntimeException
|
||||
{
|
||||
public static function fromImageError($error)
|
||||
|
|
|
@ -10,6 +10,11 @@ use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
|
|||
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
|
||||
use Zend\ServiceManager\Exception\ServiceNotFoundException;
|
||||
use Zend\ServiceManager\Factory\AbstractFactoryInterface;
|
||||
use function array_shift;
|
||||
use function explode;
|
||||
use function is_array;
|
||||
use function sprintf;
|
||||
use function substr_count;
|
||||
|
||||
class DottedAccessConfigAbstractFactory implements AbstractFactoryInterface
|
||||
{
|
||||
|
|
|
@ -33,7 +33,9 @@ class EntityManagerFactory implements FactoryInterface
|
|||
$connectionConfig = $emConfig['connection'] ?? [];
|
||||
$ormConfig = $emConfig['orm'] ?? [];
|
||||
|
||||
Type::addType(ChronosDateTimeType::CHRONOS_DATETIME, ChronosDateTimeType::class);
|
||||
if (! Type::hasType(ChronosDateTimeType::CHRONOS_DATETIME)) {
|
||||
Type::addType(ChronosDateTimeType::CHRONOS_DATETIME, ChronosDateTimeType::class);
|
||||
}
|
||||
|
||||
return EntityManager::create($connectionConfig, Setup::createAnnotationMetadataConfiguration(
|
||||
$ormConfig['entities_paths'] ?? [],
|
||||
|
|
|
@ -9,6 +9,8 @@ use Interop\Container\Exception\ContainerException;
|
|||
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
|
||||
use Zend\ServiceManager\Exception\ServiceNotFoundException;
|
||||
use Zend\ServiceManager\Factory\FactoryInterface;
|
||||
use function count;
|
||||
use function explode;
|
||||
|
||||
class LoggerFactory implements FactoryInterface
|
||||
{
|
||||
|
|
|
@ -8,6 +8,8 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
|||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface as DelegateInterface;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use function count;
|
||||
use function explode;
|
||||
|
||||
class LocaleMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
|
|
@ -7,6 +7,8 @@ use mikehaertl\wkhtmlto\Image;
|
|||
use Shlinkio\Shlink\Common\Exception\PreviewGenerationException;
|
||||
use Shlinkio\Shlink\Common\Image\ImageBuilderInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use function sprintf;
|
||||
use function urlencode;
|
||||
|
||||
class PreviewGenerator implements PreviewGeneratorInterface
|
||||
{
|
||||
|
|
|
@ -8,6 +8,8 @@ use Psr\Http\Message\ResponseInterface;
|
|||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\Stream;
|
||||
use Zend\Stdlib\ArrayUtils;
|
||||
use const FILEINFO_MIME;
|
||||
use function basename;
|
||||
|
||||
trait ResponseUtilsTrait
|
||||
{
|
||||
|
|
|
@ -12,6 +12,10 @@ use PHPUnit\Framework\TestCase;
|
|||
use Shlinkio\Shlink\Common\Factory\CacheFactory;
|
||||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||
use Zend\ServiceManager\ServiceManager;
|
||||
use function count;
|
||||
use function putenv;
|
||||
use function realpath;
|
||||
use function sys_get_temp_dir;
|
||||
|
||||
class CacheFactoryTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -11,6 +11,8 @@ use Shlinkio\Shlink\Common\Image\ImageBuilder;
|
|||
use Shlinkio\Shlink\Common\Service\PreviewGenerator;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Zend\ServiceManager\ServiceManager;
|
||||
use function sprintf;
|
||||
use function urlencode;
|
||||
|
||||
class PreviewGeneratorTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -3,6 +3,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shlinkio\Shlink\Core\Exception;
|
||||
|
||||
use function implode;
|
||||
use function sprintf;
|
||||
|
||||
class EntityDoesNotExistException extends RuntimeException
|
||||
{
|
||||
public static function createFromEntityAndConditions($entityName, array $conditions)
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
namespace Shlinkio\Shlink\Core\Exception;
|
||||
|
||||
use Throwable;
|
||||
use function sprintf;
|
||||
|
||||
class InvalidUrlException extends RuntimeException
|
||||
{
|
||||
|
|
|
@ -3,6 +3,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shlinkio\Shlink\Core\Exception;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class NonUniqueSlugException extends InvalidArgumentException
|
||||
{
|
||||
public static function fromSlug(string $slug): self
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Shlinkio\Shlink\Core\Exception;
|
|||
|
||||
use Throwable;
|
||||
use Zend\InputFilter\InputFilterInterface;
|
||||
use const PHP_EOL;
|
||||
use function is_array;
|
||||
use function print_r;
|
||||
use function sprintf;
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Shlinkio\Shlink\Core\Options;
|
|||
|
||||
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
|
||||
use Zend\Stdlib\AbstractOptions;
|
||||
use function sprintf;
|
||||
|
||||
class AppOptions extends AbstractOptions
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ use Shlinkio\Shlink\Core\Entity\Visit;
|
|||
use Shlinkio\Shlink\Core\Exception\InvalidArgumentException;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
use Shlinkio\Shlink\Core\Repository\VisitRepository;
|
||||
use function sprintf;
|
||||
|
||||
class VisitsTracker implements VisitsTrackerInterface
|
||||
{
|
||||
|
|
|
@ -18,6 +18,8 @@ use Shlinkio\Shlink\Core\Service\UrlShortener;
|
|||
use ShlinkioTest\Shlink\Common\Util\TestUtils;
|
||||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use const FILEINFO_MIME;
|
||||
use function filesize;
|
||||
|
||||
class PreviewActionTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
|
|||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
|
||||
use Shlinkio\Shlink\Core\Service\ShortUrlService;
|
||||
use function count;
|
||||
|
||||
class ShortUrlServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ use Symfony\Component\Filesystem\Exception\IOException;
|
|||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
use Zend\Config\Writer\WriterInterface;
|
||||
use function sprintf;
|
||||
|
||||
class InstallCommand extends Command
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
|
|||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
use Zend\I18n\Translator\TranslatorInterface;
|
||||
use function sprintf;
|
||||
|
||||
class EditShortUrlTagsAction extends AbstractRestAction
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ use Shlinkio\Shlink\Rest\Util\RestUtils;
|
|||
use Zend\Diactoros\Response\EmptyResponse;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
use Zend\I18n\Translator\TranslatorInterface;
|
||||
use function sprintf;
|
||||
|
||||
class UpdateTagAction extends AbstractRestAction
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
|
|||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
use Zend\I18n\Translator\TranslatorInterface;
|
||||
use function sprintf;
|
||||
|
||||
class GetVisitsAction extends AbstractRestAction
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use function strpos;
|
||||
|
||||
class AuthenticateActionTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ use Shlinkio\Shlink\Rest\Util\RestUtils;
|
|||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\Diactoros\Uri;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use function strpos;
|
||||
|
||||
class CreateShortUrlActionTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@ use Shlinkio\Shlink\Rest\Action\ShortUrl\ResolveShortUrlAction;
|
|||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use function strpos;
|
||||
|
||||
class ResolveShortUrlActionTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase;
|
|||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||
use Shlinkio\Shlink\Rest\Authentication\JWTService;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
use function time;
|
||||
|
||||
class JWTServiceTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@ use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException;
|
|||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
use function sprintf;
|
||||
|
||||
class AuthorizationHeaderPluginTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -12,6 +12,8 @@ use Shlinkio\Shlink\Rest\Authentication\Plugin\AuthorizationHeaderPlugin;
|
|||
use Shlinkio\Shlink\Rest\Authentication\RequestToHttpAuthPlugin;
|
||||
use Shlinkio\Shlink\Rest\Exception\NoAuthenticationException;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use function implode;
|
||||
use function sprintf;
|
||||
|
||||
class RequestToAuthPluginTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware;
|
|||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\Diactoros\Stream;
|
||||
use function array_shift;
|
||||
|
||||
class BodyParserMiddlewareTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -40,7 +40,12 @@
|
|||
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
|
||||
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
|
||||
<!-- Enforce all global namespace classes, functions and constants to be explicitly imported -->
|
||||
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
|
||||
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
|
||||
<properties>
|
||||
<property name="allowFallbackGlobalFunctions" value="false"/>
|
||||
<property name="allowFallbackGlobalConstants" value="false"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<!-- Paths to check -->
|
||||
<file>bin</file>
|
||||
|
|
Loading…
Add table
Reference in a new issue