Added all missing use statements from global functions and constants

This commit is contained in:
Alejandro Celaya 2018-10-28 08:34:02 +01:00
parent 77d810b735
commit 025135b8c6
36 changed files with 67 additions and 6 deletions

View File

@ -50,7 +50,7 @@
"infection/infection": "^0.9.0", "infection/infection": "^0.9.0",
"phpstan/phpstan": "^0.10.0", "phpstan/phpstan": "^0.10.0",
"phpunit/phpcov": "^5.0", "phpunit/phpcov": "^5.0",
"phpunit/phpunit": "^7.0", "phpunit/phpunit": "^7.3",
"slevomat/coding-standard": "^4.0", "slevomat/coding-standard": "^4.0",
"squizlabs/php_codesniffer": "^3.2.3", "squizlabs/php_codesniffer": "^3.2.3",
"symfony/dotenv": "^4.0", "symfony/dotenv": "^4.0",
@ -101,15 +101,15 @@
"@test:unit", "@test:unit",
"@test:func" "@test:func"
], ],
"test:unit": "phpunit --coverage-php build/coverage-unit.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", "test:func": "phpunit -c phpunit-func.xml --coverage-php build/coverage-func.cov --order-by=random",
"test:pretty": [ "test:pretty": [
"@test:unit", "@test:unit",
"@test:func", "@test:func",
"phpcov merge build --html build/html" "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": "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" "infect:show": "infection --threads=4 --min-msi=60 --only-covered --log-verbosity=2 --show-mutations"

View File

@ -8,6 +8,9 @@ use Shlinkio\Shlink\CLI\Command\Config\GenerateCharsetCommand;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Tester\CommandTester;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use function implode;
use function sort;
use function str_split;
class GenerateCharsetCommandTest extends TestCase class GenerateCharsetCommandTest extends TestCase
{ {

View File

@ -16,6 +16,8 @@ use Symfony\Component\Console\Tester\CommandTester;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use Zend\Paginator\Adapter\ArrayAdapter; use Zend\Paginator\Adapter\ArrayAdapter;
use Zend\Paginator\Paginator; use Zend\Paginator\Paginator;
use function count;
use function substr_count;
class GeneratePreviewCommandTest extends TestCase class GeneratePreviewCommandTest extends TestCase
{ {

View File

@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\Service\UrlShortener;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Tester\CommandTester;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use function strpos;
class GenerateShortcodeCommandTest extends TestCase class GenerateShortcodeCommandTest extends TestCase
{ {

View File

@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\Service\UrlShortener;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Tester\CommandTester;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use const PHP_EOL;
class ResolveUrlCommandTest extends TestCase class ResolveUrlCommandTest extends TestCase
{ {

View File

@ -10,6 +10,7 @@ use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use Zend\ServiceManager\ServiceManager; use Zend\ServiceManager\ServiceManager;
use function array_merge;
class ApplicationFactoryTest extends TestCase class ApplicationFactoryTest extends TestCase
{ {

View File

@ -9,6 +9,7 @@ use function in_array;
use function json_decode as spl_json_decode; use function json_decode as spl_json_decode;
use function json_last_error; use function json_last_error;
use function json_last_error_msg; use function json_last_error_msg;
use function sprintf;
use function strtolower; use function strtolower;
use function trim; use function trim;

View File

@ -3,6 +3,8 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception; namespace Shlinkio\Shlink\Common\Exception;
use function sprintf;
class PreviewGenerationException extends RuntimeException class PreviewGenerationException extends RuntimeException
{ {
public static function fromImageError($error) public static function fromImageError($error)

View File

@ -10,6 +10,11 @@ use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
use Zend\ServiceManager\Exception\ServiceNotCreatedException; use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException; use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\Factory\AbstractFactoryInterface; 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 class DottedAccessConfigAbstractFactory implements AbstractFactoryInterface
{ {

View File

@ -33,7 +33,9 @@ class EntityManagerFactory implements FactoryInterface
$connectionConfig = $emConfig['connection'] ?? []; $connectionConfig = $emConfig['connection'] ?? [];
$ormConfig = $emConfig['orm'] ?? []; $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( return EntityManager::create($connectionConfig, Setup::createAnnotationMetadataConfiguration(
$ormConfig['entities_paths'] ?? [], $ormConfig['entities_paths'] ?? [],

View File

@ -9,6 +9,8 @@ use Interop\Container\Exception\ContainerException;
use Zend\ServiceManager\Exception\ServiceNotCreatedException; use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException; use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\Factory\FactoryInterface; use Zend\ServiceManager\Factory\FactoryInterface;
use function count;
use function explode;
class LoggerFactory implements FactoryInterface class LoggerFactory implements FactoryInterface
{ {

View File

@ -8,6 +8,8 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; use Psr\Http\Server\RequestHandlerInterface as DelegateInterface;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use function count;
use function explode;
class LocaleMiddleware implements MiddlewareInterface class LocaleMiddleware implements MiddlewareInterface
{ {

View File

@ -7,6 +7,8 @@ use mikehaertl\wkhtmlto\Image;
use Shlinkio\Shlink\Common\Exception\PreviewGenerationException; use Shlinkio\Shlink\Common\Exception\PreviewGenerationException;
use Shlinkio\Shlink\Common\Image\ImageBuilderInterface; use Shlinkio\Shlink\Common\Image\ImageBuilderInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use function sprintf;
use function urlencode;
class PreviewGenerator implements PreviewGeneratorInterface class PreviewGenerator implements PreviewGeneratorInterface
{ {

View File

@ -8,6 +8,8 @@ use Psr\Http\Message\ResponseInterface;
use Zend\Diactoros\Response; use Zend\Diactoros\Response;
use Zend\Diactoros\Stream; use Zend\Diactoros\Stream;
use Zend\Stdlib\ArrayUtils; use Zend\Stdlib\ArrayUtils;
use const FILEINFO_MIME;
use function basename;
trait ResponseUtilsTrait trait ResponseUtilsTrait
{ {

View File

@ -12,6 +12,10 @@ use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Factory\CacheFactory; use Shlinkio\Shlink\Common\Factory\CacheFactory;
use Shlinkio\Shlink\Core\Options\AppOptions; use Shlinkio\Shlink\Core\Options\AppOptions;
use Zend\ServiceManager\ServiceManager; use Zend\ServiceManager\ServiceManager;
use function count;
use function putenv;
use function realpath;
use function sys_get_temp_dir;
class CacheFactoryTest extends TestCase class CacheFactoryTest extends TestCase
{ {

View File

@ -11,6 +11,8 @@ use Shlinkio\Shlink\Common\Image\ImageBuilder;
use Shlinkio\Shlink\Common\Service\PreviewGenerator; use Shlinkio\Shlink\Common\Service\PreviewGenerator;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Zend\ServiceManager\ServiceManager; use Zend\ServiceManager\ServiceManager;
use function sprintf;
use function urlencode;
class PreviewGeneratorTest extends TestCase class PreviewGeneratorTest extends TestCase
{ {

View File

@ -3,6 +3,9 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Exception; namespace Shlinkio\Shlink\Core\Exception;
use function implode;
use function sprintf;
class EntityDoesNotExistException extends RuntimeException class EntityDoesNotExistException extends RuntimeException
{ {
public static function createFromEntityAndConditions($entityName, array $conditions) public static function createFromEntityAndConditions($entityName, array $conditions)

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Exception; namespace Shlinkio\Shlink\Core\Exception;
use Throwable; use Throwable;
use function sprintf;
class InvalidUrlException extends RuntimeException class InvalidUrlException extends RuntimeException
{ {

View File

@ -3,6 +3,8 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Exception; namespace Shlinkio\Shlink\Core\Exception;
use function sprintf;
class NonUniqueSlugException extends InvalidArgumentException class NonUniqueSlugException extends InvalidArgumentException
{ {
public static function fromSlug(string $slug): self public static function fromSlug(string $slug): self

View File

@ -5,6 +5,7 @@ namespace Shlinkio\Shlink\Core\Exception;
use Throwable; use Throwable;
use Zend\InputFilter\InputFilterInterface; use Zend\InputFilter\InputFilterInterface;
use const PHP_EOL;
use function is_array; use function is_array;
use function print_r; use function print_r;
use function sprintf; use function sprintf;

View File

@ -5,6 +5,7 @@ namespace Shlinkio\Shlink\Core\Options;
use Shlinkio\Shlink\Common\Util\StringUtilsTrait; use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
use Zend\Stdlib\AbstractOptions; use Zend\Stdlib\AbstractOptions;
use function sprintf;
class AppOptions extends AbstractOptions class AppOptions extends AbstractOptions
{ {

View File

@ -10,6 +10,7 @@ use Shlinkio\Shlink\Core\Entity\Visit;
use Shlinkio\Shlink\Core\Exception\InvalidArgumentException; use Shlinkio\Shlink\Core\Exception\InvalidArgumentException;
use Shlinkio\Shlink\Core\Model\Visitor; use Shlinkio\Shlink\Core\Model\Visitor;
use Shlinkio\Shlink\Core\Repository\VisitRepository; use Shlinkio\Shlink\Core\Repository\VisitRepository;
use function sprintf;
class VisitsTracker implements VisitsTrackerInterface class VisitsTracker implements VisitsTrackerInterface
{ {

View File

@ -18,6 +18,8 @@ use Shlinkio\Shlink\Core\Service\UrlShortener;
use ShlinkioTest\Shlink\Common\Util\TestUtils; use ShlinkioTest\Shlink\Common\Util\TestUtils;
use Zend\Diactoros\Response; use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\ServerRequestFactory;
use const FILEINFO_MIME;
use function filesize;
class PreviewActionTest extends TestCase class PreviewActionTest extends TestCase
{ {

View File

@ -15,6 +15,7 @@ use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta; use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository; use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
use Shlinkio\Shlink\Core\Service\ShortUrlService; use Shlinkio\Shlink\Core\Service\ShortUrlService;
use function count;
class ShortUrlServiceTest extends TestCase class ShortUrlServiceTest extends TestCase
{ {

View File

@ -21,6 +21,7 @@ use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
use Zend\Config\Writer\WriterInterface; use Zend\Config\Writer\WriterInterface;
use function sprintf;
class InstallCommand extends Command class InstallCommand extends Command
{ {

View File

@ -12,6 +12,7 @@ use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
use Shlinkio\Shlink\Rest\Util\RestUtils; use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\Response\JsonResponse; use Zend\Diactoros\Response\JsonResponse;
use Zend\I18n\Translator\TranslatorInterface; use Zend\I18n\Translator\TranslatorInterface;
use function sprintf;
class EditShortUrlTagsAction extends AbstractRestAction class EditShortUrlTagsAction extends AbstractRestAction
{ {

View File

@ -13,6 +13,7 @@ use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\Response\EmptyResponse; use Zend\Diactoros\Response\EmptyResponse;
use Zend\Diactoros\Response\JsonResponse; use Zend\Diactoros\Response\JsonResponse;
use Zend\I18n\Translator\TranslatorInterface; use Zend\I18n\Translator\TranslatorInterface;
use function sprintf;
class UpdateTagAction extends AbstractRestAction class UpdateTagAction extends AbstractRestAction
{ {

View File

@ -15,6 +15,7 @@ use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
use Shlinkio\Shlink\Rest\Util\RestUtils; use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\Response\JsonResponse; use Zend\Diactoros\Response\JsonResponse;
use Zend\I18n\Translator\TranslatorInterface; use Zend\I18n\Translator\TranslatorInterface;
use function sprintf;
class GetVisitsAction extends AbstractRestAction class GetVisitsAction extends AbstractRestAction
{ {

View File

@ -12,6 +12,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
use Shlinkio\Shlink\Rest\Service\ApiKeyService; use Shlinkio\Shlink\Rest\Service\ApiKeyService;
use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\ServerRequestFactory;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use function strpos;
class AuthenticateActionTest extends TestCase class AuthenticateActionTest extends TestCase
{ {

View File

@ -16,6 +16,7 @@ use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\ServerRequestFactory;
use Zend\Diactoros\Uri; use Zend\Diactoros\Uri;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use function strpos;
class CreateShortUrlActionTest extends TestCase class CreateShortUrlActionTest extends TestCase
{ {

View File

@ -14,6 +14,7 @@ use Shlinkio\Shlink\Rest\Action\ShortUrl\ResolveShortUrlAction;
use Shlinkio\Shlink\Rest\Util\RestUtils; use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\ServerRequestFactory;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use function strpos;
class ResolveShortUrlActionTest extends TestCase class ResolveShortUrlActionTest extends TestCase
{ {

View File

@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Options\AppOptions; use Shlinkio\Shlink\Core\Options\AppOptions;
use Shlinkio\Shlink\Rest\Authentication\JWTService; use Shlinkio\Shlink\Rest\Authentication\JWTService;
use Shlinkio\Shlink\Rest\Entity\ApiKey; use Shlinkio\Shlink\Rest\Entity\ApiKey;
use function time;
class JWTServiceTest extends TestCase class JWTServiceTest extends TestCase
{ {

View File

@ -11,6 +11,7 @@ use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException;
use Zend\Diactoros\Response; use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\ServerRequestFactory;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use function sprintf;
class AuthorizationHeaderPluginTest extends TestCase class AuthorizationHeaderPluginTest extends TestCase
{ {

View File

@ -12,6 +12,8 @@ use Shlinkio\Shlink\Rest\Authentication\Plugin\AuthorizationHeaderPlugin;
use Shlinkio\Shlink\Rest\Authentication\RequestToHttpAuthPlugin; use Shlinkio\Shlink\Rest\Authentication\RequestToHttpAuthPlugin;
use Shlinkio\Shlink\Rest\Exception\NoAuthenticationException; use Shlinkio\Shlink\Rest\Exception\NoAuthenticationException;
use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\ServerRequestFactory;
use function implode;
use function sprintf;
class RequestToAuthPluginTest extends TestCase class RequestToAuthPluginTest extends TestCase
{ {

View File

@ -12,6 +12,7 @@ use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware;
use Zend\Diactoros\Response; use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\ServerRequestFactory;
use Zend\Diactoros\Stream; use Zend\Diactoros\Stream;
use function array_shift;
class BodyParserMiddlewareTest extends TestCase class BodyParserMiddlewareTest extends TestCase
{ {

View File

@ -40,7 +40,12 @@
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/> <rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/> <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<!-- Enforce all global namespace classes, functions and constants to be explicitly imported --> <!-- 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 --> <!-- Paths to check -->
<file>bin</file> <file>bin</file>