diff --git a/.php_cs.dist b/.php_cs.dist index fd6832920b..ac3e985281 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -15,7 +15,7 @@ return PhpCsFixer\Config::create() 'ordered_imports' => true, 'protected_to_private' => false, // Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading - 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], + 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true], // Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], ]) diff --git a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php index 24aa66a7dd..709b66e01b 100644 --- a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php +++ b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php @@ -61,7 +61,7 @@ class DoctrineTestHelper $config = new Configuration(); $config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']); $config->setAutoGenerateProxyClasses(true); - $config->setProxyDir(\sys_get_temp_dir()); + $config->setProxyDir(sys_get_temp_dir()); $config->setProxyNamespace('SymfonyTests\Doctrine'); $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader())); $config->setQueryCacheImpl(new ArrayCache()); diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 47cb2bd730..cf0ed8c962 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -186,7 +186,7 @@ class UniqueEntityValidator extends ConstraintValidator return $this->formatValue($value, self::PRETTY_DATE); } - if (\method_exists($value, '__toString')) { + if (method_exists($value, '__toString')) { return (string) $value; } diff --git a/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php b/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php index 24a670de79..f4e37ff44e 100644 --- a/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php @@ -67,7 +67,7 @@ class DebugProcessor implements DebugLoggerInterface, ResetInterface @trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); } - if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) { + if (1 <= \func_num_args() && null !== $request = func_get_arg(0)) { return $this->records[spl_object_hash($request)] ?? []; } @@ -89,7 +89,7 @@ class DebugProcessor implements DebugLoggerInterface, ResetInterface @trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); } - if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) { + if (1 <= \func_num_args() && null !== $request = func_get_arg(0)) { return $this->errorCount[spl_object_hash($request)] ?? 0; } diff --git a/src/Symfony/Bridge/PhpUnit/ClassExistsMock.php b/src/Symfony/Bridge/PhpUnit/ClassExistsMock.php index e8ca4ac940..fbd0a4fa4d 100644 --- a/src/Symfony/Bridge/PhpUnit/ClassExistsMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClassExistsMock.php @@ -30,17 +30,17 @@ class ClassExistsMock public static function class_exists($name, $autoload = true) { - return (bool) (self::$classes[ltrim($name, '\\')] ?? \class_exists($name, $autoload)); + return (bool) (self::$classes[ltrim($name, '\\')] ?? class_exists($name, $autoload)); } public static function interface_exists($name, $autoload = true) { - return (bool) (self::$classes[ltrim($name, '\\')] ?? \interface_exists($name, $autoload)); + return (bool) (self::$classes[ltrim($name, '\\')] ?? interface_exists($name, $autoload)); } public static function trait_exists($name, $autoload = true) { - return (bool) (self::$classes[ltrim($name, '\\')] ?? \trait_exists($name, $autoload)); + return (bool) (self::$classes[ltrim($name, '\\')] ?? trait_exists($name, $autoload)); } public static function register($class) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php index 44f0341205..6b42814bbc 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php @@ -90,9 +90,12 @@ class Configuration */ public function tolerates(array $deprecations) { - $deprecationCounts = array_filter($deprecations, function ($key) { - return false !== strpos($key, 'Count') && false === strpos($key, 'legacy'); - }, ARRAY_FILTER_USE_KEY); + $deprecationCounts = []; + foreach ($deprecations as $key => $deprecation) { + if (false !== strpos($key, 'Count') && false === strpos($key, 'legacy')) { + $deprecationCounts[$key] = $deprecation; + } + } if (array_sum($deprecationCounts) > $this->thresholds['total']) { return false; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 632a4ca878..bb1e8ab4c2 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -53,7 +53,7 @@ class SymfonyTestsListenerTrait Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; } - $enableDebugClassLoader = \class_exists('Symfony\Component\Debug\DebugClassLoader'); + $enableDebugClassLoader = class_exists('Symfony\Component\Debug\DebugClassLoader'); foreach ($mockedNamespaces as $type => $namespaces) { if (!\is_array($namespaces)) { diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index 70ca302aff..e09d540748 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -99,7 +99,7 @@ EOF; private static function getProxyManagerVersion(): string { - if (!\class_exists(Version::class)) { + if (!class_exists(Version::class)) { return '0.0.1'; } diff --git a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php index a72339e124..e7421b16d7 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php @@ -46,7 +46,7 @@ class HttpFoundationExtension extends AbstractExtension $requestContext = null; if (2 === \func_num_args()) { - $requestContext = \func_get_arg(1); + $requestContext = func_get_arg(1); if (null !== $requestContext && !$requestContext instanceof RequestContext) { throw new \TypeError(sprintf('The second argument must be an instance of "%s".', RequestContext::class)); } diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 516dd75387..f6a52c2e02 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -295,7 +295,7 @@ TXT $tester = $this->createCommandTester([], [], null, null, false, ['message' => $message]); $tester->execute([], ['decorated' => true]); $display = $tester->getDisplay(); - $this->assertContains(\json_encode($message), $display); + $this->assertContains(json_encode($message), $display); } public function testWithGlobalsJson() @@ -304,7 +304,7 @@ TXT $tester = $this->createCommandTester([], [], null, null, false, $globals); $tester->execute(['--format' => 'json'], ['decorated' => true]); $display = $tester->getDisplay(); - $display = \json_decode($display, true); + $display = json_decode($display, true); $this->assertSame($globals, $display['globals']); } @@ -313,10 +313,10 @@ TXT $tester = $this->createCommandTester(); $tester->execute(['--format' => 'json'], ['decorated' => false]); $display = $tester->getDisplay(); - $display1 = \json_decode($display, true); + $display1 = json_decode($display, true); $tester->execute(['--filter' => 'date', '--format' => 'json'], ['decorated' => false]); $display = $tester->getDisplay(); - $display2 = \json_decode($display, true); + $display2 = json_decode($display, true); $this->assertNotSame($display1, $display2); } diff --git a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php index ff88c69852..8c6253ef2b 100644 --- a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php +++ b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php @@ -85,7 +85,7 @@ class UndefinedCallableHandler private static function onUndefined($name, $type, $component) { - if (\class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) { + if (class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) { throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index f3d6a875e0..340198e5e2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -40,7 +40,7 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer if ($excludeRegexp instanceof CacheItemPoolInterface) { @trigger_error(sprintf('The CacheItemPoolInterface $fallbackPool argument of "%s()" is deprecated since Symfony 4.2, you should not pass it anymore.', __METHOD__), E_USER_DEPRECATED); $excludeRegexp = $debug; - $debug = 4 < \func_num_args() && \func_get_arg(4); + $debug = 4 < \func_num_args() && func_get_arg(4); } parent::__construct($phpArrayFile); $this->annotationReader = $annotationReader; diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php index 535161b119..41a8aaa04d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php @@ -36,7 +36,7 @@ class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer */ public function __construct(array $loaders, string $phpArrayFile) { - if (2 < \func_num_args() && \func_get_arg(2) instanceof CacheItemPoolInterface) { + if (2 < \func_num_args() && func_get_arg(2) instanceof CacheItemPoolInterface) { @trigger_error(sprintf('The CacheItemPoolInterface $fallbackPool argument of "%s()" is deprecated since Symfony 4.2, you should not pass it anymore.', __METHOD__), E_USER_DEPRECATED); } parent::__construct($phpArrayFile); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 87975d96cb..19386d9721 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1115,12 +1115,12 @@ class FrameworkExtension extends Extension $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); $rootDir = $container->getParameter('kernel.root_dir'); foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { - if (\is_dir($dir = $bundle['path'].'/Resources/translations')) { + if (is_dir($dir = $bundle['path'].'/Resources/translations')) { $dirs[] = $dir; } else { $nonExistingDirs[] = $dir; } - if (\is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { + if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); $dirs[] = $dir; } else { @@ -1129,7 +1129,7 @@ class FrameworkExtension extends Extension } foreach ($config['paths'] as $dir) { - if (\is_dir($dir)) { + if (is_dir($dir)) { $dirs[] = $transPaths[] = $dir; } else { throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir)); @@ -1144,13 +1144,13 @@ class FrameworkExtension extends Extension $container->getDefinition('console.command.translation_update')->replaceArgument(6, $transPaths); } - if (\is_dir($defaultDir)) { + if (is_dir($defaultDir)) { $dirs[] = $defaultDir; } else { $nonExistingDirs[] = $defaultDir; } - if (\is_dir($dir = $rootDir.'/Resources/translations')) { + if (is_dir($dir = $rootDir.'/Resources/translations')) { if ($dir !== $defaultDir) { @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); } @@ -1187,7 +1187,7 @@ class FrameworkExtension extends Extension $translator->getArgument(4), [ 'resource_files' => $files, - 'scanned_directories' => \array_merge($dirs, $nonExistingDirs), + 'scanned_directories' => array_merge($dirs, $nonExistingDirs), ] ); diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php index e3e37a5359..f820e8d080 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php @@ -195,7 +195,7 @@ trait WebTestAssertionsTrait } if (!$client instanceof KernelBrowser) { - static::fail(\sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__)); + static::fail(sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__)); } return $client; diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 883a94ba9b..d6df7f48a2 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -48,9 +48,9 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg // Detect wrapped values that encode for their expiry and creation duration // For compactness, these values are packed in the key of an array using // magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F - if (\is_array($v) && 1 === \count($v) && 10 === \strlen($k = \key($v)) && "\x9D" === $k[0] && "\0" === $k[5] && "\x5F" === $k[9]) { + if (\is_array($v) && 1 === \count($v) && 10 === \strlen($k = key($v)) && "\x9D" === $k[0] && "\0" === $k[5] && "\x5F" === $k[9]) { $item->value = $v[$k]; - $v = \unpack('Ve/Nc', \substr($k, 1, -1)); + $v = unpack('Ve/Nc', substr($k, 1, -1)); $item->metadata[CacheItem::METADATA_EXPIRY] = $v['e'] + CacheItem::METADATA_EXPIRY_OFFSET; $item->metadata[CacheItem::METADATA_CTIME] = $v['c']; } diff --git a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php index 2eb5ce8c6e..97476a8a71 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php @@ -60,7 +60,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA $item->metadata[CacheItem::METADATA_TAGS] = $value['tags'] ?? []; if (isset($value['meta'])) { // For compactness these values are packed, & expiry is offset to reduce size - $v = \unpack('Ve/Nc', $value['meta']); + $v = unpack('Ve/Nc', $value['meta']); $item->metadata[CacheItem::METADATA_EXPIRY] = $v['e'] + CacheItem::METADATA_EXPIRY_OFFSET; $item->metadata[CacheItem::METADATA_CTIME] = $v['c']; } @@ -96,16 +96,16 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA if ($metadata) { // For compactness, expiry and creation duration are packed, using magic numbers as separators - $value['meta'] = \pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME]); + $value['meta'] = pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME]); } // Extract tag changes, these should be removed from values in doSave() $value['tag-operations'] = ['add' => [], 'remove' => []]; $oldTags = $item->metadata[CacheItem::METADATA_TAGS] ?? []; - foreach (\array_diff($value['tags'], $oldTags) as $addedTag) { + foreach (array_diff($value['tags'], $oldTags) as $addedTag) { $value['tag-operations']['add'][] = $getId($tagPrefix.$addedTag); } - foreach (\array_diff($oldTags, $value['tags']) as $removedTag) { + foreach (array_diff($oldTags, $value['tags']) as $removedTag) { $value['tag-operations']['remove'][] = $getId($tagPrefix.$removedTag); } @@ -236,7 +236,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA } try { - if ($this->doDelete(\array_values($ids), $tagData)) { + if ($this->doDelete(array_values($ids), $tagData)) { return true; } } catch (\Exception $e) { @@ -271,7 +271,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA } $tagIds = []; - foreach (\array_unique($tags) as $tag) { + foreach (array_unique($tags) as $tag) { $tagIds[] = $this->getId(self::TAGS_PREFIX.$tag); } diff --git a/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php index f96c670ae9..0dd81a9970 100644 --- a/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php @@ -126,7 +126,7 @@ class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements Prune } $valueFile = $itemLink->getRealPath(); - if ($valueFile && \file_exists($valueFile)) { + if ($valueFile && file_exists($valueFile)) { @unlink($valueFile); } diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index cf51b90d8d..bccafcf47e 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -58,9 +58,9 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa // Detect wrapped values that encode for their expiry and creation duration // For compactness, these values are packed in the key of an array using // magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F - if (\is_array($v) && 1 === \count($v) && 10 === \strlen($k = \key($v)) && "\x9D" === $k[0] && "\0" === $k[5] && "\x5F" === $k[9]) { + if (\is_array($v) && 1 === \count($v) && 10 === \strlen($k = key($v)) && "\x9D" === $k[0] && "\0" === $k[5] && "\x5F" === $k[9]) { $item->value = $v[$k]; - $v = \unpack('Ve/Nc', \substr($k, 1, -1)); + $v = unpack('Ve/Nc', substr($k, 1, -1)); $item->metadata[CacheItem::METADATA_EXPIRY] = $v['e'] + CacheItem::METADATA_EXPIRY_OFFSET; $item->metadata[CacheItem::METADATA_CTIME] = $v['c']; } elseif ($innerItem instanceof CacheItem) { diff --git a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php index 4e09387213..382defcd2c 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php @@ -82,7 +82,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter $this->init($redisClient, $namespace, $defaultLifetime, $marshaller); // Make sure php-redis is 3.1.3 or higher configured for Redis classes - if (!$this->redis instanceof Predis\Client && \version_compare(\phpversion('redis'), '3.1.3', '<')) { + if (!$this->redis instanceof Predis\Client && version_compare(phpversion('redis'), '3.1.3', '<')) { throw new LogicException('RedisTagAwareAdapter requires php-redis 3.1.3 or higher, alternatively use predis/predis'); } } @@ -120,7 +120,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter foreach ($results as $id => $result) { // Skip results of SADD/SREM operations, they'll be 1 or 0 depending on if set value already existed or not - if (\is_numeric($result)) { + if (is_numeric($result)) { continue; } // setEx results @@ -152,7 +152,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter } foreach ($tagData as $tagId => $idList) { - yield 'sRem' => \array_merge([$tagId], $idList); + yield 'sRem' => array_merge([$tagId], $idList); } })->rewind(); @@ -178,10 +178,10 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter }); // Flatten generator result from pipeline, ignore keys (tag ids) - $ids = \array_unique(\array_merge(...\iterator_to_array($tagIdSets, false))); + $ids = array_unique(array_merge(...iterator_to_array($tagIdSets, false))); // Delete cache in chunks to avoid overloading the connection - foreach (\array_chunk($ids, self::BULK_DELETE_LIMIT) as $chunkIds) { + foreach (array_chunk($ids, self::BULK_DELETE_LIMIT) as $chunkIds) { $this->doDelete($chunkIds); } diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index 92eb9c39df..3cc3fb8f2e 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -110,7 +110,7 @@ final class CacheItem implements ItemInterface if (!$this->isTaggable) { throw new LogicException(sprintf('Cache item "%s" comes from a non tag-aware pool: you cannot tag it.', $this->key)); } - if (!\is_iterable($tags)) { + if (!is_iterable($tags)) { $tags = [$tags]; } foreach ($tags as $tag) { diff --git a/src/Symfony/Component/Cache/Traits/ArrayTrait.php b/src/Symfony/Component/Cache/Traits/ArrayTrait.php index d29b528b96..df7d238e2d 100644 --- a/src/Symfony/Component/Cache/Traits/ArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/ArrayTrait.php @@ -123,7 +123,7 @@ trait ArrayTrait if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) { return serialize($value); } - } elseif (!\is_scalar($value)) { + } elseif (!is_scalar($value)) { try { $serialized = serialize($value); } catch (\Exception $e) { diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php index 0bec18a07a..4395de0252 100644 --- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php @@ -86,7 +86,7 @@ EOF; $isStaticValue = false; } $value = var_export($value, true); - } elseif (!\is_scalar($value)) { + } elseif (!is_scalar($value)) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value))); } else { $value = var_export($value, true); diff --git a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php index 37d25f87a9..6afdd8c3a5 100644 --- a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php @@ -182,7 +182,7 @@ trait PhpFilesTrait $isStaticValue = false; } $value = var_export($value, true); - } elseif (!\is_scalar($value)) { + } elseif (!is_scalar($value)) { throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value))); } else { $value = var_export($value, true); diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index fac90216ca..563eaf33f8 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -786,7 +786,7 @@ class Application if (false !== strpos($message, "class@anonymous\0")) { $message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) { - return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0]; + return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0]; }, $message); } diff --git a/src/Symfony/Component/Console/Helper/ProcessHelper.php b/src/Symfony/Component/Console/Helper/ProcessHelper.php index e3a7c77b35..41f128bb49 100644 --- a/src/Symfony/Component/Console/Helper/ProcessHelper.php +++ b/src/Symfony/Component/Console/Helper/ProcessHelper.php @@ -51,7 +51,7 @@ class ProcessHelper extends Helper if (!\is_array($cmd)) { @trigger_error(sprintf('Passing a command as a string to "%s()" is deprecated since Symfony 4.2, pass it the command as an array of arguments instead.', __METHOD__), E_USER_DEPRECATED); - $cmd = [\method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd)]; + $cmd = [method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd)]; } if (\is_string($cmd[0] ?? null)) { diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 34e6aa5d2b..e30fe786e3 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -250,7 +250,7 @@ final class ProgressBar */ public function iterate(iterable $iterable, ?int $max = null): iterable { - $this->start($max ?? (\is_countable($iterable) ? \count($iterable) : 0)); + $this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0)); foreach ($iterable as $key => $value) { yield $key => $value; diff --git a/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php b/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php index 4ada2e8673..ce2c28ba1a 100644 --- a/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php @@ -50,7 +50,7 @@ class ConsoleSectionOutput extends StreamOutput } if ($lines) { - \array_splice($this->content, -($lines * 2)); // Multiply lines by 2 to cater for each new line added between content + array_splice($this->content, -($lines * 2)); // Multiply lines by 2 to cater for each new line added between content } else { $lines = $this->lines; $this->content = []; diff --git a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php index 5387a9e3c2..82c6b44517 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php @@ -26,7 +26,7 @@ class ProcessHelperTest extends TestCase public function testVariousProcessRuns($expected, $cmd, $verbosity, $error) { if (\is_string($cmd)) { - $cmd = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd); + $cmd = method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd); } $helper = new ProcessHelper(); @@ -99,7 +99,7 @@ EOT; $args = new Process(['php', '-r', 'echo 42;']); $args = $args->getCommandLine(); $successOutputProcessDebug = str_replace("'php' '-r' 'echo 42;'", $args, $successOutputProcessDebug); - $fromShellCommandline = \method_exists(Process::class, 'fromShellCommandline') ? [Process::class, 'fromShellCommandline'] : function ($cmd) { return new Process($cmd); }; + $fromShellCommandline = method_exists(Process::class, 'fromShellCommandline') ? [Process::class, 'fromShellCommandline'] : function ($cmd) { return new Process($cmd); }; return [ ['', 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERBOSE, null], diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index 8d37d3af04..2dcd51f7b1 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -884,7 +884,7 @@ class ProgressBarTest extends TestCase { $bar = new ProgressBar($output = $this->getOutputStream()); - $this->assertEquals([1, 2], \iterator_to_array($bar->iterate([1, 2]))); + $this->assertEquals([1, 2], iterator_to_array($bar->iterate([1, 2]))); rewind($output->getStream()); $this->assertEquals( @@ -900,7 +900,7 @@ class ProgressBarTest extends TestCase { $bar = new ProgressBar($output = $this->getOutputStream()); - $this->assertEquals([1, 2], \iterator_to_array($bar->iterate((function () { + $this->assertEquals([1, 2], iterator_to_array($bar->iterate((function () { yield 1; yield 2; })()))); diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index db92f5adf8..ff9a8d72f9 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -172,7 +172,7 @@ class DebugClassLoader private function checkClass($class, $file = null) { - $exists = null === $file || \class_exists($class, false) || \interface_exists($class, false) || \trait_exists($class, false); + $exists = null === $file || class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); if (null !== $file && $class && '\\' === $class[0]) { $class = substr($class, 1); @@ -190,7 +190,7 @@ class DebugClassLoader } $name = $refl->getName(); - if ($name !== $class && 0 === \strcasecmp($name, $class)) { + if ($name !== $class && 0 === strcasecmp($name, $class)) { throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: "%s" vs "%s".', $class, $name)); } @@ -223,22 +223,22 @@ class DebugClassLoader $deprecations = []; // Don't trigger deprecations for classes in the same vendor - if (2 > $len = 1 + (\strpos($class, '\\') ?: \strpos($class, '_'))) { + if (2 > $len = 1 + (strpos($class, '\\') ?: strpos($class, '_'))) { $len = 0; $ns = ''; } else { - $ns = \str_replace('_', '\\', \substr($class, 0, $len)); + $ns = str_replace('_', '\\', substr($class, 0, $len)); } // Detect annotations on the class if (false !== $doc = $refl->getDocComment()) { foreach (['final', 'deprecated', 'internal'] as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { + if (false !== strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : ''; } } - if ($refl->isInterface() && false !== \strpos($doc, 'method') && preg_match_all('#\n \* @method\s+(static\s+)?+(?:[\w\|&\[\]\\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))#', $doc, $notice, PREG_SET_ORDER)) { + if ($refl->isInterface() && false !== strpos($doc, 'method') && preg_match_all('#\n \* @method\s+(static\s+)?+(?:[\w\|&\[\]\\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))#', $doc, $notice, PREG_SET_ORDER)) { foreach ($notice as $method) { $static = '' !== $method[1]; $name = $method[2]; @@ -257,7 +257,7 @@ class DebugClassLoader } } - $parent = \get_parent_class($class); + $parent = get_parent_class($class); $parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent); if ($parent) { $parentAndOwnInterfaces[$parent] = $parent; @@ -272,17 +272,17 @@ class DebugClassLoader } // Detect if the parent is annotated - foreach ($parentAndOwnInterfaces + \class_uses($class, false) as $use) { + foreach ($parentAndOwnInterfaces + class_uses($class, false) as $use) { if (!isset(self::$checkedClasses[$use])) { $this->checkClass($use); } - if (isset(self::$deprecated[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) { + if (isset(self::$deprecated[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) { $type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait'); $verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses'); $deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]); } - if (isset(self::$internal[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) { + if (isset(self::$internal[$use]) && strncmp($ns, str_replace('_', '\\', $use), $len)) { $deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class); } if (isset(self::$method[$use])) { @@ -309,7 +309,7 @@ class DebugClassLoader } } - if (\trait_exists($class)) { + if (trait_exists($class)) { return $deprecations; } @@ -337,7 +337,7 @@ class DebugClassLoader if (isset(self::$internalMethods[$class][$method->name])) { list($declaringClass, $message) = self::$internalMethods[$class][$method->name]; - if (\strncmp($ns, $declaringClass, $len)) { + if (strncmp($ns, $declaringClass, $len)) { $deprecations[] = sprintf('The "%s::%s()" method is considered internal%s. It may change without further notice. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class); } } @@ -365,14 +365,14 @@ class DebugClassLoader $finalOrInternal = false; foreach (['final', 'internal'] as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { + if (false !== strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { $message = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : ''; self::${$annotation.'Methods'}[$class][$method->name] = [$class, $message]; $finalOrInternal = true; } } - if ($finalOrInternal || $method->isConstructor() || false === \strpos($doc, '@param') || StatelessInvocation::class === $class) { + if ($finalOrInternal || $method->isConstructor() || false === strpos($doc, '@param') || StatelessInvocation::class === $class) { continue; } if (!preg_match_all('#\n\s+\* @param +((?(?!callable *\().*?|callable *\(.*\).*?))(?<= )\$([a-zA-Z0-9_\x7f-\xff]++)#', $doc, $matches, PREG_SET_ORDER)) { diff --git a/src/Symfony/Component/Debug/Exception/FlattenException.php b/src/Symfony/Component/Debug/Exception/FlattenException.php index 304df0405c..2e97ac39bb 100644 --- a/src/Symfony/Component/Debug/Exception/FlattenException.php +++ b/src/Symfony/Component/Debug/Exception/FlattenException.php @@ -173,7 +173,7 @@ class FlattenException { if (false !== strpos($message, "class@anonymous\0")) { $message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) { - return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0]; + return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0]; }, $message); } diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 7ae85eebb7..743de65622 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -457,10 +457,10 @@ EOF; private function addElementToGhost() { - if (!isset(self::GHOST_ADDONS[\date('m-d')])) { + if (!isset(self::GHOST_ADDONS[date('m-d')])) { return ''; } - return ''; + return ''; } } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 2700f88c47..ff41c1a7eb 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -354,7 +354,7 @@ class Definition if (empty($method)) { throw new InvalidArgumentException('Method name cannot be empty.'); } - $this->calls[] = 2 < \func_num_args() && \func_get_arg(2) ? [$method, $arguments, true] : [$method, $arguments]; + $this->calls[] = 2 < \func_num_args() && func_get_arg(2) ? [$method, $arguments, true] : [$method, $arguments]; return $this; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index b57f10c597..2ca7866cd2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -649,7 +649,7 @@ class XmlFileLoaderTest extends TestCase $fixturesDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR; $this->assertContains((string) new FileResource($fixturesDir.'xml'.\DIRECTORY_SEPARATOR.'services_prototype.xml'), $resources); - $prototypeRealPath = \realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Prototype'); + $prototypeRealPath = realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Prototype'); $globResource = new GlobResource( $fixturesDir.'Prototype', '/*', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 0aa30f288c..4b118fd903 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -415,7 +415,7 @@ class YamlFileLoaderTest extends TestCase $fixturesDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR; $this->assertContains((string) new FileResource($fixturesDir.'yaml'.\DIRECTORY_SEPARATOR.'services_prototype.yml'), $resources); - $prototypeRealPath = \realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Prototype'); + $prototypeRealPath = realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'Prototype'); $globResource = new GlobResource( $fixturesDir.'Prototype', '', diff --git a/src/Symfony/Component/DependencyInjection/TypedReference.php b/src/Symfony/Component/DependencyInjection/TypedReference.php index f80ac50563..56a878874e 100644 --- a/src/Symfony/Component/DependencyInjection/TypedReference.php +++ b/src/Symfony/Component/DependencyInjection/TypedReference.php @@ -34,7 +34,7 @@ class TypedReference extends Reference @trigger_error(sprintf('The $requiringClass argument of "%s()" is deprecated since Symfony 4.1.', __METHOD__), E_USER_DEPRECATED); $this->requiringClass = $invalidBehavior; - $invalidBehavior = 3 < \func_num_args() ? \func_get_arg(3) : ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + $invalidBehavior = 3 < \func_num_args() ? func_get_arg(3) : ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; } else { $this->name = $type === $id ? $name : null; } diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 70a4b607dc..d44540722c 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -566,7 +566,7 @@ class Crawler implements \Countable, \IteratorAggregate { if (!$this->nodes) { if (0 < \func_num_args()) { - return \func_get_arg(0); + return func_get_arg(0); } throw new \InvalidArgumentException('The current node list is empty.'); @@ -588,7 +588,7 @@ class Crawler implements \Countable, \IteratorAggregate { if (!$this->nodes) { if (0 < \func_num_args()) { - return \func_get_arg(0); + return func_get_arg(0); } throw new \InvalidArgumentException('The current node list is empty.'); @@ -1220,7 +1220,7 @@ class Crawler implements \Countable, \IteratorAggregate */ private function createCssSelectorConverter(): CssSelectorConverter { - if (!\class_exists(CssSelectorConverter::class)) { + if (!class_exists(CssSelectorConverter::class)) { throw new \LogicException('To filter with a CSS selector, install the CssSelector component ("composer require symfony/css-selector"). Or use filterXpath instead.'); } diff --git a/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextContains.php b/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextContains.php index 260ec57b07..0ddca40869 100644 --- a/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextContains.php +++ b/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextContains.php @@ -45,7 +45,7 @@ final class CrawlerSelectorTextContains extends Constraint return false; } - return false !== \mb_strpos($crawler->text(), $this->expectedText); + return false !== mb_strpos($crawler->text(), $this->expectedText); } /** diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php index 2f699ce860..66a2c105a8 100644 --- a/src/Symfony/Component/Dotenv/Dotenv.php +++ b/src/Symfony/Component/Dotenv/Dotenv.php @@ -401,7 +401,7 @@ final class Dotenv throw new \LogicException('Resolving commands requires the Symfony Process component.'); } - $process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline('echo '.$matches[0]) : new Process('echo '.$matches[0]); + $process = method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline('echo '.$matches[0]) : new Process('echo '.$matches[0]); $process->inheritEnvironmentVariables(true); $process->setEnv($this->values); try { diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php index 7716d86631..2da03e82c1 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -140,7 +140,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface } $currentRequestHash = $this->currentRequestHash = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_hash($request) : ''; - $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; + $eventName = 1 < \func_num_args() ? func_get_arg(1) : null; if (\is_object($event)) { $eventName = $eventName ?? \get_class($event); @@ -193,7 +193,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface return []; } - $hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null; + $hash = 1 <= \func_num_args() && null !== ($request = func_get_arg(0)) ? spl_object_hash($request) : null; $called = []; foreach ($this->callStack as $listener) { list($eventName, $requestHash) = $this->callStack->getInfo(); @@ -223,23 +223,23 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface return []; } - $hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null; + $hash = 1 <= \func_num_args() && null !== ($request = func_get_arg(0)) ? spl_object_hash($request) : null; + $calledListeners = []; + + if (null !== $this->callStack) { + foreach ($this->callStack as $calledListener) { + list(, $requestHash) = $this->callStack->getInfo(); + + if (null === $hash || $hash === $requestHash) { + $calledListeners[] = $calledListener->getWrappedListener(); + } + } + } + $notCalled = []; foreach ($allListeners as $eventName => $listeners) { foreach ($listeners as $listener) { - $called = false; - if (null !== $this->callStack) { - foreach ($this->callStack as $calledListener) { - list(, $requestHash) = $this->callStack->getInfo(); - if ((null === $hash || $hash === $requestHash) && $calledListener->getWrappedListener() === $listener) { - $called = true; - - break; - } - } - } - - if (!$called) { + if (!\in_array($listener, $calledListeners, true)) { if (!$listener instanceof WrappedListener) { $listener = new WrappedListener($listener, null, $this->stopwatch, $this); } @@ -258,7 +258,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface */ public function getOrphanedEvents(/* Request $request = null */): array { - if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) { + if (1 <= \func_num_args() && null !== $request = func_get_arg(0)) { return $this->orphanedEvents[spl_object_hash($request)] ?? []; } diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index e68918c31c..304caec1d1 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -50,7 +50,7 @@ class EventDispatcher implements EventDispatcherInterface */ public function dispatch($event/*, string $eventName = null*/) { - $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; + $eventName = 1 < \func_num_args() ? func_get_arg(1) : null; if (\is_object($event)) { $eventName = $eventName ?? \get_class($event); diff --git a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php index 082e2a05d4..75a7d73181 100644 --- a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php @@ -32,9 +32,9 @@ class ImmutableEventDispatcher implements EventDispatcherInterface */ public function dispatch($event/*, string $eventName = null*/) { - $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; + $eventName = 1 < \func_num_args() ? func_get_arg(1) : null; - if (\is_scalar($event)) { + if (is_scalar($event)) { // deprecated $swap = $event; $event = $eventName ?? new Event(); diff --git a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php index 3ae3735e23..534eec98a5 100644 --- a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php +++ b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php @@ -53,7 +53,7 @@ final class LegacyEventDispatcherProxy implements EventDispatcherInterface */ public function dispatch($event/*, string $eventName = null*/) { - $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; + $eventName = 1 < \func_num_args() ? func_get_arg(1) : null; if (\is_object($event)) { $eventName = $eventName ?? \get_class($event); diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index fa88fd0d05..d83b27330c 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -744,15 +744,15 @@ class Filesystem private static function box($func) { self::$lastError = null; - \set_error_handler(__CLASS__.'::handleError'); + set_error_handler(__CLASS__.'::handleError'); try { $result = $func(...\array_slice(\func_get_args(), 1)); - \restore_error_handler(); + restore_error_handler(); return $result; } catch (\Throwable $e) { } - \restore_error_handler(); + restore_error_handler(); throw $e; } diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 33b1805979..2fdf21ae4a 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -174,7 +174,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function name($patterns) { - $this->names = \array_merge($this->names, (array) $patterns); + $this->names = array_merge($this->names, (array) $patterns); return $this; } @@ -190,7 +190,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function notName($patterns) { - $this->notNames = \array_merge($this->notNames, (array) $patterns); + $this->notNames = array_merge($this->notNames, (array) $patterns); return $this; } @@ -212,7 +212,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function contains($patterns) { - $this->contains = \array_merge($this->contains, (array) $patterns); + $this->contains = array_merge($this->contains, (array) $patterns); return $this; } @@ -234,7 +234,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function notContains($patterns) { - $this->notContains = \array_merge($this->notContains, (array) $patterns); + $this->notContains = array_merge($this->notContains, (array) $patterns); return $this; } @@ -258,7 +258,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function path($patterns) { - $this->paths = \array_merge($this->paths, (array) $patterns); + $this->paths = array_merge($this->paths, (array) $patterns); return $this; } @@ -282,7 +282,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function notPath($patterns) { - $this->notPaths = \array_merge($this->notPaths, (array) $patterns); + $this->notPaths = array_merge($this->notPaths, (array) $patterns); return $this; } diff --git a/src/Symfony/Component/Finder/SplFileInfo.php b/src/Symfony/Component/Finder/SplFileInfo.php index ee798dc703..65d7423e0d 100644 --- a/src/Symfony/Component/Finder/SplFileInfo.php +++ b/src/Symfony/Component/Finder/SplFileInfo.php @@ -61,7 +61,7 @@ class SplFileInfo extends \SplFileInfo { $filename = $this->getFilename(); - return \pathinfo($filename, PATHINFO_FILENAME); + return pathinfo($filename, PATHINFO_FILENAME); } /** diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 46ca01c6d4..19196729f1 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -61,7 +61,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface $this->name = $name; $this->options = $options; - if (\preg_match('/^([^a-z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) { + if (preg_match('/^([^a-z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) { if (isset($matches[1])) { @trigger_error(sprintf('Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated since Symfony 4.3 and will throw an exception in 5.0 ("%s" given).', $name), E_USER_DEPRECATED); } diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php index e7100d2237..68da1b2516 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php @@ -236,7 +236,7 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface return; } - $groupLabels = \is_array($groupLabels) ? \array_map('strval', $groupLabels) : [(string) $groupLabels]; + $groupLabels = \is_array($groupLabels) ? array_map('strval', $groupLabels) : [(string) $groupLabels]; foreach ($groupLabels as $groupLabel) { // Initialize the group views if necessary. Unnecessarily built group diff --git a/src/Symfony/Component/HttpClient/CachingHttpClient.php b/src/Symfony/Component/HttpClient/CachingHttpClient.php index 7cf28a28fc..65426ef647 100644 --- a/src/Symfony/Component/HttpClient/CachingHttpClient.php +++ b/src/Symfony/Component/HttpClient/CachingHttpClient.php @@ -109,7 +109,7 @@ class CachingHttpClient implements HttpClientInterface { if ($responses instanceof ResponseInterface) { $responses = [$responses]; - } elseif (!\is_iterable($responses)) { + } elseif (!is_iterable($responses)) { throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of ResponseInterface objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index 9f7401b0aa..199a3b4ea1 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -284,7 +284,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface { if ($responses instanceof CurlResponse) { $responses = [$responses]; - } elseif (!\is_iterable($responses)) { + } elseif (!is_iterable($responses)) { throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 2df830e111..4d263f46db 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -200,7 +200,7 @@ trait HttpClientTrait if (\is_int($name)) { [$name, $values] = explode(':', $values, 2); $values = [ltrim($values)]; - } elseif (!\is_iterable($values)) { + } elseif (!is_iterable($values)) { $values = (array) $values; } diff --git a/src/Symfony/Component/HttpClient/MockHttpClient.php b/src/Symfony/Component/HttpClient/MockHttpClient.php index 987f04211f..cb3cb969b0 100644 --- a/src/Symfony/Component/HttpClient/MockHttpClient.php +++ b/src/Symfony/Component/HttpClient/MockHttpClient.php @@ -78,7 +78,7 @@ class MockHttpClient implements HttpClientInterface { if ($responses instanceof ResponseInterface) { $responses = [$responses]; - } elseif (!\is_iterable($responses)) { + } elseif (!is_iterable($responses)) { throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of MockResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } diff --git a/src/Symfony/Component/HttpClient/NativeHttpClient.php b/src/Symfony/Component/HttpClient/NativeHttpClient.php index 55313b1ccc..068f3eb7ba 100644 --- a/src/Symfony/Component/HttpClient/NativeHttpClient.php +++ b/src/Symfony/Component/HttpClient/NativeHttpClient.php @@ -220,7 +220,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac { if ($responses instanceof NativeResponse) { $responses = [$responses]; - } elseif (!\is_iterable($responses)) { + } elseif (!is_iterable($responses)) { throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of NativeResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 1c5114e92f..0c615bab04 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -168,8 +168,8 @@ final class CurlResponse implements ResponseInterface rewind($this->debugBuffer); $info['debug'] = stream_get_contents($this->debugBuffer); curl_setopt($this->handle, CURLOPT_VERBOSE, false); - fclose($this->debugBuffer); - $this->debugBuffer = null; + rewind($this->debugBuffer); + ftruncate($this->debugBuffer, 0); $this->finalInfo = $info; } } diff --git a/src/Symfony/Component/HttpClient/Response/MockResponse.php b/src/Symfony/Component/HttpClient/Response/MockResponse.php index 04b33a143a..47fc084d37 100644 --- a/src/Symfony/Component/HttpClient/Response/MockResponse.php +++ b/src/Symfony/Component/HttpClient/Response/MockResponse.php @@ -44,7 +44,7 @@ class MockResponse implements ResponseInterface */ public function __construct($body = '', array $info = []) { - $this->body = \is_iterable($body) ? $body : (string) $body; + $this->body = is_iterable($body) ? $body : (string) $body; $this->info = $info + $this->info; if (!isset($info['response_headers'])) { diff --git a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php index 056181e30e..4948822c5e 100644 --- a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php @@ -232,7 +232,7 @@ class HttpClientTraitTest extends TestCase public function provideFingerprints() { foreach (['md5', 'sha1', 'sha256'] as $algo) { - $hash = \hash($algo, $algo); + $hash = hash($algo, $algo); yield [$hash, [$algo => $hash]]; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index 0623318d0a..a3877ef4c7 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -681,7 +681,7 @@ class PdoSessionHandler extends AbstractSessionHandler switch ($this->driver) { case 'mysql': // MySQL 5.7.5 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced. - $lockId = \substr($sessionId, 0, 64); + $lockId = substr($sessionId, 0, 64); // should we handle the return value? 0 on timeout, null on error // we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout $stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)'); diff --git a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index f48db70568..7ab14b7cb8 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -47,7 +47,7 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf 'token' => $response->headers->get('X-Debug-Token'), 'start_time' => $startTime * 1000, 'events' => [], - 'stopwatch_installed' => \class_exists(Stopwatch::class, false), + 'stopwatch_installed' => class_exists(Stopwatch::class, false), ]; } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php index 1efad607e8..7037c497cc 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php @@ -132,12 +132,12 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface $maxAge = null; $sMaxage = null; - if (\is_numeric($this->ageDirectives['max-age'])) { + if (is_numeric($this->ageDirectives['max-age'])) { $maxAge = $this->ageDirectives['max-age'] + $this->age; $response->headers->addCacheControlDirective('max-age', $maxAge); } - if (\is_numeric($this->ageDirectives['s-maxage'])) { + if (is_numeric($this->ageDirectives['s-maxage'])) { $sMaxage = $this->ageDirectives['s-maxage'] + $this->age; if ($maxAge !== $sMaxage) { @@ -145,7 +145,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface } } - if (\is_numeric($this->ageDirectives['expires'])) { + if (is_numeric($this->ageDirectives['expires'])) { $date = clone $response->getDate(); $date->modify('+'.($this->ageDirectives['expires'] + $this->age).' seconds'); $response->setExpires($date); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php index 6756f3de42..e044e5e1ad 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -52,6 +52,6 @@ class TimeDataCollectorTest extends TestCase $c->collect($request, new Response()); $this->assertEquals(123456000, $c->getStartTime()); - $this->assertSame(\class_exists(Stopwatch::class, false), $c->isStopwatchInstalled()); + $this->assertSame(class_exists(Stopwatch::class, false), $c->isStopwatchInstalled()); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php deleted file mode 100644 index a0665ef991..0000000000 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; - -class TestEventDispatcher extends TraceableEventDispatcher -{ - public function getCalledListeners() - { - return ['foo']; - } - - public function getNotCalledListeners() - { - return ['bar']; - } - - public function reset() - { - } - - public function getOrphanedEvents() - { - return []; - } -} diff --git a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php index 9d57b07069..eda413a12b 100644 --- a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php @@ -65,9 +65,9 @@ class LocaleDataGenerator extends AbstractDataGenerator protected function preGenerate() { // Write parents locale file for the Translation component - \file_put_contents( + file_put_contents( __DIR__.'/../../../Translation/Resources/data/parents.json', - \json_encode($this->localeParents, \JSON_PRETTY_PRINT).\PHP_EOL + json_encode($this->localeParents, \JSON_PRETTY_PRINT).\PHP_EOL ); } diff --git a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php index 2d56ff9d0c..49aec06b1f 100644 --- a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php +++ b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php @@ -92,10 +92,10 @@ class LocaleScanner $fallbacks = []; foreach ($locales as $locale) { - $content = \file_get_contents($sourceDir.'/'.$locale.'.txt'); + $content = file_get_contents($sourceDir.'/'.$locale.'.txt'); // Aliases contain the text "%%PARENT" followed by the aliased locale - if (\preg_match('/%%Parent{"([^"]+)"}/', $content, $matches)) { + if (preg_match('/%%Parent{"([^"]+)"}/', $content, $matches)) { $fallbacks[$locale] = $matches[1]; } } diff --git a/src/Symfony/Component/Lock/Store/StoreFactory.php b/src/Symfony/Component/Lock/Store/StoreFactory.php index b702b81b70..5d9335db34 100644 --- a/src/Symfony/Component/Lock/Store/StoreFactory.php +++ b/src/Symfony/Component/Lock/Store/StoreFactory.php @@ -58,7 +58,7 @@ class StoreFactory return new FlockStore(substr($connection, 8)); case 'semaphore' === $connection: return new SemaphoreStore(); - case \class_exists(AbstractAdapter::class) && preg_match('#^[a-z]++://#', $connection): + case class_exists(AbstractAdapter::class) && preg_match('#^[a-z]++://#', $connection): return static::createStore(AbstractAdapter::createConnection($connection)); default: throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection)); diff --git a/src/Symfony/Component/Lock/Store/ZookeeperStore.php b/src/Symfony/Component/Lock/Store/ZookeeperStore.php index c755ce1a1c..4f8b4ee374 100644 --- a/src/Symfony/Component/Lock/Store/ZookeeperStore.php +++ b/src/Symfony/Component/Lock/Store/ZookeeperStore.php @@ -127,8 +127,8 @@ class ZookeeperStore implements StoreInterface // For example: foo/bar will become /foo-bar and /foo/bar will become /-foo-bar $resource = (string) $key; - if (false !== \strpos($resource, '/')) { - $resource = \strtr($resource, ['/' => '-']).'-'.sha1($resource); + if (false !== strpos($resource, '/')) { + $resource = strtr($resource, ['/' => '-']).'-'.sha1($resource); } if ('' === $resource) { diff --git a/src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php b/src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php index 4edb4d361a..3291b14f4e 100644 --- a/src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php @@ -38,23 +38,23 @@ class StoreFactoryTest extends TestCase public function validConnections() { - if (\class_exists(\Redis::class)) { + if (class_exists(\Redis::class)) { yield [$this->createMock(\Redis::class), RedisStore::class]; } - if (\class_exists(RedisProxy::class)) { + if (class_exists(RedisProxy::class)) { yield [$this->createMock(RedisProxy::class), RedisStore::class]; } yield [new \Predis\Client(), RedisStore::class]; - if (\class_exists(\Memcached::class)) { + if (class_exists(\Memcached::class)) { yield [new \Memcached(), MemcachedStore::class]; } - if (\class_exists(\Zookeeper::class)) { + if (class_exists(\Zookeeper::class)) { yield [$this->createMock(\Zookeeper::class), ZookeeperStore::class]; } if (\extension_loaded('sysvsem')) { yield ['semaphore', SemaphoreStore::class]; } - if (\class_exists(\Memcached::class) && \class_exists(AbstractAdapter::class)) { + if (class_exists(\Memcached::class) && class_exists(AbstractAdapter::class)) { yield ['memcached://server.com', MemcachedStore::class]; } diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Http/Api/SesTransport.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Http/Api/SesTransport.php index 9bb9850a8d..1ed145bcba 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Http/Api/SesTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Http/Api/SesTransport.php @@ -76,7 +76,7 @@ class SesTransport extends AbstractApiTransport if ($email->getAttachments()) { return [ 'Action' => 'SendRawEmail', - 'RawMessage.Data' => \base64_encode($email->toString()), + 'RawMessage.Data' => base64_encode($email->toString()), ]; } diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Http/SesTransport.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Http/SesTransport.php index 6e90be383e..c27a0d1eb2 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Http/SesTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Http/SesTransport.php @@ -56,7 +56,7 @@ class SesTransport extends AbstractHttpTransport ], 'body' => [ 'Action' => 'SendRawEmail', - 'RawMessage.Data' => \base64_encode($message->toString()), + 'RawMessage.Data' => base64_encode($message->toString()), ], ]); diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/Smtp/SesTransport.php b/src/Symfony/Component/Mailer/Bridge/Amazon/Smtp/SesTransport.php index b2773100c4..9b11096a19 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/Smtp/SesTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/Smtp/SesTransport.php @@ -27,7 +27,7 @@ class SesTransport extends EsmtpTransport */ public function __construct(string $username, string $password, string $region = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null) { - parent::__construct(\sprintf('email-smtp.%s.amazonaws.com', $region ?: 'eu-west-1'), 587, 'tls', null, $dispatcher, $logger); + parent::__construct(sprintf('email-smtp.%s.amazonaws.com', $region ?: 'eu-west-1'), 587, 'tls', null, $dispatcher, $logger); $this->setUsername($username); $this->setPassword($password); diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Http/Api/SendgridTransport.php b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Http/Api/SendgridTransport.php index ff2a28bb89..b1678da346 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Http/Api/SendgridTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Http/Api/SendgridTransport.php @@ -67,7 +67,7 @@ class SendgridTransport extends AbstractApiTransport } $personalization = [ - 'to' => \array_map($addressStringifier, $this->getRecipients($email, $envelope)), + 'to' => array_map($addressStringifier, $this->getRecipients($email, $envelope)), 'subject' => $email->getSubject(), ]; if ($emails = array_map($addressStringifier, $email->getCc())) { diff --git a/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php b/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php index ef677d7de8..479fc5be42 100644 --- a/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php +++ b/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php @@ -47,7 +47,7 @@ final class DelayedSmtpEnvelope extends SmtpEnvelope return parent::getSender(); } - return self::getSenderFromHeaders($this->message->getHeaders()); + return new Address(self::getSenderFromHeaders($this->message->getHeaders())->getAddress()); } public function setRecipients(array $recipients): void @@ -74,7 +74,9 @@ final class DelayedSmtpEnvelope extends SmtpEnvelope $recipients = []; foreach (['to', 'cc', 'bcc'] as $name) { foreach ($headers->getAll($name) as $header) { - $recipients = array_merge($recipients, $header->getAddresses()); + foreach ($header->getAddresses() as $address) { + $recipients[] = new Address($address->getAddress()); + } } } diff --git a/src/Symfony/Component/Mailer/SmtpEnvelope.php b/src/Symfony/Component/Mailer/SmtpEnvelope.php index 7f1458d0f8..cf8e08285c 100644 --- a/src/Symfony/Component/Mailer/SmtpEnvelope.php +++ b/src/Symfony/Component/Mailer/SmtpEnvelope.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Mailer; use Symfony\Component\Mailer\Exception\InvalidArgumentException; use Symfony\Component\Mime\Address; -use Symfony\Component\Mime\NamedAddress; use Symfony\Component\Mime\RawMessage; /** @@ -42,7 +41,7 @@ class SmtpEnvelope public function setSender(Address $sender): void { - $this->sender = $sender instanceof NamedAddress ? new Address($sender->getAddress()) : $sender; + $this->sender = new Address($sender->getAddress()); } public function getSender(): Address @@ -50,6 +49,9 @@ class SmtpEnvelope return $this->sender; } + /** + * @param Address[] $recipients + */ public function setRecipients(array $recipients): void { if (!$recipients) { @@ -58,12 +60,10 @@ class SmtpEnvelope $this->recipients = []; foreach ($recipients as $recipient) { - if ($recipient instanceof NamedAddress) { - $recipient = new Address($recipient->getAddress()); - } elseif (!$recipient instanceof Address) { + if (!$recipient instanceof Address) { throw new InvalidArgumentException(sprintf('A recipient must be an instance of "%s" (got "%s").', Address::class, \is_object($recipient) ? \get_class($recipient) : \gettype($recipient))); } - $this->recipients[] = $recipient; + $this->recipients[] = new Address($recipient->getAddress()); } } diff --git a/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php b/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php index e64be3100b..7b32ed4d73 100644 --- a/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php +++ b/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php @@ -17,7 +17,6 @@ use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Header\Headers; use Symfony\Component\Mime\Message; use Symfony\Component\Mime\NamedAddress; -use Symfony\Component\Mime\RawMessage; class SmtpEnvelopeTest extends TestCase { @@ -54,19 +53,19 @@ class SmtpEnvelopeTest extends TestCase public function testSenderFromHeaders() { $headers = new Headers(); - $headers->addPathHeader('Return-Path', 'return@symfony.com'); + $headers->addPathHeader('Return-Path', new NamedAddress('return@symfony.com', 'return')); $headers->addMailboxListHeader('To', ['from@symfony.com']); $e = SmtpEnvelope::create(new Message($headers)); $this->assertEquals('return@symfony.com', $e->getSender()->getAddress()); $headers = new Headers(); - $headers->addMailboxHeader('Sender', 'sender@symfony.com'); + $headers->addMailboxHeader('Sender', new NamedAddress('sender@symfony.com', 'sender')); $headers->addMailboxListHeader('To', ['from@symfony.com']); $e = SmtpEnvelope::create(new Message($headers)); $this->assertEquals('sender@symfony.com', $e->getSender()->getAddress()); $headers = new Headers(); - $headers->addMailboxListHeader('From', ['from@symfony.com', 'some@symfony.com']); + $headers->addMailboxListHeader('From', [new NamedAddress('from@symfony.com', 'from'), 'some@symfony.com']); $headers->addMailboxListHeader('To', ['from@symfony.com']); $e = SmtpEnvelope::create(new Message($headers)); $this->assertEquals('from@symfony.com', $e->getSender()->getAddress()); @@ -77,7 +76,7 @@ class SmtpEnvelopeTest extends TestCase $headers = new Headers(); $headers->addMailboxListHeader('To', ['from@symfony.com']); $e = SmtpEnvelope::create($message = new Message($headers)); - $message->getHeaders()->addMailboxListHeader('From', ['from@symfony.com']); + $message->getHeaders()->addMailboxListHeader('From', [new NamedAddress('from@symfony.com', 'from')]); $this->assertEquals('from@symfony.com', $e->getSender()->getAddress()); } @@ -85,9 +84,9 @@ class SmtpEnvelopeTest extends TestCase { $headers = new Headers(); $headers->addPathHeader('Return-Path', 'return@symfony.com'); - $headers->addMailboxListHeader('To', ['to@symfony.com']); - $headers->addMailboxListHeader('Cc', ['cc@symfony.com']); - $headers->addMailboxListHeader('Bcc', ['bcc@symfony.com']); + $headers->addMailboxListHeader('To', [new NamedAddress('to@symfony.com', 'to')]); + $headers->addMailboxListHeader('Cc', [new NamedAddress('cc@symfony.com', 'cc')]); + $headers->addMailboxListHeader('Bcc', [new NamedAddress('bcc@symfony.com', 'bcc')]); $e = SmtpEnvelope::create(new Message($headers)); $this->assertEquals([new Address('to@symfony.com'), new Address('cc@symfony.com'), new Address('bcc@symfony.com')], $e->getRecipients()); } diff --git a/src/Symfony/Component/Mailer/Transport.php b/src/Symfony/Component/Mailer/Transport.php index 0d2056e77e..cc90eef0d8 100644 --- a/src/Symfony/Component/Mailer/Transport.php +++ b/src/Symfony/Component/Mailer/Transport.php @@ -68,9 +68,9 @@ class Transport throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a mailer name.', $dsn)); } - $user = \urldecode($parsedDsn['user'] ?? ''); - $pass = \urldecode($parsedDsn['pass'] ?? ''); - \parse_str($parsedDsn['query'] ?? '', $query); + $user = urldecode($parsedDsn['user'] ?? ''); + $pass = urldecode($parsedDsn['pass'] ?? ''); + parse_str($parsedDsn['query'] ?? '', $query); switch ($parsedDsn['host']) { case 'null': diff --git a/src/Symfony/Component/Mailer/Transport/AbstractTransport.php b/src/Symfony/Component/Mailer/Transport/AbstractTransport.php index 80ab1f7296..d4453bddb0 100644 --- a/src/Symfony/Component/Mailer/Transport/AbstractTransport.php +++ b/src/Symfony/Component/Mailer/Transport/AbstractTransport.php @@ -93,7 +93,7 @@ abstract class AbstractTransport implements TransportInterface */ protected function stringifyAddresses(array $addresses): array { - return \array_map(function (Address $a) { + return array_map(function (Address $a) { return $a->toString(); }, $addresses); } diff --git a/src/Symfony/Component/Mailer/Transport/Http/Api/AbstractApiTransport.php b/src/Symfony/Component/Mailer/Transport/Http/Api/AbstractApiTransport.php index 6aa6f53bd6..3364051f07 100644 --- a/src/Symfony/Component/Mailer/Transport/Http/Api/AbstractApiTransport.php +++ b/src/Symfony/Component/Mailer/Transport/Http/Api/AbstractApiTransport.php @@ -61,8 +61,8 @@ abstract class AbstractApiTransport extends AbstractTransport protected function getRecipients(Email $email, SmtpEnvelope $envelope): array { - return \array_filter($envelope->getRecipients(), function (Address $address) use ($email) { - return false === \in_array($address, \array_merge($email->getCc(), $email->getBcc()), true); + return array_filter($envelope->getRecipients(), function (Address $address) use ($email) { + return false === \in_array($address, array_merge($email->getCc(), $email->getBcc()), true); }); } } diff --git a/src/Symfony/Component/Messenger/Envelope.php b/src/Symfony/Component/Messenger/Envelope.php index be012fba94..a876a3c3ae 100644 --- a/src/Symfony/Component/Messenger/Envelope.php +++ b/src/Symfony/Component/Messenger/Envelope.php @@ -88,7 +88,7 @@ final class Envelope $cloned = clone $this; foreach ($cloned->stamps as $class => $stamps) { - if ($class === $type || \is_subclass_of($class, $type)) { + if ($class === $type || is_subclass_of($class, $type)) { unset($cloned->stamps[$class]); } } diff --git a/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php b/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php index 431d9ca97f..d9f607140c 100644 --- a/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php +++ b/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php @@ -61,7 +61,7 @@ class SendFailedMessageToFailureTransportListener implements EventSubscriberInte $throwable = $throwable->getNestedExceptions()[0]; } - $flattenedException = \class_exists(FlattenException::class) ? FlattenException::createFromThrowable($throwable) : null; + $flattenedException = class_exists(FlattenException::class) ? FlattenException::createFromThrowable($throwable) : null; $envelope = $envelope->withoutAll(ReceivedStamp::class) ->withoutAll(TransportMessageIdStamp::class) ->with(new SentToFailureTransportStamp($event->getReceiverName())) diff --git a/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php b/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php index 864a8612a1..4efad45cb9 100644 --- a/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php +++ b/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php @@ -38,7 +38,7 @@ class StackMiddleware implements MiddlewareInterface, StackInterface $this->stack->iterator = $middlewareIterator; } elseif ($middlewareIterator instanceof MiddlewareInterface) { $this->stack->stack[] = $middlewareIterator; - } elseif (!\is_iterable($middlewareIterator)) { + } elseif (!is_iterable($middlewareIterator)) { throw new \TypeError(sprintf('Argument 1 passed to %s() must be iterable of %s, %s given.', __METHOD__, MiddlewareInterface::class, \is_object($middlewareIterator) ? \get_class($middlewareIterator) : \gettype($middlewareIterator))); } else { $this->stack->iterator = (function () use ($middlewareIterator) { diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/Fixtures/long_receiver.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/Fixtures/long_receiver.php index 3f852e44fe..aa003fdf57 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/Fixtures/long_receiver.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/Fixtures/long_receiver.php @@ -35,7 +35,7 @@ $retryStrategy = new MultiplierRetryStrategy(3, 0); $worker = new Worker(['the_receiver' => $receiver], new class() implements MessageBusInterface { public function dispatch($envelope, array $stamps = []): Envelope { - echo 'Get envelope with message: '.\get_class($envelope->getMessage())."\n"; + echo 'Get envelope with message: '.get_class($envelope->getMessage())."\n"; echo sprintf("with stamps: %s\n", json_encode(array_keys($envelope->all()), JSON_PRETTY_PRINT)); sleep(30); diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php index 1196be9f08..9393e210b7 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php @@ -30,7 +30,7 @@ class ConnectionTest extends TestCase $stmt = $this->getStatementMock([ 'id' => 1, 'body' => '{"message":"Hi"}', - 'headers' => \json_encode(['type' => DummyMessage::class]), + 'headers' => json_encode(['type' => DummyMessage::class]), ]); $driverConnection diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php index 3a250fddbc..43a0ad9fe6 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php @@ -80,7 +80,7 @@ class DoctrineReceiverTest extends TestCase $connection->method('findAll')->with(50)->willReturn([$doctrineEnvelope1, $doctrineEnvelope2]); $receiver = new DoctrineReceiver($connection, $serializer); - $actualEnvelopes = \iterator_to_array($receiver->all(50)); + $actualEnvelopes = iterator_to_array($receiver->all(50)); $this->assertCount(2, $actualEnvelopes); $this->assertEquals(new DummyMessage('Hi'), $actualEnvelopes[0]->getMessage()); } diff --git a/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php b/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php index 51ef98dd31..721949c069 100644 --- a/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php +++ b/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php @@ -156,7 +156,7 @@ class Connection continue; } - if (!\is_numeric($arguments[$key])) { + if (!is_numeric($arguments[$key])) { throw new InvalidArgumentException(sprintf('Integer expected for queue argument "%s", %s given.', $key, \gettype($arguments[$key]))); } diff --git a/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php b/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php index bd528b5b43..5b3a31c9ec 100644 --- a/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php +++ b/src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php @@ -123,7 +123,7 @@ class Connection $this->executeQuery($queryBuilder->getSQL(), [ ':body' => $body, - ':headers' => \json_encode($headers), + ':headers' => json_encode($headers), ':queue_name' => $this->configuration['queue_name'], ':created_at' => self::formatDateTime($now), ':available_at' => self::formatDateTime($availableAt), @@ -155,7 +155,7 @@ class Connection return null; } - $doctrineEnvelope['headers'] = \json_decode($doctrineEnvelope['headers'], true); + $doctrineEnvelope['headers'] = json_decode($doctrineEnvelope['headers'], true); $queryBuilder = $this->driverConnection->createQueryBuilder() ->update($this->configuration['table_name']) diff --git a/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php b/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php index 7688503264..18b6091e9c 100644 --- a/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php +++ b/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php @@ -124,7 +124,7 @@ class Connection } foreach ($messages[$this->stream] ?? [] as $key => $message) { - $redisEnvelope = \json_decode($message['message'], true); + $redisEnvelope = json_decode($message['message'], true); return [ 'id' => $key, diff --git a/src/Symfony/Component/Messenger/Worker/StopWhenMemoryUsageIsExceededWorker.php b/src/Symfony/Component/Messenger/Worker/StopWhenMemoryUsageIsExceededWorker.php index 293e6a5e9d..c95e06992b 100644 --- a/src/Symfony/Component/Messenger/Worker/StopWhenMemoryUsageIsExceededWorker.php +++ b/src/Symfony/Component/Messenger/Worker/StopWhenMemoryUsageIsExceededWorker.php @@ -33,7 +33,7 @@ class StopWhenMemoryUsageIsExceededWorker implements WorkerInterface $this->memoryLimit = $memoryLimit; $this->logger = $logger; $this->memoryResolver = $memoryResolver ?: function () { - return \memory_get_usage(true); + return memory_get_usage(true); }; } diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 0e68e75ff8..f47aef1284 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -846,7 +846,7 @@ class OptionsResolver implements Options throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); } - $triggerDeprecation = 1 === \func_num_args() || \func_get_arg(1); + $triggerDeprecation = 1 === \func_num_args() || func_get_arg(1); // Shortcut for resolved options if (isset($this->resolved[$option]) || \array_key_exists($option, $this->resolved)) { diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php index d75bf91a94..5731cf4458 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php @@ -110,7 +110,7 @@ class PropertyInfoCacheExtractor implements PropertyInfoExtractorInterface, Prop } // Calling rawurlencode escapes special characters not allowed in PSR-6's keys - $encodedMethod = \rawurlencode($method); + $encodedMethod = rawurlencode($method); if (\array_key_exists($encodedMethod, $this->arrayCache) && \array_key_exists($serializedArguments, $this->arrayCache[$encodedMethod])) { return $this->arrayCache[$encodedMethod][$serializedArguments]; } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index b30d136821..ce16144639 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -173,7 +173,7 @@ abstract class AbstractToken implements TokenInterface { $serialized = $this->__serialize(); - if (null === $isCalledFromOverridingMethod = \func_num_args() ? \func_get_arg(0) : null) { + if (null === $isCalledFromOverridingMethod = \func_num_args() ? func_get_arg(0) : null) { $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object']; } diff --git a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php index d7b53d34b0..888458ea76 100644 --- a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php @@ -51,7 +51,7 @@ class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingE return true; } - if (\class_exists('ParagonIE_Sodium_Compat') && \method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) { + if (class_exists('ParagonIE_Sodium_Compat') && method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) { return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available(); } @@ -91,8 +91,8 @@ class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingE return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded); } if (\function_exists('sodium_crypto_pwhash_str_verify')) { - $valid = !$this->isPasswordTooLong($raw) && \sodium_crypto_pwhash_str_verify($encoded, $raw); - \sodium_memzero($raw); + $valid = !$this->isPasswordTooLong($raw) && sodium_crypto_pwhash_str_verify($encoded, $raw); + sodium_memzero($raw); return $valid; } @@ -113,12 +113,12 @@ class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingE private function encodePasswordSodiumFunction($raw) { - $hash = \sodium_crypto_pwhash_str( + $hash = sodium_crypto_pwhash_str( $raw, \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE ); - \sodium_memzero($raw); + sodium_memzero($raw); return $hash; } diff --git a/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php index 82cb1e17dd..0fa3f444a4 100644 --- a/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php @@ -48,7 +48,7 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti public static function isSupported(): bool { - if (\class_exists('ParagonIE_Sodium_Compat') && \method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) { + if (class_exists('ParagonIE_Sodium_Compat') && method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) { return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available(); } @@ -65,7 +65,7 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti } if (\function_exists('sodium_crypto_pwhash_str')) { - return \sodium_crypto_pwhash_str($raw, $this->opsLimit, $this->memLimit); + return sodium_crypto_pwhash_str($raw, $this->opsLimit, $this->memLimit); } if (\extension_loaded('libsodium')) { @@ -90,7 +90,7 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti } if (\function_exists('sodium_crypto_pwhash_str_verify')) { - return \sodium_crypto_pwhash_str_verify($encoded, $raw); + return sodium_crypto_pwhash_str_verify($encoded, $raw); } if (\extension_loaded('libsodium')) { diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php index 0caa0563fd..9b1d8dbb29 100644 --- a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php @@ -69,7 +69,7 @@ class AuthenticationException extends RuntimeException { $serialized = $this->__serialize(); - if (null === $isCalledFromOverridingMethod = \func_num_args() ? \func_get_arg(0) : null) { + if (null === $isCalledFromOverridingMethod = \func_num_args() ? func_get_arg(0) : null) { $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object']; } diff --git a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php index a8ccee0f7d..3d1895f452 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php @@ -97,7 +97,7 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener $password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']); } - if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) { + if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) { throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username))); } diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php index 4cc0677af8..b3661eae8a 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php @@ -85,7 +85,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL $password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']); } - if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) { + if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) { throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username))); } diff --git a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php index 882091dca8..b55c070fb8 100644 --- a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php +++ b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php @@ -69,6 +69,6 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface */ public function hasMetadataFor($value) { - return \is_object($value) || (\is_string($value) && (\class_exists($value) || \interface_exists($value, false))); + return \is_object($value) || (\is_string($value) && (class_exists($value) || interface_exists($value, false))); } } diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 5f0fc24a1f..7b66ee9aed 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -312,7 +312,7 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer */ public function supportsDenormalization($data, $type, $format = null) { - return \class_exists($type) || (\interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type)); + return class_exists($type) || (interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type)); } /** @@ -567,7 +567,7 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer protected function createChildContext(array $parentContext, $attribute/*, ?string $format */) { if (\func_num_args() >= 3) { - $format = \func_get_arg(2); + $format = func_get_arg(2); } else { @trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED); $format = null; diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index d5a1990f0b..dcf2deef80 100644 --- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -65,7 +65,7 @@ class CustomNormalizer implements NormalizerInterface, DenormalizerInterface, Se */ public function supportsDenormalization($data, $type, $format = null) { - return \is_subclass_of($type, DenormalizableInterface::class); + return is_subclass_of($type, DenormalizableInterface::class); } /** diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php index f766286b2b..118e9856f5 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php @@ -36,7 +36,7 @@ class ObjectNormalizer extends AbstractObjectNormalizer public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null, PropertyTypeExtractorInterface $propertyTypeExtractor = null, ClassDiscriminatorResolverInterface $classDiscriminatorResolver = null, callable $objectClassResolver = null, array $defaultContext = []) { - if (!\class_exists(PropertyAccess::class)) { + if (!class_exists(PropertyAccess::class)) { throw new LogicException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.'); } diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index b950ba58b0..c7ccd9fd9f 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -84,7 +84,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface } if (!($normalizer instanceof NormalizerInterface || $normalizer instanceof DenormalizerInterface)) { - @trigger_error(\sprintf('Passing normalizers ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing normalizers ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class), E_USER_DEPRECATED); // throw new \InvalidArgumentException(\sprintf('The class "%s" does not implement "%s" or "%s".', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class)); } } @@ -104,7 +104,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface } if (!($encoder instanceof EncoderInterface || $encoder instanceof DecoderInterface)) { - @trigger_error(\sprintf('Passing encoders ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($encoder), EncoderInterface::class, DecoderInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing encoders ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($encoder), EncoderInterface::class, DecoderInterface::class), E_USER_DEPRECATED); // throw new \InvalidArgumentException(\sprintf('The class "%s" does not implement "%s" or "%s".', \get_class($normalizer), EncoderInterface::class, DecoderInterface::class)); } } diff --git a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php index d9fc71911f..8ff2587dd5 100644 --- a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php +++ b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php @@ -46,7 +46,7 @@ class TranslatorPathsPass extends AbstractRecursivePass } foreach ($this->findControllerArguments($container) as $controller => $argument) { - $id = \substr($controller, 0, \strpos($controller, ':') ?: \strlen($controller)); + $id = substr($controller, 0, strpos($controller, ':') ?: \strlen($controller)); if ($container->hasDefinition($id)) { list($locatorRef) = $argument->getValues(); $this->controllers[(string) $locatorRef][$container->getDefinition($id)->getClass()] = true; diff --git a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php index 84fd7400f8..3e1a152533 100644 --- a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php @@ -204,7 +204,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface if (\func_num_args() < 3 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { @trigger_error(sprintf('The "%s()" method will have a new "string $filename" argument in version 5.0, not defining it is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED); } - $filename = 2 < \func_num_args() ? \func_get_arg(2) : ''; + $filename = 2 < \func_num_args() ? func_get_arg(2) : ''; $tokenIterator = new \ArrayIterator($tokens); diff --git a/src/Symfony/Component/Translation/LoggingTranslator.php b/src/Symfony/Component/Translation/LoggingTranslator.php index 3a84bf1170..2996167d08 100644 --- a/src/Symfony/Component/Translation/LoggingTranslator.php +++ b/src/Symfony/Component/Translation/LoggingTranslator.php @@ -84,6 +84,10 @@ class LoggingTranslator implements TranslatorInterface, LegacyTranslatorInterfac { $prev = $this->translator->getLocale(); $this->translator->setLocale($locale); + if ($prev === $locale) { + return; + } + $this->logger->debug(sprintf('The locale of the translator has changed from "%s" to "%s".', $prev, $locale)); } diff --git a/src/Symfony/Component/Translation/PluralizationRules.php b/src/Symfony/Component/Translation/PluralizationRules.php index ee8609fada..77c276073f 100644 --- a/src/Symfony/Component/Translation/PluralizationRules.php +++ b/src/Symfony/Component/Translation/PluralizationRules.php @@ -32,7 +32,7 @@ class PluralizationRules */ public static function get($number, $locale/*, bool $triggerDeprecation = true*/) { - if (3 > \func_num_args() || \func_get_arg(2)) { + if (3 > \func_num_args() || func_get_arg(2)) { @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); } diff --git a/src/Symfony/Component/Translation/Resources/bin/translation-status.php b/src/Symfony/Component/Translation/Resources/bin/translation-status.php index 0d37c3e0aa..96ccc10574 100644 --- a/src/Symfony/Component/Translation/Resources/bin/translation-status.php +++ b/src/Symfony/Component/Translation/Resources/bin/translation-status.php @@ -73,7 +73,7 @@ foreach ($config['original_files'] as $originalFilePath) { $translationStatus = calculateTranslationStatus($originalFilePath, $translationFilePaths); $totalMissingTranslations += array_sum(array_map(function ($translation) { - return \count($translation['missingKeys']); + return count($translation['missingKeys']); }, array_values($translationStatus))); printTranslationStatus($originalFilePath, $translationStatus, $config['verbose_output']); @@ -113,8 +113,8 @@ function calculateTranslationStatus($originalFilePath, $translationFilePaths) $missingKeys = array_diff_key($allTranslationKeys, $translatedKeys); $translationStatus[$locale] = [ - 'total' => \count($allTranslationKeys), - 'translated' => \count($translatedKeys), + 'total' => count($allTranslationKeys), + 'translated' => count($translatedKeys), 'missingKeys' => $missingKeys, ]; } @@ -176,7 +176,7 @@ function printTable($translations, $verboseOutput) textColorNormal(); - if (true === $verboseOutput && \count($translation['missingKeys']) > 0) { + if (true === $verboseOutput && count($translation['missingKeys']) > 0) { echo str_repeat('-', 80).PHP_EOL; echo '| Missing Translations:'.PHP_EOL; diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index f5ce39ef0d..9846c8338b 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -433,7 +433,7 @@ EOF protected function computeFallbackLocales($locale) { if (null === $this->parentLocales) { - $parentLocales = \json_decode(\file_get_contents(__DIR__.'/Resources/data/parents.json'), true); + $parentLocales = json_decode(file_get_contents(__DIR__.'/Resources/data/parents.json'), true); } $locales = []; diff --git a/src/Symfony/Component/VarDumper/Caster/ClassStub.php b/src/Symfony/Component/VarDumper/Caster/ClassStub.php index b655ae960e..0b9329dbe9 100644 --- a/src/Symfony/Component/VarDumper/Caster/ClassStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ClassStub.php @@ -57,7 +57,7 @@ class ClassStub extends ConstStub if (false !== strpos($identifier, "class@anonymous\0")) { $this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) { - return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0]; + return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0]; }, $identifier); } diff --git a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php index 54f0ba1530..ec168c8da9 100644 --- a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php @@ -283,7 +283,7 @@ class ExceptionCaster if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) { $a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) { - return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0]; + return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0]; }, $a[Caster::PREFIX_PROTECTED.'message']); } diff --git a/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php b/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php index da037b6b3e..d8afd70400 100644 --- a/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php @@ -21,7 +21,7 @@ class ProxyManagerCaster { public static function castProxy(ProxyInterface $c, array $a, Stub $stub, $isNested) { - if ($parent = \get_parent_class($c)) { + if ($parent = get_parent_class($c)) { $stub->class .= ' - '.$parent; } $stub->class .= '@proxy'; diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index b8318c514f..58c2117737 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -73,7 +73,7 @@ class VarCloner extends AbstractCloner } if ($gk !== $k) { $fromObjCast = true; - $refs = $vals = \array_values($queue[$i]); + $refs = $vals = array_values($queue[$i]); break; } } @@ -84,7 +84,7 @@ class VarCloner extends AbstractCloner if ($zvalIsRef = $vals[$k] === $cookie) { $vals[$k] = &$stub; // Break hard references to make $queue completely unset($stub); // independent from the original structure - if ($v instanceof Stub && isset($hardRefs[\spl_object_id($v)])) { + if ($v instanceof Stub && isset($hardRefs[spl_object_id($v)])) { $vals[$k] = $refs[$k] = $v; if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) { ++$v->value->refCount; @@ -94,7 +94,7 @@ class VarCloner extends AbstractCloner } $refs[$k] = $vals[$k] = new Stub(); $refs[$k]->value = $v; - $h = \spl_object_id($refs[$k]); + $h = spl_object_id($refs[$k]); $hardRefs[$h] = &$refs[$k]; $values[$h] = $v; $vals[$k]->handle = ++$refsCounter; @@ -112,22 +112,22 @@ class VarCloner extends AbstractCloner if ('' === $v) { continue 2; } - if (!\preg_match('//u', $v)) { + if (!preg_match('//u', $v)) { $stub = new Stub(); $stub->type = Stub::TYPE_STRING; $stub->class = Stub::STRING_BINARY; if (0 <= $maxString && 0 < $cut = \strlen($v) - $maxString) { $stub->cut = $cut; - $stub->value = \substr($v, 0, -$cut); + $stub->value = substr($v, 0, -$cut); } else { $stub->value = $v; } - } elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = \mb_strlen($v, 'UTF-8') - $maxString) { + } elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = mb_strlen($v, 'UTF-8') - $maxString) { $stub = new Stub(); $stub->type = Stub::TYPE_STRING; $stub->class = Stub::STRING_UTF8; $stub->cut = $cut; - $stub->value = \mb_substr($v, 0, $maxString, 'UTF-8'); + $stub->value = mb_substr($v, 0, $maxString, 'UTF-8'); } else { continue 2; } @@ -173,7 +173,7 @@ class VarCloner extends AbstractCloner case \is_object($v): case $v instanceof \__PHP_Incomplete_Class: - if (empty($objRefs[$h = \spl_object_id($v)])) { + if (empty($objRefs[$h = spl_object_id($v)])) { $stub = new Stub(); $stub->type = Stub::TYPE_OBJECT; $stub->class = \get_class($v); @@ -184,7 +184,7 @@ class VarCloner extends AbstractCloner if (Stub::TYPE_OBJECT !== $stub->type || null === $stub->value) { break; } - $stub->handle = $h = \spl_object_id($stub->value); + $stub->handle = $h = spl_object_id($stub->value); } $stub->value = null; if (0 <= $maxItems && $maxItems <= $pos && $minimumDepthReached) { @@ -206,7 +206,7 @@ class VarCloner extends AbstractCloner if (empty($resRefs[$h = (int) $v])) { $stub = new Stub(); $stub->type = Stub::TYPE_RESOURCE; - if ('Unknown' === $stub->class = @\get_resource_type($v)) { + if ('Unknown' === $stub->class = @get_resource_type($v)) { $stub->class = 'Closed'; } $stub->value = $v; diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index 74a324691e..87b3156d41 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -40,7 +40,7 @@ class Exporter $refs = $values; foreach ($values as $k => $value) { if (\is_resource($value)) { - throw new NotInstantiableTypeException(\get_resource_type($value).' resource'); + throw new NotInstantiableTypeException(get_resource_type($value).' resource'); } $refs[$k] = $objectsPool; @@ -115,14 +115,14 @@ class Exporter goto handle_value; } - if (\method_exists($class, '__sleep')) { + if (method_exists($class, '__sleep')) { if (!\is_array($sleep = $value->__sleep())) { trigger_error('serialize(): __sleep should return an array only containing the names of instance-variables to serialize', E_USER_NOTICE); $value = null; goto handle_value; } foreach ($sleep as $name) { - if (\property_exists($value, $name) && !$reflector->hasProperty($name)) { + if (property_exists($value, $name) && !$reflector->hasProperty($name)) { $arrayValue[$name] = $value->$name; } } @@ -171,7 +171,7 @@ class Exporter $objectsPool[$value] = [$id = \count($objectsPool)]; $properties = self::prepare($properties, $objectsPool, $refsPool, $objectsCount, $valueIsStatic); ++$objectsCount; - $objectsPool[$value] = [$id, $class, $properties, \method_exists($class, '__unserialize') ? -$objectsCount : (\method_exists($class, '__wakeup') ? $objectsCount : 0)]; + $objectsPool[$value] = [$id, $class, $properties, method_exists($class, '__unserialize') ? -$objectsCount : (method_exists($class, '__wakeup') ? $objectsCount : 0)]; $value = new Reference($id); diff --git a/src/Symfony/Component/VarExporter/Internal/Hydrator.php b/src/Symfony/Component/VarExporter/Internal/Hydrator.php index 5f64adf96f..364d292d91 100644 --- a/src/Symfony/Component/VarExporter/Internal/Hydrator.php +++ b/src/Symfony/Component/VarExporter/Internal/Hydrator.php @@ -65,7 +65,7 @@ class Hydrator }; } - if (!\class_exists($class) && !\interface_exists($class, false) && !\trait_exists($class, false)) { + if (!class_exists($class) && !interface_exists($class, false) && !trait_exists($class, false)) { throw new ClassNotFoundException($class); } $classReflector = new \ReflectionClass($class); diff --git a/src/Symfony/Component/VarExporter/Internal/Registry.php b/src/Symfony/Component/VarExporter/Internal/Registry.php index b5069dd16a..dd2792133e 100644 --- a/src/Symfony/Component/VarExporter/Internal/Registry.php +++ b/src/Symfony/Component/VarExporter/Internal/Registry.php @@ -65,7 +65,7 @@ class Registry public static function getClassReflector($class, $instantiableWithoutConstructor = false, $cloneable = null) { - if (!($isClass = \class_exists($class)) && !\interface_exists($class, false) && !\trait_exists($class, false)) { + if (!($isClass = class_exists($class)) && !interface_exists($class, false) && !trait_exists($class, false)) { throw new ClassNotFoundException($class); } $reflector = new \ReflectionClass($class); @@ -86,14 +86,14 @@ class Registry $proto = $reflector->newInstanceWithoutConstructor(); $instantiableWithoutConstructor = true; } catch (\ReflectionException $e) { - $proto = $reflector->implementsInterface('Serializable') && (\PHP_VERSION_ID < 70400 || !\method_exists($class, '__unserialize')) ? 'C:' : 'O:'; + $proto = $reflector->implementsInterface('Serializable') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__unserialize')) ? 'C:' : 'O:'; if ('C:' === $proto && !$reflector->getMethod('unserialize')->isInternal()) { $proto = null; } elseif (false === $proto = @unserialize($proto.\strlen($class).':"'.$class.'":0:{}')) { throw new NotInstantiableTypeException($class); } } - if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !\method_exists($class, '__sleep') && (\PHP_VERSION_ID < 70400 || !\method_exists($class, '__serialize'))) { + if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !method_exists($class, '__sleep') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__serialize'))) { try { serialize($proto); } catch (\Exception $e) { @@ -103,7 +103,7 @@ class Registry } if (null === $cloneable) { - if (($proto instanceof \Reflector || $proto instanceof \ReflectionGenerator || $proto instanceof \ReflectionType || $proto instanceof \IteratorIterator || $proto instanceof \RecursiveIteratorIterator) && (!$proto instanceof \Serializable && !\method_exists($proto, '__wakeup') && (\PHP_VERSION_ID < 70400 || !\method_exists($class, '__unserialize')))) { + if (($proto instanceof \Reflector || $proto instanceof \ReflectionGenerator || $proto instanceof \ReflectionType || $proto instanceof \IteratorIterator || $proto instanceof \RecursiveIteratorIterator) && (!$proto instanceof \Serializable && !method_exists($proto, '__wakeup') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__unserialize')))) { throw new NotInstantiableTypeException($class); } diff --git a/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php b/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php index 84206aea77..82034bb7bd 100644 --- a/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php +++ b/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php @@ -246,7 +246,7 @@ class GraphvizDumper implements DumperInterface */ protected function escape($value): string { - return \is_bool($value) ? ($value ? '1' : '0') : \addslashes($value); + return \is_bool($value) ? ($value ? '1' : '0') : addslashes($value); } protected function addAttributes(array $attributes): string diff --git a/src/Symfony/Component/Workflow/Tests/StateMachineTest.php b/src/Symfony/Component/Workflow/Tests/StateMachineTest.php index dd791239c4..9224f7cb12 100644 --- a/src/Symfony/Component/Workflow/Tests/StateMachineTest.php +++ b/src/Symfony/Component/Workflow/Tests/StateMachineTest.php @@ -78,7 +78,7 @@ class StateMachineTest extends TestCase $net = new StateMachine($definition, null, $dispatcher); $dispatcher->addListener('workflow.guard', function (GuardEvent $event) { - $event->addTransitionBlocker(new TransitionBlocker(\sprintf('Transition blocker of place %s', $event->getTransition()->getFroms()[0]), 'blocker')); + $event->addTransitionBlocker(new TransitionBlocker(sprintf('Transition blocker of place %s', $event->getTransition()->getFroms()[0]), 'blocker')); }); $subject = new Subject(); diff --git a/src/Symfony/Contracts/Cache/composer.json b/src/Symfony/Contracts/Cache/composer.json index 719146ace1..e30b0bca8f 100644 --- a/src/Symfony/Contracts/Cache/composer.json +++ b/src/Symfony/Contracts/Cache/composer.json @@ -16,10 +16,10 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.1.3", + "psr/cache": "^1.0" }, "suggest": { - "psr/cache": "", "symfony/cache-implementation": "" }, "autoload": { diff --git a/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php b/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php index 6763198937..8d1762913c 100644 --- a/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php +++ b/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php @@ -80,7 +80,7 @@ switch ($vars['REQUEST_URI']) { case '/post': $output = json_encode($_POST + ['REQUEST_METHOD' => $vars['REQUEST_METHOD']], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); header('Content-Type: application/json', true); - header('Content-Length: '.\strlen($output)); + header('Content-Length: '.strlen($output)); echo $output; exit; diff --git a/src/Symfony/Contracts/Service/composer.json b/src/Symfony/Contracts/Service/composer.json index 11f98854f1..d8738fa213 100644 --- a/src/Symfony/Contracts/Service/composer.json +++ b/src/Symfony/Contracts/Service/composer.json @@ -16,10 +16,10 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.1.3", + "psr/container": "^1.0" }, "suggest": { - "psr/container": "", "symfony/service-implementation": "" }, "autoload": { diff --git a/src/Symfony/Contracts/Translation/TranslatorTrait.php b/src/Symfony/Contracts/Translation/TranslatorTrait.php index c1021923c8..488b4f4f23 100644 --- a/src/Symfony/Contracts/Translation/TranslatorTrait.php +++ b/src/Symfony/Contracts/Translation/TranslatorTrait.php @@ -91,7 +91,7 @@ EOF; } } else { $leftNumber = '-Inf' === $matches['left'] ? -INF : (float) $matches['left']; - $rightNumber = \is_numeric($matches['right']) ? (float) $matches['right'] : INF; + $rightNumber = is_numeric($matches['right']) ? (float) $matches['right'] : INF; if (('[' === $matches['left_delimiter'] ? $number >= $leftNumber : $number > $leftNumber) && (']' === $matches['right_delimiter'] ? $number <= $rightNumber : $number < $rightNumber) @@ -117,7 +117,7 @@ EOF; $message = sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number); - if (\class_exists(InvalidArgumentException::class)) { + if (class_exists(InvalidArgumentException::class)) { throw new InvalidArgumentException($message); } diff --git a/src/Symfony/Contracts/composer.json b/src/Symfony/Contracts/composer.json index 850d66eb54..a3fa4afd98 100644 --- a/src/Symfony/Contracts/composer.json +++ b/src/Symfony/Contracts/composer.json @@ -16,11 +16,11 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.1.3", + "psr/cache": "^1.0", + "psr/container": "^1.0" }, "require-dev": { - "psr/cache": "^1.0", - "psr/container": "^1.0", "symfony/polyfill-intl-idn": "^1.10" }, "replace": { @@ -31,8 +31,6 @@ "symfony/translation-contracts": "self.version" }, "suggest": { - "psr/cache": "When using the Cache contracts", - "psr/container": "When using the Service contracts", "psr/event-dispatcher": "When using the EventDispatcher contracts", "symfony/cache-implementation": "", "symfony/event-dispatcher-implementation": "",