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",
"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"

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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;

View file

@ -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)

View file

@ -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
{

View file

@ -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'] ?? [],

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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)

View file

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

View file

@ -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

View file

@ -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;

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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
{

View file

@ -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>