From f64f59a9c0d92fdd65f9de3e44b612402b224aaf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Feb 2020 10:47:34 +0100 Subject: [PATCH] Fix CS --- .../DeprecationErrorHandler/Deprecation.php | 2 +- src/Symfony/Bridge/Twig/Node/DumpNode.php | 3 --- .../TranslationDefaultDomainNodeVisitor.php | 2 -- .../NodeVisitor/TranslationNodeVisitor.php | 2 -- .../Debug/WrappedLazyListener.php | 1 - .../Tests/Functional/Bundle/TestBundle.php | 1 - .../Compiler/ExtensionPass.php | 1 - .../Component/Cache/Adapter/PdoAdapter.php | 2 +- .../Component/Console/Command/Command.php | 2 +- .../DependencyInjection/Loader/FileLoader.php | 2 +- .../Loader/IniFileLoader.php | 2 +- .../Fragment/HIncludeFragmentRenderer.php | 3 --- .../Transport/AbstractTransportFactory.php | 1 - .../Component/Security/Http/Firewall.php | 1 - .../Tests/Firewall/ContextListenerTest.php | 5 ++-- .../Component/String/AbstractString.php | 24 +++++++++---------- .../String/AbstractUnicodeString.php | 6 ++--- src/Symfony/Component/String/ByteString.php | 4 ++-- .../Constraints/ExpressionValidatorTest.php | 1 - .../LazyLoadingMetadataFactoryTest.php | 1 - .../VarDumper/Test/VarDumperTestTrait.php | 3 --- .../VarExporter/Internal/Exporter.php | 2 -- 22 files changed, 25 insertions(+), 46 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index 6263267fef..eef3f62a06 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -247,7 +247,7 @@ class Deprecation foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $v = \dirname(\dirname($r->getFileName())); + $v = \dirname($r->getFileName(), 2); if (file_exists($v.'/composer/installed.json')) { self::$vendors[] = $v; $loader = require $v.'/autoload.php'; diff --git a/src/Symfony/Bridge/Twig/Node/DumpNode.php b/src/Symfony/Bridge/Twig/Node/DumpNode.php index e94f1b7189..16718e8a75 100644 --- a/src/Symfony/Bridge/Twig/Node/DumpNode.php +++ b/src/Symfony/Bridge/Twig/Node/DumpNode.php @@ -32,9 +32,6 @@ final class DumpNode extends Node $this->varPrefix = $varPrefix; } - /** - * @return void - */ public function compile(Compiler $compiler): void { $compiler diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index d8a791b3a4..55bc3ae9a8 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -107,8 +107,6 @@ final class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor /** * {@inheritdoc} - * - * @return int */ public function getPriority(): int { diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php index 2764afc0a4..89a15cd622 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php @@ -97,8 +97,6 @@ final class TranslationNodeVisitor extends AbstractNodeVisitor /** * {@inheritdoc} - * - * @return int */ public function getPriority(): int { diff --git a/src/Symfony/Bundle/SecurityBundle/Debug/WrappedLazyListener.php b/src/Symfony/Bundle/SecurityBundle/Debug/WrappedLazyListener.php index 67b178f3f6..8e06d6ed1e 100644 --- a/src/Symfony/Bundle/SecurityBundle/Debug/WrappedLazyListener.php +++ b/src/Symfony/Bundle/SecurityBundle/Debug/WrappedLazyListener.php @@ -15,7 +15,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\Security\Core\Exception\LazyResponseException; use Symfony\Component\Security\Http\Firewall\AbstractListener; -use Symfony\Component\VarDumper\Caster\ClassStub; /** * Wraps a lazy security listener. diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/TestBundle.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/TestBundle.php index d302b63791..8336dce245 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/TestBundle.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/TestBundle.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle; use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index 062d843cd0..6c955aae6f 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -11,7 +11,6 @@ namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler; -use Symfony\Bridge\Twig\Extension\AssetExtension; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php index a7b6780acd..99a671516a 100644 --- a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php @@ -427,7 +427,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface } else { switch ($this->driver = $this->conn->getDriver()->getName()) { case 'mysqli': - throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', \get_class($this))); + throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', static::class)); case 'pdo_mysql': case 'drizzle_pdo_mysql': $this->driver = 'mysql'; diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index cfb29a2a6f..07da4a9223 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -255,7 +255,7 @@ class Command $statusCode = $this->execute($input, $output); if (!\is_int($statusCode)) { - throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, %s returned.', \get_class($this), \gettype($statusCode))); + throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, %s returned.', static::class, \gettype($statusCode))); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php index 26577c9ef8..eff0866e50 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -57,7 +57,7 @@ abstract class FileLoader extends BaseFileLoader if ($ignoreNotFound = 'not_found' === $ignoreErrors) { $args[2] = false; } elseif (!\is_bool($ignoreErrors)) { - throw new \TypeError(sprintf('Invalid argument $ignoreErrors provided to %s::import(): boolean or "not_found" expected, %s given.', \get_class($this), \gettype($ignoreErrors))); + throw new \TypeError(sprintf('Invalid argument $ignoreErrors provided to %s::import(): boolean or "not_found" expected, %s given.', static::class, \gettype($ignoreErrors))); } try { diff --git a/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php index 8ed1e42778..e6384803c3 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php @@ -49,7 +49,7 @@ class IniFileLoader extends FileLoader /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports($resource, string $type = null) { if (!\is_string($resource)) { return false; diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 9db6557663..618859d0f9 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -16,9 +16,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\UriSigner; use Twig\Environment; -use Twig\Error\LoaderError; -use Twig\Loader\ExistsLoaderInterface; -use Twig\Loader\SourceContextLoaderInterface; /** * Implements the Hinclude rendering strategy. diff --git a/src/Symfony/Component/Notifier/Transport/AbstractTransportFactory.php b/src/Symfony/Component/Notifier/Transport/AbstractTransportFactory.php index 2b0cae4b20..98e97be5f8 100644 --- a/src/Symfony/Component/Notifier/Transport/AbstractTransportFactory.php +++ b/src/Symfony/Component/Notifier/Transport/AbstractTransportFactory.php @@ -18,7 +18,6 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; /** * @author Konstantin Myakshin - * * @author Fabien Potencier * * @experimental in 5.0 diff --git a/src/Symfony/Component/Security/Http/Firewall.php b/src/Symfony/Component/Security/Http/Firewall.php index 7ccccdb623..b239911b8b 100644 --- a/src/Symfony/Component/Security/Http/Firewall.php +++ b/src/Symfony/Component/Security/Http/Firewall.php @@ -15,7 +15,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\Security\Http\Firewall\AbstractListener; use Symfony\Component\Security\Http\Firewall\AccessListener; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index 187058f514..6eef745579 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -399,8 +399,9 @@ class ContextListenerTest extends TestCase $tokenStorage = new TokenStorage(); $usageIndex = $session->getUsageIndex(); - $tokenStorage = new UsageTrackingTokenStorage($tokenStorage, new class([ - 'session' => function () use ($session) { return $session; } + $tokenStorage = new UsageTrackingTokenStorage($tokenStorage, new class(['session' => function () use ($session) { + return $session; + }, ]) implements ContainerInterface { use ServiceLocatorTrait; }); diff --git a/src/Symfony/Component/String/AbstractString.php b/src/Symfony/Component/String/AbstractString.php index e56697e391..73daa1d495 100644 --- a/src/Symfony/Component/String/AbstractString.php +++ b/src/Symfony/Component/String/AbstractString.php @@ -31,15 +31,15 @@ use Symfony\Component\String\Exception\RuntimeException; */ abstract class AbstractString implements \JsonSerializable { - public const PREG_PATTERN_ORDER = \PREG_PATTERN_ORDER; - public const PREG_SET_ORDER = \PREG_SET_ORDER; - public const PREG_OFFSET_CAPTURE = \PREG_OFFSET_CAPTURE; - public const PREG_UNMATCHED_AS_NULL = \PREG_UNMATCHED_AS_NULL; + public const PREG_PATTERN_ORDER = PREG_PATTERN_ORDER; + public const PREG_SET_ORDER = PREG_SET_ORDER; + public const PREG_OFFSET_CAPTURE = PREG_OFFSET_CAPTURE; + public const PREG_UNMATCHED_AS_NULL = PREG_UNMATCHED_AS_NULL; public const PREG_SPLIT = 0; - public const PREG_SPLIT_NO_EMPTY = \PREG_SPLIT_NO_EMPTY; - public const PREG_SPLIT_DELIM_CAPTURE = \PREG_SPLIT_DELIM_CAPTURE; - public const PREG_SPLIT_OFFSET_CAPTURE = \PREG_SPLIT_OFFSET_CAPTURE; + public const PREG_SPLIT_NO_EMPTY = PREG_SPLIT_NO_EMPTY; + public const PREG_SPLIT_DELIM_CAPTURE = PREG_SPLIT_DELIM_CAPTURE; + public const PREG_SPLIT_OFFSET_CAPTURE = PREG_SPLIT_OFFSET_CAPTURE; protected $string = ''; protected $ignoreCase = false; @@ -262,7 +262,7 @@ abstract class AbstractString implements \JsonSerializable public function endsWith($suffix): bool { if (!\is_array($suffix) && !$suffix instanceof \Traversable) { - throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, \get_class($this))); + throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); } foreach ($suffix as $s) { @@ -317,7 +317,7 @@ abstract class AbstractString implements \JsonSerializable public function equalsTo($string): bool { if (!\is_array($string) && !$string instanceof \Traversable) { - throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, \get_class($this))); + throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); } foreach ($string as $s) { @@ -351,7 +351,7 @@ abstract class AbstractString implements \JsonSerializable public function indexOf($needle, int $offset = 0): ?int { if (!\is_array($needle) && !$needle instanceof \Traversable) { - throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, \get_class($this))); + throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); } $i = \PHP_INT_MAX; @@ -373,7 +373,7 @@ abstract class AbstractString implements \JsonSerializable public function indexOfLast($needle, int $offset = 0): ?int { if (!\is_array($needle) && !$needle instanceof \Traversable) { - throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, \get_class($this))); + throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); } $i = null; @@ -536,7 +536,7 @@ abstract class AbstractString implements \JsonSerializable public function startsWith($prefix): bool { if (!\is_array($prefix) && !$prefix instanceof \Traversable) { - throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, \get_class($this))); + throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); } foreach ($prefix as $prefix) { diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index bc3e05cd6f..1e1b9d7de6 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -139,7 +139,7 @@ abstract class AbstractUnicodeString extends AbstractString } } elseif (!\function_exists('iconv')) { $s = preg_replace('/[^\x00-\x7F]/u', '?', $s); - } elseif (\ICONV_IMPL === 'glibc') { + } elseif (ICONV_IMPL === 'glibc') { $s = iconv('UTF-8', 'ASCII//TRANSLIT', $s); } else { $s = preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) { @@ -223,7 +223,7 @@ abstract class AbstractUnicodeString extends AbstractString public function match(string $regexp, int $flags = 0, int $offset = 0): array { - $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; + $match = ((PREG_PATTERN_ORDER | PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; if ($this->ignoreCase) { $regexp .= 'i'; @@ -309,7 +309,7 @@ abstract class AbstractUnicodeString extends AbstractString if (\is_array($to) || $to instanceof \Closure) { if (!\is_callable($to)) { - throw new \TypeError(sprintf('Argument 2 passed to %s::replaceMatches() must be callable, array given.', \get_class($this))); + throw new \TypeError(sprintf('Argument 2 passed to %s::replaceMatches() must be callable, array given.', static::class)); } $replace = 'preg_replace_callback'; diff --git a/src/Symfony/Component/String/ByteString.php b/src/Symfony/Component/String/ByteString.php index d831940e16..b1bb82ec22 100644 --- a/src/Symfony/Component/String/ByteString.php +++ b/src/Symfony/Component/String/ByteString.php @@ -193,7 +193,7 @@ class ByteString extends AbstractString public function match(string $regexp, int $flags = 0, int $offset = 0): array { - $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; + $match = ((PREG_PATTERN_ORDER | PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; if ($this->ignoreCase) { $regexp .= 'i'; @@ -271,7 +271,7 @@ class ByteString extends AbstractString if (\is_array($to)) { if (!\is_callable($to)) { - throw new \TypeError(sprintf('Argument 2 passed to %s::replaceMatches() must be callable, array given.', \get_class($this))); + throw new \TypeError(sprintf('Argument 2 passed to %s::replaceMatches() must be callable, array given.', static::class)); } $replace = 'preg_replace_callback'; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 34d280b5da..280757b8e9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\Validator\Constraints\Expression; use Symfony\Component\Validator\Constraints\ExpressionValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index 6eb82b7585..2cda5c6310 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php @@ -15,7 +15,6 @@ use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Validator\Constraints\Callback; -use Symfony\Component\Validator\Mapping\Cache\Psr6Cache; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; diff --git a/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php b/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php index 258419c8f3..33d60c0201 100644 --- a/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php +++ b/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php @@ -52,9 +52,6 @@ trait VarDumperTestTrait $this->assertStringMatchesFormat($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message); } - /** - * @return string|null - */ protected function getDump($data, $key = null, int $filter = 0): ?string { if (null === $flags = $this->varDumperConfig['flags']) { diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index 4d83a4b094..776f3bb380 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -31,8 +31,6 @@ class Exporter * @param int &$objectsCount * @param bool &$valuesAreStatic * - * @return array - * * @throws NotInstantiableTypeException When a value cannot be serialized */ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount, &$valuesAreStatic): array