diff --git a/.php_cs.dist b/.php_cs.dist index 5d699d34d9..8b691441a3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -13,6 +13,7 @@ return PhpCsFixer\Config::create() 'array_syntax' => ['syntax' => 'short'], 'fopen_flags' => false, 'protected_to_private' => false, + 'native_constant_invocation' => true, 'combine_nested_dirname' => true, ]) ->setRiskyAllowed(true) diff --git a/CHANGELOG-4.4.md b/CHANGELOG-4.4.md index ce1903a958..2c30e0de97 100644 --- a/CHANGELOG-4.4.md +++ b/CHANGELOG-4.4.md @@ -7,6 +7,15 @@ in 4.4 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.4.0...v4.4.1 +* 4.4.13 (2020-09-02) + + * security #cve-2020-15094 Remove headers with internal meaning from HttpClient responses (mpdude) + * bug #38024 [Console] Fix undefined index for inconsistent command name definition (chalasr) + * bug #38023 [DI] fix inlining of non-shared services (nicolas-grekas) + * bug #38020 [PhpUnitBridge] swallow deprecations (xabbuh) + * bug #38010 [Cache] Psr16Cache does not handle Proxy cache items (alex-dev) + * bug #37937 [Serializer] fixed fix encoding of cache keys with anonymous classes (michaelzangerle) + * 4.4.12 (2020-08-31) * bug #37966 [HttpClient][MockHttpClient][DX] Throw when the response factory callable does not return a valid response (fancyweb) diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index ad94a37ff0..211992d149 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -242,11 +242,11 @@ abstract class AbstractDoctrineExtension extends Extension $configPath = $this->getMappingResourceConfigDirectory(); $extension = $this->getMappingResourceExtension(); - if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml', GLOB_NOSORT)) { + if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml', \GLOB_NOSORT)) { $driver = 'xml'; - } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml', GLOB_NOSORT)) { + } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml', \GLOB_NOSORT)) { $driver = 'yml'; - } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php', GLOB_NOSORT)) { + } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php', \GLOB_NOSORT)) { $driver = 'php'; } else { // add the closest existing directory as a resource diff --git a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php index d6d0c5dabf..056b4ab9a9 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php @@ -99,7 +99,7 @@ trait ServerLogHandlerTrait try { if (-1 === stream_socket_sendto($this->socket, $recordFormatted)) { - stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR); + stream_socket_shutdown($this->socket, \STREAM_SHUT_RDWR); // Let's retry: the persistent connection might just be stale if ($this->socket = $this->createSocket()) { @@ -125,7 +125,7 @@ trait ServerLogHandlerTrait private function createSocket() { - $socket = stream_socket_client($this->host, $errno, $errstr, 0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_PERSISTENT, $this->context); + $socket = stream_socket_client($this->host, $errno, $errstr, 0, \STREAM_CLIENT_CONNECT | \STREAM_CLIENT_ASYNC_CONNECT | \STREAM_CLIENT_PERSISTENT, $this->context); if ($socket) { stream_set_blocking($socket, false); diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index ed4ee5c8eb..c6f9a2170e 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -89,7 +89,7 @@ class DeprecationErrorHandler { $deprecations = []; $previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) { - if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type && (E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) { + if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) { if ($previousErrorHandler) { return $previousErrorHandler($type, $msg, $file, $line, $context); } @@ -121,7 +121,7 @@ class DeprecationErrorHandler */ public function handleError($type, $msg, $file, $line, $context = []) { - if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type && (E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) { + if ((\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) { return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context); } @@ -337,7 +337,7 @@ class DeprecationErrorHandler return 'PHPUnit\Util\ErrorHandler::handleError'; } - foreach (debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) { + foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) { if (isset($frame['object']) && $frame['object'] instanceof TestResult) { return new ErrorHandler( $frame['object']->getConvertDeprecationsToExceptions(), @@ -376,21 +376,21 @@ class DeprecationErrorHandler if (\DIRECTORY_SEPARATOR === '\\') { return (\function_exists('sapi_windows_vt100_support') - && sapi_windows_vt100_support(STDOUT)) + && sapi_windows_vt100_support(\STDOUT)) || false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM'); } if (\function_exists('stream_isatty')) { - return stream_isatty(STDOUT); + return stream_isatty(\STDOUT); } if (\function_exists('posix_isatty')) { - return posix_isatty(STDOUT); + return posix_isatty(\STDOUT); } - $stat = fstat(STDOUT); + $stat = fstat(\STDOUT); // Check if formatted mode is S_IFCHR return $stat ? 0020000 === ($stat['mode'] & 0170000) : false; diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php index 11984df735..a4892c3d5d 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php @@ -173,13 +173,13 @@ class Configuration 'quiet' => [], ]; - if ('' === $normalizedConfiguration['disabled'] || filter_var($normalizedConfiguration['disabled'], FILTER_VALIDATE_BOOLEAN)) { + if ('' === $normalizedConfiguration['disabled'] || filter_var($normalizedConfiguration['disabled'], \FILTER_VALIDATE_BOOLEAN)) { return self::inDisabledMode(); } $verboseOutput = []; foreach (['unsilenced', 'direct', 'indirect', 'self', 'other'] as $group) { - $verboseOutput[$group] = filter_var($normalizedConfiguration['verbose'], FILTER_VALIDATE_BOOLEAN); + $verboseOutput[$group] = filter_var($normalizedConfiguration['verbose'], \FILTER_VALIDATE_BOOLEAN); } if (\is_array($normalizedConfiguration['quiet'])) { diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index b209618f61..2ee9e48c5d 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -270,7 +270,10 @@ class Deprecation if (file_exists($v.'/composer/installed.json')) { self::$vendors[] = $v; $loader = require $v.'/autoload.php'; - $paths = self::getSourcePathsFromPrefixes(array_merge($loader->getPrefixes(), $loader->getPrefixesPsr4())); + $paths = self::addSourcePathsFromPrefixes( + array_merge($loader->getPrefixes(), $loader->getPrefixesPsr4()), + $paths + ); } } } @@ -286,15 +289,17 @@ class Deprecation return self::$vendors; } - private static function getSourcePathsFromPrefixes(array $prefixesByNamespace) + private static function addSourcePathsFromPrefixes(array $prefixesByNamespace, array $paths) { foreach ($prefixesByNamespace as $prefixes) { foreach ($prefixes as $prefix) { if (false !== realpath($prefix)) { - yield realpath($prefix); + $paths[] = realpath($prefix); } } } + + return $paths; } /** diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/autoload.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/autoload.php new file mode 100644 index 0000000000..c1c963926b --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/autoload.php @@ -0,0 +1,5 @@ + [__DIR__.'/../foo/lib/'], + ]; + } + + public function loadClass($className) + { + foreach ($this->getPrefixesPsr4() as $prefix => $baseDirs) { + if (strpos($className, $prefix) !== 0) { + continue; + } + + foreach ($baseDirs as $baseDir) { + $file = str_replace([$prefix, '\\'], [$baseDir, '/'], $className.'.php'); + if (file_exists($file)) { + require $file; + } + } + } + } +} + +class ComposerAutoloaderInitFakeBis +{ + private static $loader; + + public static function getLoader() + { + if (null === self::$loader) { + self::$loader = new ComposerLoaderFakeBis(); + spl_autoload_register([self::$loader, 'loadClass']); + } + + return self::$loader; + } +} diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/installed.json b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/installed.json new file mode 100644 index 0000000000..bf4fecc9fb --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/installed.json @@ -0,0 +1 @@ +{"just here": "for the detection"} diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/foo/lib/SomeOtherService.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/foo/lib/SomeOtherService.php new file mode 100644 index 0000000000..b1e8fab2bd --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/foo/lib/SomeOtherService.php @@ -0,0 +1,14 @@ +directDeprecations(); +?> +--EXPECTF-- +Remaining direct deprecation notices (2) + + 1x: deprecatedApi is deprecated! You should stop relying on it! + 1x in AppService::directDeprecations from App\Services + + 1x: deprecatedApi from foo is deprecated! You should stop relying on it! + 1x in AppService::directDeprecations from App\Services diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php index 635c43c4af..f47ba9fa22 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php @@ -141,8 +141,8 @@ class DnsMockTest extends TestCase $this->assertFalse(DnsMock::dns_get_record('foobar.com')); $this->assertSame($records, DnsMock::dns_get_record('example.com')); - $this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_ALL)); - $this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR)); - $this->assertSame([$ptr], DnsMock::dns_get_record('example.com', DNS_PTR)); + $this->assertSame($records, DnsMock::dns_get_record('example.com', \DNS_ALL)); + $this->assertSame($records, DnsMock::dns_get_record('example.com', \DNS_A | \DNS_PTR)); + $this->assertSame([$ptr], DnsMock::dns_get_record('example.com', \DNS_PTR)); } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php index 2830daef6e..5e6350e673 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ExpectDeprecationTraitTest.php @@ -26,7 +26,7 @@ final class ExpectDeprecationTraitTest extends TestCase public function testOne() { $this->expectDeprecation('foo'); - @trigger_error('foo', E_USER_DEPRECATED); + @trigger_error('foo', \E_USER_DEPRECATED); } /** @@ -38,7 +38,7 @@ final class ExpectDeprecationTraitTest extends TestCase public function testOneInIsolation() { $this->expectDeprecation('foo'); - @trigger_error('foo', E_USER_DEPRECATED); + @trigger_error('foo', \E_USER_DEPRECATED); } /** @@ -50,8 +50,8 @@ final class ExpectDeprecationTraitTest extends TestCase { $this->expectDeprecation('foo'); $this->expectDeprecation('bar'); - @trigger_error('foo', E_USER_DEPRECATED); - @trigger_error('bar', E_USER_DEPRECATED); + @trigger_error('foo', \E_USER_DEPRECATED); + @trigger_error('bar', \E_USER_DEPRECATED); } /** @@ -64,8 +64,8 @@ final class ExpectDeprecationTraitTest extends TestCase public function testOneWithAnnotation() { $this->expectDeprecation('bar'); - @trigger_error('foo', E_USER_DEPRECATED); - @trigger_error('bar', E_USER_DEPRECATED); + @trigger_error('foo', \E_USER_DEPRECATED); + @trigger_error('bar', \E_USER_DEPRECATED); } /** @@ -80,9 +80,9 @@ final class ExpectDeprecationTraitTest extends TestCase { $this->expectDeprecation('ccc'); $this->expectDeprecation('fcy'); - @trigger_error('foo', E_USER_DEPRECATED); - @trigger_error('bar', E_USER_DEPRECATED); - @trigger_error('ccc', E_USER_DEPRECATED); - @trigger_error('fcy', E_USER_DEPRECATED); + @trigger_error('foo', \E_USER_DEPRECATED); + @trigger_error('bar', \E_USER_DEPRECATED); + @trigger_error('ccc', \E_USER_DEPRECATED); + @trigger_error('fcy', \E_USER_DEPRECATED); } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ExpectedDeprecationAnnotationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ExpectedDeprecationAnnotationTest.php index 259c99162a..329bf694d2 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ExpectedDeprecationAnnotationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ExpectedDeprecationAnnotationTest.php @@ -24,7 +24,7 @@ final class ExpectedDeprecationAnnotationTest extends TestCase */ public function testOne() { - @trigger_error('foo', E_USER_DEPRECATED); + @trigger_error('foo', \E_USER_DEPRECATED); } /** @@ -37,7 +37,7 @@ final class ExpectedDeprecationAnnotationTest extends TestCase */ public function testMany() { - @trigger_error('foo', E_USER_DEPRECATED); - @trigger_error('bar', E_USER_DEPRECATED); + @trigger_error('foo', \E_USER_DEPRECATED); + @trigger_error('bar', \E_USER_DEPRECATED); } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/FailTests/ExpectDeprecationTraitTestFail.php b/src/Symfony/Bridge/PhpUnit/Tests/FailTests/ExpectDeprecationTraitTestFail.php index 43a3e34f96..ba35b268de 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/FailTests/ExpectDeprecationTraitTestFail.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/FailTests/ExpectDeprecationTraitTestFail.php @@ -32,7 +32,7 @@ final class ExpectDeprecationTraitTestFail extends TestCase public function testOne() { $this->expectDeprecation('foo'); - @trigger_error('bar', E_USER_DEPRECATED); + @trigger_error('bar', \E_USER_DEPRECATED); } /** @@ -44,6 +44,6 @@ final class ExpectDeprecationTraitTestFail extends TestCase public function testOneInIsolation() { $this->expectDeprecation('foo'); - @trigger_error('bar', E_USER_DEPRECATED); + @trigger_error('bar', \E_USER_DEPRECATED); } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php index 28277161b9..1471e9c7be 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php @@ -18,7 +18,7 @@ class ProcessIsolationTest extends TestCase */ public function testIsolation() { - @trigger_error('Test abc', E_USER_DEPRECATED); + @trigger_error('Test abc', \E_USER_DEPRECATED); $this->addToAssertionCount(1); } @@ -27,6 +27,6 @@ class ProcessIsolationTest extends TestCase $this->expectException('PHPUnit\Framework\Exception'); $this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.'); - trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING); + trigger_error('Test that PHPUnit\'s error handler fires.', \E_USER_WARNING); } } diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php index 39b61ca5e1..c03a4c2962 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -30,7 +30,7 @@ $getEnvVar = function ($name, $default = false) use ($argv) { return null; } if (is_dir($probableConfig)) { - return $getPhpUnitConfig($probableConfig.DIRECTORY_SEPARATOR.'phpunit.xml'); + return $getPhpUnitConfig($probableConfig.\DIRECTORY_SEPARATOR.'phpunit.xml'); } if (file_exists($probableConfig)) { @@ -93,19 +93,19 @@ $passthruOrFail = function ($command) { } }; -if (PHP_VERSION_ID >= 80000) { +if (\PHP_VERSION_ID >= 80000) { // PHP 8 requires PHPUnit 9.3+ $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.3'); -} elseif (PHP_VERSION_ID >= 70200) { +} elseif (\PHP_VERSION_ID >= 70200) { // PHPUnit 8 requires PHP 7.2+ $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3'); -} elseif (PHP_VERSION_ID >= 70100) { +} elseif (\PHP_VERSION_ID >= 70100) { // PHPUnit 7 requires PHP 7.1+ $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5'); -} elseif (PHP_VERSION_ID >= 70000) { +} elseif (\PHP_VERSION_ID >= 70000) { // PHPUnit 6 requires PHP 7.0+ $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5'); -} elseif (PHP_VERSION_ID >= 50600) { +} elseif (\PHP_VERSION_ID >= 50600) { // PHPUnit 4 does not support PHP 7 $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7'); } else { @@ -113,7 +113,7 @@ if (PHP_VERSION_ID >= 80000) { $PHPUNIT_VERSION = '4.8'; } -$PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var($getEnvVar('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT', '0'), FILTER_VALIDATE_BOOLEAN); +$PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var($getEnvVar('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT', '0'), \FILTER_VALIDATE_BOOLEAN); $COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json'; @@ -127,9 +127,9 @@ while (!file_exists($root.'/'.$COMPOSER_JSON) || file_exists($root.'/Deprecation $oldPwd = getcwd(); $PHPUNIT_DIR = $getEnvVar('SYMFONY_PHPUNIT_DIR', $root.'/vendor/bin/.phpunit'); -$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php'; +$PHP = defined('PHP_BINARY') ? \PHP_BINARY : 'php'; $PHP = escapeshellarg($PHP); -if ('phpdbg' === PHP_SAPI) { +if ('phpdbg' === \PHP_SAPI) { $PHP .= ' -qrr'; } @@ -148,14 +148,14 @@ foreach ($defaultEnvs as $envName => $envValue) { } $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar') - || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) - || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) - || file_exists($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).DIRECTORY_SEPARATOR.'composer.phar') + || ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) + || ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) + || file_exists($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).\DIRECTORY_SEPARATOR.'composer.phar') ? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang : 'composer'; $SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : '')); -$configurationHash = md5(implode(PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT])); +$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT])); $PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT); if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) { // Build a standalone phpunit without symfony/yaml nor prophecy by default @@ -163,9 +163,9 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH @mkdir($PHPUNIT_DIR, 0777, true); chdir($PHPUNIT_DIR); if (file_exists("$PHPUNIT_VERSION_DIR")) { - passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); + passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); rename("$PHPUNIT_VERSION_DIR", "$PHPUNIT_VERSION_DIR.old"); - passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); + passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); } $info = []; @@ -216,15 +216,15 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); } - if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', PHP_VERSION, '<')) { + if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', \PHP_VERSION, '<')) { $passthruOrFail("$COMPOSER config platform.php \"$phpVersion[1].99\""); } else { $passthruOrFail("$COMPOSER config --unset platform.php"); } if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) { $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); - $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); - if ('\\' === DIRECTORY_SEPARATOR) { + $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $path))); + if ('\\' === \DIRECTORY_SEPARATOR) { file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json'))); } } else { @@ -232,7 +232,7 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH } $prevRoot = getenv('COMPOSER_ROOT_VERSION'); putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); - $q = '\\' === DIRECTORY_SEPARATOR ? '"' : ''; + $q = '\\' === \DIRECTORY_SEPARATOR ? '"' : ''; // --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS $exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress $q", [], $p, getcwd())); putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : '')); @@ -245,12 +245,12 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH if ($PHPUNIT_REMOVE_RETURN_TYPEHINT) { $alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode); } - $alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); + $alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); file_put_contents($alteredFile, $alteredCode); // Mutate Assert code $alteredCode = file_get_contents($alteredFile = './src/Framework/Assert.php'); - $alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1); + $alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1); file_put_contents($alteredFile, $alteredCode); file_put_contents('phpunit', <<<'EOPHP' @@ -303,7 +303,7 @@ if ($PHPUNIT_VERSION < 8.0) { return false; }); -} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) { +} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) { $argv[] = '--do-not-cache-result'; ++$argc; } @@ -335,7 +335,7 @@ if (isset($argv[1]) && is_dir($argv[1]) && !file_exists($argv[1].'/phpunit.xml.d $cmd[0] = sprintf('%s %s --colors=always', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit")); $cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s'; -if ('\\' === DIRECTORY_SEPARATOR) { +if ('\\' === \DIRECTORY_SEPARATOR) { $cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"'; } else { $cmd .= '%2$s'; @@ -385,7 +385,7 @@ if ($components) { // STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) // STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) // STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374) - if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) { + if ($procStatus && ('\\' !== \DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) { $exit = $procStatus; echo "\033[41mKO\033[0m $component\n\n"; } else { diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index 286e166ba5..490b1bfded 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -115,7 +115,7 @@ if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Comman } // Enforce a consistent locale -setlocale(LC_ALL, 'C'); +setlocale(\LC_ALL, 'C'); if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) { if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) { diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php index 54d0483f7d..2ff31bbda3 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php @@ -66,7 +66,7 @@ class LazyLoadingValueHolderGenerator extends BaseGenerator if (null !== $docBlock = $method->getDocBlock()) { $code = substr($code, \strlen($docBlock->generate())); } - $refAmp = (strpos($code, '&') ?: PHP_INT_MAX) <= strpos($code, '(') ? '&' : ''; + $refAmp = (strpos($code, '&') ?: \PHP_INT_MAX) <= strpos($code, '(') ? '&' : ''; $body = preg_replace( '/\nreturn (\$this->valueHolder[0-9a-f]++)(->[^;]++);$/', "\nif ($1 === \$returnValue = {$refAmp}$1$2) {\n \$returnValue = \$this;\n}\n\nreturn \$returnValue;", diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index 219613eb2f..974a38a9c3 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -262,7 +262,7 @@ EOF $data['warnings'] = $this->buildWarningMessages($wrongBundles); } - $data = json_encode($data, JSON_PRETTY_PRINT); + $data = json_encode($data, \JSON_PRETTY_PRINT); $io->writeln($decorated ? OutputFormatter::escape($data) : $data); } @@ -392,7 +392,7 @@ EOF $bundleNames = []; if ($this->twigDefaultPath && $this->projectDir) { - $folders = glob($this->twigDefaultPath.'/bundles/*', GLOB_ONLYDIR); + $folders = glob($this->twigDefaultPath.'/bundles/*', \GLOB_ONLYDIR); $relativePath = ltrim(substr($this->twigDefaultPath.'/bundles/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR); $bundleNames = array_reduce($folders, function ($carry, $absolutePath) use ($relativePath) { if (0 === strpos($absolutePath, $this->projectDir)) { @@ -532,7 +532,7 @@ EOF $threshold = 1e3; $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; }); - ksort($alternatives, SORT_NATURAL | SORT_FLAG_CASE); + ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE); return array_keys($alternatives); } @@ -548,7 +548,7 @@ EOF private function isAbsolutePath(string $file): bool { - return strspn($file, '/\\', 0, 1) || (\strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && strspn($file, '/\\', 2, 1)) || null !== parse_url($file, PHP_URL_SCHEME); + return strspn($file, '/\\', 0, 1) || (\strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && strspn($file, '/\\', 2, 1)) || null !== parse_url($file, \PHP_URL_SCHEME); } /** diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 66c108af35..505f05959b 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -101,7 +101,7 @@ EOF if ($showDeprecations) { $prevErrorHandler = set_error_handler(static function ($level, $message, $file, $line) use (&$prevErrorHandler) { - if (E_USER_DEPRECATED === $level) { + if (\E_USER_DEPRECATED === $level) { $templateLine = 0; if (preg_match('/ at line (\d+)[ .]/', $message, $matches)) { $templateLine = $matches[1]; @@ -214,7 +214,7 @@ EOF } }); - $output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $output->writeln(json_encode($filesInfo, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); return min($errors, 1); } diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index f35725af0d..0ff70eccd6 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -97,7 +97,7 @@ final class CodeExtension extends AbstractExtension } elseif ('resource' === $item[0]) { $formattedValue = 'resource'; } else { - $formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), ENT_COMPAT | ENT_SUBSTITUTE, $this->charset)); + $formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset)); } $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); @@ -166,7 +166,7 @@ final class CodeExtension extends AbstractExtension } if (false !== $link = $this->getFileLink($file, $line)) { - return sprintf('%s', htmlspecialchars($link, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset), $text); + return sprintf('%s', htmlspecialchars($link, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $text); } return $text; @@ -222,7 +222,7 @@ final class CodeExtension extends AbstractExtension } } - return htmlspecialchars($message, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset); + return htmlspecialchars($message, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset); } protected static function fixCodeMarkup(string $line): string diff --git a/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php b/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php index 186f8b01b2..2da0492144 100644 --- a/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php @@ -102,11 +102,11 @@ EOF; ], [new JsonEncoder()]); $serialized = $serializer->serialize($e, 'json'); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n = $serializer->deserialize($serialized, TemplatedEmail::class, 'json'); $serialized = $serializer->serialize($e, 'json'); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n->from('fabien@symfony.com'); $expected->from('fabien@symfony.com'); diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php index e9e13395c7..e79ec697e0 100644 --- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php +++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php @@ -89,7 +89,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface */ protected function canBeExtracted(string $file) { - return $this->isFile($file) && 'twig' === pathinfo($file, PATHINFO_EXTENSION); + return $this->isFile($file) && 'twig' === pathinfo($file, \PATHINFO_EXTENSION); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php index 44a53a542e..e39772edf4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php @@ -87,12 +87,12 @@ EOT new TableSeparator(), ['PHP'], new TableSeparator(), - ['Version', PHP_VERSION], + ['Version', \PHP_VERSION], ['Architecture', (\PHP_INT_SIZE * 8).' bits'], ['Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'], ['Timezone', date_default_timezone_get().' ('.(new \DateTime())->format(\DateTime::W3C).')'], - ['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], - ['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], + ['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], + ['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], ['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'], ]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index 9caefac32f..bda4956df7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -63,7 +63,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand protected function findExtension(string $name) { $bundles = $this->initializeBundles(); - $minScore = INF; + $minScore = \INF; $kernel = $this->getApplication()->getKernel(); if ($kernel instanceof ExtensionInterface && ($kernel instanceof ConfigurationInterface || $kernel instanceof ConfigurationExtensionInterface)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index dc0fe17937..3eb98fc921 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -183,7 +183,7 @@ class JsonDescriptor extends Descriptor { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; - $this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); + $this->write(json_encode($data, $flags | \JSON_PRETTY_PRINT)."\n"); } protected function getRouteData(Route $route): array diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index a1f1c16979..7ab276128f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -120,7 +120,7 @@ class RedirectController } // redirect if the path is a full URL - if (parse_url($path, PHP_URL_SCHEME)) { + if (parse_url($path, \PHP_URL_SCHEME)) { return new RedirectResponse($path, $statusCode); } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php index 493b0b6561..a3339ba355 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php @@ -33,7 +33,7 @@ class ProfilerPass implements CompilerPassInterface $definition = $container->getDefinition('profiler'); $collectors = new \SplPriorityQueue(); - $order = PHP_INT_MAX; + $order = \PHP_INT_MAX; foreach ($container->findTaggedServiceIds('data_collector', true) as $id => $attributes) { $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; $template = null; diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 0378470985..c1ce91dd4d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -196,7 +196,7 @@ class Configuration implements ConfigurationInterface ->validate() ->ifTrue() ->then(function ($v) { - @trigger_error('Since symfony/framework-bundle 5.2: Setting the "framework.form.legacy_error_messages" option to "true" is deprecated. It will have no effect as of Symfony 6.0.', E_USER_DEPRECATED); + @trigger_error('Since symfony/framework-bundle 5.2: Setting the "framework.form.legacy_error_messages" option to "true" is deprecated. It will have no effect as of Symfony 6.0.', \E_USER_DEPRECATED); return $v; }) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index e929724c7f..51e74d2766 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1093,7 +1093,7 @@ class FrameworkExtension extends Extension if (null !== $jsonManifestPath) { $definitionName = 'assets.json_manifest_version_strategy'; - if (0 === strpos(parse_url($jsonManifestPath, PHP_URL_SCHEME), 'http')) { + if (0 === strpos(parse_url($jsonManifestPath, \PHP_URL_SCHEME), 'http')) { $definitionName = 'assets.remote_json_manifest_version_strategy'; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php index 029ef3463e..7b2740fea7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php @@ -89,7 +89,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface $list = $this->list(); $list[$name] = null; uksort($list, 'strnatcmp'); - file_put_contents($this->pathPrefix.'list.php', sprintf("pathPrefix.'list.php', sprintf("lastMessage = sprintf('Secret "%s" encrypted in "%s"; you can commit it.', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR)); } @@ -141,7 +141,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface $list = $this->list(); unset($list[$name]); - file_put_contents($this->pathPrefix.'list.php', sprintf("pathPrefix.'list.php', sprintf("lastMessage = sprintf('Secret "%s" removed from "%s".', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR)); @@ -205,9 +205,9 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface $this->createSecretsDir(); - if (false === file_put_contents($this->pathPrefix.$file.'.php', $data, LOCK_EX)) { + if (false === file_put_contents($this->pathPrefix.$file.'.php', $data, \LOCK_EX)) { $e = error_get_last(); - throw new \ErrorException($e['message'] ?? 'Failed to write secrets data.', 0, $e['type'] ?? E_USER_WARNING); + throw new \ErrorException($e['message'] ?? 'Failed to write secrets data.', 0, $e['type'] ?? \E_USER_WARNING); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php index 8321236226..47221463fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php @@ -242,9 +242,9 @@ abstract class AbstractDescriptorTest extends TestCase $this->getDescriptor()->describe($output, $describedObject, $options); if ('json' === $this->getFormat()) { - $this->assertEquals(json_encode(json_decode($expectedDescription), JSON_PRETTY_PRINT), json_encode(json_decode($output->fetch()), JSON_PRETTY_PRINT)); + $this->assertEquals(json_encode(json_decode($expectedDescription), \JSON_PRETTY_PRINT), json_encode(json_decode($output->fetch()), \JSON_PRETTY_PRINT)); } else { - $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch()))); + $this->assertEquals(trim($expectedDescription), trim(str_replace(\PHP_EOL, "\n", $output->fetch()))); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 0b30d684d8..447f48984b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -224,7 +224,7 @@ class AbstractControllerTest extends TestCase $response = $controller->json([], 200, [], ['json_encode_options' => 0, 'other' => 'context']); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals('[]', $response->getContent()); - $response->setEncodingOptions(JSON_FORCE_OBJECT); + $response->setEncodingOptions(\JSON_FORCE_OBJECT); $this->assertEquals('{}', $response->getContent()); } diff --git a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php index 24f289f0fb..de23fdd618 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php @@ -134,7 +134,7 @@ EOF if ($input->isInteractive() && !$emptySalt) { $emptySalt = true; - $errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.'); + $errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.\PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.'); if ($errorIo->confirm('Confirm salt generation ?')) { $salt = $this->generateSalt(); diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 889f75f819..334eb2e906 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -696,7 +696,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface // bcrypt encoder if ('bcrypt' === $config['algorithm']) { $config['algorithm'] = 'native'; - $config['native_algorithm'] = PASSWORD_BCRYPT; + $config['native_algorithm'] = \PASSWORD_BCRYPT; return $this->createEncoder($config); } @@ -707,7 +707,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface $config['algorithm'] = 'sodium'; } elseif (\defined('PASSWORD_ARGON2I')) { $config['algorithm'] = 'native'; - $config['native_algorithm'] = PASSWORD_ARGON2I; + $config['native_algorithm'] = \PASSWORD_ARGON2I; } else { throw new InvalidConfigurationException(sprintf('Algorithm "argon2i" is not available. Either use "%s" or upgrade to PHP 7.2+ instead.', \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13') ? 'argon2id", "auto' : 'auto')); } @@ -720,7 +720,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface $config['algorithm'] = 'sodium'; } elseif (\defined('PASSWORD_ARGON2ID')) { $config['algorithm'] = 'native'; - $config['native_algorithm'] = PASSWORD_ARGON2ID; + $config['native_algorithm'] = \PASSWORD_ARGON2ID; } else { throw new InvalidConfigurationException(sprintf('Algorithm "argon2id" is not available. Either use "%s", upgrade to PHP 7.3+ or use libsodium 1.0.15+ instead.', \defined('PASSWORD_ARGON2I') || $hasSodium ? 'argon2i", "auto' : 'auto')); } @@ -944,7 +944,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface $cidrParts = explode('/', $cidr); if (1 === \count($cidrParts)) { - return false !== filter_var($cidrParts[0], FILTER_VALIDATE_IP); + return false !== filter_var($cidrParts[0], \FILTER_VALIDATE_IP); } $ip = $cidrParts[0]; @@ -954,11 +954,11 @@ class SecurityExtension extends Extension implements PrependExtensionInterface return false; } - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + if (filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { return $netmask <= 32; } - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + if (filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { return $netmask <= 128; } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index 77b6933ffd..a7f56e9958 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -432,7 +432,7 @@ abstract class CompleteConfigurationTest extends TestCase ], 'JMS\FooBundle\Entity\User7' => [ 'class' => $sodium ? SodiumPasswordEncoder::class : NativePasswordEncoder::class, - 'arguments' => $sodium ? [256, 1] : [1, 262144, null, PASSWORD_ARGON2I], + 'arguments' => $sodium ? [256, 1] : [1, 262144, null, \PASSWORD_ARGON2I], ], ]], $container->getDefinition('security.encoder_factory.generic')->getArguments()); } @@ -542,7 +542,7 @@ abstract class CompleteConfigurationTest extends TestCase ], 'JMS\FooBundle\Entity\User7' => [ 'class' => NativePasswordEncoder::class, - 'arguments' => [null, null, 15, PASSWORD_BCRYPT], + 'arguments' => [null, null, 15, \PASSWORD_BCRYPT], ], ]], $container->getDefinition('security.encoder_factory.generic')->getArguments()); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index 40653dec80..f4cb1c72ba 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -38,7 +38,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase 'user-class' => 'Symfony\Component\Security\Core\User\User', '--empty-salt' => true, ], ['decorated' => false]); - $expected = str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt')); + $expected = str_replace("\n", \PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt')); $this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay()); } @@ -65,7 +65,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase $output = $this->passwordEncoderCommandTester->getDisplay(); $this->assertStringContainsString('Password encoding succeeded', $output); - $encoder = new NativePasswordEncoder(null, null, 17, PASSWORD_BCRYPT); + $encoder = new NativePasswordEncoder(null, null, 17, \PASSWORD_BCRYPT); preg_match('# Encoded password\s{1,}([\w+\/$.]+={0,2})\s+#', $output, $matches); $hash = $matches[1]; $this->assertTrue($encoder->isPasswordValid($hash, 'password', null)); @@ -86,7 +86,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase $output = $this->passwordEncoderCommandTester->getDisplay(); $this->assertStringContainsString('Password encoding succeeded', $output); - $encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, PASSWORD_ARGON2I); + $encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, \PASSWORD_ARGON2I); preg_match('# Encoded password\s+(\$argon2i?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches); $hash = $matches[1]; $this->assertTrue($encoder->isPasswordValid($hash, 'password', null)); @@ -107,7 +107,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase $output = $this->passwordEncoderCommandTester->getDisplay(); $this->assertStringContainsString('Password encoding succeeded', $output); - $encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, PASSWORD_ARGON2ID); + $encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, \PASSWORD_ARGON2ID); preg_match('# Encoded password\s+(\$argon2id?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches); $hash = $matches[1]; $this->assertTrue($encoder->isPasswordValid($hash, 'password', null)); @@ -314,7 +314,7 @@ EOTXT protected function setUp(): void { - putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); + putenv('COLUMNS='.(119 + \strlen(\PHP_EOL))); $kernel = $this->createKernel(['test_case' => 'PasswordEncode']); $kernel->boot(); @@ -332,7 +332,7 @@ EOTXT private function setupArgon2i() { - putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); + putenv('COLUMNS='.(119 + \strlen(\PHP_EOL))); $kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2i.yml']); $kernel->boot(); @@ -345,7 +345,7 @@ EOTXT private function setupArgon2id() { - putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); + putenv('COLUMNS='.(119 + \strlen(\PHP_EOL))); $kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2id.yml']); $kernel->boot(); @@ -358,7 +358,7 @@ EOTXT private function setupBcrypt() { - putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); + putenv('COLUMNS='.(119 + \strlen(\PHP_EOL))); $kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'bcrypt.yml']); $kernel->boot(); @@ -371,7 +371,7 @@ EOTXT private function setupSodium() { - putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); + putenv('COLUMNS='.(119 + \strlen(\PHP_EOL))); $kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'sodium.yml']); $kernel->boot(); diff --git a/src/Symfony/Bundle/WebProfilerBundle/WebProfilerBundle.php b/src/Symfony/Bundle/WebProfilerBundle/WebProfilerBundle.php index 897c3ffb7f..7fcc4ec47f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/WebProfilerBundle.php +++ b/src/Symfony/Bundle/WebProfilerBundle/WebProfilerBundle.php @@ -21,7 +21,7 @@ class WebProfilerBundle extends Bundle public function boot() { if ('prod' === $this->container->getParameter('kernel.environment')) { - @trigger_error('Using WebProfilerBundle in production is not supported and puts your project at risk, disable it.', E_USER_WARNING); + @trigger_error('Using WebProfilerBundle in production is not supported and puts your project at risk, disable it.', \E_USER_WARNING); } } } diff --git a/src/Symfony/Component/Asset/UrlPackage.php b/src/Symfony/Component/Asset/UrlPackage.php index bc4da2435f..43351027d8 100644 --- a/src/Symfony/Component/Asset/UrlPackage.php +++ b/src/Symfony/Component/Asset/UrlPackage.php @@ -123,7 +123,7 @@ class UrlPackage extends Package foreach ($urls as $url) { if ('https://' === substr($url, 0, 8) || '//' === substr($url, 0, 2)) { $sslUrls[] = $url; - } elseif (null === parse_url($url, PHP_URL_SCHEME)) { + } elseif (null === parse_url($url, \PHP_URL_SCHEME)) { throw new InvalidArgumentException(sprintf('"%s" is not a valid URL.', $url)); } } diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/Component/BrowserKit/AbstractBrowser.php index 60f2fcb182..f8c8987114 100644 --- a/src/Symfony/Component/BrowserKit/AbstractBrowser.php +++ b/src/Symfony/Component/BrowserKit/AbstractBrowser.php @@ -352,12 +352,12 @@ abstract class AbstractBrowser $server = array_merge($this->server, $server); - if (!empty($server['HTTP_HOST']) && null === parse_url($originalUri, PHP_URL_HOST)) { + if (!empty($server['HTTP_HOST']) && null === parse_url($originalUri, \PHP_URL_HOST)) { $uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri); } - if (isset($server['HTTPS']) && null === parse_url($originalUri, PHP_URL_SCHEME)) { - $uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); + if (isset($server['HTTPS']) && null === parse_url($originalUri, \PHP_URL_SCHEME)) { + $uri = preg_replace('{^'.parse_url($uri, \PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); } if (!isset($server['HTTP_REFERER']) && !$this->history->isEmpty()) { @@ -368,7 +368,7 @@ abstract class AbstractBrowser $server['HTTP_HOST'] = $this->extractHost($uri); } - $server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME); + $server['HTTPS'] = 'https' == parse_url($uri, \PHP_URL_SCHEME); $this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content); @@ -437,9 +437,9 @@ abstract class AbstractBrowser foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) { if ($deprecation[0]) { // unsilenced on purpose - trigger_error($deprecation[1], E_USER_DEPRECATED); + trigger_error($deprecation[1], \E_USER_DEPRECATED); } else { - @trigger_error($deprecation[1], E_USER_DEPRECATED); + @trigger_error($deprecation[1], \E_USER_DEPRECATED); } } } @@ -653,7 +653,7 @@ abstract class AbstractBrowser // protocol relative URL if (0 === strpos($uri, '//')) { - return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri; + return parse_url($currentUri, \PHP_URL_SCHEME).':'.$uri; } // anchor or query string parameters? @@ -662,7 +662,7 @@ abstract class AbstractBrowser } if ('/' !== $uri[0]) { - $path = parse_url($currentUri, PHP_URL_PATH); + $path = parse_url($currentUri, \PHP_URL_PATH); if ('/' !== substr($path, -1)) { $path = substr($path, 0, strrpos($path, '/') + 1); @@ -689,7 +689,7 @@ abstract class AbstractBrowser private function updateServerFromUri(array $server, string $uri): array { $server['HTTP_HOST'] = $this->extractHost($uri); - $scheme = parse_url($uri, PHP_URL_SCHEME); + $scheme = parse_url($uri, \PHP_URL_SCHEME); $server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme; unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']); @@ -698,9 +698,9 @@ abstract class AbstractBrowser private function extractHost(string $uri): ?string { - $host = parse_url($uri, PHP_URL_HOST); + $host = parse_url($uri, \PHP_URL_HOST); - if ($port = parse_url($uri, PHP_URL_PORT)) { + if ($port = parse_url($uri, \PHP_URL_PORT)) { return $host.':'.$port; } diff --git a/src/Symfony/Component/BrowserKit/HttpBrowser.php b/src/Symfony/Component/BrowserKit/HttpBrowser.php index ed6c100281..6f5749c264 100644 --- a/src/Symfony/Component/BrowserKit/HttpBrowser.php +++ b/src/Symfony/Component/BrowserKit/HttpBrowser.php @@ -91,7 +91,7 @@ class HttpBrowser extends AbstractBrowser return ['', []]; } - return [http_build_query($fields, '', '&', PHP_QUERY_RFC1738), ['Content-Type' => 'application/x-www-form-urlencoded']]; + return [http_build_query($fields, '', '&', \PHP_QUERY_RFC1738), ['Content-Type' => 'application/x-www-form-urlencoded']]; } private function getHeaders(Request $request): array diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 2b276f60b6..b2faae2840 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -112,7 +112,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg return $opcache; } - if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { + if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { return $opcache; } diff --git a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php index 48d2f5ec4b..b4906382d0 100644 --- a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php @@ -44,7 +44,7 @@ class ApcuAdapter extends AbstractAdapter public static function isSupported() { - return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN); + return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN); } /** @@ -63,7 +63,7 @@ class ApcuAdapter extends AbstractAdapter return $values; } catch (\Error $e) { - throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine()); } finally { ini_set('unserialize_callback_func', $unserializeCallbackHandler); } @@ -82,8 +82,8 @@ class ApcuAdapter extends AbstractAdapter */ protected function doClear(string $namespace) { - return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) - ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY)) + return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) + ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY)) : apcu_clear_cache(); } diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 46f7e646f5..63761947e7 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -78,7 +78,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter $metadata = $item->getMetadata(); // ArrayAdapter works in memory, we don't care about stampede protection - if (INF === $beta || !$item->isHit()) { + if (\INF === $beta || !$item->isHit()) { $save = true; $this->save($item->set($callback($item, $save))); } @@ -197,7 +197,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter $now = microtime(true); if (0 === $expiry) { - $expiry = PHP_INT_MAX; + $expiry = \PHP_INT_MAX; } if (null !== $expiry && $expiry <= $now) { @@ -229,7 +229,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter } $this->values[$key] = $value; - $this->expiries[$key] = null !== $expiry ? $expiry : PHP_INT_MAX; + $this->expiries[$key] = null !== $expiry ? $expiry : \PHP_INT_MAX; return true; } diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index d2ff15eb9d..1029bbff69 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -51,7 +51,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa if (!$adapter instanceof CacheItemPoolInterface) { throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_debug_type($adapter), CacheItemPoolInterface::class)); } - if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { + if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { continue; // skip putting APCu in the chain when the backend is disabled } @@ -95,7 +95,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa $adapter = $this->adapters[$i]; if (isset($this->adapters[++$i])) { $callback = $wrap; - $beta = INF === $beta ? INF : 0; + $beta = \INF === $beta ? \INF : 0; } if ($adapter instanceof CacheInterface) { $value = $adapter->get($key, $callback, $beta, $metadata); diff --git a/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php b/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php index 55a36e17f8..dc70ea6973 100644 --- a/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php @@ -52,7 +52,7 @@ class DoctrineAdapter extends AbstractAdapter case 'unserialize': case 'apcu_fetch': case 'apc_fetch': - throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine()); } } diff --git a/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php index bf6bee659e..e5cbf90ce7 100644 --- a/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php @@ -72,7 +72,7 @@ class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements Prune if (!is_dir($d = $dir.$chars[$i].\DIRECTORY_SEPARATOR.$chars[$j])) { continue; } - foreach (scandir($d, SCANDIR_SORT_NONE) ?: [] as $link) { + foreach (scandir($d, \SCANDIR_SORT_NONE) ?: [] as $link) { if ('.' !== $link && '..' !== $link && (null !== $renamed || !realpath($d.\DIRECTORY_SEPARATOR.$link))) { unlink($d.\DIRECTORY_SEPARATOR.$link); } diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index abf706a844..63f720dfdb 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -172,7 +172,7 @@ class MemcachedAdapter extends AbstractAdapter // set client's options unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']); - $options = array_change_key_case($options, CASE_UPPER); + $options = array_change_key_case($options, \CASE_UPPER); $client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); $client->setOption(\Memcached::OPT_NO_BLOCK, true); $client->setOption(\Memcached::OPT_TCP_NODELAY, true); @@ -269,7 +269,7 @@ class MemcachedAdapter extends AbstractAdapter return $result; } catch (\Error $e) { - throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine()); } } diff --git a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php index ebdb840978..d3ac2293c0 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php @@ -58,7 +58,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface { self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time(); - return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN)); + return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN)); } /** diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index 295b0c1366..3f121766fe 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -183,7 +183,7 @@ final class CacheItem implements ItemInterface $replace['{'.$k.'}'] = $v; } } - @trigger_error(strtr($message, $replace), E_USER_WARNING); + @trigger_error(strtr($message, $replace), \E_USER_WARNING); } } } diff --git a/src/Symfony/Component/Cache/LockRegistry.php b/src/Symfony/Component/Cache/LockRegistry.php index ac2670c231..c2ad45cdef 100644 --- a/src/Symfony/Component/Cache/LockRegistry.php +++ b/src/Symfony/Component/Cache/LockRegistry.php @@ -70,7 +70,7 @@ final class LockRegistry foreach (self::$openedFiles as $file) { if ($file) { - flock($file, LOCK_UN); + flock($file, \LOCK_UN); fclose($file); } } @@ -90,7 +90,7 @@ final class LockRegistry while (true) { try { // race to get the lock in non-blocking mode - $locked = flock($lock, LOCK_EX | LOCK_NB, $wouldBlock); + $locked = flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock); if ($locked || !$wouldBlock) { $logger && $logger->info(sprintf('Lock %s, now computing item "{key}"', $locked ? 'acquired' : 'not supported'), ['key' => $item->getKey()]); @@ -111,9 +111,9 @@ final class LockRegistry } // if we failed the race, retry locking in blocking mode to wait for the winner $logger && $logger->info('Item "{key}" is locked, waiting for it to be released', ['key' => $item->getKey()]); - flock($lock, LOCK_SH); + flock($lock, \LOCK_SH); } finally { - flock($lock, LOCK_UN); + flock($lock, \LOCK_UN); unset(self::$lockedFiles[$key]); } static $signalingException, $signalingCallback; diff --git a/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php b/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php index 62f1a9082b..e00c8f4845 100644 --- a/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php +++ b/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php @@ -83,7 +83,7 @@ class DefaultMarshaller implements MarshallerInterface throw new \DomainException(error_get_last() ? error_get_last()['message'] : 'Failed to unserialize values.'); } catch (\Error $e) { - throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine()); } finally { ini_set('unserialize_callback_func', $unserializeCallbackHandler); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php index a856940634..05b863d1ac 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php @@ -58,7 +58,7 @@ abstract class AdapterTestCase extends CachePoolTest $isHit = false; $this->assertTrue($item->isHit()); $this->assertSame($value, $item->get()); - }, INF)); + }, \INF)); $this->assertFalse($isHit); $this->assertSame($value, $cache->get('bar', new class($value) implements CallbackInterface { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php index a4a7fc1b58..120a4e5a17 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php @@ -25,10 +25,10 @@ class ApcuAdapterTest extends AdapterTestCase public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface { - if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) { + if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN)) { $this->markTestSkipped('APCu extension is required.'); } - if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { + if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { if ('testWithCliSapi' !== $this->getName()) { $this->markTestSkipped('apc.enable_cli=1 is required.'); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php index 5600d8b72b..6c9afe04ab 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php @@ -146,7 +146,7 @@ class MemcachedAdapterTest extends AdapterTestCase 'localhost', 11222, ]; - if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { + if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { yield [ 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', @@ -163,7 +163,7 @@ class MemcachedAdapterTest extends AdapterTestCase '/var/local/run/memcached.socket', 0, ]; - if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { + if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) { yield [ 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php index 3f2d49d412..99413a6b62 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php @@ -143,7 +143,7 @@ trait FilesystemCommonTrait continue; } - foreach (@scandir($dir, SCANDIR_SORT_NONE) ?: [] as $file) { + foreach (@scandir($dir, \SCANDIR_SORT_NONE) ?: [] as $file) { if ('.' !== $file && '..' !== $file) { yield $dir.\DIRECTORY_SEPARATOR.$file; } diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index ddb104fd2f..2a828caf78 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -298,7 +298,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface $guesses = []; foreach (array_keys($value) as $subject) { - $minScore = INF; + $minScore = \INF; foreach ($proposals as $proposal) { $distance = levenshtein($subject, $proposal); if ($distance <= $minScore && $distance < 3) { diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index b86f7e77b5..f686c53b57 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -189,7 +189,7 @@ class XmlReferenceDumper $commentDepth = $depth + 4 + \strlen($attrName) + 2; $commentLines = explode("\n", $comment); $multiline = (\count($commentLines) > 1); - $comment = implode(PHP_EOL.str_repeat(' ', $commentDepth), $commentLines); + $comment = implode(\PHP_EOL.str_repeat(' ', $commentDepth), $commentLines); if ($multiline) { $this->writeLine(' diff --git a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php index 693b1a2272..84df7d8516 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php @@ -57,7 +57,7 @@ class ScalarNodeTest extends TestCase $deprecationTriggered = 0; $deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) { - if (E_USER_DEPRECATED === $level) { + if (\E_USER_DEPRECATED === $level) { return ++$deprecationTriggered; } diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index e1660da6e3..d075764af2 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -107,7 +107,7 @@ class ProjectLoader1 extends Loader public function supports($resource, string $type = null): bool { - return \is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION); + return \is_string($resource) && 'foo' === pathinfo($resource, \PATHINFO_EXTENSION); } public function getType() diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index a82e939d91..f0b77ae6f6 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -199,7 +199,7 @@ class XmlUtilsTest extends TestCase // test for issue https://github.com/symfony/symfony/issues/9731 public function testLoadWrongEmptyXMLWithErrorHandler() { - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $originalDisableEntities = libxml_disable_entity_loader(false); } $errorReporting = error_reporting(-1); @@ -221,7 +221,7 @@ class XmlUtilsTest extends TestCase error_reporting($errorReporting); } - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(true); libxml_disable_entity_loader($disableEntities); diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index a313472722..196d44f07e 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -51,15 +51,15 @@ class XmlUtils } $internalErrors = libxml_use_internal_errors(true); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(true); } libxml_clear_errors(); $dom = new \DOMDocument(); $dom->validateOnParse = true; - if (!$dom->loadXML($content, LIBXML_NONET | (\defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) { - if (LIBXML_VERSION < 20900) { + if (!$dom->loadXML($content, \LIBXML_NONET | (\defined('LIBXML_COMPACT') ? \LIBXML_COMPACT : 0))) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } @@ -69,12 +69,12 @@ class XmlUtils $dom->normalizeDocument(); libxml_use_internal_errors($internalErrors); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } foreach ($dom->childNodes as $child) { - if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) { + if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) { throw new XmlParsingException('Document types are not allowed.'); } } @@ -267,7 +267,7 @@ class XmlUtils $errors = []; foreach (libxml_get_errors() as $error) { $errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)', - LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', + \LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', $error->code, trim($error->message), $error->file ?: 'n/a', diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 0c4295379b..1405ed7622 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -90,7 +90,7 @@ class Application implements ResetInterface $this->defaultCommand = 'list'; $this->signalRegistry = new SignalRegistry(); if (\defined('SIGINT')) { - $this->signalsToDispatchEvent = [SIGINT, SIGTERM, SIGUSR1, SIGUSR2]; + $this->signalsToDispatchEvent = [\SIGINT, \SIGTERM, \SIGUSR1, \SIGUSR2]; } } @@ -288,7 +288,7 @@ class Application implements ResetInterface // No more handlers, we try to simulate PHP default behavior if (!$hasNext) { - if (!\in_array($signal, [SIGUSR1, SIGUSR2], true)) { + if (!\in_array($signal, [\SIGUSR1, \SIGUSR2], true)) { exit(0); } } @@ -828,7 +828,7 @@ class Application implements ResetInterface }, $message); } - $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX; + $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX; $lines = []; foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) { foreach ($this->splitStringByWidth($line, $width - 4) as $line) { @@ -1117,7 +1117,7 @@ class Application implements ResetInterface } $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; }); - ksort($alternatives, SORT_NATURAL | SORT_FLAG_CASE); + ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE); return array_keys($alternatives); } diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 000921fba4..e5d4cf18a1 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -223,7 +223,7 @@ class Command if (null !== $this->processTitle) { if (\function_exists('cli_set_process_title')) { if (!@cli_set_process_title($this->processTitle)) { - if ('Darwin' === PHP_OS) { + if ('Darwin' === \PHP_OS) { $output->writeln('Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.', OutputInterface::VERBOSITY_VERY_VERBOSE); } else { cli_set_process_title($this->processTitle); diff --git a/src/Symfony/Component/Console/Cursor.php b/src/Symfony/Component/Console/Cursor.php index 2da899b556..dcb5b5ad39 100644 --- a/src/Symfony/Component/Console/Cursor.php +++ b/src/Symfony/Component/Console/Cursor.php @@ -24,7 +24,7 @@ final class Cursor public function __construct(OutputInterface $output, $input = null) { $this->output = $output; - $this->input = $input ?? (\defined('STDIN') ? STDIN : fopen('php://input', 'r+')); + $this->input = $input ?? (\defined('STDIN') ? \STDIN : fopen('php://input', 'r+')); } public function moveUp(int $lines = 1): self diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index ebae9a234e..8b2a279489 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -107,7 +107,7 @@ class JsonDescriptor extends Descriptor 'is_required' => $argument->isRequired(), 'is_array' => $argument->isArray(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()), - 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(), + 'default' => \INF === $argument->getDefault() ? 'INF' : $argument->getDefault(), ]; } @@ -120,7 +120,7 @@ class JsonDescriptor extends Descriptor 'is_value_required' => $option->isValueRequired(), 'is_multiple' => $option->isArray(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()), - 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(), + 'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault(), ]; } diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index cecfba0e66..e73b8a99fb 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -278,7 +278,7 @@ class TextDescriptor extends Descriptor */ private function formatDefaultValue($default): string { - if (INF === $default) { + if (\INF === $default) { return 'INF'; } @@ -292,7 +292,7 @@ class TextDescriptor extends Descriptor } } - return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + return str_replace('\\\\', '\\', json_encode($default, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE)); } /** diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 8fc9f286ec..edc6a1d71d 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -136,7 +136,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface $output = ''; $tagRegex = '[a-z][^<>]*+'; $currentLineLength = 0; - preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE); + preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE); foreach ($matches[0] as $i => $match) { $pos = $match[1]; $text = $match[0]; @@ -194,7 +194,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface return $this->styles[$string]; } - if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) { + if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) { return null; } diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 670e015750..7b6b99e431 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -474,7 +474,7 @@ final class ProgressBar } } } elseif ($this->step > 0) { - $message = PHP_EOL.$message; + $message = \PHP_EOL.$message; } $this->previousMessage = $originalMessage; @@ -533,7 +533,7 @@ final class ProgressBar return Helper::formatMemory(memory_get_usage(true)); }, 'current' => function (self $bar) { - return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT); + return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT); }, 'max' => function (self $bar) { return $bar->getMaxSteps(); diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 11d510ef43..998613eac8 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -107,7 +107,7 @@ class QuestionHelper extends Helper { $this->writePrompt($output, $question); - $inputStream = $this->inputStream ?: STDIN; + $inputStream = $this->inputStream ?: \STDIN; $autocomplete = $question->getAutocompleterCallback(); if (\function_exists('sapi_windows_cp_set')) { diff --git a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php index 6c2596dfa7..8b923bb13c 100644 --- a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php @@ -100,7 +100,7 @@ class SymfonyQuestionHelper extends QuestionHelper private function getEofShortcut(): string { - if (false !== strpos(PHP_OS, 'WIN')) { + if (false !== strpos(\PHP_OS, 'WIN')) { return 'Ctrl+Z then Enter'; } diff --git a/src/Symfony/Component/Console/Helper/TableCellStyle.php b/src/Symfony/Component/Console/Helper/TableCellStyle.php index 148a28e488..4766ba3736 100644 --- a/src/Symfony/Component/Console/Helper/TableCellStyle.php +++ b/src/Symfony/Component/Console/Helper/TableCellStyle.php @@ -35,9 +35,9 @@ class TableCellStyle ]; private $alignMap = [ - 'left' => STR_PAD_RIGHT, - 'center' => STR_PAD_BOTH, - 'right' => STR_PAD_LEFT, + 'left' => \STR_PAD_RIGHT, + 'center' => \STR_PAD_BOTH, + 'right' => \STR_PAD_LEFT, ]; public function __construct(array $options = []) @@ -70,7 +70,7 @@ class TableCellStyle function ($key) { return \in_array($key, $this->tagOptions) && isset($this->options[$key]); }, - ARRAY_FILTER_USE_KEY + \ARRAY_FILTER_USE_KEY ); } diff --git a/src/Symfony/Component/Console/Helper/TableStyle.php b/src/Symfony/Component/Console/Helper/TableStyle.php index 28c950cf67..07265b467a 100644 --- a/src/Symfony/Component/Console/Helper/TableStyle.php +++ b/src/Symfony/Component/Console/Helper/TableStyle.php @@ -46,7 +46,7 @@ class TableStyle private $cellRowFormat = '%s'; private $cellRowContentFormat = ' %s '; private $borderFormat = '%s'; - private $padType = STR_PAD_RIGHT; + private $padType = \STR_PAD_RIGHT; /** * Sets padding character, used for cell padding. @@ -319,7 +319,7 @@ class TableStyle */ public function setPadType(int $padType) { - if (!\in_array($padType, [STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH], true)) { + if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) { throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); } diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index 4e95e9b331..a32e913b7d 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -171,7 +171,7 @@ class InputDefinition */ public function getArgumentCount() { - return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments); + return $this->hasAnArrayArgument ? \PHP_INT_MAX : \count($this->arguments); } /** diff --git a/src/Symfony/Component/Console/Output/BufferedOutput.php b/src/Symfony/Component/Console/Output/BufferedOutput.php index a5ad7ada50..d37c6e3238 100644 --- a/src/Symfony/Component/Console/Output/BufferedOutput.php +++ b/src/Symfony/Component/Console/Output/BufferedOutput.php @@ -39,7 +39,7 @@ class BufferedOutput extends Output $this->buffer .= $message; if ($newline) { - $this->buffer .= PHP_EOL; + $this->buffer .= \PHP_EOL; } } } diff --git a/src/Symfony/Component/Console/Output/ConsoleOutput.php b/src/Symfony/Component/Console/Output/ConsoleOutput.php index 8356d4d554..96664f1508 100644 --- a/src/Symfony/Component/Console/Output/ConsoleOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleOutput.php @@ -131,7 +131,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface $checks = [ \function_exists('php_uname') ? php_uname('s') : '', getenv('OSTYPE'), - PHP_OS, + \PHP_OS, ]; return false !== stripos(implode(';', $checks), 'OS400'); diff --git a/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php b/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php index 024d99d966..c19edbf95e 100644 --- a/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php @@ -82,10 +82,10 @@ class ConsoleSectionOutput extends StreamOutput */ public function addContent(string $input) { - foreach (explode(PHP_EOL, $input) as $lineContent) { + foreach (explode(\PHP_EOL, $input) as $lineContent) { $this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1; $this->content[] = $lineContent; - $this->content[] = PHP_EOL; + $this->content[] = \PHP_EOL; } } diff --git a/src/Symfony/Component/Console/Output/StreamOutput.php b/src/Symfony/Component/Console/Output/StreamOutput.php index 9b78f432a0..ea434527b9 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -70,7 +70,7 @@ class StreamOutput extends Output protected function doWrite(string $message, bool $newline) { if ($newline) { - $message .= PHP_EOL; + $message .= \PHP_EOL; } @fwrite($this->stream, $message); diff --git a/src/Symfony/Component/Console/Style/OutputStyle.php b/src/Symfony/Component/Console/Style/OutputStyle.php index d46947f053..67a98ff073 100644 --- a/src/Symfony/Component/Console/Style/OutputStyle.php +++ b/src/Symfony/Component/Console/Style/OutputStyle.php @@ -35,7 +35,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface */ public function newLine(int $count = 1) { - $this->output->write(str_repeat(PHP_EOL, $count)); + $this->output->write(str_repeat(\PHP_EOL, $count)); } /** diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index 0d32763a0f..ba8626f74b 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -432,7 +432,7 @@ class SymfonyStyle extends OutputStyle private function autoPrependBlock(): void { - $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); + $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); if (!isset($chars[0])) { $this->newLine(); //empty history, so we should start with a new line. @@ -477,7 +477,7 @@ class SymfonyStyle extends OutputStyle $message = OutputFormatter::escape($message); } - $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true))); + $lines = array_merge($lines, explode(\PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, \PHP_EOL, true))); if (\count($messages) > 1 && $key < \count($messages) - 1) { $lines[] = ''; diff --git a/src/Symfony/Component/Console/Tester/TesterTrait.php b/src/Symfony/Component/Console/Tester/TesterTrait.php index b73a41945e..69442b22d8 100644 --- a/src/Symfony/Component/Console/Tester/TesterTrait.php +++ b/src/Symfony/Component/Console/Tester/TesterTrait.php @@ -44,7 +44,7 @@ trait TesterTrait $display = stream_get_contents($this->output->getStream()); if ($normalize) { - $display = str_replace(PHP_EOL, "\n", $display); + $display = str_replace(\PHP_EOL, "\n", $display); } return $display; @@ -68,7 +68,7 @@ trait TesterTrait $display = stream_get_contents($this->output->getErrorOutput()->getStream()); if ($normalize) { - $display = str_replace(PHP_EOL, "\n", $display); + $display = str_replace(\PHP_EOL, "\n", $display); } return $display; @@ -176,7 +176,7 @@ trait TesterTrait $stream = fopen('php://memory', 'r+', false); foreach ($inputs as $input) { - fwrite($stream, $input.PHP_EOL); + fwrite($stream, $input.\PHP_EOL); } rewind($stream); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index dd33ab2c09..88631e0b6e 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -81,7 +81,7 @@ class ApplicationTest extends TestCase protected function normalizeLineBreaks($text) { - return str_replace(PHP_EOL, "\n", $text); + return str_replace(\PHP_EOL, "\n", $text); } /** @@ -1018,10 +1018,10 @@ class ApplicationTest extends TestCase $tester = new ApplicationTester($application); $tester->run(['command' => 'foo:bar', '--no-interaction' => true], ['decorated' => false]); - $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); + $this->assertSame('called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); $tester->run(['command' => 'foo:bar', '-n' => true], ['decorated' => false]); - $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); + $this->assertSame('called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); } public function testRunWithGlobalOptionAndNoCommand() @@ -1318,7 +1318,7 @@ class ApplicationTest extends TestCase $tester = new ApplicationTester($application); $tester->run(['command' => 'foo']); - $this->assertEquals('before.foo.after.'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('before.foo.after.'.\PHP_EOL, $tester->getDisplay()); } public function testRunWithExceptionAndDispatcher() @@ -1602,7 +1602,7 @@ class ApplicationTest extends TestCase $tester = new ApplicationTester($application); $tester->run([], ['interactive' => false]); - $this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + $this->assertEquals('called'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); $application = new CustomDefaultCommandApplication(); $application->setAutoExit(false); @@ -1610,7 +1610,7 @@ class ApplicationTest extends TestCase $tester = new ApplicationTester($application); $tester->run([], ['interactive' => false]); - $this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + $this->assertEquals('called'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); } public function testSetRunCustomDefaultCommandWithOption() @@ -1625,7 +1625,7 @@ class ApplicationTest extends TestCase $tester = new ApplicationTester($application); $tester->run(['--fooopt' => 'opt'], ['interactive' => false]); - $this->assertEquals('called'.PHP_EOL.'opt'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); + $this->assertEquals('called'.\PHP_EOL.'opt'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); } public function testSetRunCustomSingleCommand() diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index bbfd228ac7..c15555897b 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -264,7 +264,7 @@ class CommandTest extends TestCase $tester->execute([], ['interactive' => true]); - $this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); + $this->assertEquals('interact called'.\PHP_EOL.'execute called'.\PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); } public function testRunNonInteractive() @@ -273,7 +273,7 @@ class CommandTest extends TestCase $tester->execute([], ['interactive' => false]); - $this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); + $this->assertEquals('execute called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); } public function testExecuteMethodNeedsToBeOverridden() @@ -316,7 +316,7 @@ class CommandTest extends TestCase $command->setProcessTitle('foo'); $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); if (\function_exists('cli_set_process_title')) { - if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) { + if (null === @cli_get_process_title() && 'Darwin' === \PHP_OS) { $this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); } $this->assertEquals('foo', cli_get_process_title()); @@ -332,7 +332,7 @@ class CommandTest extends TestCase $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute([]); - $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay()); } public function getSetCodeBindToClosureTests() @@ -357,7 +357,7 @@ class CommandTest extends TestCase $command->setCode($code); $tester = new CommandTester($command); $tester->execute([]); - $this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.$expected.\PHP_EOL, $tester->getDisplay()); } public function testSetCodeWithStaticClosure() @@ -367,7 +367,7 @@ class CommandTest extends TestCase $tester = new CommandTester($command); $tester->execute([]); - $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.'bound'.\PHP_EOL, $tester->getDisplay()); } private static function createClosure() @@ -384,7 +384,7 @@ class CommandTest extends TestCase $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); $tester->execute([]); - $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); + $this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay()); } public function callableMethodCommand(InputInterface $input, OutputInterface $output) diff --git a/src/Symfony/Component/Console/Tests/CursorTest.php b/src/Symfony/Component/Console/Tests/CursorTest.php index 08e84fa2cd..3c22f252d6 100644 --- a/src/Symfony/Component/Console/Tests/CursorTest.php +++ b/src/Symfony/Component/Console/Tests/CursorTest.php @@ -198,7 +198,7 @@ class CursorTest extends TestCase { rewind($output->getStream()); - return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream())); + return str_replace(\PHP_EOL, "\n", stream_get_contents($output->getStream())); } protected function getOutputStream(): StreamOutput diff --git a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php index 320a4fb9f4..5d9257fbed 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php @@ -102,6 +102,6 @@ abstract class AbstractDescriptorTest extends TestCase { $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); $this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]); - $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch()))); + $this->assertEquals(trim($expectedDescription), trim(str_replace(\PHP_EOL, "\n", $output->fetch()))); } } diff --git a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php index fb596b8d7a..d3f962fea0 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php @@ -30,6 +30,6 @@ class JsonDescriptorTest extends AbstractDescriptorTest { $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); $this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]); - $this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(PHP_EOL, "\n", $output->fetch())), true)); + $this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(\PHP_EOL, "\n", $output->fetch())), true)); } } diff --git a/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php b/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php index d46d6f18ba..ccd4c3b071 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php @@ -32,7 +32,7 @@ class ObjectsProvider 'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'), 'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"), 'input_argument_with_style' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'style'), - 'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', INF), + 'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', \INF), ]; } @@ -47,7 +47,7 @@ class ObjectsProvider 'input_option_6' => new InputOption('option_name', ['o', 'O'], InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'), 'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', 'style'), 'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', ['Hello', 'world']), - 'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', INF), + 'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', \INF), ]; } diff --git a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php index 82c6b44517..e2880f22f4 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php @@ -109,9 +109,9 @@ EOT; ['', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null], [$syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null], [$syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null], - [$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage], - [$syntaxErrorOutputVerbose.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage], - [$syntaxErrorOutputDebug.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage], + [$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage], + [$syntaxErrorOutputVerbose.$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage], + [$syntaxErrorOutputDebug.$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage], [$successOutputProcessDebug, ['php', '-r', 'echo 42;'], StreamOutput::VERBOSITY_DEBUG, null], [$successOutputDebug, $fromShellCommandline('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null], [$successOutputProcessDebug, [new Process(['php', '-r', 'echo 42;'])], StreamOutput::VERBOSITY_DEBUG, null], diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index 099f6aedf7..b5d2b5f6e2 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -336,9 +336,9 @@ class ProgressBarTest extends TestCase rewind($output->getStream()); $this->assertEquals( - ' 0/50 [>---------------------------] 0%'.PHP_EOL. - "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - "\x1b[1A\x1b[0J".' 2/50 [=>--------------------------] 4%'.PHP_EOL, + ' 0/50 [>---------------------------] 0%'.\PHP_EOL. + "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + "\x1b[1A\x1b[0J".' 2/50 [=>--------------------------] 4%'.\PHP_EOL, stream_get_contents($output->getStream()) ); } @@ -362,12 +362,12 @@ class ProgressBarTest extends TestCase rewind($stream->getStream()); $this->assertEquals( - ' 0/50 [>---------------------------] 0%'.PHP_EOL. - ' 0/50 [>---------------------------] 0%'.PHP_EOL. - "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - "\x1b[2A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - ' 1/50 [>---------------------------] 2%'.PHP_EOL, + ' 0/50 [>---------------------------] 0%'.\PHP_EOL. + ' 0/50 [>---------------------------] 0%'.\PHP_EOL. + "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + "\x1b[2A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + "\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + ' 1/50 [>---------------------------] 2%'.\PHP_EOL, stream_get_contents($stream->getStream()) ); } @@ -393,12 +393,12 @@ class ProgressBarTest extends TestCase rewind($stream->getStream()); - $this->assertEquals(' 0/50 [>---------------------------] 0%'.PHP_EOL. - ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL. - "\x1b[4A\x1b[0J".' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL. - "\x1b[3A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL. - ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL. - "\x1b[3A\x1b[0J".' 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL, + $this->assertEquals(' 0/50 [>---------------------------] 0%'.\PHP_EOL. + ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL. + "\x1b[4A\x1b[0J".' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL. + "\x1b[3A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL. + ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL. + "\x1b[3A\x1b[0J".' 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL, stream_get_contents($stream->getStream()) ); } @@ -555,16 +555,16 @@ class ProgressBarTest extends TestCase rewind($output->getStream()); $this->assertEquals( - ' 0/200 [>---------------------------] 0%'.PHP_EOL. - ' 20/200 [==>-------------------------] 10%'.PHP_EOL. - ' 40/200 [=====>----------------------] 20%'.PHP_EOL. - ' 60/200 [========>-------------------] 30%'.PHP_EOL. - ' 80/200 [===========>----------------] 40%'.PHP_EOL. - ' 100/200 [==============>-------------] 50%'.PHP_EOL. - ' 120/200 [================>-----------] 60%'.PHP_EOL. - ' 140/200 [===================>--------] 70%'.PHP_EOL. - ' 160/200 [======================>-----] 80%'.PHP_EOL. - ' 180/200 [=========================>--] 90%'.PHP_EOL. + ' 0/200 [>---------------------------] 0%'.\PHP_EOL. + ' 20/200 [==>-------------------------] 10%'.\PHP_EOL. + ' 40/200 [=====>----------------------] 20%'.\PHP_EOL. + ' 60/200 [========>-------------------] 30%'.\PHP_EOL. + ' 80/200 [===========>----------------] 40%'.\PHP_EOL. + ' 100/200 [==============>-------------] 50%'.\PHP_EOL. + ' 120/200 [================>-----------] 60%'.\PHP_EOL. + ' 140/200 [===================>--------] 70%'.\PHP_EOL. + ' 160/200 [======================>-----] 80%'.\PHP_EOL. + ' 180/200 [=========================>--] 90%'.\PHP_EOL. ' 200/200 [============================] 100%', stream_get_contents($output->getStream()) ); @@ -581,8 +581,8 @@ class ProgressBarTest extends TestCase rewind($output->getStream()); $this->assertEquals( - ' 0/50 [>---------------------------] 0%'.PHP_EOL. - ' 25/50 [==============>-------------] 50%'.PHP_EOL. + ' 0/50 [>---------------------------] 0%'.\PHP_EOL. + ' 25/50 [==============>-------------] 50%'.\PHP_EOL. ' 50/50 [============================] 100%', stream_get_contents($output->getStream()) ); @@ -596,7 +596,7 @@ class ProgressBarTest extends TestCase rewind($output->getStream()); $this->assertEquals( - ' 0 [>---------------------------]'.PHP_EOL. + ' 0 [>---------------------------]'.\PHP_EOL. ' 1 [->--------------------------]', stream_get_contents($output->getStream()) ); diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php index 4abb9706aa..986646794b 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php @@ -46,11 +46,11 @@ class ProgressIndicatorTest extends TestCase $this->generateOutput(' \\ Advancing...'). $this->generateOutput(' | Advancing...'). $this->generateOutput(' | Done...'). - PHP_EOL. + \PHP_EOL. $this->generateOutput(' - Starting Again...'). $this->generateOutput(' \\ Starting Again...'). $this->generateOutput(' \\ Done Again...'). - PHP_EOL, + \PHP_EOL, stream_get_contents($output->getStream()) ); } @@ -70,9 +70,9 @@ class ProgressIndicatorTest extends TestCase rewind($output->getStream()); $this->assertEquals( - ' Starting...'.PHP_EOL. - ' Midway...'.PHP_EOL. - ' Done...'.PHP_EOL.PHP_EOL, + ' Starting...'.\PHP_EOL. + ' Midway...'.\PHP_EOL. + ' Done...'.\PHP_EOL.\PHP_EOL, stream_get_contents($output->getStream()) ); } diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index 4bf604904a..5d3ebe1708 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -206,7 +206,7 @@ EOT $stream = stream_get_contents($output->getStream()); if ($normalize) { - $stream = str_replace(PHP_EOL, "\n", $stream); + $stream = str_replace(\PHP_EOL, "\n", $stream); } $this->assertStringContainsString($expected, $stream); @@ -216,7 +216,7 @@ EOT { $expected = 'Write an essay (press Ctrl+D to continue)'; - if (false !== strpos(PHP_OS, 'WIN')) { + if (false !== strpos(\PHP_OS, 'WIN')) { $expected = 'Write an essay (press Ctrl+Z then Enter to continue)'; } diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 1b264afd84..24d075bad4 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -994,7 +994,7 @@ TABLE; ]); $style = new TableStyle(); - $style->setPadType(STR_PAD_LEFT); + $style->setPadType(\STR_PAD_LEFT); $table->setColumnStyle(3, $style); $table->render(); @@ -1040,7 +1040,7 @@ TABLE; ->setColumnWidth(3, 10); $style = new TableStyle(); - $style->setPadType(STR_PAD_LEFT); + $style->setPadType(\STR_PAD_LEFT); $table->setColumnStyle(3, $style); $table->render(); @@ -1071,7 +1071,7 @@ TABLE; ->setColumnWidths([15, 0, -1, 10]); $style = new TableStyle(); - $style->setPadType(STR_PAD_LEFT); + $style->setPadType(\STR_PAD_LEFT); $table->setColumnStyle(3, $style); $table->render(); @@ -1467,7 +1467,7 @@ EOTXT; { rewind($output->getStream()); - return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream())); + return str_replace(\PHP_EOL, "\n", stream_get_contents($output->getStream())); } public function testWithColspanAndMaxWith(): void diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index 0f5884136b..283eccaf2b 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -67,7 +67,7 @@ class ConsoleLoggerTest extends TestCase $logger = new ConsoleLogger($out, $addVerbosityLevelMap); $logger->log($logLevel, 'foo bar'); $logs = $out->fetch(); - $this->assertEquals($isOutput ? "[$logLevel] foo bar".PHP_EOL : '', $logs); + $this->assertEquals($isOutput ? "[$logLevel] foo bar".\PHP_EOL : '', $logs); } public function provideOutputMappingParams() diff --git a/src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php b/src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php index e8c65f9b21..6abe040b4f 100644 --- a/src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/ConsoleSectionOutputTest.php @@ -39,11 +39,11 @@ class ConsoleSectionOutputTest extends TestCase $sections = []; $output = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter()); - $output->writeln('Foo'.PHP_EOL.'Bar'); + $output->writeln('Foo'.\PHP_EOL.'Bar'); $output->clear(); rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream())); } public function testClearNumberOfLines() @@ -55,7 +55,7 @@ class ConsoleSectionOutputTest extends TestCase $output->clear(2); rewind($output->getStream()); - $this->assertEquals("Foo\nBar\nBaz\nFooBar".PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream())); + $this->assertEquals("Foo\nBar\nBaz\nFooBar".\PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream())); } public function testClearNumberOfLinesWithMultipleSections() @@ -72,7 +72,7 @@ class ConsoleSectionOutputTest extends TestCase rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL."\x1b[1A\x1b[0J\e[1A\e[0J".'Baz'.PHP_EOL.'Foo'.PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL."\x1b[1A\x1b[0J\e[1A\e[0J".'Baz'.\PHP_EOL.'Foo'.\PHP_EOL, stream_get_contents($output->getStream())); } public function testClearPreservingEmptyLines() @@ -82,13 +82,13 @@ class ConsoleSectionOutputTest extends TestCase $output1 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter()); $output2 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter()); - $output2->writeln(PHP_EOL.'foo'); + $output2->writeln(\PHP_EOL.'foo'); $output2->clear(1); $output1->writeln('bar'); rewind($output->getStream()); - $this->assertEquals(PHP_EOL.'foo'.PHP_EOL."\x1b[1A\x1b[0J\x1b[1A\x1b[0J".'bar'.PHP_EOL.PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals(\PHP_EOL.'foo'.\PHP_EOL."\x1b[1A\x1b[0J\x1b[1A\x1b[0J".'bar'.\PHP_EOL.\PHP_EOL, stream_get_contents($output->getStream())); } public function testOverwrite() @@ -100,7 +100,7 @@ class ConsoleSectionOutputTest extends TestCase $output->overwrite('Bar'); rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL."\x1b[1A\x1b[0JBar".PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL."\x1b[1A\x1b[0JBar".\PHP_EOL, stream_get_contents($output->getStream())); } public function testOverwriteMultipleLines() @@ -108,11 +108,11 @@ class ConsoleSectionOutputTest extends TestCase $sections = []; $output = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter()); - $output->writeln('Foo'.PHP_EOL.'Bar'.PHP_EOL.'Baz'); + $output->writeln('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.'Baz'); $output->overwrite('Bar'); rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL.'Baz'.PHP_EOL.sprintf("\x1b[%dA", 3)."\x1b[0J".'Bar'.PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.'Baz'.\PHP_EOL.sprintf("\x1b[%dA", 3)."\x1b[0J".'Bar'.\PHP_EOL, stream_get_contents($output->getStream())); } public function testAddingMultipleSections() @@ -138,7 +138,7 @@ class ConsoleSectionOutputTest extends TestCase $output2->overwrite('Foobar'); rewind($output->getStream()); - $this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL."\x1b[2A\x1b[0JBar".PHP_EOL."\x1b[1A\x1b[0JBaz".PHP_EOL.'Bar'.PHP_EOL."\x1b[1A\x1b[0JFoobar".PHP_EOL, stream_get_contents($output->getStream())); + $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL."\x1b[2A\x1b[0JBar".\PHP_EOL."\x1b[1A\x1b[0JBaz".\PHP_EOL.'Bar'.\PHP_EOL."\x1b[1A\x1b[0JFoobar".\PHP_EOL, stream_get_contents($output->getStream())); } public function testClearSectionContainingQuestion() @@ -158,6 +158,6 @@ class ConsoleSectionOutputTest extends TestCase $output->clear(); rewind($output->getStream()); - $this->assertSame('What\'s your favorite super hero?'.PHP_EOL."\x1b[2A\x1b[0J", stream_get_contents($output->getStream())); + $this->assertSame('What\'s your favorite super hero?'.\PHP_EOL."\x1b[2A\x1b[0J", stream_get_contents($output->getStream())); } } diff --git a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php index 8fa9dfd104..a434fead42 100644 --- a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php @@ -54,7 +54,7 @@ class StreamOutputTest extends TestCase $output = new StreamOutput($this->stream); $output->writeln('foo'); rewind($output->getStream()); - $this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream'); + $this->assertEquals('foo'.\PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream'); } public function testDoWriteOnFailure() diff --git a/src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php b/src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php index e8e31fcab1..56f7d44443 100644 --- a/src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php +++ b/src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php @@ -22,8 +22,8 @@ class SignalRegistryTest extends TestCase protected function tearDown(): void { pcntl_async_signals(false); - pcntl_signal(SIGUSR1, SIG_DFL); - pcntl_signal(SIGUSR2, SIG_DFL); + pcntl_signal(\SIGUSR1, \SIG_DFL); + pcntl_signal(\SIGUSR2, \SIG_DFL); } public function testOneCallbackForASignal_signalIsHandled() @@ -31,11 +31,11 @@ class SignalRegistryTest extends TestCase $signalRegistry = new SignalRegistry(); $isHandled = false; - $signalRegistry->register(SIGUSR1, function () use (&$isHandled) { + $signalRegistry->register(\SIGUSR1, function () use (&$isHandled) { $isHandled = true; }); - posix_kill(posix_getpid(), SIGUSR1); + posix_kill(posix_getpid(), \SIGUSR1); $this->assertTrue($isHandled); } @@ -45,16 +45,16 @@ class SignalRegistryTest extends TestCase $signalRegistry = new SignalRegistry(); $isHandled1 = false; - $signalRegistry->register(SIGUSR1, function () use (&$isHandled1) { + $signalRegistry->register(\SIGUSR1, function () use (&$isHandled1) { $isHandled1 = true; }); $isHandled2 = false; - $signalRegistry->register(SIGUSR1, function () use (&$isHandled2) { + $signalRegistry->register(\SIGUSR1, function () use (&$isHandled2) { $isHandled2 = true; }); - posix_kill(posix_getpid(), SIGUSR1); + posix_kill(posix_getpid(), \SIGUSR1); $this->assertTrue($isHandled1); $this->assertTrue($isHandled2); @@ -67,20 +67,20 @@ class SignalRegistryTest extends TestCase $isHandled1 = false; $isHandled2 = false; - $signalRegistry->register(SIGUSR1, function () use (&$isHandled1) { + $signalRegistry->register(\SIGUSR1, function () use (&$isHandled1) { $isHandled1 = true; }); - posix_kill(posix_getpid(), SIGUSR1); + posix_kill(posix_getpid(), \SIGUSR1); $this->assertTrue($isHandled1); $this->assertFalse($isHandled2); - $signalRegistry->register(SIGUSR2, function () use (&$isHandled2) { + $signalRegistry->register(\SIGUSR2, function () use (&$isHandled2) { $isHandled2 = true; }); - posix_kill(posix_getpid(), SIGUSR2); + posix_kill(posix_getpid(), \SIGUSR2); $this->assertTrue($isHandled2); } @@ -90,16 +90,16 @@ class SignalRegistryTest extends TestCase $signalRegistry = new SignalRegistry(); $isHandled1 = false; - pcntl_signal(SIGUSR1, function () use (&$isHandled1) { + pcntl_signal(\SIGUSR1, function () use (&$isHandled1) { $isHandled1 = true; }); $isHandled2 = false; - $signalRegistry->register(SIGUSR1, function () use (&$isHandled2) { + $signalRegistry->register(\SIGUSR1, function () use (&$isHandled2) { $isHandled2 = true; }); - posix_kill(posix_getpid(), SIGUSR1); + posix_kill(posix_getpid(), \SIGUSR1); $this->assertTrue($isHandled1); $this->assertTrue($isHandled2); @@ -110,18 +110,18 @@ class SignalRegistryTest extends TestCase $signalRegistry1 = new SignalRegistry(); $isHandled1 = false; - $signalRegistry1->register(SIGUSR1, function () use (&$isHandled1) { + $signalRegistry1->register(\SIGUSR1, function () use (&$isHandled1) { $isHandled1 = true; }); $signalRegistry2 = new SignalRegistry(); $isHandled2 = false; - $signalRegistry2->register(SIGUSR1, function () use (&$isHandled2) { + $signalRegistry2->register(\SIGUSR1, function () use (&$isHandled2) { $isHandled2 = true; }); - posix_kill(posix_getpid(), SIGUSR1); + posix_kill(posix_getpid(), \SIGUSR1); $this->assertTrue($isHandled1); $this->assertTrue($isHandled2); diff --git a/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php index 8361602dd7..dabf009887 100644 --- a/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php @@ -59,12 +59,12 @@ class ApplicationTesterTest extends TestCase public function testGetOutput() { rewind($this->tester->getOutput()->getStream()); - $this->assertEquals('foo'.PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); + $this->assertEquals('foo'.\PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); } public function testGetDisplay() { - $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); + $this->assertEquals('foo'.\PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); } public function testSetInputs() diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index 12cfc9b382..a7c4b57105 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -59,12 +59,12 @@ class CommandTesterTest extends TestCase public function testGetOutput() { rewind($this->tester->getOutput()->getStream()); - $this->assertEquals('foo'.PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); + $this->assertEquals('foo'.\PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); } public function testGetDisplay() { - $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); + $this->assertEquals('foo'.\PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); } public function testGetDisplayWithoutCallingExecuteBefore() diff --git a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php index 2a26c674e3..b15506d20b 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php @@ -36,7 +36,7 @@ class DecoratorServicePass extends AbstractRecursivePass public function process(ContainerBuilder $container) { $definitions = new \SplPriorityQueue(); - $order = PHP_INT_MAX; + $order = \PHP_INT_MAX; foreach ($container->getDefinitions() as $id => $definition) { if (!$decorated = $definition->getDecoratedService()) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 2126eabf54..e10e6c3dd5 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -2052,7 +2052,7 @@ EOF; */ private function export($value) { - if (null !== $this->targetDirRegex && \is_string($value) && preg_match($this->targetDirRegex, $value, $matches, PREG_OFFSET_CAPTURE)) { + if (null !== $this->targetDirRegex && \is_string($value) && preg_match($this->targetDirRegex, $value, $matches, \PREG_OFFSET_CAPTURE)) { $suffix = $matches[0][1] + \strlen($matches[0][0]); $matches[0][1] += \strlen($matches[1][0]); $prefix = $matches[0][1] ? $this->doExport(substr($value, 0, $matches[0][1]), true).'.' : ''; diff --git a/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php b/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php index ef5a1c3237..70c6609956 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php @@ -27,14 +27,14 @@ final class Preloader foreach ($list as $item) { if (0 === strpos($item, $cacheDir)) { - file_put_contents($file, sprintf("require_once __DIR__.%s;\n", var_export(substr($item, \strlen($cacheDir)), true)), FILE_APPEND); + file_put_contents($file, sprintf("require_once __DIR__.%s;\n", var_export(substr($item, \strlen($cacheDir)), true)), \FILE_APPEND); continue; } $classes[] = sprintf("\$classes[] = %s;\n", var_export($item, true)); } - file_put_contents($file, sprintf("\n\$classes = [];\n%sPreloader::preload(\$classes);\n", implode('', $classes)), FILE_APPEND); + file_put_contents($file, sprintf("\n\$classes = [];\n%sPreloader::preload(\$classes);\n", implode('', $classes)), \FILE_APPEND); } public static function preload(array $classes): void diff --git a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php index 8d13b16e37..a85fc64b04 100644 --- a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php +++ b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php @@ -192,11 +192,11 @@ class EnvVarProcessor implements EnvVarProcessorInterface } if ('bool' === $prefix) { - return (bool) (filter_var($env, FILTER_VALIDATE_BOOLEAN) ?: filter_var($env, FILTER_VALIDATE_INT) ?: filter_var($env, FILTER_VALIDATE_FLOAT)); + return (bool) (filter_var($env, \FILTER_VALIDATE_BOOLEAN) ?: filter_var($env, \FILTER_VALIDATE_INT) ?: filter_var($env, \FILTER_VALIDATE_FLOAT)); } if ('int' === $prefix) { - if (false === $env = filter_var($env, FILTER_VALIDATE_INT) ?: filter_var($env, FILTER_VALIDATE_FLOAT)) { + if (false === $env = filter_var($env, \FILTER_VALIDATE_INT) ?: filter_var($env, \FILTER_VALIDATE_FLOAT)) { throw new RuntimeException(sprintf('Non-numeric env var "%s" cannot be cast to int.', $name)); } @@ -204,7 +204,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface } if ('float' === $prefix) { - if (false === $env = filter_var($env, FILTER_VALIDATE_FLOAT)) { + if (false === $env = filter_var($env, \FILTER_VALIDATE_FLOAT)) { throw new RuntimeException(sprintf('Non-numeric env var "%s" cannot be cast to float.', $name)); } @@ -226,7 +226,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface if ('json' === $prefix) { $env = json_decode($env, true); - if (JSON_ERROR_NONE !== json_last_error()) { + if (\JSON_ERROR_NONE !== json_last_error()) { throw new RuntimeException(sprintf('Invalid JSON in env var "%s": ', $name).json_last_error_msg()); } @@ -262,7 +262,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface } if ('query_string' === $prefix) { - $queryString = parse_url($env, PHP_URL_QUERY) ?: $env; + $queryString = parse_url($env, \PHP_URL_QUERY) ?: $env; parse_str($queryString, $result); return $result; diff --git a/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php index e6384803c3..f313cbcae4 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php @@ -37,7 +37,7 @@ class IniFileLoader extends FileLoader } // real raw parsing - $result = parse_ini_file($path, true, INI_SCANNER_RAW); + $result = parse_ini_file($path, true, \INI_SCANNER_RAW); if (isset($result['parameters']) && \is_array($result['parameters'])) { foreach ($result['parameters'] as $key => $value) { @@ -55,7 +55,7 @@ class IniFileLoader extends FileLoader return false; } - if (null === $type && 'ini' === pathinfo($resource, PATHINFO_EXTENSION)) { + if (null === $type && 'ini' === pathinfo($resource, \PATHINFO_EXTENSION)) { return true; } diff --git a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php index 207fb83ec1..196baf622b 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php @@ -64,7 +64,7 @@ class PhpFileLoader extends FileLoader return false; } - if (null === $type && 'php' === pathinfo($resource, PATHINFO_EXTENSION)) { + if (null === $type && 'php' === pathinfo($resource, \PATHINFO_EXTENSION)) { return true; } diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 1294edba71..33b5a009f7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -82,7 +82,7 @@ class XmlFileLoader extends FileLoader return false; } - if (null === $type && 'xml' === pathinfo($resource, PATHINFO_EXTENSION)) { + if (null === $type && 'xml' === pathinfo($resource, \PATHINFO_EXTENSION)) { return true; } @@ -624,7 +624,7 @@ $imports EOF ; - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(false); $valid = @$dom->schemaValidateSource($source); libxml_disable_entity_loader($disableEntities); diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index a5d9e1da87..bbe82c664e 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -167,7 +167,7 @@ class YamlFileLoader extends FileLoader return false; } - if (null === $type && \in_array(pathinfo($resource, PATHINFO_EXTENSION), ['yaml', 'yml'], true)) { + if (null === $type && \in_array(pathinfo($resource, \PATHINFO_EXTENSION), ['yaml', 'yml'], true)) { return true; } diff --git a/src/Symfony/Component/DependencyInjection/ServiceLocator.php b/src/Symfony/Component/DependencyInjection/ServiceLocator.php index dd97e39d13..41f6c97d44 100644 --- a/src/Symfony/Component/DependencyInjection/ServiceLocator.php +++ b/src/Symfony/Component/DependencyInjection/ServiceLocator.php @@ -84,7 +84,7 @@ class ServiceLocator implements ServiceProviderInterface return new ServiceNotFoundException($id, end($this->loading) ?: null, null, [], $msg); } - $class = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 4); + $class = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 4); $class = isset($class[3]['object']) ? \get_class($class[3]['object']) : null; $externalId = $this->externalId ?: $class; diff --git a/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php b/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php index 313bce5973..116f571770 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php @@ -196,7 +196,7 @@ class EnvVarProcessorTest extends TestCase { return [ ['Symfony\Component\DependencyInjection\Tests\EnvVarProcessorTest::TEST_CONST', self::TEST_CONST], - ['E_ERROR', E_ERROR], + ['E_ERROR', \E_ERROR], ]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php index 7ecf8685e0..34dbe43c5b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -75,7 +75,7 @@ class FileLoaderTest extends TestCase ['foo', 'bar'], ], 'mixedcase' => ['MixedCaseKey' => 'value'], - 'constant' => PHP_EOL, + 'constant' => \PHP_EOL, 'bar' => '%foo%', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar'), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php index 4b08d059b3..52c3129fbd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php @@ -53,7 +53,7 @@ class IniFileLoaderTest extends TestCase $this->markTestSkipped(sprintf('Converting the value "%s" to "%s" is not supported by the IniFileLoader.', $key, $value)); } - $expected = parse_ini_file(__DIR__.'/../Fixtures/ini/types.ini', true, INI_SCANNER_TYPED); + $expected = parse_ini_file(__DIR__.'/../Fixtures/ini/types.ini', true, \INI_SCANNER_TYPED); $this->assertSame($value, $expected['parameters'][$key], '->load() converts values to PHP types'); } @@ -69,7 +69,7 @@ class IniFileLoaderTest extends TestCase ['no', false, true], ['none', false, true], ['null', null, true], - ['constant', PHP_VERSION, true], + ['constant', \PHP_VERSION, true], ['12', 12, true], ['12_string', '12', true], ['12_quoted_number', 12, false], // INI_SCANNER_RAW removes the double quotes diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index a01f54b533..88657cd87f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -104,7 +104,7 @@ class XmlFileLoaderTest extends TestCase public function testLoadWithExternalEntitiesDisabled() { - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(true); } @@ -112,7 +112,7 @@ class XmlFileLoaderTest extends TestCase $loader = new XmlFileLoader($containerBuilder, new FileLocator(self::$fixturesPath.'/xml')); $loader->load('services2.xml'); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } @@ -144,7 +144,7 @@ class XmlFileLoaderTest extends TestCase ['foo', 'bar'], ], 'mixedcase' => ['MixedCaseKey' => 'value'], - 'constant' => PHP_EOL, + 'constant' => \PHP_EOL, ]; $this->assertEquals($expected, $actual, '->load() converts XML values to PHP ones'); @@ -180,7 +180,7 @@ class XmlFileLoaderTest extends TestCase ['foo', 'bar'], ], 'mixedcase' => ['MixedCaseKey' => 'value'], - 'constant' => PHP_EOL, + 'constant' => \PHP_EOL, 'bar' => '%foo%', 'imported_from_ini' => true, 'imported_from_yaml' => true, diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 6f09bbbebd..2fa71d546d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -106,7 +106,7 @@ class YamlFileLoaderTest extends TestCase $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('services2.yml'); - $this->assertEquals(['foo' => 'bar', 'mixedcase' => ['MixedCaseKey' => 'value'], 'values' => [true, false, 0, 1000.3, PHP_INT_MAX], 'bar' => 'foo', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar')], $container->getParameterBag()->all(), '->load() converts YAML keys to lowercase'); + $this->assertEquals(['foo' => 'bar', 'mixedcase' => ['MixedCaseKey' => 'value'], 'values' => [true, false, 0, 1000.3, \PHP_INT_MAX], 'bar' => 'foo', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar')], $container->getParameterBag()->all(), '->load() converts YAML keys to lowercase'); } public function testLoadImports() @@ -124,7 +124,7 @@ class YamlFileLoaderTest extends TestCase $actual = $container->getParameterBag()->all(); $expected = [ 'foo' => 'bar', - 'values' => [true, false, PHP_INT_MAX], + 'values' => [true, false, \PHP_INT_MAX], 'bar' => '%foo%', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar'), diff --git a/src/Symfony/Component/DomCrawler/AbstractUriElement.php b/src/Symfony/Component/DomCrawler/AbstractUriElement.php index ac77724a60..773e9f650f 100644 --- a/src/Symfony/Component/DomCrawler/AbstractUriElement.php +++ b/src/Symfony/Component/DomCrawler/AbstractUriElement.php @@ -46,7 +46,7 @@ abstract class AbstractUriElement $this->method = $method ? strtoupper($method) : null; $this->currentUri = $currentUri; - $elementUriIsRelative = null === parse_url(trim($this->getRawUri()), PHP_URL_SCHEME); + $elementUriIsRelative = null === parse_url(trim($this->getRawUri()), \PHP_URL_SCHEME); $baseUriIsAbsolute = \in_array(strtolower(substr($this->currentUri, 0, 4)), ['http', 'file']); if ($elementUriIsRelative && !$baseUriIsAbsolute) { throw new \InvalidArgumentException(sprintf('The URL of the element is relative, so you must define its base URI passing an absolute URL to the constructor of the "%s" class ("%s" was passed).', __CLASS__, $this->currentUri)); diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 0f80578a82..3627aad5a1 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -214,7 +214,7 @@ class Crawler implements \Countable, \IteratorAggregate * LIBXML_PARSEHUGE is dangerous, see * http://symfony.com/blog/security-release-symfony-2-0-17-released */ - public function addXmlContent(string $content, string $charset = 'UTF-8', int $options = LIBXML_NONET) + public function addXmlContent(string $content, string $charset = 'UTF-8', int $options = \LIBXML_NONET) { // remove the default namespace if it's the only namespace to make XPath expressions simpler if (!preg_match('/xmlns:/', $content)) { @@ -222,7 +222,7 @@ class Crawler implements \Countable, \IteratorAggregate } $internalErrors = libxml_use_internal_errors(true); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(true); } @@ -234,7 +234,7 @@ class Crawler implements \Countable, \IteratorAggregate } libxml_use_internal_errors($internalErrors); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } @@ -442,7 +442,7 @@ class Crawler implements \Countable, \IteratorAggregate $domNode = $this->getNode(0); - while (XML_ELEMENT_NODE === $domNode->nodeType) { + while (\XML_ELEMENT_NODE === $domNode->nodeType) { $node = $this->createSubCrawler($domNode); if ($node->matches($selector)) { return $node; @@ -503,7 +503,7 @@ class Crawler implements \Countable, \IteratorAggregate $nodes = []; while ($node = $node->parentNode) { - if (XML_ELEMENT_NODE === $node->nodeType) { + if (\XML_ELEMENT_NODE === $node->nodeType) { $nodes[] = $node; } } @@ -1104,7 +1104,7 @@ class Crawler implements \Countable, \IteratorAggregate $currentNode = $this->getNode(0); do { - if ($node !== $currentNode && XML_ELEMENT_NODE === $node->nodeType) { + if ($node !== $currentNode && \XML_ELEMENT_NODE === $node->nodeType) { $nodes[] = $node; } } while ($node = $node->$siblingDir); @@ -1122,7 +1122,7 @@ class Crawler implements \Countable, \IteratorAggregate $htmlContent = $this->convertToHtmlEntities($htmlContent, $charset); $internalErrors = libxml_use_internal_errors(true); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(true); } @@ -1134,7 +1134,7 @@ class Crawler implements \Countable, \IteratorAggregate } libxml_use_internal_errors($internalErrors); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } diff --git a/src/Symfony/Component/DomCrawler/Field/FileFormField.php b/src/Symfony/Component/DomCrawler/Field/FileFormField.php index d4d60be227..bd97e7688e 100644 --- a/src/Symfony/Component/DomCrawler/Field/FileFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/FileFormField.php @@ -27,7 +27,7 @@ class FileFormField extends FormField */ public function setErrorCode(int $error) { - $codes = [UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION]; + $codes = [\UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION]; if (!\in_array($error, $codes)) { throw new \InvalidArgumentException(sprintf('The error code "%s" is not valid.', $error)); } @@ -49,7 +49,7 @@ class FileFormField extends FormField public function setValue(?string $value) { if (null !== $value && is_readable($value)) { - $error = UPLOAD_ERR_OK; + $error = \UPLOAD_ERR_OK; $size = filesize($value); $info = pathinfo($value); $name = $info['basename']; @@ -65,7 +65,7 @@ class FileFormField extends FormField copy($value, $tmp); $value = $tmp; } else { - $error = UPLOAD_ERR_NO_FILE; + $error = \UPLOAD_ERR_NO_FILE; $size = 0; $name = ''; $value = ''; diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index adafc0a07c..9b5c2892d0 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -203,7 +203,7 @@ class Form extends Link implements \ArrayAccess $uri = parent::getUri(); if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) { - $query = parse_url($uri, PHP_URL_QUERY); + $query = parse_url($uri, \PHP_URL_QUERY); $currentParameters = []; if ($query) { parse_str($query, $currentParameters); diff --git a/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php b/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php index 381386cd81..dc665f1546 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php @@ -20,7 +20,7 @@ class FileFormFieldTest extends FormFieldTestCase $node = $this->createNode('input', '', ['type' => 'file']); $field = new FileFormField($node); - $this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), '->initialize() sets the value of the field to no file uploaded'); + $this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), '->initialize() sets the value of the field to no file uploaded'); $node = $this->createNode('textarea', ''); try { @@ -48,7 +48,7 @@ class FileFormFieldTest extends FormFieldTestCase $field = new FileFormField($node); $field->$method(null); - $this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), "->$method() clears the uploaded file if the value is null"); + $this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), "->$method() clears the uploaded file if the value is null"); $field->$method(__FILE__); $value = $field->getValue(); @@ -91,9 +91,9 @@ class FileFormFieldTest extends FormFieldTestCase $node = $this->createNode('input', '', ['type' => 'file']); $field = new FileFormField($node); - $field->setErrorCode(UPLOAD_ERR_FORM_SIZE); + $field->setErrorCode(\UPLOAD_ERR_FORM_SIZE); $value = $field->getValue(); - $this->assertEquals(UPLOAD_ERR_FORM_SIZE, $value['error'], '->setErrorCode() sets the file input field error code'); + $this->assertEquals(\UPLOAD_ERR_FORM_SIZE, $value['error'], '->setErrorCode() sets the file input field error code'); try { $field->setErrorCode(12345); diff --git a/src/Symfony/Component/DomCrawler/UriResolver.php b/src/Symfony/Component/DomCrawler/UriResolver.php index 5a57fcc517..be64f52570 100644 --- a/src/Symfony/Component/DomCrawler/UriResolver.php +++ b/src/Symfony/Component/DomCrawler/UriResolver.php @@ -33,7 +33,7 @@ class UriResolver $uri = trim($uri); // absolute URL? - if (null !== parse_url($uri, PHP_URL_SCHEME)) { + if (null !== parse_url($uri, \PHP_URL_SCHEME)) { return $uri; } @@ -70,7 +70,7 @@ class UriResolver } // relative path - $path = parse_url(substr($baseUri, \strlen($baseUriCleaned)), PHP_URL_PATH); + $path = parse_url(substr($baseUri, \strlen($baseUriCleaned)), \PHP_URL_PATH); $path = self::canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri); return $baseUriCleaned.('' === $path || '/' !== $path[0] ? '/' : '').$path; diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php index c33caa43f3..8cb2ba82c2 100644 --- a/src/Symfony/Component/Dotenv/Dotenv.php +++ b/src/Symfony/Component/Dotenv/Dotenv.php @@ -161,7 +161,7 @@ final class Dotenv $k = $this->debugKey; $debug = $_SERVER[$k] ?? !\in_array($_SERVER[$this->envKey], $this->prodEnvs, true); - $_SERVER[$k] = $_ENV[$k] = (int) $debug || (!\is_bool($debug) && filter_var($debug, FILTER_VALIDATE_BOOLEAN)) ? '1' : '0'; + $_SERVER[$k] = $_ENV[$k] = (int) $debug || (!\is_bool($debug) && filter_var($debug, \FILTER_VALIDATE_BOOLEAN)) ? '1' : '0'; } /** diff --git a/src/Symfony/Component/ErrorHandler/Debug.php b/src/Symfony/Component/ErrorHandler/Debug.php index 9cc8ec17a8..4a82812182 100644 --- a/src/Symfony/Component/ErrorHandler/Debug.php +++ b/src/Symfony/Component/ErrorHandler/Debug.php @@ -24,7 +24,7 @@ class Debug if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { ini_set('display_errors', 0); - } elseif (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log')) { + } elseif (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log')) { // CLI - display errors only if they're not already logged to STDERR ini_set('display_errors', 1); } diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index a0c8954c5f..42aba12a2d 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -204,7 +204,7 @@ class DebugClassLoader } elseif (substr($test, -\strlen($file)) === $file) { // filesystem is case insensitive and realpath() normalizes the case of characters self::$caseCheck = 1; - } elseif (false !== stripos(PHP_OS, 'darwin')) { + } elseif (false !== stripos(\PHP_OS, 'darwin')) { // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters self::$caseCheck = 2; } else { @@ -329,7 +329,7 @@ class DebugClassLoader */ public function loadClass(string $class): void { - $e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); + $e = error_reporting(error_reporting() | \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR); try { if ($this->isFinder && !isset($this->loaded[$class])) { @@ -381,7 +381,7 @@ class DebugClassLoader $deprecations = $this->checkAnnotations($refl, $name); foreach ($deprecations as $message) { - @trigger_error($message, E_USER_DEPRECATED); + @trigger_error($message, \E_USER_DEPRECATED); } } @@ -433,7 +433,7 @@ class DebugClassLoader } } - 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] && !empty($method[2]); $name = $method[3]; @@ -657,7 +657,7 @@ class DebugClassLoader 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)) { + if (!preg_match_all('#\n\s+\* @param +((?(?!callable *\().*?|callable *\(.*\).*?))(?<= )\$([a-zA-Z0-9_\x7f-\xff]++)#', $doc, $matches, \PREG_SET_ORDER)) { continue; } if (!isset(self::$annotatedParameters[$class][$method->name])) { diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index 55164d6509..b8b4713b78 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -51,39 +51,39 @@ use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext; class ErrorHandler { private $levels = [ - E_DEPRECATED => 'Deprecated', - E_USER_DEPRECATED => 'User Deprecated', - E_NOTICE => 'Notice', - E_USER_NOTICE => 'User Notice', - E_STRICT => 'Runtime Notice', - E_WARNING => 'Warning', - E_USER_WARNING => 'User Warning', - E_COMPILE_WARNING => 'Compile Warning', - E_CORE_WARNING => 'Core Warning', - E_USER_ERROR => 'User Error', - E_RECOVERABLE_ERROR => 'Catchable Fatal Error', - E_COMPILE_ERROR => 'Compile Error', - E_PARSE => 'Parse Error', - E_ERROR => 'Error', - E_CORE_ERROR => 'Core Error', + \E_DEPRECATED => 'Deprecated', + \E_USER_DEPRECATED => 'User Deprecated', + \E_NOTICE => 'Notice', + \E_USER_NOTICE => 'User Notice', + \E_STRICT => 'Runtime Notice', + \E_WARNING => 'Warning', + \E_USER_WARNING => 'User Warning', + \E_COMPILE_WARNING => 'Compile Warning', + \E_CORE_WARNING => 'Core Warning', + \E_USER_ERROR => 'User Error', + \E_RECOVERABLE_ERROR => 'Catchable Fatal Error', + \E_COMPILE_ERROR => 'Compile Error', + \E_PARSE => 'Parse Error', + \E_ERROR => 'Error', + \E_CORE_ERROR => 'Core Error', ]; private $loggers = [ - E_DEPRECATED => [null, LogLevel::INFO], - E_USER_DEPRECATED => [null, LogLevel::INFO], - E_NOTICE => [null, LogLevel::WARNING], - E_USER_NOTICE => [null, LogLevel::WARNING], - E_STRICT => [null, LogLevel::WARNING], - E_WARNING => [null, LogLevel::WARNING], - E_USER_WARNING => [null, LogLevel::WARNING], - E_COMPILE_WARNING => [null, LogLevel::WARNING], - E_CORE_WARNING => [null, LogLevel::WARNING], - E_USER_ERROR => [null, LogLevel::CRITICAL], - E_RECOVERABLE_ERROR => [null, LogLevel::CRITICAL], - E_COMPILE_ERROR => [null, LogLevel::CRITICAL], - E_PARSE => [null, LogLevel::CRITICAL], - E_ERROR => [null, LogLevel::CRITICAL], - E_CORE_ERROR => [null, LogLevel::CRITICAL], + \E_DEPRECATED => [null, LogLevel::INFO], + \E_USER_DEPRECATED => [null, LogLevel::INFO], + \E_NOTICE => [null, LogLevel::WARNING], + \E_USER_NOTICE => [null, LogLevel::WARNING], + \E_STRICT => [null, LogLevel::WARNING], + \E_WARNING => [null, LogLevel::WARNING], + \E_USER_WARNING => [null, LogLevel::WARNING], + \E_COMPILE_WARNING => [null, LogLevel::WARNING], + \E_CORE_WARNING => [null, LogLevel::WARNING], + \E_USER_ERROR => [null, LogLevel::CRITICAL], + \E_RECOVERABLE_ERROR => [null, LogLevel::CRITICAL], + \E_COMPILE_ERROR => [null, LogLevel::CRITICAL], + \E_PARSE => [null, LogLevel::CRITICAL], + \E_ERROR => [null, LogLevel::CRITICAL], + \E_CORE_ERROR => [null, LogLevel::CRITICAL], ]; private $thrownErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED @@ -150,7 +150,7 @@ class ErrorHandler $handler->setExceptionHandler($prev ?? [$handler, 'renderException']); } - $handler->throwAt(E_ALL & $handler->thrownErrors, true); + $handler->throwAt(\E_ALL & $handler->thrownErrors, true); return $handler; } @@ -166,7 +166,7 @@ class ErrorHandler { set_error_handler(static function (int $type, string $message, string $file, int $line) { if (__FILE__ === $file) { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); + $trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 3); $file = $trace[2]['file'] ?? $file; $line = $trace[2]['line'] ?? $line; } @@ -205,7 +205,7 @@ class ErrorHandler * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants * @param bool $replace Whether to replace or not any existing logger */ - public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, bool $replace = false): void + public function setDefaultLogger(LoggerInterface $logger, $levels = \E_ALL, bool $replace = false): void { $loggers = []; @@ -217,7 +217,7 @@ class ErrorHandler } } else { if (null === $levels) { - $levels = E_ALL; + $levels = \E_ALL; } foreach ($this->loggers as $type => $log) { if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) { @@ -309,7 +309,7 @@ class ErrorHandler public function throwAt(int $levels, bool $replace = false): int { $prev = $this->thrownErrors; - $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; + $this->thrownErrors = ($levels | \E_RECOVERABLE_ERROR | \E_USER_ERROR) & ~\E_USER_DEPRECATED & ~\E_DEPRECATED; if (!$replace) { $this->thrownErrors |= $prev; } @@ -406,21 +406,21 @@ class ErrorHandler */ public function handleError(int $type, string $message, string $file, int $line): bool { - if (\PHP_VERSION_ID >= 70300 && E_WARNING === $type && '"' === $message[0] && false !== strpos($message, '" targeting switch is equivalent to "break')) { - $type = E_DEPRECATED; + if (\PHP_VERSION_ID >= 70300 && \E_WARNING === $type && '"' === $message[0] && false !== strpos($message, '" targeting switch is equivalent to "break')) { + $type = \E_DEPRECATED; } // Level is the current error reporting level to manage silent error. $level = error_reporting(); $silenced = 0 === ($level & $type); // Strong errors are not authorized to be silenced. - $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED; + $level |= \E_RECOVERABLE_ERROR | \E_USER_ERROR | \E_DEPRECATED | \E_USER_DEPRECATED; $log = $this->loggedErrors & $type; $throw = $this->thrownErrors & $type & $level; $type &= $level | $this->screamedErrors; // Never throw on warnings triggered by assert() - if (E_WARNING === $type && 'a' === $message[0] && 0 === strncmp($message, 'assert(): ', 10)) { + if (\E_WARNING === $type && 'a' === $message[0] && 0 === strncmp($message, 'assert(): ', 10)) { $throw = 0; } @@ -440,7 +440,7 @@ class ErrorHandler self::$toStringException = null; } elseif (!$throw && !($type & $level)) { if (!isset(self::$silencedErrorCache[$id = $file.':'.$line])) { - $lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5), $type, $file, $line, false) : []; + $lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 5), $type, $file, $line, false) : []; $errorAsException = new SilencedErrorContext($type, $file, $line, isset($lightTrace[1]) ? [$lightTrace[0]] : $lightTrace); } elseif (isset(self::$silencedErrorCache[$id][$message])) { $lightTrace = null; @@ -475,7 +475,7 @@ class ErrorHandler } if ($throw) { - if (\PHP_VERSION_ID < 70400 && E_USER_ERROR & $type) { + if (\PHP_VERSION_ID < 70400 && \E_USER_ERROR & $type) { for ($i = 1; isset($backtrace[$i]); ++$i) { if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function']) && '__toString' === $backtrace[$i]['function'] @@ -663,7 +663,7 @@ class ErrorHandler $error = error_get_last(); } - if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) { + if ($error && $error['type'] &= \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR) { // Let's not throw anymore but keep logging $handler->throwAt(0, true); $trace = isset($error['backtrace']) ? $error['backtrace'] : null; @@ -742,7 +742,7 @@ class ErrorHandler break; } } - if (E_USER_DEPRECATED === $type) { + if (\E_USER_DEPRECATED === $type) { for ($i = 0; isset($lightTrace[$i]); ++$i) { if (!isset($lightTrace[$i]['file'], $lightTrace[$i]['line'], $lightTrace[$i]['function'])) { continue; diff --git a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php index ecad8c3d3f..429f0dfdbb 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php @@ -188,7 +188,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface private function escape(string $string): string { - return htmlspecialchars($string, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset); + return htmlspecialchars($string, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset); } private function abbrClass(string $class): string @@ -347,7 +347,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface private function include(string $name, array $context = []): string { - extract($context, EXTR_SKIP); + extract($context, \EXTR_SKIP); ob_start(); include file_exists($name) ? $name : __DIR__.'/../Resources/'.$name; diff --git a/src/Symfony/Component/ErrorHandler/Resources/views/logs.html.php b/src/Symfony/Component/ErrorHandler/Resources/views/logs.html.php index c866e06978..1129925d48 100644 --- a/src/Symfony/Component/ErrorHandler/Resources/views/logs.html.php +++ b/src/Symfony/Component/ErrorHandler/Resources/views/logs.html.php @@ -20,7 +20,7 @@ if (($exception = $log['context']['exception'] ?? null) instanceof \ErrorException) { $severity = $exception->getSeverity(); } - $status = E_DEPRECATED === $severity || E_USER_DEPRECATED === $severity ? 'warning' : 'normal'; + $status = \E_DEPRECATED === $severity || \E_USER_DEPRECATED === $severity ? 'warning' : 'normal'; } ?> data-filter-channel="escape($log['channel']); ?>"> @@ -35,7 +35,7 @@ formatLogMessage($log['message'], $log['context']); ?> -
+
diff --git a/src/Symfony/Component/ErrorHandler/Resources/views/trace.html.php b/src/Symfony/Component/ErrorHandler/Resources/views/trace.html.php index 153f7d6f8e..6b4261f3f4 100644 --- a/src/Symfony/Component/ErrorHandler/Resources/views/trace.html.php +++ b/src/Symfony/Component/ErrorHandler/Resources/views/trace.html.php @@ -13,7 +13,7 @@ $lineNumber = $trace['line'] ?: 1; $fileLink = $this->getFileLink($trace['file'], $lineNumber); $filePath = strtr(strip_tags($this->formatFile($trace['file'], $lineNumber)), [' at line '.$lineNumber => '']); - $filePathParts = explode(DIRECTORY_SEPARATOR, $filePath); + $filePathParts = explode(\DIRECTORY_SEPARATOR, $filePath); ?> in diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php index 1e09afbb9f..eefba23fa6 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorEnhancer/ClassNotFoundErrorEnhancerTest.php @@ -125,7 +125,7 @@ class ClassNotFoundErrorEnhancerTest extends TestCase public function testEnhanceWithFatalError() { $error = (new ClassNotFoundErrorEnhancer())->enhance(new FatalError('foo', 0, [ - 'type' => E_ERROR, + 'type' => \E_ERROR, 'message' => "Class 'FooBarCcc' not found", 'file' => $expectedFile = realpath(__FILE__), 'line' => $expectedLine = __LINE__, diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php index b31b728e94..4239be1ed3 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php @@ -65,12 +65,12 @@ class ErrorHandlerTest extends TestCase $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger); - $handler->screamAt(E_ALL); + $handler->screamAt(\E_ALL); try { - @trigger_error('Hello', E_USER_WARNING); + @trigger_error('Hello', \E_USER_WARNING); $expected = [ - 'type' => E_USER_WARNING, + 'type' => \E_USER_WARNING, 'message' => 'Hello', 'file' => __FILE__, 'line' => __LINE__ - 5, @@ -92,10 +92,10 @@ class ErrorHandlerTest extends TestCase } catch (\ErrorException $exception) { // if an exception is thrown, the test passed if (\PHP_VERSION_ID < 80000) { - $this->assertEquals(E_NOTICE, $exception->getSeverity()); + $this->assertEquals(\E_NOTICE, $exception->getSeverity()); $this->assertMatchesRegularExpression('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); } else { - $this->assertEquals(E_WARNING, $exception->getSeverity()); + $this->assertEquals(\E_WARNING, $exception->getSeverity()); $this->assertMatchesRegularExpression('/^Warning: Undefined variable \$(foo|bar)/', $exception->getMessage()); } $this->assertEquals(__FILE__, $exception->getFile()); @@ -155,10 +155,10 @@ class ErrorHandlerTest extends TestCase } catch (\ErrorException $e) { $trace = $e->getTrace(); if (\PHP_VERSION_ID < 80000) { - $this->assertEquals(E_NOTICE, $e->getSeverity()); + $this->assertEquals(\E_NOTICE, $e->getSeverity()); $this->assertSame('Undefined variable: foo', $e->getMessage()); } else { - $this->assertEquals(E_WARNING, $e->getSeverity()); + $this->assertEquals(\E_WARNING, $e->getSeverity()); $this->assertSame('Undefined variable $foo', $e->getMessage()); } $this->assertSame(__FILE__, $e->getFile()); @@ -184,7 +184,7 @@ class ErrorHandlerTest extends TestCase try { $handler = ErrorHandler::register(); $handler->throwAt(3, true); - $this->assertEquals(3 | E_RECOVERABLE_ERROR | E_USER_ERROR, $handler->throwAt(0)); + $this->assertEquals(3 | \E_RECOVERABLE_ERROR | \E_USER_ERROR, $handler->throwAt(0)); } finally { restore_error_handler(); restore_exception_handler(); @@ -197,25 +197,25 @@ class ErrorHandlerTest extends TestCase $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $handler = ErrorHandler::register(); - $handler->setDefaultLogger($logger, E_NOTICE); - $handler->setDefaultLogger($logger, [E_USER_NOTICE => LogLevel::CRITICAL]); + $handler->setDefaultLogger($logger, \E_NOTICE); + $handler->setDefaultLogger($logger, [\E_USER_NOTICE => LogLevel::CRITICAL]); $loggers = [ - E_DEPRECATED => [null, LogLevel::INFO], - E_USER_DEPRECATED => [null, LogLevel::INFO], - E_NOTICE => [$logger, LogLevel::WARNING], - E_USER_NOTICE => [$logger, LogLevel::CRITICAL], - E_STRICT => [null, LogLevel::WARNING], - E_WARNING => [null, LogLevel::WARNING], - E_USER_WARNING => [null, LogLevel::WARNING], - E_COMPILE_WARNING => [null, LogLevel::WARNING], - E_CORE_WARNING => [null, LogLevel::WARNING], - E_USER_ERROR => [null, LogLevel::CRITICAL], - E_RECOVERABLE_ERROR => [null, LogLevel::CRITICAL], - E_COMPILE_ERROR => [null, LogLevel::CRITICAL], - E_PARSE => [null, LogLevel::CRITICAL], - E_ERROR => [null, LogLevel::CRITICAL], - E_CORE_ERROR => [null, LogLevel::CRITICAL], + \E_DEPRECATED => [null, LogLevel::INFO], + \E_USER_DEPRECATED => [null, LogLevel::INFO], + \E_NOTICE => [$logger, LogLevel::WARNING], + \E_USER_NOTICE => [$logger, LogLevel::CRITICAL], + \E_STRICT => [null, LogLevel::WARNING], + \E_WARNING => [null, LogLevel::WARNING], + \E_USER_WARNING => [null, LogLevel::WARNING], + \E_COMPILE_WARNING => [null, LogLevel::WARNING], + \E_CORE_WARNING => [null, LogLevel::WARNING], + \E_USER_ERROR => [null, LogLevel::CRITICAL], + \E_RECOVERABLE_ERROR => [null, LogLevel::CRITICAL], + \E_COMPILE_ERROR => [null, LogLevel::CRITICAL], + \E_PARSE => [null, LogLevel::CRITICAL], + \E_ERROR => [null, LogLevel::CRITICAL], + \E_CORE_ERROR => [null, LogLevel::CRITICAL], ]; $this->assertSame($loggers, $handler->setLoggers([])); } finally { @@ -256,15 +256,15 @@ class ErrorHandlerTest extends TestCase restore_exception_handler(); $handler = ErrorHandler::register(); - $handler->throwAt(E_USER_DEPRECATED, true); - $this->assertFalse($handler->handleError(E_USER_DEPRECATED, 'foo', 'foo.php', 12, [])); + $handler->throwAt(\E_USER_DEPRECATED, true); + $this->assertFalse($handler->handleError(\E_USER_DEPRECATED, 'foo', 'foo.php', 12, [])); restore_error_handler(); restore_exception_handler(); $handler = ErrorHandler::register(); - $handler->throwAt(E_DEPRECATED, true); - $this->assertFalse($handler->handleError(E_DEPRECATED, 'foo', 'foo.php', 12, [])); + $handler->throwAt(\E_DEPRECATED, true); + $this->assertFalse($handler->handleError(\E_DEPRECATED, 'foo', 'foo.php', 12, [])); restore_error_handler(); restore_exception_handler(); @@ -278,7 +278,7 @@ class ErrorHandlerTest extends TestCase $exception = $context['exception']; $this->assertInstanceOf(\ErrorException::class, $exception); $this->assertSame('User Deprecated: foo', $exception->getMessage()); - $this->assertSame(E_USER_DEPRECATED, $exception->getSeverity()); + $this->assertSame(\E_USER_DEPRECATED, $exception->getSeverity()); }; $logger @@ -288,8 +288,8 @@ class ErrorHandlerTest extends TestCase ; $handler = ErrorHandler::register(); - $handler->setDefaultLogger($logger, E_USER_DEPRECATED); - $this->assertTrue($handler->handleError(E_USER_DEPRECATED, 'foo', 'foo.php', 12, [])); + $handler->setDefaultLogger($logger, \E_USER_DEPRECATED); + $this->assertTrue($handler->handleError(\E_USER_DEPRECATED, 'foo', 'foo.php', 12, [])); restore_error_handler(); restore_exception_handler(); @@ -303,10 +303,10 @@ class ErrorHandlerTest extends TestCase if (\PHP_VERSION_ID < 80000) { $this->assertEquals('Notice: Undefined variable: undefVar', $message); - $this->assertSame(E_NOTICE, $exception->getSeverity()); + $this->assertSame(\E_NOTICE, $exception->getSeverity()); } else { $this->assertEquals('Warning: Undefined variable $undefVar', $message); - $this->assertSame(E_WARNING, $exception->getSeverity()); + $this->assertSame(\E_WARNING, $exception->getSeverity()); } $this->assertInstanceOf(SilencedErrorContext::class, $exception); @@ -324,11 +324,11 @@ class ErrorHandlerTest extends TestCase $handler = ErrorHandler::register(); if (\PHP_VERSION_ID < 80000) { - $handler->setDefaultLogger($logger, E_NOTICE); - $handler->screamAt(E_NOTICE); + $handler->setDefaultLogger($logger, \E_NOTICE); + $handler->screamAt(\E_NOTICE); } else { - $handler->setDefaultLogger($logger, E_WARNING); - $handler->screamAt(E_WARNING); + $handler->setDefaultLogger($logger, \E_WARNING); + $handler->screamAt(\E_WARNING); } unset($undefVar); $line = __LINE__ + 1; @@ -404,7 +404,7 @@ class ErrorHandlerTest extends TestCase $handler = new ErrorHandler(); $handler->setDefaultLogger($logger); - @$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, []); + @$handler->handleError(\E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, []); } /** @@ -428,7 +428,7 @@ class ErrorHandlerTest extends TestCase ->willReturnCallback($logArgCheck) ; - $handler->setDefaultLogger($logger, E_ERROR); + $handler->setDefaultLogger($logger, \E_ERROR); $handler->setExceptionHandler(null); try { @@ -468,26 +468,26 @@ class ErrorHandlerTest extends TestCase $handler = new ErrorHandler($bootLogger); $loggers = [ - E_DEPRECATED => [$bootLogger, LogLevel::INFO], - E_USER_DEPRECATED => [$bootLogger, LogLevel::INFO], - E_NOTICE => [$bootLogger, LogLevel::WARNING], - E_USER_NOTICE => [$bootLogger, LogLevel::WARNING], - E_STRICT => [$bootLogger, LogLevel::WARNING], - E_WARNING => [$bootLogger, LogLevel::WARNING], - E_USER_WARNING => [$bootLogger, LogLevel::WARNING], - E_COMPILE_WARNING => [$bootLogger, LogLevel::WARNING], - E_CORE_WARNING => [$bootLogger, LogLevel::WARNING], - E_USER_ERROR => [$bootLogger, LogLevel::CRITICAL], - E_RECOVERABLE_ERROR => [$bootLogger, LogLevel::CRITICAL], - E_COMPILE_ERROR => [$bootLogger, LogLevel::CRITICAL], - E_PARSE => [$bootLogger, LogLevel::CRITICAL], - E_ERROR => [$bootLogger, LogLevel::CRITICAL], - E_CORE_ERROR => [$bootLogger, LogLevel::CRITICAL], + \E_DEPRECATED => [$bootLogger, LogLevel::INFO], + \E_USER_DEPRECATED => [$bootLogger, LogLevel::INFO], + \E_NOTICE => [$bootLogger, LogLevel::WARNING], + \E_USER_NOTICE => [$bootLogger, LogLevel::WARNING], + \E_STRICT => [$bootLogger, LogLevel::WARNING], + \E_WARNING => [$bootLogger, LogLevel::WARNING], + \E_USER_WARNING => [$bootLogger, LogLevel::WARNING], + \E_COMPILE_WARNING => [$bootLogger, LogLevel::WARNING], + \E_CORE_WARNING => [$bootLogger, LogLevel::WARNING], + \E_USER_ERROR => [$bootLogger, LogLevel::CRITICAL], + \E_RECOVERABLE_ERROR => [$bootLogger, LogLevel::CRITICAL], + \E_COMPILE_ERROR => [$bootLogger, LogLevel::CRITICAL], + \E_PARSE => [$bootLogger, LogLevel::CRITICAL], + \E_ERROR => [$bootLogger, LogLevel::CRITICAL], + \E_CORE_ERROR => [$bootLogger, LogLevel::CRITICAL], ]; $this->assertSame($loggers, $handler->setLoggers([])); - $handler->handleError(E_DEPRECATED, 'Foo message', __FILE__, 123, []); + $handler->handleError(\E_DEPRECATED, 'Foo message', __FILE__, 123, []); $logs = $bootLogger->cleanLogs(); @@ -501,7 +501,7 @@ class ErrorHandlerTest extends TestCase $this->assertSame('Deprecated: Foo message', $exception->getMessage()); $this->assertSame(__FILE__, $exception->getFile()); $this->assertSame(123, $exception->getLine()); - $this->assertSame(E_DEPRECATED, $exception->getSeverity()); + $this->assertSame(\E_DEPRECATED, $exception->getSeverity()); $bootLogger->log(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); @@ -510,7 +510,7 @@ class ErrorHandlerTest extends TestCase ->method('log') ->with(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); - $handler->setLoggers([E_DEPRECATED => [$mockLogger, LogLevel::WARNING]]); + $handler->setLoggers([\E_DEPRECATED => [$mockLogger, LogLevel::WARNING]]); } public function testSettingLoggerWhenExceptionIsBuffered() @@ -539,7 +539,7 @@ class ErrorHandlerTest extends TestCase $handler = ErrorHandler::register(); $error = [ - 'type' => E_PARSE, + 'type' => \E_PARSE, 'message' => 'foo', 'file' => 'bar', 'line' => 123, @@ -557,7 +557,7 @@ class ErrorHandlerTest extends TestCase ->willReturnCallback($logArgCheck) ; - $handler->setDefaultLogger($logger, E_PARSE); + $handler->setDefaultLogger($logger, \E_PARSE); $handler->setExceptionHandler(null); $handler->handleFatalError($error); @@ -625,8 +625,8 @@ class ErrorHandlerTest extends TestCase $handler = ErrorHandlerThatUsesThePreviousOne::register(); } - @trigger_error('foo', E_USER_DEPRECATED); - @trigger_error('bar', E_USER_DEPRECATED); + @trigger_error('foo', \E_USER_DEPRECATED); + @trigger_error('bar', \E_USER_DEPRECATED); $this->assertSame([$handler, 'handleError'], set_error_handler('var_dump')); diff --git a/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php b/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php index 35b33d2800..30c5234669 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php @@ -269,8 +269,8 @@ class FlattenExceptionTest extends TestCase 0.0, '0', '', - INF, - NAN, + \INF, + \NAN, ]); $flattened = FlattenException::createFromThrowable($exception); @@ -301,7 +301,7 @@ class FlattenExceptionTest extends TestCase $this->assertSame(['float', 0.0], $array[$i++]); $this->assertSame(['string', '0'], $array[$i++]); $this->assertSame(['string', ''], $array[$i++]); - $this->assertSame(['float', INF], $array[$i++]); + $this->assertSame(['float', \INF], $array[$i++]); // assertEquals() does not like NAN values. $this->assertEquals('float', $array[$i][0]); diff --git a/src/Symfony/Component/ErrorHandler/ThrowableUtils.php b/src/Symfony/Component/ErrorHandler/ThrowableUtils.php index 5cbe87f493..d6efcbefa0 100644 --- a/src/Symfony/Component/ErrorHandler/ThrowableUtils.php +++ b/src/Symfony/Component/ErrorHandler/ThrowableUtils.php @@ -23,13 +23,13 @@ class ThrowableUtils } if ($throwable instanceof \ParseError) { - return E_PARSE; + return \E_PARSE; } if ($throwable instanceof \TypeError) { - return E_RECOVERABLE_ERROR; + return \E_RECOVERABLE_ERROR; } - return E_ERROR; + return \E_ERROR; } } diff --git a/src/Symfony/Component/ExpressionLanguage/Compiler.php b/src/Symfony/Component/ExpressionLanguage/Compiler.php index e040e8c4bf..6fcdac4459 100644 --- a/src/Symfony/Component/ExpressionLanguage/Compiler.php +++ b/src/Symfony/Component/ExpressionLanguage/Compiler.php @@ -109,14 +109,14 @@ class Compiler implements ResetInterface public function repr($value) { if (\is_int($value) || \is_float($value)) { - if (false !== $locale = setlocale(LC_NUMERIC, 0)) { - setlocale(LC_NUMERIC, 'C'); + if (false !== $locale = setlocale(\LC_NUMERIC, 0)) { + setlocale(\LC_NUMERIC, 'C'); } $this->raw($value); if (false !== $locale) { - setlocale(LC_NUMERIC, $locale); + setlocale(\LC_NUMERIC, $locale); } } elseif (null === $value) { $this->raw('null'); diff --git a/src/Symfony/Component/ExpressionLanguage/Lexer.php b/src/Symfony/Component/ExpressionLanguage/Lexer.php index b5648d2f67..5a3fb0a0ef 100644 --- a/src/Symfony/Component/ExpressionLanguage/Lexer.php +++ b/src/Symfony/Component/ExpressionLanguage/Lexer.php @@ -43,7 +43,7 @@ class Lexer if (preg_match('/[0-9]+(?:\.[0-9]+)?([Ee][\+\-][0-9]+)?/A', $expression, $match, 0, $cursor)) { // numbers $number = (float) $match[0]; // floats - if (preg_match('/^[0-9]+$/', $match[0]) && $number <= PHP_INT_MAX) { + if (preg_match('/^[0-9]+$/', $match[0]) && $number <= \PHP_INT_MAX) { $number = (int) $match[0]; // integers lower than the maximum } $tokens[] = new Token(Token::NUMBER_TYPE, $number, $cursor + 1); diff --git a/src/Symfony/Component/ExpressionLanguage/SyntaxError.php b/src/Symfony/Component/ExpressionLanguage/SyntaxError.php index b67fdd12e6..0bfd7e9977 100644 --- a/src/Symfony/Component/ExpressionLanguage/SyntaxError.php +++ b/src/Symfony/Component/ExpressionLanguage/SyntaxError.php @@ -22,7 +22,7 @@ class SyntaxError extends \LogicException $message .= '.'; if (null !== $subject && null !== $proposals) { - $minScore = INF; + $minScore = \INF; foreach ($proposals as $proposal) { $distance = levenshtein($subject, $proposal); if ($distance < $minScore) { diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php index ed8b6852a5..bd044621fe 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php @@ -66,7 +66,7 @@ class ExpressionLanguageTest extends TestCase public function testConstantFunction() { $expressionLanguage = new ExpressionLanguage(); - $this->assertEquals(PHP_VERSION, $expressionLanguage->evaluate('constant("PHP_VERSION")')); + $this->assertEquals(\PHP_VERSION, $expressionLanguage->evaluate('constant("PHP_VERSION")')); $expressionLanguage = new ExpressionLanguage(); $this->assertEquals('\constant("PHP_VERSION")', $expressionLanguage->compile('constant("PHP_VERSION")')); diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index d2131c9b9d..eb14fee9e9 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -44,7 +44,7 @@ class Filesystem $this->mkdir(\dirname($targetFile)); $doCopy = true; - if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) { + if (!$overwriteNewerFiles && null === parse_url($originFile, \PHP_URL_HOST) && is_file($targetFile)) { $doCopy = filemtime($originFile) > filemtime($targetFile); } @@ -114,7 +114,7 @@ class Filesystem */ public function exists($files) { - $maxPathLength = PHP_MAXPATHLEN - 2; + $maxPathLength = \PHP_MAXPATHLEN - 2; foreach ($this->toIterable($files) as $file) { if (\strlen($file) > $maxPathLength) { @@ -289,7 +289,7 @@ class Filesystem */ private function isReadable(string $filename): bool { - $maxPathLength = PHP_MAXPATHLEN - 2; + $maxPathLength = \PHP_MAXPATHLEN - 2; if (\strlen($filename) > $maxPathLength) { throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename); @@ -574,7 +574,7 @@ class Filesystem && ':' === $file[1] && strspn($file, '/\\', 2, 1) ) - || null !== parse_url($file, PHP_URL_SCHEME) + || null !== parse_url($file, \PHP_URL_SCHEME) ; } @@ -690,7 +690,7 @@ class Filesystem throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir); } - if (false === @file_put_contents($filename, $content, FILE_APPEND)) { + if (false === @file_put_contents($filename, $content, \FILE_APPEND)) { throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename); } } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index c6e63fbc56..dcd6a393a9 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -377,7 +377,7 @@ class FilesystemTest extends FilesystemTestCase $this->markTestSkipped('Long file names are an issue on Windows'); } $basePath = $this->workspace.'\\directory\\'; - $maxPathLength = PHP_MAXPATHLEN - 2; + $maxPathLength = \PHP_MAXPATHLEN - 2; $oldPath = getcwd(); mkdir($basePath); diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php index 396a3ab2e8..76cfb9f9ff 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php @@ -159,7 +159,7 @@ class FilesystemTestCase extends TestCase } // https://bugs.php.net/69473 - if ($relative && '\\' === \DIRECTORY_SEPARATOR && 1 === PHP_ZTS) { + if ($relative && '\\' === \DIRECTORY_SEPARATOR && 1 === \PHP_ZTS) { $this->markTestSkipped('symlink does not support relative paths on thread safe Windows PHP versions'); } } diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index e1bcea35d2..2b13a73ceb 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -582,7 +582,7 @@ class Finder implements \IteratorAggregate, \Countable foreach ((array) $dirs as $dir) { if (is_dir($dir)) { $resolvedDirs[] = $this->normalizeDir($dir); - } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR | GLOB_NOSORT)) { + } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) { sort($glob); $resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob)); } else { @@ -700,7 +700,7 @@ class Finder implements \IteratorAggregate, \Countable } $minDepth = 0; - $maxDepth = PHP_INT_MAX; + $maxDepth = \PHP_INT_MAX; foreach ($this->depths as $comparator) { switch ($comparator->getOperator()) { @@ -735,7 +735,7 @@ class Finder implements \IteratorAggregate, \Countable $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST); - if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) { + if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) { $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth); } diff --git a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php index 436a66d84b..18e751d77b 100644 --- a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php @@ -25,10 +25,10 @@ class DepthRangeFilterIterator extends \FilterIterator * @param int $minDepth The min depth * @param int $maxDepth The max depth */ - public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = PHP_INT_MAX) + public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = \PHP_INT_MAX) { $this->minDepth = $minDepth; - $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth); + $iterator->setMaxDepth(\PHP_INT_MAX === $maxDepth ? -1 : $maxDepth); parent::__construct($iterator); } diff --git a/src/Symfony/Component/Finder/SplFileInfo.php b/src/Symfony/Component/Finder/SplFileInfo.php index 65d7423e0d..62c9faa6e9 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/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php index 7c2572d210..150a9d819e 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php @@ -97,8 +97,8 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase return [ [0, 0, $this->toAbsolute($lessThan1)], [0, 1, $this->toAbsolute($lessThanOrEqualTo1)], - [2, PHP_INT_MAX, []], - [1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)], + [2, \PHP_INT_MAX, []], + [1, \PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)], [1, 1, $this->toAbsolute($equalTo1)], ]; } diff --git a/src/Symfony/Component/Form/Command/DebugCommand.php b/src/Symfony/Component/Form/Command/DebugCommand.php index 160b30d77b..4150feaf8c 100644 --- a/src/Symfony/Component/Form/Command/DebugCommand.php +++ b/src/Symfony/Component/Form/Command/DebugCommand.php @@ -237,7 +237,7 @@ EOF $threshold = 1e3; $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; }); - ksort($alternatives, SORT_NATURAL | SORT_FLAG_CASE); + ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE); return array_keys($alternatives); } diff --git a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php index 20f827bed3..59a6fdc6e9 100644 --- a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php @@ -97,7 +97,7 @@ class JsonDescriptor extends Descriptor { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; - $this->output->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); + $this->output->write(json_encode($data, $flags | \JSON_PRETTY_PRINT)."\n"); } private function sortOptions(array &$options) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index 85cba6a691..060c2d3ec2 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -165,7 +165,7 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface throw new TransformationFailedException($formatter->getErrorMessage()); } - if ($result >= PHP_INT_MAX || $result <= -PHP_INT_MAX) { + if ($result >= \PHP_INT_MAX || $result <= -\PHP_INT_MAX) { throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like.'); } @@ -255,13 +255,13 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface $number = $number > 0 ? floor($number) : ceil($number); break; case \NumberFormatter::ROUND_HALFEVEN: - $number = round($number, 0, PHP_ROUND_HALF_EVEN); + $number = round($number, 0, \PHP_ROUND_HALF_EVEN); break; case \NumberFormatter::ROUND_HALFUP: - $number = round($number, 0, PHP_ROUND_HALF_UP); + $number = round($number, 0, \PHP_ROUND_HALF_UP); break; case \NumberFormatter::ROUND_HALFDOWN: - $number = round($number, 0, PHP_ROUND_HALF_DOWN); + $number = round($number, 0, \PHP_ROUND_HALF_DOWN); break; } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php index a08b141517..fd3d57c816 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php @@ -227,13 +227,13 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface $number = $number > 0 ? floor($number) : ceil($number); break; case \NumberFormatter::ROUND_HALFEVEN: - $number = round($number, 0, PHP_ROUND_HALF_EVEN); + $number = round($number, 0, \PHP_ROUND_HALF_EVEN); break; case \NumberFormatter::ROUND_HALFUP: - $number = round($number, 0, PHP_ROUND_HALF_UP); + $number = round($number, 0, \PHP_ROUND_HALF_UP); break; case \NumberFormatter::ROUND_HALFDOWN: - $number = round($number, 0, PHP_ROUND_HALF_DOWN); + $number = round($number, 0, \PHP_ROUND_HALF_DOWN); break; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php index 7840b74935..09c5d69a2e 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php @@ -150,14 +150,14 @@ class FileType extends AbstractType { $messageParameters = []; - if (UPLOAD_ERR_INI_SIZE === $errorCode) { + if (\UPLOAD_ERR_INI_SIZE === $errorCode) { list($limitAsString, $suffix) = $this->factorizeSizes(0, self::getMaxFilesize()); $messageTemplate = 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.'; $messageParameters = [ '{{ limit }}' => $limitAsString, '{{ suffix }}' => $suffix, ]; - } elseif (UPLOAD_ERR_FORM_SIZE === $errorCode) { + } elseif (\UPLOAD_ERR_FORM_SIZE === $errorCode) { $messageTemplate = 'The file is too large.'; } else { $messageTemplate = 'The file could not be uploaded.'; @@ -182,7 +182,7 @@ class FileType extends AbstractType $iniMax = strtolower(ini_get('upload_max_filesize')); if ('' === $iniMax) { - return PHP_INT_MAX; + return \PHP_INT_MAX; } $max = ltrim($iniMax, '+'); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index d4e10f53eb..58c807fbf5 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -126,7 +126,7 @@ class TimeType extends AbstractType $hours = $minutes = []; foreach ($options['hours'] as $hour) { - $hours[str_pad($hour, 2, '0', STR_PAD_LEFT)] = $hour; + $hours[str_pad($hour, 2, '0', \STR_PAD_LEFT)] = $hour; } // Only pass a subset of the options to children @@ -136,7 +136,7 @@ class TimeType extends AbstractType if ($options['with_minutes']) { foreach ($options['minutes'] as $minute) { - $minutes[str_pad($minute, 2, '0', STR_PAD_LEFT)] = $minute; + $minutes[str_pad($minute, 2, '0', \STR_PAD_LEFT)] = $minute; } $minuteOptions['choices'] = $minutes; @@ -148,7 +148,7 @@ class TimeType extends AbstractType $seconds = []; foreach ($options['seconds'] as $second) { - $seconds[str_pad($second, 2, '0', STR_PAD_LEFT)] = $second; + $seconds[str_pad($second, 2, '0', \STR_PAD_LEFT)] = $second; } $secondOptions['choices'] = $seconds; diff --git a/src/Symfony/Component/Form/FormRenderer.php b/src/Symfony/Component/Form/FormRenderer.php index 2ac3b57ee5..ed63d9499c 100644 --- a/src/Symfony/Component/Form/FormRenderer.php +++ b/src/Symfony/Component/Form/FormRenderer.php @@ -291,9 +291,9 @@ class FormRenderer implements FormRendererInterface public function encodeCurrency(Environment $environment, string $text, string $widget = ''): string { if ('UTF-8' === $charset = $environment->getCharset()) { - $text = htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); + $text = htmlspecialchars($text, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8'); } else { - $text = htmlentities($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); + $text = htmlentities($text, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8'); $text = iconv('UTF-8', $charset, $text); $widget = iconv('UTF-8', $charset, $widget); } diff --git a/src/Symfony/Component/Form/NativeRequestHandler.php b/src/Symfony/Component/Form/NativeRequestHandler.php index f7db42e0f7..2532256f2b 100644 --- a/src/Symfony/Component/Form/NativeRequestHandler.php +++ b/src/Symfony/Component/Form/NativeRequestHandler.php @@ -152,7 +152,7 @@ class NativeRequestHandler implements RequestHandlerInterface return null; } - if (UPLOAD_ERR_OK === $data['error']) { + if (\UPLOAD_ERR_OK === $data['error']) { return null; } @@ -238,7 +238,7 @@ class NativeRequestHandler implements RequestHandlerInterface sort($keys); if (self::$fileKeys === $keys) { - if (UPLOAD_ERR_NO_FILE === $data['error']) { + if (\UPLOAD_ERR_NO_FILE === $data['error']) { return null; } diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index 61455a5133..b7e6eef38b 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php @@ -371,14 +371,14 @@ abstract class AbstractRequestHandlerTest extends TestCase public function uploadFileErrorCodes() { return [ - 'no error' => [UPLOAD_ERR_OK, null], - 'upload_max_filesize ini directive' => [UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_INI_SIZE], - 'MAX_FILE_SIZE from form' => [UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_FORM_SIZE], - 'partially uploaded' => [UPLOAD_ERR_PARTIAL, UPLOAD_ERR_PARTIAL], - 'no file upload' => [UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_FILE], - 'missing temporary directory' => [UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_NO_TMP_DIR], - 'write failure' => [UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_CANT_WRITE], - 'stopped by extension' => [UPLOAD_ERR_EXTENSION, UPLOAD_ERR_EXTENSION], + 'no error' => [\UPLOAD_ERR_OK, null], + 'upload_max_filesize ini directive' => [\UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_INI_SIZE], + 'MAX_FILE_SIZE from form' => [\UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_FORM_SIZE], + 'partially uploaded' => [\UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_PARTIAL], + 'no file upload' => [\UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_FILE], + 'missing temporary directory' => [\UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_NO_TMP_DIR], + 'write failure' => [\UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_CANT_WRITE], + 'stopped by extension' => [\UPLOAD_ERR_EXTENSION, \UPLOAD_ERR_EXTENSION], ]; } diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index 988161953c..45786c85f3 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -623,7 +623,7 @@ class CompoundFormTest extends AbstractFormTest $files = [ 'author' => [ - 'error' => ['image' => UPLOAD_ERR_OK], + 'error' => ['image' => \UPLOAD_ERR_OK], 'name' => ['image' => 'upload.png'], 'size' => ['image' => null], 'tmp_name' => ['image' => $path], @@ -646,7 +646,7 @@ class CompoundFormTest extends AbstractFormTest $form->handleRequest($request); - $file = new UploadedFile($path, 'upload.png', 'image/png', UPLOAD_ERR_OK); + $file = new UploadedFile($path, 'upload.png', 'image/png', \UPLOAD_ERR_OK); $this->assertEquals('Bernhard', $form['name']->getData()); $this->assertEquals($file, $form['image']->getData()); @@ -670,7 +670,7 @@ class CompoundFormTest extends AbstractFormTest $files = [ 'image' => [ - 'error' => UPLOAD_ERR_OK, + 'error' => \UPLOAD_ERR_OK, 'name' => 'upload.png', 'size' => null, 'tmp_name' => $path, @@ -693,7 +693,7 @@ class CompoundFormTest extends AbstractFormTest $form->handleRequest($request); - $file = new UploadedFile($path, 'upload.png', 'image/png', UPLOAD_ERR_OK); + $file = new UploadedFile($path, 'upload.png', 'image/png', \UPLOAD_ERR_OK); $this->assertEquals('Bernhard', $form['name']->getData()); $this->assertEquals($file, $form['image']->getData()); @@ -713,7 +713,7 @@ class CompoundFormTest extends AbstractFormTest $files = [ 'image' => [ - 'error' => UPLOAD_ERR_OK, + 'error' => \UPLOAD_ERR_OK, 'name' => 'upload.png', 'size' => null, 'tmp_name' => $path, @@ -732,7 +732,7 @@ class CompoundFormTest extends AbstractFormTest $form->handleRequest($request); - $file = new UploadedFile($path, 'upload.png', 'image/png', UPLOAD_ERR_OK); + $file = new UploadedFile($path, 'upload.png', 'image/png', \UPLOAD_ERR_OK); $this->assertEquals($file, $form->getData()); @@ -1117,7 +1117,7 @@ class CompoundFormTest extends AbstractFormTest $this->form->submit([ 'foo' => 'Foo', - 'bar' => new UploadedFile(__FILE__, 'upload.png', 'image/png', UPLOAD_ERR_OK), + 'bar' => new UploadedFile(__FILE__, 'upload.png', 'image/png', \UPLOAD_ERR_OK), ]); $this->assertSame('Submitted data was expected to be text or number, file upload given.', $this->form->get('bar')->getTransformationFailure()->getMessage()); diff --git a/src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTest.php index e535fe5c03..e5f5d1228b 100644 --- a/src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Component/Form/Tests/Console/Descriptor/AbstractDescriptorTest.php @@ -35,9 +35,9 @@ abstract class AbstractDescriptorTest extends TestCase $expectedDescription = $this->getExpectedDescription($fixtureName); if ('json' === $this->getFormat()) { - $this->assertEquals(json_encode(json_decode($expectedDescription), JSON_PRETTY_PRINT), json_encode(json_decode($describedObject), JSON_PRETTY_PRINT)); + $this->assertEquals(json_encode(json_decode($expectedDescription), \JSON_PRETTY_PRINT), json_encode(json_decode($describedObject), \JSON_PRETTY_PRINT)); } else { - $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $describedObject))); + $this->assertEquals(trim($expectedDescription), trim(str_replace(\PHP_EOL, "\n", $describedObject))); } } @@ -48,9 +48,9 @@ abstract class AbstractDescriptorTest extends TestCase $expectedDescription = $this->getExpectedDescription($fixtureName); if ('json' === $this->getFormat()) { - $this->assertEquals(json_encode(json_decode($expectedDescription), JSON_PRETTY_PRINT), json_encode(json_decode($describedObject), JSON_PRETTY_PRINT)); + $this->assertEquals(json_encode(json_decode($expectedDescription), \JSON_PRETTY_PRINT), json_encode(json_decode($describedObject), \JSON_PRETTY_PRINT)); } else { - $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $describedObject))); + $this->assertEquals(trim($expectedDescription), trim(str_replace(\PHP_EOL, "\n", $describedObject))); } } @@ -61,9 +61,9 @@ abstract class AbstractDescriptorTest extends TestCase $expectedDescription = $this->getExpectedDescription($fixtureName); if ('json' === $this->getFormat()) { - $this->assertEquals(json_encode(json_decode($expectedDescription), JSON_PRETTY_PRINT), json_encode(json_decode($describedObject), JSON_PRETTY_PRINT)); + $this->assertEquals(json_encode(json_decode($expectedDescription), \JSON_PRETTY_PRINT), json_encode(json_decode($describedObject), \JSON_PRETTY_PRINT)); } else { - $this->assertStringMatchesFormat(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $describedObject))); + $this->assertStringMatchesFormat(trim($expectedDescription), trim(str_replace(\PHP_EOL, "\n", $describedObject))); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index c9821bfe74..ae23428a43 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -335,7 +335,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase $this->markTestSkipped('intl extension is not loaded'); } - $this->iniSet('intl.error_level', E_WARNING); + $this->iniSet('intl.error_level', \E_WARNING); $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $transformer = new DateTimeToLocalizedStringTransformer(); @@ -362,7 +362,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase } $this->iniSet('intl.use_exceptions', 1); - $this->iniSet('intl.error_level', E_WARNING); + $this->iniSet('intl.error_level', \E_WARNING); $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $transformer = new DateTimeToLocalizedStringTransformer(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php index 69d9e85267..cb94ca785d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php @@ -21,12 +21,12 @@ class MoneyToLocalizedStringTransformerTest extends TestCase protected function setUp(): void { - $this->previousLocale = setlocale(LC_ALL, '0'); + $this->previousLocale = setlocale(\LC_ALL, '0'); } protected function tearDown(): void { - setlocale(LC_ALL, $this->previousLocale); + setlocale(\LC_ALL, $this->previousLocale); } public function testTransform() @@ -106,7 +106,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase public function testValidNumericValuesWithNonDotDecimalPointCharacter() { // calling setlocale() here is important as it changes the representation of floats when being cast to strings - setlocale(LC_ALL, 'de_AT.UTF-8'); + setlocale(\LC_ALL, 'de_AT.UTF-8'); $transformer = new MoneyToLocalizedStringTransformer(4, null, null, 100); IntlTestHelper::requireFullIntl($this, false); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 66e955a1dc..41b927d04a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -622,7 +622,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase { $transformer = new NumberToLocalizedStringTransformer(null, true); - $this->assertEquals(PHP_INT_MAX - 1, (int) $transformer->reverseTransform((string) (PHP_INT_MAX - 1))); + $this->assertEquals(\PHP_INT_MAX - 1, (int) $transformer->reverseTransform((string) (\PHP_INT_MAX - 1))); } public function testReverseTransformSmallInt() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php index 0731942c89..7c6e639354 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php @@ -206,7 +206,7 @@ class FileTypeTest extends BaseTypeTest ->getForm(); $form->submit($this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'foo', $errorCode)); - if (UPLOAD_ERR_OK === $errorCode) { + if (\UPLOAD_ERR_OK === $errorCode) { $this->assertTrue($form->isValid()); } else { $this->assertFalse($form->isValid()); @@ -231,7 +231,7 @@ class FileTypeTest extends BaseTypeTest 'size' => 100, ]); - if (UPLOAD_ERR_OK === $errorCode) { + if (\UPLOAD_ERR_OK === $errorCode) { $this->assertTrue($form->isValid()); } else { $this->assertFalse($form->isValid()); @@ -256,7 +256,7 @@ class FileTypeTest extends BaseTypeTest $this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'bar', $errorCode), ]); - if (UPLOAD_ERR_OK === $errorCode) { + if (\UPLOAD_ERR_OK === $errorCode) { $this->assertTrue($form->isValid()); } else { $this->assertFalse($form->isValid()); @@ -294,7 +294,7 @@ class FileTypeTest extends BaseTypeTest ], ]); - if (UPLOAD_ERR_OK === $errorCode) { + if (\UPLOAD_ERR_OK === $errorCode) { $this->assertTrue($form->isValid()); } else { $this->assertFalse($form->isValid()); @@ -307,14 +307,14 @@ class FileTypeTest extends BaseTypeTest public function uploadFileErrorCodes() { return [ - 'no error' => [UPLOAD_ERR_OK, null], - 'upload_max_filesize ini directive' => [UPLOAD_ERR_INI_SIZE, 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.'], - 'MAX_FILE_SIZE from form' => [UPLOAD_ERR_FORM_SIZE, 'The file is too large.'], - 'partially uploaded' => [UPLOAD_ERR_PARTIAL, 'The file could not be uploaded.'], - 'no file upload' => [UPLOAD_ERR_NO_FILE, 'The file could not be uploaded.'], - 'missing temporary directory' => [UPLOAD_ERR_NO_TMP_DIR, 'The file could not be uploaded.'], - 'write failure' => [UPLOAD_ERR_CANT_WRITE, 'The file could not be uploaded.'], - 'stopped by extension' => [UPLOAD_ERR_EXTENSION, 'The file could not be uploaded.'], + 'no error' => [\UPLOAD_ERR_OK, null], + 'upload_max_filesize ini directive' => [\UPLOAD_ERR_INI_SIZE, 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.'], + 'MAX_FILE_SIZE from form' => [\UPLOAD_ERR_FORM_SIZE, 'The file is too large.'], + 'partially uploaded' => [\UPLOAD_ERR_PARTIAL, 'The file could not be uploaded.'], + 'no file upload' => [\UPLOAD_ERR_NO_FILE, 'The file could not be uploaded.'], + 'missing temporary directory' => [\UPLOAD_ERR_NO_TMP_DIR, 'The file could not be uploaded.'], + 'write failure' => [\UPLOAD_ERR_CANT_WRITE, 'The file could not be uploaded.'], + 'stopped by extension' => [\UPLOAD_ERR_EXTENSION, 'The file could not be uploaded.'], ]; } diff --git a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php index bff9852bbb..ad1ea18e4a 100644 --- a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php @@ -78,7 +78,7 @@ class NativeRequestHandlerTest extends AbstractRequestHandlerTest 'name' => '', 'type' => '', 'tmp_name' => '', - 'error' => UPLOAD_ERR_NO_FILE, + 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0, ]]); @@ -105,7 +105,7 @@ class NativeRequestHandlerTest extends AbstractRequestHandlerTest 'field' => 'owfdskjasdfsa', ], 'error' => [ - 'field' => UPLOAD_ERR_OK, + 'field' => \UPLOAD_ERR_OK, ], 'size' => [ 'field' => 100, @@ -119,7 +119,7 @@ class NativeRequestHandlerTest extends AbstractRequestHandlerTest 'name' => 'upload.txt', 'type' => 'text/plain', 'tmp_name' => 'owfdskjasdfsa', - 'error' => UPLOAD_ERR_OK, + 'error' => \UPLOAD_ERR_OK, 'size' => 100, ], $fieldForm->getData()); } @@ -143,7 +143,7 @@ class NativeRequestHandlerTest extends AbstractRequestHandlerTest 'field' => ['subfield' => 'owfdskjasdfsa'], ], 'error' => [ - 'field' => ['subfield' => UPLOAD_ERR_OK], + 'field' => ['subfield' => \UPLOAD_ERR_OK], ], 'size' => [ 'field' => ['subfield' => 100], @@ -157,7 +157,7 @@ class NativeRequestHandlerTest extends AbstractRequestHandlerTest 'name' => 'upload.txt', 'type' => 'text/plain', 'tmp_name' => 'owfdskjasdfsa', - 'error' => UPLOAD_ERR_OK, + 'error' => \UPLOAD_ERR_OK, 'size' => 100, ], $subfieldForm->getData()); } @@ -258,7 +258,7 @@ class NativeRequestHandlerTest extends AbstractRequestHandlerTest 'name' => 'upload'.$suffix.'.txt', 'type' => 'text/plain', 'tmp_name' => 'owfdskjasdfsa'.$suffix, - 'error' => UPLOAD_ERR_OK, + 'error' => \UPLOAD_ERR_OK, 'size' => 100, ]; } diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index fc10683a5f..b7f814ed14 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -75,13 +75,13 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, // Don't enable HTTP/1.1 pipelining: it forces responses to be sent in order if (\defined('CURLPIPE_MULTIPLEX')) { - curl_multi_setopt($this->multi->handle, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); + curl_multi_setopt($this->multi->handle, \CURLMOPT_PIPELINING, \CURLPIPE_MULTIPLEX); } if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS')) { - $maxHostConnections = curl_multi_setopt($this->multi->handle, CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : PHP_INT_MAX) ? 0 : $maxHostConnections; + $maxHostConnections = curl_multi_setopt($this->multi->handle, \CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : \PHP_INT_MAX) ? 0 : $maxHostConnections; } if (\defined('CURLMOPT_MAXCONNECTS') && 0 < $maxHostConnections) { - curl_multi_setopt($this->multi->handle, CURLMOPT_MAXCONNECTS, $maxHostConnections); + curl_multi_setopt($this->multi->handle, \CURLMOPT_MAXCONNECTS, $maxHostConnections); } // Skip configuring HTTP/2 push when it's unsupported or buggy, see https://bugs.php.net/77535 @@ -90,11 +90,11 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, } // HTTP/2 push crashes before curl 7.61 - if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073d00 > self::$curlVersion['version_number'] || !(CURL_VERSION_HTTP2 & self::$curlVersion['features'])) { + if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073d00 > self::$curlVersion['version_number'] || !(\CURL_VERSION_HTTP2 & self::$curlVersion['features'])) { return; } - curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, function ($parent, $pushed, array $requestHeaders) use ($maxPendingPushes) { + curl_multi_setopt($this->multi->handle, \CURLMOPT_PUSHFUNCTION, function ($parent, $pushed, array $requestHeaders) use ($maxPendingPushes) { return $this->handlePush($parent, $pushed, $requestHeaders, $maxPendingPushes); }); } @@ -109,7 +109,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, [$url, $options] = self::prepareRequest($method, $url, $options, $this->defaultOptions); $scheme = $url['scheme']; $authority = $url['authority']; - $host = parse_url($authority, PHP_URL_HOST); + $host = parse_url($authority, \PHP_URL_HOST); $url = implode('', $url); if (!isset($options['normalized_headers']['user-agent'])) { @@ -117,38 +117,38 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, } $curlopts = [ - CURLOPT_URL => $url, - CURLOPT_TCP_NODELAY => true, - CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS, - CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_MAXREDIRS => 0 < $options['max_redirects'] ? $options['max_redirects'] : 0, - CURLOPT_COOKIEFILE => '', // Keep track of cookies during redirects - CURLOPT_TIMEOUT => 0, - CURLOPT_PROXY => $options['proxy'], - CURLOPT_NOPROXY => $options['no_proxy'] ?? $_SERVER['no_proxy'] ?? $_SERVER['NO_PROXY'] ?? '', - CURLOPT_SSL_VERIFYPEER => $options['verify_peer'], - CURLOPT_SSL_VERIFYHOST => $options['verify_host'] ? 2 : 0, - CURLOPT_CAINFO => $options['cafile'], - CURLOPT_CAPATH => $options['capath'], - CURLOPT_SSL_CIPHER_LIST => $options['ciphers'], - CURLOPT_SSLCERT => $options['local_cert'], - CURLOPT_SSLKEY => $options['local_pk'], - CURLOPT_KEYPASSWD => $options['passphrase'], - CURLOPT_CERTINFO => $options['capture_peer_cert_chain'], + \CURLOPT_URL => $url, + \CURLOPT_TCP_NODELAY => true, + \CURLOPT_PROTOCOLS => \CURLPROTO_HTTP | \CURLPROTO_HTTPS, + \CURLOPT_REDIR_PROTOCOLS => \CURLPROTO_HTTP | \CURLPROTO_HTTPS, + \CURLOPT_FOLLOWLOCATION => true, + \CURLOPT_MAXREDIRS => 0 < $options['max_redirects'] ? $options['max_redirects'] : 0, + \CURLOPT_COOKIEFILE => '', // Keep track of cookies during redirects + \CURLOPT_TIMEOUT => 0, + \CURLOPT_PROXY => $options['proxy'], + \CURLOPT_NOPROXY => $options['no_proxy'] ?? $_SERVER['no_proxy'] ?? $_SERVER['NO_PROXY'] ?? '', + \CURLOPT_SSL_VERIFYPEER => $options['verify_peer'], + \CURLOPT_SSL_VERIFYHOST => $options['verify_host'] ? 2 : 0, + \CURLOPT_CAINFO => $options['cafile'], + \CURLOPT_CAPATH => $options['capath'], + \CURLOPT_SSL_CIPHER_LIST => $options['ciphers'], + \CURLOPT_SSLCERT => $options['local_cert'], + \CURLOPT_SSLKEY => $options['local_pk'], + \CURLOPT_KEYPASSWD => $options['passphrase'], + \CURLOPT_CERTINFO => $options['capture_peer_cert_chain'], ]; if (1.0 === (float) $options['http_version']) { - $curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; + $curlopts[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_0; } elseif (1.1 === (float) $options['http_version']) { - $curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; - } elseif (\defined('CURL_VERSION_HTTP2') && (CURL_VERSION_HTTP2 & self::$curlVersion['features']) && ('https:' === $scheme || 2.0 === (float) $options['http_version'])) { - $curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0; + $curlopts[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_1; + } elseif (\defined('CURL_VERSION_HTTP2') && (\CURL_VERSION_HTTP2 & self::$curlVersion['features']) && ('https:' === $scheme || 2.0 === (float) $options['http_version'])) { + $curlopts[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_2_0; } if (isset($options['auth_ntlm'])) { - $curlopts[CURLOPT_HTTPAUTH] = CURLAUTH_NTLM; - $curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; + $curlopts[\CURLOPT_HTTPAUTH] = \CURLAUTH_NTLM; + $curlopts[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_1; if (\is_array($options['auth_ntlm'])) { $count = \count($options['auth_ntlm']); @@ -163,15 +163,15 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must be a string or an array, "%s" given.', get_debug_type($options['auth_ntlm']))); } - $curlopts[CURLOPT_USERPWD] = $options['auth_ntlm']; + $curlopts[\CURLOPT_USERPWD] = $options['auth_ntlm']; } - if (!ZEND_THREAD_SAFE) { - $curlopts[CURLOPT_DNS_USE_GLOBAL_CACHE] = false; + if (!\ZEND_THREAD_SAFE) { + $curlopts[\CURLOPT_DNS_USE_GLOBAL_CACHE] = false; } if (\defined('CURLOPT_HEADEROPT')) { - $curlopts[CURLOPT_HEADEROPT] = CURLHEADER_SEPARATE; + $curlopts[\CURLOPT_HEADEROPT] = \CURLHEADER_SEPARATE; } // curl's resolve feature varies by host:port but ours varies by host only, let's handle this with our own DNS map @@ -183,7 +183,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, // First reset any old DNS cache entries then add the new ones $resolve = $this->multi->dnsCache->evictions; $this->multi->dnsCache->evictions = []; - $port = parse_url($authority, PHP_URL_PORT) ?: ('http:' === $scheme ? 80 : 443); + $port = parse_url($authority, \PHP_URL_PORT) ?: ('http:' === $scheme ? 80 : 443); if ($resolve && 0x072a00 > self::$curlVersion['version_number']) { // DNS cache removals require curl 7.42 or higher @@ -198,20 +198,20 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, $this->multi->dnsCache->removals["-$host:$port"] = "-$host:$port"; } - $curlopts[CURLOPT_RESOLVE] = $resolve; + $curlopts[\CURLOPT_RESOLVE] = $resolve; } if ('POST' === $method) { // Use CURLOPT_POST to have browser-like POST-to-GET redirects for 301, 302 and 303 - $curlopts[CURLOPT_POST] = true; + $curlopts[\CURLOPT_POST] = true; } elseif ('HEAD' === $method) { - $curlopts[CURLOPT_NOBODY] = true; + $curlopts[\CURLOPT_NOBODY] = true; } else { - $curlopts[CURLOPT_CUSTOMREQUEST] = $method; + $curlopts[\CURLOPT_CUSTOMREQUEST] = $method; } if ('\\' !== \DIRECTORY_SEPARATOR && $options['timeout'] < 1) { - $curlopts[CURLOPT_NOSIGNAL] = true; + $curlopts[\CURLOPT_NOSIGNAL] = true; } if (\extension_loaded('zlib') && !isset($options['normalized_headers']['accept-encoding'])) { @@ -221,41 +221,41 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, foreach ($options['headers'] as $header) { if (':' === $header[-2] && \strlen($header) - 2 === strpos($header, ': ')) { // curl requires a special syntax to send empty headers - $curlopts[CURLOPT_HTTPHEADER][] = substr_replace($header, ';', -2); + $curlopts[\CURLOPT_HTTPHEADER][] = substr_replace($header, ';', -2); } else { - $curlopts[CURLOPT_HTTPHEADER][] = $header; + $curlopts[\CURLOPT_HTTPHEADER][] = $header; } } // Prevent curl from sending its default Accept and Expect headers foreach (['accept', 'expect'] as $header) { if (!isset($options['normalized_headers'][$header][0])) { - $curlopts[CURLOPT_HTTPHEADER][] = $header.':'; + $curlopts[\CURLOPT_HTTPHEADER][] = $header.':'; } } if (!\is_string($body = $options['body'])) { if (\is_resource($body)) { - $curlopts[CURLOPT_INFILE] = $body; + $curlopts[\CURLOPT_INFILE] = $body; } else { $eof = false; $buffer = ''; - $curlopts[CURLOPT_READFUNCTION] = static function ($ch, $fd, $length) use ($body, &$buffer, &$eof) { + $curlopts[\CURLOPT_READFUNCTION] = static function ($ch, $fd, $length) use ($body, &$buffer, &$eof) { return self::readRequestBody($length, $body, $buffer, $eof); }; } if (isset($options['normalized_headers']['content-length'][0])) { - $curlopts[CURLOPT_INFILESIZE] = substr($options['normalized_headers']['content-length'][0], \strlen('Content-Length: ')); + $curlopts[\CURLOPT_INFILESIZE] = substr($options['normalized_headers']['content-length'][0], \strlen('Content-Length: ')); } elseif (!isset($options['normalized_headers']['transfer-encoding'])) { - $curlopts[CURLOPT_HTTPHEADER][] = 'Transfer-Encoding: chunked'; // Enable chunked request bodies + $curlopts[\CURLOPT_HTTPHEADER][] = 'Transfer-Encoding: chunked'; // Enable chunked request bodies } if ('POST' !== $method) { - $curlopts[CURLOPT_UPLOAD] = true; + $curlopts[\CURLOPT_UPLOAD] = true; } } elseif ('' !== $body || 'POST' === $method) { - $curlopts[CURLOPT_POSTFIELDS] = $body; + $curlopts[\CURLOPT_POSTFIELDS] = $body; } if ($options['peer_fingerprint']) { @@ -263,15 +263,15 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, throw new TransportException(__CLASS__.' supports only "pin-sha256" fingerprints.'); } - $curlopts[CURLOPT_PINNEDPUBLICKEY] = 'sha256//'.implode(';sha256//', $options['peer_fingerprint']['pin-sha256']); + $curlopts[\CURLOPT_PINNEDPUBLICKEY] = 'sha256//'.implode(';sha256//', $options['peer_fingerprint']['pin-sha256']); } if ($options['bindto']) { - $curlopts[file_exists($options['bindto']) ? CURLOPT_UNIX_SOCKET_PATH : CURLOPT_INTERFACE] = $options['bindto']; + $curlopts[file_exists($options['bindto']) ? \CURLOPT_UNIX_SOCKET_PATH : \CURLOPT_INTERFACE] = $options['bindto']; } if (0 < $options['max_duration']) { - $curlopts[CURLOPT_TIMEOUT_MS] = 1000 * $options['max_duration']; + $curlopts[\CURLOPT_TIMEOUT_MS] = 1000 * $options['max_duration']; } if ($pushedResponse = $this->multi->pushedResponses[$url] ?? null) { @@ -296,10 +296,10 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, } foreach ($curlopts as $opt => $value) { - if (null !== $value && !curl_setopt($ch, $opt, $value) && CURLOPT_CERTINFO !== $opt) { + if (null !== $value && !curl_setopt($ch, $opt, $value) && \CURLOPT_CERTINFO !== $opt) { $constants = array_filter(get_defined_constants(), static function ($v, $k) use ($opt) { return $v === $opt && 'C' === $k[0] && (0 === strpos($k, 'CURLOPT_') || 0 === strpos($k, 'CURLINFO_')); - }, ARRAY_FILTER_USE_BOTH); + }, \ARRAY_FILTER_USE_BOTH); throw new TransportException(sprintf('Curl option "%s" is not supported.', key($constants) ?? $opt)); } @@ -320,7 +320,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, } $active = 0; - while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active)); + while (\CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active)); return new ResponseStream(CurlResponse::stream($responses, $timeout)); } @@ -339,16 +339,16 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, if (\is_resource($this->multi->handle) || $this->multi->handle instanceof \CurlMultiHandle) { if (\defined('CURLMOPT_PUSHFUNCTION')) { - curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null); + curl_multi_setopt($this->multi->handle, \CURLMOPT_PUSHFUNCTION, null); } $active = 0; - while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active)); + while (\CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active)); } foreach ($this->multi->openHandles as [$ch]) { if (\is_resource($ch) || $ch instanceof \CurlHandle) { - curl_setopt($ch, CURLOPT_VERBOSE, false); + curl_setopt($ch, \CURLOPT_VERBOSE, false); } } } @@ -361,7 +361,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, private function handlePush($parent, $pushed, array $requestHeaders, int $maxPendingPushes): int { $headers = []; - $origin = curl_getinfo($parent, CURLINFO_EFFECTIVE_URL); + $origin = curl_getinfo($parent, \CURLINFO_EFFECTIVE_URL); foreach ($requestHeaders as $h) { if (false !== $i = strpos($h, ':', 1)) { @@ -372,7 +372,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, if (!isset($headers[':method']) || !isset($headers[':scheme']) || !isset($headers[':authority']) || !isset($headers[':path'])) { $this->logger && $this->logger->debug(sprintf('Rejecting pushed response from "%s": pushed headers are invalid', $origin)); - return CURL_PUSH_DENY; + return \CURL_PUSH_DENY; } $url = $headers[':scheme'][0].'://'.$headers[':authority'][0]; @@ -383,7 +383,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, if (0 !== strpos($origin, $url.'/')) { $this->logger && $this->logger->debug(sprintf('Rejecting pushed response from "%s": server is not authoritative for "%s"', $origin, $url)); - return CURL_PUSH_DENY; + return \CURL_PUSH_DENY; } if ($maxPendingPushes <= \count($this->multi->pushedResponses)) { @@ -397,7 +397,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, $this->multi->pushedResponses[$url] = new PushedResponse(new CurlResponse($this->multi, $pushed), $headers, $this->multi->openHandles[(int) $parent][1] ?? [], $pushed); - return CURL_PUSH_OK; + return \CURL_PUSH_OK; } /** @@ -477,12 +477,12 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, return null; } - if ($redirectHeaders && $host = parse_url('http:'.$location['authority'], PHP_URL_HOST)) { + if ($redirectHeaders && $host = parse_url('http:'.$location['authority'], \PHP_URL_HOST)) { $requestHeaders = $redirectHeaders['host'] === $host ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth']; - curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders); + curl_setopt($ch, \CURLOPT_HTTPHEADER, $requestHeaders); } - $url = self::parseUrl(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); + $url = self::parseUrl(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL)); return implode('', self::resolveUrl($location, $url)); }; diff --git a/src/Symfony/Component/HttpClient/EventSourceHttpClient.php b/src/Symfony/Component/HttpClient/EventSourceHttpClient.php index 0c6536f508..5dfa929c54 100644 --- a/src/Symfony/Component/HttpClient/EventSourceHttpClient.php +++ b/src/Symfony/Component/HttpClient/EventSourceHttpClient.php @@ -121,7 +121,7 @@ final class EventSourceHttpClient implements HttpClientInterface if ($chunk->isLast()) { $rx = substr_replace($rx, '|$', -2, 0); } - $events = preg_split($rx, $content, -1, PREG_SPLIT_DELIM_CAPTURE); + $events = preg_split($rx, $content, -1, \PREG_SPLIT_DELIM_CAPTURE); $state->buffer = array_pop($events); for ($i = 0; isset($events[$i]); $i += 2) { diff --git a/src/Symfony/Component/HttpClient/HttpClient.php b/src/Symfony/Component/HttpClient/HttpClient.php index 76031d7298..606d043298 100644 --- a/src/Symfony/Component/HttpClient/HttpClient.php +++ b/src/Symfony/Component/HttpClient/HttpClient.php @@ -44,7 +44,7 @@ final class HttpClient $curlVersion = $curlVersion ?? curl_version(); // HTTP/2 push crashes before curl 7.61 - if (0x073d00 > $curlVersion['version_number'] || !(CURL_VERSION_HTTP2 & $curlVersion['features'])) { + if (0x073d00 > $curlVersion['version_number'] || !(\CURL_VERSION_HTTP2 & $curlVersion['features'])) { return new AmpHttpClient($defaultOptions, null, $maxHostConnections, $maxPendingPushes); } } @@ -54,14 +54,14 @@ final class HttpClient return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes); } - @trigger_error('Configure the "curl.cainfo", "openssl.cafile" or "openssl.capath" php.ini setting to enable the CurlHttpClient', E_USER_WARNING); + @trigger_error('Configure the "curl.cainfo", "openssl.cafile" or "openssl.capath" php.ini setting to enable the CurlHttpClient', \E_USER_WARNING); } if ($amp) { return new AmpHttpClient($defaultOptions, null, $maxHostConnections, $maxPendingPushes); } - @trigger_error((\extension_loaded('curl') ? 'Upgrade' : 'Install').' the curl extension or run "composer require amphp/http-client" to perform async HTTP operations, including full HTTP/2 support', E_USER_NOTICE); + @trigger_error((\extension_loaded('curl') ? 'Upgrade' : 'Install').' the curl extension or run "composer require amphp/http-client" to perform async HTTP operations, including full HTTP/2 support', \E_USER_NOTICE); return new NativeHttpClient($defaultOptions, $maxHostConnections); } diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index f447ce1049..b001f28c18 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -269,7 +269,7 @@ trait HttpClientTrait private static function normalizeBody($body) { if (\is_array($body)) { - return http_build_query($body, '', '&', PHP_QUERY_RFC1738); + return http_build_query($body, '', '&', \PHP_QUERY_RFC1738); } if (\is_string($body)) { @@ -352,15 +352,15 @@ trait HttpClientTrait */ private static function jsonEncode($value, int $flags = null, int $maxDepth = 512): string { - $flags = $flags ?? (JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION); + $flags = $flags ?? (\JSON_HEX_TAG | \JSON_HEX_APOS | \JSON_HEX_AMP | \JSON_HEX_QUOT | \JSON_PRESERVE_ZERO_FRACTION); try { - $value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0), $maxDepth); + $value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth); } catch (\JsonException $e) { throw new InvalidArgumentException('Invalid value for "json" option: '.$e->getMessage()); } - if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error() && (false === $value || !($flags & JSON_PARTIAL_OUTPUT_ON_ERROR))) { + if (\PHP_VERSION_ID < 70300 && \JSON_ERROR_NONE !== json_last_error() && (false === $value || !($flags & \JSON_PARTIAL_OUTPUT_ON_ERROR))) { throw new InvalidArgumentException('Invalid value for "json" option: '.json_last_error_msg()); } @@ -455,7 +455,7 @@ trait HttpClientTrait throw new InvalidArgumentException(sprintf('Unsupported IDN "%s", try enabling the "intl" PHP extension or running "composer require symfony/polyfill-intl-idn".', $host)); } - $host = \defined('INTL_IDNA_VARIANT_UTS46') ? idn_to_ascii($host, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46) ?: strtolower($host) : strtolower($host); + $host = \defined('INTL_IDNA_VARIANT_UTS46') ? idn_to_ascii($host, \IDNA_DEFAULT, \INTL_IDNA_VARIANT_UTS46) ?: strtolower($host) : strtolower($host); $host .= $port ? ':'.$port : ''; } @@ -540,7 +540,7 @@ trait HttpClientTrait } } - $queryString = http_build_query($queryArray, '', '&', PHP_QUERY_RFC3986); + $queryString = http_build_query($queryArray, '', '&', \PHP_QUERY_RFC3986); $queryArray = []; if ($queryString) { diff --git a/src/Symfony/Component/HttpClient/Internal/AmpClientState.php b/src/Symfony/Component/HttpClient/Internal/AmpClientState.php index afd4c88fb8..61a0c004ac 100644 --- a/src/Symfony/Component/HttpClient/Internal/AmpClientState.php +++ b/src/Symfony/Component/HttpClient/Internal/AmpClientState.php @@ -185,7 +185,7 @@ final class AmpClientState extends ClientState } } - $maxHostConnections = 0 < $this->maxHostConnections ? $this->maxHostConnections : PHP_INT_MAX; + $maxHostConnections = 0 < $this->maxHostConnections ? $this->maxHostConnections : \PHP_INT_MAX; $pool = new DefaultConnectionFactory($connector, $context); $pool = ConnectionLimitingPool::byAuthority($maxHostConnections, $pool); diff --git a/src/Symfony/Component/HttpClient/Internal/CurlClientState.php b/src/Symfony/Component/HttpClient/Internal/CurlClientState.php index 8a997be5a2..f381968d14 100644 --- a/src/Symfony/Component/HttpClient/Internal/CurlClientState.php +++ b/src/Symfony/Component/HttpClient/Internal/CurlClientState.php @@ -28,7 +28,7 @@ final class CurlClientState extends ClientState public $dnsCache; /** @var float[] */ public $pauseExpiries = []; - public $execCounter = PHP_INT_MIN; + public $execCounter = \PHP_INT_MIN; public function __construct() { diff --git a/src/Symfony/Component/HttpClient/Internal/NativeClientState.php b/src/Symfony/Component/HttpClient/Internal/NativeClientState.php index 658fdcd97e..4e3684ad30 100644 --- a/src/Symfony/Component/HttpClient/Internal/NativeClientState.php +++ b/src/Symfony/Component/HttpClient/Internal/NativeClientState.php @@ -23,7 +23,7 @@ final class NativeClientState extends ClientState /** @var int */ public $id; /** @var int */ - public $maxHostConnections = PHP_INT_MAX; + public $maxHostConnections = \PHP_INT_MAX; /** @var int */ public $responseCount = 0; /** @var string[] */ @@ -35,6 +35,6 @@ final class NativeClientState extends ClientState public function __construct() { - $this->id = random_int(PHP_INT_MIN, PHP_INT_MAX); + $this->id = random_int(\PHP_INT_MIN, \PHP_INT_MAX); } } diff --git a/src/Symfony/Component/HttpClient/NativeHttpClient.php b/src/Symfony/Component/HttpClient/NativeHttpClient.php index 26a0b3ea8e..f21d2a44e8 100644 --- a/src/Symfony/Component/HttpClient/NativeHttpClient.php +++ b/src/Symfony/Component/HttpClient/NativeHttpClient.php @@ -55,7 +55,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac } $this->multi = new NativeClientState(); - $this->multi->maxHostConnections = 0 < $maxHostConnections ? $maxHostConnections : PHP_INT_MAX; + $this->multi->maxHostConnections = 0 < $maxHostConnections ? $maxHostConnections : \PHP_INT_MAX; } /** @@ -116,7 +116,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac if ($onProgress = $options['on_progress']) { // Memoize the last progress to ease calling the callback periodically when no network transfer happens $lastProgress = [0, 0]; - $maxDuration = 0 < $options['max_duration'] ? $options['max_duration'] : INF; + $maxDuration = 0 < $options['max_duration'] ? $options['max_duration'] : \INF; $onProgress = static function (...$progress) use ($onProgress, &$lastProgress, &$info, $maxDuration) { if ($info['total_time'] >= $maxDuration) { throw new TransportException(sprintf('Max duration was reached for "%s".', implode('', $info['url']))); @@ -148,11 +148,11 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac $notification = static function (int $code, int $severity, ?string $msg, int $msgCode, int $dlNow, int $dlSize) use ($onProgress, &$info) { $info['total_time'] = microtime(true) - $info['start_time']; - if (STREAM_NOTIFY_PROGRESS === $code) { + if (\STREAM_NOTIFY_PROGRESS === $code) { $info['starttransfer_time'] = $info['starttransfer_time'] ?: $info['total_time']; $info['size_upload'] += $dlNow ? 0 : $info['size_body']; $info['size_download'] = $dlNow; - } elseif (STREAM_NOTIFY_CONNECT === $code) { + } elseif (\STREAM_NOTIFY_CONNECT === $code) { $info['connect_time'] = $info['total_time']; $info['debug'] .= $info['request_header']; unset($info['request_header']); @@ -273,14 +273,14 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac */ private static function dnsResolve(array $url, NativeClientState $multi, array &$info, ?\Closure $onProgress): array { - if ($port = parse_url($url['authority'], PHP_URL_PORT) ?: '') { + if ($port = parse_url($url['authority'], \PHP_URL_PORT) ?: '') { $info['primary_port'] = $port; $port = ':'.$port; } else { $info['primary_port'] = 'http:' === $url['scheme'] ? 80 : 443; } - $host = parse_url($url['authority'], PHP_URL_HOST); + $host = parse_url($url['authority'], \PHP_URL_HOST); if (null === $ip = $multi->dnsCache[$host] ?? null) { $info['debug'] .= "* Hostname was NOT found in DNS cache\n"; @@ -370,7 +370,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac [$host, $port, $url['authority']] = self::dnsResolve($url, $multi, $info, $onProgress); stream_context_set_option($context, 'ssl', 'peer_name', $host); - if (false !== (parse_url($location, PHP_URL_HOST) ?? false)) { + if (false !== (parse_url($location, \PHP_URL_HOST) ?? false)) { // Authorization and Cookie headers MUST NOT follow except for the initial host name $requestHeaders = $redirectHeaders['host'] === $host ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth']; $requestHeaders[] = 'Host: '.$host.$port; diff --git a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php index 664a273fef..3650706fd9 100644 --- a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php +++ b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php @@ -98,7 +98,7 @@ final class AsyncResponse implements ResponseInterface, StreamableInterface $handle = function () { $stream = $this->response instanceof StreamableInterface ? $this->response->toStream(false) : StreamWrapper::createResource($this->response); - return stream_get_meta_data($stream)['wrapper_data']->stream_cast(STREAM_CAST_FOR_SELECT); + return stream_get_meta_data($stream)['wrapper_data']->stream_cast(\STREAM_CAST_FOR_SELECT); }; $stream = StreamWrapper::createResource($this); diff --git a/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php b/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php index 9fc0fa2d63..a7a41811e7 100644 --- a/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php @@ -97,12 +97,12 @@ trait CommonResponseTrait } try { - $content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0)); + $content = json_decode($content, true, 512, \JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0)); } catch (\JsonException $e) { throw new JsonException($e->getMessage().sprintf(' for "%s".', $this->getInfo('url')), $e->getCode()); } - if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error()) { + if (\PHP_VERSION_ID < 70300 && \JSON_ERROR_NONE !== json_last_error()) { throw new JsonException(json_last_error_msg().sprintf(' for "%s".', $this->getInfo('url')), json_last_error()); } diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index c1c7e2644b..a3667ad787 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -51,8 +51,8 @@ final class CurlResponse implements ResponseInterface, StreamableInterface if (0x074000 === $curlVersion) { fwrite($this->debugBuffer, 'Due to a bug in curl 7.64.0, the debug log is disabled; use another version to work around the issue.'); } else { - curl_setopt($ch, CURLOPT_VERBOSE, true); - curl_setopt($ch, CURLOPT_STDERR, $this->debugBuffer); + curl_setopt($ch, \CURLOPT_VERBOSE, true); + curl_setopt($ch, \CURLOPT_STDERR, $this->debugBuffer); } } else { $this->info['url'] = $ch; @@ -72,10 +72,10 @@ final class CurlResponse implements ResponseInterface, StreamableInterface if (!$info['response_headers']) { // Used to keep track of what we're waiting for - curl_setopt($ch, CURLOPT_PRIVATE, \in_array($method, ['GET', 'HEAD', 'OPTIONS', 'TRACE'], true) && 1.0 < (float) ($options['http_version'] ?? 1.1) ? 'H2' : 'H0'); // H = headers + retry counter + curl_setopt($ch, \CURLOPT_PRIVATE, \in_array($method, ['GET', 'HEAD', 'OPTIONS', 'TRACE'], true) && 1.0 < (float) ($options['http_version'] ?? 1.1) ? 'H2' : 'H0'); // H = headers + retry counter } - curl_setopt($ch, CURLOPT_HEADERFUNCTION, static function ($ch, string $data) use (&$info, &$headers, $options, $multi, $id, &$location, $resolveRedirect, $logger): int { + curl_setopt($ch, \CURLOPT_HEADERFUNCTION, static function ($ch, string $data) use (&$info, &$headers, $options, $multi, $id, &$location, $resolveRedirect, $logger): int { if (0 !== substr_compare($data, "\r\n", -2)) { return 0; } @@ -91,9 +91,9 @@ final class CurlResponse implements ResponseInterface, StreamableInterface if (null === $options) { // Pushed response: buffer until requested - curl_setopt($ch, CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int { + curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int { $multi->handlesActivity[$id][] = $data; - curl_pause($ch, CURLPAUSE_RECV); + curl_pause($ch, \CURLPAUSE_RECV); return \strlen($data); }); @@ -105,7 +105,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface $this->info['pause_handler'] = static function (float $duration) use ($ch, $multi, $execCounter) { if (0 < $duration) { if ($execCounter === $multi->execCounter) { - $multi->execCounter = !\is_float($execCounter) ? 1 + $execCounter : PHP_INT_MIN; + $multi->execCounter = !\is_float($execCounter) ? 1 + $execCounter : \PHP_INT_MIN; curl_multi_remove_handle($multi->handle, $ch); } @@ -114,21 +114,21 @@ final class CurlResponse implements ResponseInterface, StreamableInterface if (false !== $lastExpiry && $lastExpiry > $duration) { asort($multi->pauseExpiries); } - curl_pause($ch, CURLPAUSE_ALL); + curl_pause($ch, \CURLPAUSE_ALL); } else { unset($multi->pauseExpiries[(int) $ch]); - curl_pause($ch, CURLPAUSE_CONT); + curl_pause($ch, \CURLPAUSE_CONT); curl_multi_add_handle($multi->handle, $ch); } }; $this->inflate = !isset($options['normalized_headers']['accept-encoding']); - curl_pause($ch, CURLPAUSE_CONT); + curl_pause($ch, \CURLPAUSE_CONT); if ($onProgress = $options['on_progress']) { $url = isset($info['url']) ? ['url' => $info['url']] : []; - curl_setopt($ch, CURLOPT_NOPROGRESS, false); - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, static function ($ch, $dlSize, $dlNow) use ($onProgress, &$info, $url, $multi, $debugBuffer) { + curl_setopt($ch, \CURLOPT_NOPROGRESS, false); + curl_setopt($ch, \CURLOPT_PROGRESSFUNCTION, static function ($ch, $dlSize, $dlNow) use ($onProgress, &$info, $url, $multi, $debugBuffer) { try { rewind($debugBuffer); $debug = ['debug' => stream_get_contents($debugBuffer)]; @@ -144,14 +144,14 @@ final class CurlResponse implements ResponseInterface, StreamableInterface }); } - curl_setopt($ch, CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int { + curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int { $multi->handlesActivity[$id][] = $data; return \strlen($data); }); $this->initializer = static function (self $response) { - $waitFor = curl_getinfo($ch = $response->handle, CURLINFO_PRIVATE); + $waitFor = curl_getinfo($ch = $response->handle, \CURLINFO_PRIVATE); return 'H' === $waitFor[0]; }; @@ -179,10 +179,10 @@ final class CurlResponse implements ResponseInterface, StreamableInterface rewind($this->debugBuffer); $info['debug'] = stream_get_contents($this->debugBuffer); - $waitFor = curl_getinfo($this->handle, CURLINFO_PRIVATE); + $waitFor = curl_getinfo($this->handle, \CURLINFO_PRIVATE); if ('H' !== $waitFor[0] && 'C' !== $waitFor[0]) { - curl_setopt($this->handle, CURLOPT_VERBOSE, false); + curl_setopt($this->handle, \CURLOPT_VERBOSE, false); rewind($this->debugBuffer); ftruncate($this->debugBuffer, 0); $this->finalInfo = $info; @@ -198,7 +198,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface public function getContent(bool $throw = true): string { $performing = self::$performing; - self::$performing = $performing || '_0' === curl_getinfo($this->handle, CURLINFO_PRIVATE); + self::$performing = $performing || '_0' === curl_getinfo($this->handle, \CURLINFO_PRIVATE); try { return $this->doGetContent($throw); @@ -240,7 +240,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface { $this->inflate = null; unset($this->multi->pauseExpiries[$this->id], $this->multi->openHandles[$this->id], $this->multi->handlesActivity[$this->id]); - curl_setopt($this->handle, CURLOPT_PRIVATE, '_0'); + curl_setopt($this->handle, \CURLOPT_PRIVATE, '_0'); if (self::$performing) { return; @@ -248,12 +248,12 @@ final class CurlResponse implements ResponseInterface, StreamableInterface curl_multi_remove_handle($this->multi->handle, $this->handle); curl_setopt_array($this->handle, [ - CURLOPT_NOPROGRESS => true, - CURLOPT_PROGRESSFUNCTION => null, - CURLOPT_HEADERFUNCTION => null, - CURLOPT_WRITEFUNCTION => null, - CURLOPT_READFUNCTION => null, - CURLOPT_INFILE => null, + \CURLOPT_NOPROGRESS => true, + \CURLOPT_PROGRESSFUNCTION => null, + \CURLOPT_HEADERFUNCTION => null, + \CURLOPT_WRITEFUNCTION => null, + \CURLOPT_READFUNCTION => null, + \CURLOPT_INFILE => null, ]); } @@ -268,7 +268,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface $runningResponses[$i] = [$response->multi, [$response->id => $response]]; } - if ('_0' === curl_getinfo($ch = $response->handle, CURLINFO_PRIVATE)) { + if ('_0' === curl_getinfo($ch = $response->handle, \CURLINFO_PRIVATE)) { // Response already completed $response->multi->handlesActivity[$response->id][] = null; $response->multi->handlesActivity[$response->id][] = null !== $response->info['error'] ? new TransportException($response->info['error']) : null; @@ -286,7 +286,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface if ($responses) { $response = current($responses); $multi->handlesActivity[(int) $response->handle][] = null; - $multi->handlesActivity[(int) $response->handle][] = new TransportException(sprintf('Userland callback cannot use the client nor the response while processing "%s".', curl_getinfo($response->handle, CURLINFO_EFFECTIVE_URL))); + $multi->handlesActivity[(int) $response->handle][] = new TransportException(sprintf('Userland callback cannot use the client nor the response while processing "%s".', curl_getinfo($response->handle, \CURLINFO_EFFECTIVE_URL))); } return; @@ -296,20 +296,20 @@ final class CurlResponse implements ResponseInterface, StreamableInterface self::$performing = true; ++$multi->execCounter; $active = 0; - while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($multi->handle, $active)); + while (\CURLM_CALL_MULTI_PERFORM === curl_multi_exec($multi->handle, $active)); while ($info = curl_multi_info_read($multi->handle)) { $result = $info['result']; $id = (int) $ch = $info['handle']; - $waitFor = @curl_getinfo($ch, CURLINFO_PRIVATE) ?: '_0'; + $waitFor = @curl_getinfo($ch, \CURLINFO_PRIVATE) ?: '_0'; - if (\in_array($result, [CURLE_SEND_ERROR, CURLE_RECV_ERROR, /*CURLE_HTTP2*/ 16, /*CURLE_HTTP2_STREAM*/ 92], true) && $waitFor[1] && 'C' !== $waitFor[0]) { + if (\in_array($result, [\CURLE_SEND_ERROR, \CURLE_RECV_ERROR, /*CURLE_HTTP2*/ 16, /*CURLE_HTTP2_STREAM*/ 92], true) && $waitFor[1] && 'C' !== $waitFor[0]) { curl_multi_remove_handle($multi->handle, $ch); $waitFor[1] = (string) ((int) $waitFor[1] - 1); // decrement the retry counter - curl_setopt($ch, CURLOPT_PRIVATE, $waitFor); + curl_setopt($ch, \CURLOPT_PRIVATE, $waitFor); if ('1' === $waitFor[1]) { - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); + curl_setopt($ch, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_1); } if (0 === curl_multi_add_handle($multi->handle, $ch)) { @@ -318,7 +318,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface } $multi->handlesActivity[$id][] = null; - $multi->handlesActivity[$id][] = \in_array($result, [CURLE_OK, CURLE_TOO_MANY_REDIRECTS], true) || '_0' === $waitFor || curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD) === curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD) ? null : new TransportException(sprintf('%s for "%s".', curl_strerror($result), curl_getinfo($ch, CURLINFO_EFFECTIVE_URL))); + $multi->handlesActivity[$id][] = \in_array($result, [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || '_0' === $waitFor || curl_getinfo($ch, \CURLINFO_SIZE_DOWNLOAD) === curl_getinfo($ch, \CURLINFO_CONTENT_LENGTH_DOWNLOAD) ? null : new TransportException(sprintf('%s for "%s".', curl_strerror($result), curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL))); } } finally { self::$performing = false; @@ -347,7 +347,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface } unset($multi->pauseExpiries[$id]); - curl_pause($multi->openHandles[$id][0], CURLPAUSE_CONT); + curl_pause($multi->openHandles[$id][0], \CURLPAUSE_CONT); curl_multi_add_handle($multi->handle, $multi->openHandles[$id][0]); } } @@ -368,7 +368,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface */ private static function parseHeaderLine($ch, string $data, array &$info, array &$headers, ?array $options, CurlClientState $multi, int $id, ?string &$location, ?callable $resolveRedirect, ?LoggerInterface $logger, &$content = null): int { - $waitFor = @curl_getinfo($ch, CURLINFO_PRIVATE) ?: '_0'; + $waitFor = @curl_getinfo($ch, \CURLINFO_PRIVATE) ?: '_0'; if ('H' !== $waitFor[0]) { return \strlen($data); // Ignore HTTP trailers @@ -393,16 +393,16 @@ final class CurlResponse implements ResponseInterface, StreamableInterface return \strlen($data); } - if (\function_exists('openssl_x509_read') && $certinfo = curl_getinfo($ch, CURLINFO_CERTINFO)) { + if (\function_exists('openssl_x509_read') && $certinfo = curl_getinfo($ch, \CURLINFO_CERTINFO)) { $info['peer_certificate_chain'] = array_map('openssl_x509_read', array_column($certinfo, 'Cert')); } if (300 <= $info['http_code'] && $info['http_code'] < 400) { - if (curl_getinfo($ch, CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); + if (curl_getinfo($ch, \CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) { + curl_setopt($ch, \CURLOPT_FOLLOWLOCATION, false); } elseif (303 === $info['http_code'] || ('POST' === $info['http_method'] && \in_array($info['http_code'], [301, 302], true))) { $info['http_method'] = 'HEAD' === $info['http_method'] ? 'HEAD' : 'GET'; - curl_setopt($ch, CURLOPT_POSTFIELDS, ''); + curl_setopt($ch, \CURLOPT_POSTFIELDS, ''); } } @@ -411,7 +411,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface // End of headers: handle informational responses, redirects, etc. - if (200 > $statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE)) { + if (200 > $statusCode = curl_getinfo($ch, \CURLINFO_RESPONSE_CODE)) { $multi->handlesActivity[$id][] = new InformationalChunk($statusCode, $headers); $location = null; @@ -422,16 +422,16 @@ final class CurlResponse implements ResponseInterface, StreamableInterface if (300 <= $statusCode && $statusCode < 400 && null !== $location) { if (null === $info['redirect_url'] = $resolveRedirect($ch, $location)) { - $options['max_redirects'] = curl_getinfo($ch, CURLINFO_REDIRECT_COUNT); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - curl_setopt($ch, CURLOPT_MAXREDIRS, $options['max_redirects']); + $options['max_redirects'] = curl_getinfo($ch, \CURLINFO_REDIRECT_COUNT); + curl_setopt($ch, \CURLOPT_FOLLOWLOCATION, false); + curl_setopt($ch, \CURLOPT_MAXREDIRS, $options['max_redirects']); } else { $url = parse_url($location ?? ':'); if (isset($url['host']) && null !== $ip = $multi->dnsCache->hostnames[$url['host'] = strtolower($url['host'])] ?? null) { // Populate DNS cache for redirects if needed - $port = $url['port'] ?? ('http' === ($url['scheme'] ?? parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL), PHP_URL_SCHEME)) ? 80 : 443); - curl_setopt($ch, CURLOPT_RESOLVE, ["{$url['host']}:$port:$ip"]); + $port = $url['port'] ?? ('http' === ($url['scheme'] ?? parse_url(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL), \PHP_URL_SCHEME)) ? 80 : 443); + curl_setopt($ch, \CURLOPT_RESOLVE, ["{$url['host']}:$port:$ip"]); $multi->dnsCache->removals["-{$url['host']}:$port"] = "-{$url['host']}:$port"; } } @@ -439,7 +439,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface if (401 === $statusCode && isset($options['auth_ntlm']) && 0 === strncasecmp($headers['www-authenticate'][0] ?? '', 'NTLM ', 5)) { // Continue with NTLM auth - } elseif ($statusCode < 300 || 400 <= $statusCode || null === $location || curl_getinfo($ch, CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) { + } elseif ($statusCode < 300 || 400 <= $statusCode || null === $location || curl_getinfo($ch, \CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) { // Headers and redirects completed, time to get the response's content $multi->handlesActivity[$id][] = new FirstChunk(); @@ -451,7 +451,7 @@ final class CurlResponse implements ResponseInterface, StreamableInterface $waitFor[0] = 'C'; // C = content } - curl_setopt($ch, CURLOPT_PRIVATE, $waitFor); + curl_setopt($ch, \CURLOPT_PRIVATE, $waitFor); } elseif (null !== $info['redirect_url'] && $logger) { $logger->info(sprintf('Redirecting: "%s %s"', $info['http_code'], $info['redirect_url'])); } diff --git a/src/Symfony/Component/HttpClient/Response/NativeResponse.php b/src/Symfony/Component/HttpClient/Response/NativeResponse.php index d74bf55632..cdf5cabc48 100644 --- a/src/Symfony/Component/HttpClient/Response/NativeResponse.php +++ b/src/Symfony/Component/HttpClient/Response/NativeResponse.php @@ -118,7 +118,7 @@ final class NativeResponse implements ResponseInterface, StreamableInterface $url = $this->url; set_error_handler(function ($type, $msg) use (&$url) { - if (E_NOTICE !== $type || 'fopen(): Content-type not specified assuming application/x-www-form-urlencoded' !== $msg) { + if (\E_NOTICE !== $type || 'fopen(): Content-type not specified assuming application/x-www-form-urlencoded' !== $msg) { throw new TransportException($msg); } @@ -177,7 +177,7 @@ final class NativeResponse implements ResponseInterface, StreamableInterface if (isset($this->headers['content-length'])) { $this->remaining = (int) $this->headers['content-length'][0]; } elseif ('chunked' === ($this->headers['transfer-encoding'][0] ?? null)) { - stream_filter_append($this->buffer, 'dechunk', STREAM_FILTER_WRITE); + stream_filter_append($this->buffer, 'dechunk', \STREAM_FILTER_WRITE); $this->remaining = -1; } else { $this->remaining = -2; @@ -192,7 +192,7 @@ final class NativeResponse implements ResponseInterface, StreamableInterface return; } - $host = parse_url($this->info['redirect_url'] ?? $this->url, PHP_URL_HOST); + $host = parse_url($this->info['redirect_url'] ?? $this->url, \PHP_URL_HOST); $this->multi->openHandles[$this->id] = [&$this->pauseExpiry, $h, $this->buffer, $this->onProgress, &$this->remaining, &$this->info, $host]; $this->multi->hosts[$host] = 1 + ($this->multi->hosts[$host] ?? 0); } @@ -327,8 +327,8 @@ final class NativeResponse implements ResponseInterface, StreamableInterface if ($response->pauseExpiry && microtime(true) < $response->pauseExpiry) { // Create empty open handles to tell we still have pending requests - $multi->openHandles[$i] = [INF, null, null, null]; - } elseif ($maxHosts && $maxHosts > ($multi->hosts[parse_url($response->url, PHP_URL_HOST)] ?? 0)) { + $multi->openHandles[$i] = [\INF, null, null, null]; + } elseif ($maxHosts && $maxHosts > ($multi->hosts[parse_url($response->url, \PHP_URL_HOST)] ?? 0)) { // Open the next pending request - this is a blocking operation so we do only one of them $response->open(); $multi->sleep = false; diff --git a/src/Symfony/Component/HttpClient/Response/StreamWrapper.php b/src/Symfony/Component/HttpClient/Response/StreamWrapper.php index fd79eb0078..988ec53bd9 100644 --- a/src/Symfony/Component/HttpClient/Response/StreamWrapper.php +++ b/src/Symfony/Component/HttpClient/Response/StreamWrapper.php @@ -50,7 +50,7 @@ class StreamWrapper public static function createResource(ResponseInterface $response, HttpClientInterface $client = null) { if ($response instanceof StreamableInterface) { - $stack = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $stack = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 2); if ($response !== ($stack[1]['object'] ?? null)) { return $response->toStream(false); @@ -61,7 +61,7 @@ class StreamWrapper throw new \InvalidArgumentException(sprintf('Providing a client to "%s()" is required when the response doesn\'t have any "stream()" method.', __CLASS__)); } - if (false === stream_wrapper_register('symfony', __CLASS__, STREAM_IS_URL)) { + if (false === stream_wrapper_register('symfony', __CLASS__, \STREAM_IS_URL)) { throw new \RuntimeException(error_get_last()['message'] ?? 'Registering the "symfony" stream wrapper failed.'); } @@ -96,8 +96,8 @@ class StreamWrapper public function stream_open(string $path, string $mode, int $options): bool { if ('r' !== $mode) { - if ($options & STREAM_REPORT_ERRORS) { - trigger_error(sprintf('Invalid mode "%s": only "r" is supported.', $mode), E_USER_WARNING); + if ($options & \STREAM_REPORT_ERRORS) { + trigger_error(sprintf('Invalid mode "%s": only "r" is supported.', $mode), \E_USER_WARNING); } return false; @@ -112,8 +112,8 @@ class StreamWrapper return true; } - if ($options & STREAM_REPORT_ERRORS) { - trigger_error('Missing options "client" or "response" in "symfony" stream context.', E_USER_WARNING); + if ($options & \STREAM_REPORT_ERRORS) { + trigger_error('Missing options "client" or "response" in "symfony" stream context.', \E_USER_WARNING); } return false; @@ -129,7 +129,7 @@ class StreamWrapper $this->response->getStatusCode(); // ignore 3/4/5xx } } catch (ExceptionInterface $e) { - trigger_error($e->getMessage(), E_USER_WARNING); + trigger_error($e->getMessage(), \E_USER_WARNING); return false; } @@ -140,7 +140,7 @@ class StreamWrapper } if ('' !== $data = fread($this->content, $count)) { - fseek($this->content, 0, SEEK_END); + fseek($this->content, 0, \SEEK_END); $this->offset += \strlen($data); return $data; @@ -182,7 +182,7 @@ class StreamWrapper return $data; } } catch (ExceptionInterface $e) { - trigger_error($e->getMessage(), E_USER_WARNING); + trigger_error($e->getMessage(), \E_USER_WARNING); return false; } @@ -193,9 +193,9 @@ class StreamWrapper public function stream_set_option(int $option, int $arg1, ?int $arg2): bool { - if (STREAM_OPTION_BLOCKING === $option) { + if (\STREAM_OPTION_BLOCKING === $option) { $this->blocking = (bool) $arg1; - } elseif (STREAM_OPTION_READ_TIMEOUT === $option) { + } elseif (\STREAM_OPTION_READ_TIMEOUT === $option) { $this->timeout = $arg1 + $arg2 / 1e6; } else { return false; @@ -214,19 +214,19 @@ class StreamWrapper return $this->eof && !\is_string($this->content); } - public function stream_seek(int $offset, int $whence = SEEK_SET): bool + public function stream_seek(int $offset, int $whence = \SEEK_SET): bool { - if (!\is_resource($this->content) || 0 !== fseek($this->content, 0, SEEK_END)) { + if (!\is_resource($this->content) || 0 !== fseek($this->content, 0, \SEEK_END)) { return false; } $size = ftell($this->content); - if (SEEK_CUR === $whence) { + if (\SEEK_CUR === $whence) { $offset += $this->offset; } - if (SEEK_END === $whence || $size < $offset) { + if (\SEEK_END === $whence || $size < $offset) { foreach ($this->client->stream([$this->response]) as $chunk) { try { if ($chunk->isFirst()) { @@ -236,17 +236,17 @@ class StreamWrapper // Chunks are buffered in $this->content already $size += \strlen($chunk->getContent()); - if (SEEK_END !== $whence && $offset <= $size) { + if (\SEEK_END !== $whence && $offset <= $size) { break; } } catch (ExceptionInterface $e) { - trigger_error($e->getMessage(), E_USER_WARNING); + trigger_error($e->getMessage(), \E_USER_WARNING); return false; } } - if (SEEK_END === $whence) { + if (\SEEK_END === $whence) { $offset += $size; } } @@ -263,7 +263,7 @@ class StreamWrapper public function stream_cast(int $castAs) { - if (STREAM_CAST_FOR_SELECT === $castAs) { + if (\STREAM_CAST_FOR_SELECT === $castAs) { $this->response->getHeaders(false); return (\is_callable($this->handle) ? ($this->handle)() : $this->handle) ?? false; @@ -277,7 +277,7 @@ class StreamWrapper try { $headers = $this->response->getHeaders(false); } catch (ExceptionInterface $e) { - trigger_error($e->getMessage(), E_USER_WARNING); + trigger_error($e->getMessage(), \E_USER_WARNING); $headers = []; } diff --git a/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php b/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php index 9ac6bd9f52..18fda3ee0e 100644 --- a/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php @@ -152,7 +152,7 @@ trait TransportResponseTrait while (true) { $hasActivity = false; $timeoutMax = 0; - $timeoutMin = $timeout ?? INF; + $timeoutMin = $timeout ?? \INF; /** @var ClientState $multi */ foreach ($runningResponses as $i => [$multi]) { @@ -218,7 +218,7 @@ trait TransportResponseTrait $response->logger->info(sprintf('Response: "%s %s"', $info['http_code'], $info['url'])); } - $response->inflate = \extension_loaded('zlib') && $response->inflate && 'gzip' === ($response->headers['content-encoding'][0] ?? null) ? inflate_init(ZLIB_ENCODING_GZIP) : null; + $response->inflate = \extension_loaded('zlib') && $response->inflate && 'gzip' === ($response->headers['content-encoding'][0] ?? null) ? inflate_init(\ZLIB_ENCODING_GZIP) : null; if ($response->shouldBuffer instanceof \Closure) { try { diff --git a/src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php b/src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php index f8ff835408..9dd745152d 100644 --- a/src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php @@ -92,7 +92,7 @@ class AsyncDecoratorTraitTest extends NativeHttpClientTest $this->assertSame('{"documents":[{"id":"\/json\/1"},{"id":"\/json\/2"},{"id":"\/json\/3"}]}', $content); - $steps = preg_split('{\{"id":"\\\/json\\\/(\d)"\}}', $content, -1, PREG_SPLIT_DELIM_CAPTURE); + $steps = preg_split('{\{"id":"\\\/json\\\/(\d)"\}}', $content, -1, \PREG_SPLIT_DELIM_CAPTURE); $steps[7] = $context->getResponse(); $steps[1] = $context->replaceRequest('GET', 'http://localhost:8057/json/1'); $steps[3] = $context->replaceRequest('GET', 'http://localhost:8057/json/2'); diff --git a/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php index 269464d400..e0a12a49a5 100644 --- a/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php @@ -26,7 +26,7 @@ class CurlHttpClientTest extends HttpClientTestCase $this->markTestSkipped('PHP 7.3.0 to 7.3.3 don\'t support HTTP/2 PUSH'); } - if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073d00 > ($v = curl_version())['version_number'] || !(CURL_VERSION_HTTP2 & $v['features'])) { + if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073d00 > ($v = curl_version())['version_number'] || !(\CURL_VERSION_HTTP2 & $v['features'])) { $this->markTestSkipped('curl <7.61 is used or it is not compiled with support for HTTP/2 PUSH'); } } diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index aa5cb9b1b3..f490f8f7f3 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -64,10 +64,10 @@ class UploadedFile extends File { $this->originalName = $this->getName($originalName); $this->mimeType = $mimeType ?: 'application/octet-stream'; - $this->error = $error ?: UPLOAD_ERR_OK; + $this->error = $error ?: \UPLOAD_ERR_OK; $this->test = $test; - parent::__construct($path, UPLOAD_ERR_OK === $this->error); + parent::__construct($path, \UPLOAD_ERR_OK === $this->error); } /** @@ -93,7 +93,7 @@ class UploadedFile extends File */ public function getClientOriginalExtension() { - return pathinfo($this->originalName, PATHINFO_EXTENSION); + return pathinfo($this->originalName, \PATHINFO_EXTENSION); } /** @@ -160,7 +160,7 @@ class UploadedFile extends File */ public function isValid() { - $isOk = UPLOAD_ERR_OK === $this->error; + $isOk = \UPLOAD_ERR_OK === $this->error; return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); } @@ -194,19 +194,19 @@ class UploadedFile extends File } switch ($this->error) { - case UPLOAD_ERR_INI_SIZE: + case \UPLOAD_ERR_INI_SIZE: throw new IniSizeFileException($this->getErrorMessage()); - case UPLOAD_ERR_FORM_SIZE: + case \UPLOAD_ERR_FORM_SIZE: throw new FormSizeFileException($this->getErrorMessage()); - case UPLOAD_ERR_PARTIAL: + case \UPLOAD_ERR_PARTIAL: throw new PartialFileException($this->getErrorMessage()); - case UPLOAD_ERR_NO_FILE: + case \UPLOAD_ERR_NO_FILE: throw new NoFileException($this->getErrorMessage()); - case UPLOAD_ERR_CANT_WRITE: + case \UPLOAD_ERR_CANT_WRITE: throw new CannotWriteFileException($this->getErrorMessage()); - case UPLOAD_ERR_NO_TMP_DIR: + case \UPLOAD_ERR_NO_TMP_DIR: throw new NoTmpDirFileException($this->getErrorMessage()); - case UPLOAD_ERR_EXTENSION: + case \UPLOAD_ERR_EXTENSION: throw new ExtensionFileException($this->getErrorMessage()); } @@ -223,7 +223,7 @@ class UploadedFile extends File $sizePostMax = self::parseFilesize(ini_get('post_max_size')); $sizeUploadMax = self::parseFilesize(ini_get('upload_max_filesize')); - return min($sizePostMax ?: PHP_INT_MAX, $sizeUploadMax ?: PHP_INT_MAX); + return min($sizePostMax ?: \PHP_INT_MAX, $sizeUploadMax ?: \PHP_INT_MAX); } /** @@ -267,17 +267,17 @@ class UploadedFile extends File public function getErrorMessage() { static $errors = [ - UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).', - UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.', - UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded.', - UPLOAD_ERR_NO_FILE => 'No file was uploaded.', - UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.', - UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.', - UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.', + \UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).', + \UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.', + \UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded.', + \UPLOAD_ERR_NO_FILE => 'No file was uploaded.', + \UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.', + \UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.', + \UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.', ]; $errorCode = $this->error; - $maxFilesize = UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0; + $maxFilesize = \UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0; $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.'; return sprintf($message, $this->getClientOriginalName(), $maxFilesize); diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php index 5edd372b62..67784087ec 100644 --- a/src/Symfony/Component/HttpFoundation/FileBag.php +++ b/src/Symfony/Component/HttpFoundation/FileBag.php @@ -81,7 +81,7 @@ class FileBag extends ParameterBag sort($keys); if ($keys == self::$fileKeys) { - if (UPLOAD_ERR_NO_FILE == $file['error']) { + if (\UPLOAD_ERR_NO_FILE == $file['error']) { $file = null; } else { $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false); diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index d45d95e096..db0f483651 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -198,7 +198,7 @@ class HeaderBag implements \IteratorAggregate, \Countable return $default; } - if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) { + if (false === $date = \DateTime::createFromFormat(\DATE_RFC2822, $value)) { throw new \RuntimeException(sprintf('The "%s" HTTP header is not parseable (%s).', $key, $value)); } diff --git a/src/Symfony/Component/HttpFoundation/HeaderUtils.php b/src/Symfony/Component/HttpFoundation/HeaderUtils.php index bd9d04dfac..6421b1121c 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderUtils.php +++ b/src/Symfony/Component/HttpFoundation/HeaderUtils.php @@ -62,7 +62,7 @@ class HeaderUtils \s* (?['.$quotedSeparators.']) \s* - /x', trim($header), $matches, PREG_SET_ORDER); + /x', trim($header), $matches, \PREG_SET_ORDER); return self::groupParts($matches, $separators); } diff --git a/src/Symfony/Component/HttpFoundation/InputBag.php b/src/Symfony/Component/HttpFoundation/InputBag.php index c83d63d6d5..a45c9529ed 100644 --- a/src/Symfony/Component/HttpFoundation/InputBag.php +++ b/src/Symfony/Component/HttpFoundation/InputBag.php @@ -86,7 +86,7 @@ final class InputBag extends ParameterBag /** * {@inheritdoc} */ - public function filter(string $key, $default = null, int $filter = FILTER_DEFAULT, $options = []) + public function filter(string $key, $default = null, int $filter = \FILTER_DEFAULT, $options = []) { $value = $this->has($key) ? $this->all()[$key] : $default; @@ -95,11 +95,11 @@ final class InputBag extends ParameterBag $options = ['flags' => $options]; } - if (\is_array($value) && !(($options['flags'] ?? 0) & (FILTER_REQUIRE_ARRAY | FILTER_FORCE_ARRAY))) { + if (\is_array($value) && !(($options['flags'] ?? 0) & (\FILTER_REQUIRE_ARRAY | \FILTER_FORCE_ARRAY))) { trigger_deprecation('symfony/http-foundation', '5.1', 'Filtering an array value with "%s()" without passing the FILTER_REQUIRE_ARRAY or FILTER_FORCE_ARRAY flag is deprecated', __METHOD__); if (!isset($options['flags'])) { - $options['flags'] = FILTER_REQUIRE_ARRAY; + $options['flags'] = \FILTER_REQUIRE_ARRAY; } } diff --git a/src/Symfony/Component/HttpFoundation/IpUtils.php b/src/Symfony/Component/HttpFoundation/IpUtils.php index 80c5a950c9..0599ce553e 100644 --- a/src/Symfony/Component/HttpFoundation/IpUtils.php +++ b/src/Symfony/Component/HttpFoundation/IpUtils.php @@ -66,7 +66,7 @@ class IpUtils return self::$checkedIps[$cacheKey]; } - if (!filter_var($requestIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + if (!filter_var($requestIp, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { return self::$checkedIps[$cacheKey] = false; } @@ -74,7 +74,7 @@ class IpUtils list($address, $netmask) = explode('/', $ip, 2); if ('0' === $netmask) { - return self::$checkedIps[$cacheKey] = filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); + return self::$checkedIps[$cacheKey] = filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4); } if ($netmask < 0 || $netmask > 32) { diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index b361d0852d..cf15c59a58 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -161,11 +161,11 @@ class JsonResponse extends Response throw $e; } - if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) { + if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $this->encodingOptions)) { return $this->setJson($data); } - if (JSON_ERROR_NONE !== json_last_error()) { + if (\JSON_ERROR_NONE !== json_last_error()) { throw new \InvalidArgumentException(json_last_error_msg()); } diff --git a/src/Symfony/Component/HttpFoundation/ParameterBag.php b/src/Symfony/Component/HttpFoundation/ParameterBag.php index dc45bec4d5..1de54859a1 100644 --- a/src/Symfony/Component/HttpFoundation/ParameterBag.php +++ b/src/Symfony/Component/HttpFoundation/ParameterBag.php @@ -146,7 +146,7 @@ class ParameterBag implements \IteratorAggregate, \Countable public function getDigits(string $key, string $default = '') { // we need to remove - and + because they're allowed in the filter - return str_replace(['-', '+'], '', $this->filter($key, $default, FILTER_SANITIZE_NUMBER_INT)); + return str_replace(['-', '+'], '', $this->filter($key, $default, \FILTER_SANITIZE_NUMBER_INT)); } /** @@ -166,7 +166,7 @@ class ParameterBag implements \IteratorAggregate, \Countable */ public function getBoolean(string $key, bool $default = false) { - return $this->filter($key, $default, FILTER_VALIDATE_BOOLEAN); + return $this->filter($key, $default, \FILTER_VALIDATE_BOOLEAN); } /** @@ -180,7 +180,7 @@ class ParameterBag implements \IteratorAggregate, \Countable * * @return mixed */ - public function filter(string $key, $default = null, int $filter = FILTER_DEFAULT, $options = []) + public function filter(string $key, $default = null, int $filter = \FILTER_DEFAULT, $options = []) { $value = $this->get($key, $default); @@ -191,7 +191,7 @@ class ParameterBag implements \IteratorAggregate, \Countable // Add a convenience check for arrays. if (\is_array($value) && !isset($options['flags'])) { - $options['flags'] = FILTER_REQUIRE_ARRAY; + $options['flags'] = \FILTER_REQUIRE_ARRAY; } return filter_var($value, $filter, $options); diff --git a/src/Symfony/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php index 0dfb80c039..c00548348f 100644 --- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -42,7 +42,7 @@ class RedirectResponse extends Response throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status)); } - if (301 == $status && !\array_key_exists('cache-control', array_change_key_case($headers, CASE_LOWER))) { + if (301 == $status && !\array_key_exists('cache-control', array_change_key_case($headers, \CASE_LOWER))) { $this->headers->remove('cache-control'); } } @@ -100,7 +100,7 @@ class RedirectResponse extends Response Redirecting to %1$s. -', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'))); +', htmlspecialchars($url, \ENT_QUOTES, 'UTF-8'))); $this->headers->set('Location', $url); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 2fccdedb7e..7c59428b75 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -521,7 +521,7 @@ class Request throw $e; } - return trigger_error($e, E_USER_ERROR); + return trigger_error($e, \E_USER_ERROR); } $cookieHeader = ''; @@ -667,7 +667,7 @@ class Request $qs = HeaderUtils::parseQuery($qs); ksort($qs); - return http_build_query($qs, '', '&', PHP_QUERY_RFC3986); + return http_build_query($qs, '', '&', \PHP_QUERY_RFC3986); } /** @@ -1576,7 +1576,7 @@ class Request */ public function getETags() { - return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY); + return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, \PREG_SPLIT_NO_EMPTY); } /** @@ -2098,7 +2098,7 @@ class Request $clientIps[$key] = $clientIp = substr($clientIp, 1, $i - 1); } - if (!filter_var($clientIp, FILTER_VALIDATE_IP)) { + if (!filter_var($clientIp, \FILTER_VALIDATE_IP)) { unset($clientIps[$key]); continue; diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index ddfd1826e4..df65652456 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -1228,7 +1228,7 @@ class Response { $status = ob_get_status(true); $level = \count($status); - $flags = PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE); + $flags = \PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? \PHP_OUTPUT_HANDLER_FLUSHABLE : \PHP_OUTPUT_HANDLER_CLEANABLE); while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) { if ($flush) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php index 15b3ba0df4..0bb236156d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php @@ -66,7 +66,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess if (\PHP_VERSION_ID < 70317 || (70400 <= \PHP_VERSION_ID && \PHP_VERSION_ID < 70405)) { // work around https://bugs.php.net/79413 - foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) { + foreach (debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) { if (!isset($frame['class']) && isset($frame['function']) && \in_array($frame['function'], ['session_regenerate_id', 'session_create_id'], true)) { return '' === $this->prefetchData; } @@ -121,7 +121,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess */ public function destroy($sessionId) { - if (!headers_sent() && filter_var(ini_get('session.use_cookies'), FILTER_VALIDATE_BOOLEAN)) { + if (!headers_sent() && filter_var(ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN)) { if (!$this->sessionName) { throw new \LogicException(sprintf('Session name cannot be empty, did you forget to call "parent::open()" in "%s"?.', static::class)); } @@ -136,7 +136,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess */ if (null === $cookie || isset($_COOKIE[$this->sessionName])) { if (\PHP_VERSION_ID < 70300) { - setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), filter_var(ini_get('session.cookie_secure'), FILTER_VALIDATE_BOOLEAN), filter_var(ini_get('session.cookie_httponly'), FILTER_VALIDATE_BOOLEAN)); + setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), filter_var(ini_get('session.cookie_secure'), \FILTER_VALIDATE_BOOLEAN), filter_var(ini_get('session.cookie_httponly'), \FILTER_VALIDATE_BOOLEAN)); } else { $params = session_get_cookie_params(); unset($params['lifetime']); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index a301e9f054..92174485c7 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -643,7 +643,7 @@ class PdoSessionHandler extends AbstractSessionHandler throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.'); } - if (!filter_var(ini_get('session.use_strict_mode'), FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) { + if (!filter_var(ini_get('session.use_strict_mode'), \FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) { // In strict mode, session fixation is not possible: new sessions always start with a unique // random id, so that concurrency is not possible and this code path can be skipped. // Exclusive-reading of non-existent rows does not block, so we need to do an insert to block diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 2446b36958..bb34d724b3 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -144,11 +144,11 @@ class NativeSessionStorage implements SessionStorageInterface return true; } - if (PHP_SESSION_ACTIVE === session_status()) { + if (\PHP_SESSION_ACTIVE === session_status()) { throw new \RuntimeException('Failed to start the session: already started by PHP.'); } - if (filter_var(ini_get('session.use_cookies'), FILTER_VALIDATE_BOOLEAN) && headers_sent($file, $line)) { + if (filter_var(ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN) && headers_sent($file, $line)) { throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line)); } @@ -207,7 +207,7 @@ class NativeSessionStorage implements SessionStorageInterface public function regenerate(bool $destroy = false, int $lifetime = null) { // Cannot regenerate the session ID for non-active sessions. - if (PHP_SESSION_ACTIVE !== session_status()) { + if (\PHP_SESSION_ACTIVE !== session_status()) { return false; } @@ -256,7 +256,7 @@ class NativeSessionStorage implements SessionStorageInterface // Register error handler to add information about the current save handler $previousHandler = set_error_handler(function ($type, $msg, $file, $line) use (&$previousHandler) { - if (E_WARNING === $type && 0 === strpos($msg, 'session_write_close():')) { + if (\E_WARNING === $type && 0 === strpos($msg, 'session_write_close():')) { $handler = $this->saveHandler instanceof SessionHandlerProxy ? $this->saveHandler->getHandler() : $this->saveHandler; $msg = sprintf('session_write_close(): Failed to write session data with "%s" handler', \get_class($handler)); } @@ -365,7 +365,7 @@ class NativeSessionStorage implements SessionStorageInterface */ public function setOptions(array $options) { - if (headers_sent() || PHP_SESSION_ACTIVE === session_status()) { + if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) { return; } @@ -430,7 +430,7 @@ class NativeSessionStorage implements SessionStorageInterface } $this->saveHandler = $saveHandler; - if (headers_sent() || PHP_SESSION_ACTIVE === session_status()) { + if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) { return; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php index e7be22c019..edd04dff80 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php @@ -65,7 +65,7 @@ abstract class AbstractProxy */ public function isActive() { - return PHP_SESSION_ACTIVE === session_status(); + return \PHP_SESSION_ACTIVE === session_status(); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index 86fa24e454..5565b0384f 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php @@ -48,7 +48,7 @@ class UploadedFileTest extends TestCase __DIR__.'/Fixtures/test.gif', 'original.gif', null, - UPLOAD_ERR_OK + \UPLOAD_ERR_OK ); $this->assertEquals('application/octet-stream', $file->getClientMimeType()); @@ -64,7 +64,7 @@ class UploadedFileTest extends TestCase __DIR__.'/Fixtures/.unknownextension', 'original.gif', null, - UPLOAD_ERR_OK + \UPLOAD_ERR_OK ); $this->assertEquals('application/octet-stream', $file->getClientMimeType()); @@ -115,7 +115,7 @@ class UploadedFileTest extends TestCase null ); - $this->assertEquals(UPLOAD_ERR_OK, $file->getError()); + $this->assertEquals(\UPLOAD_ERR_OK, $file->getError()); } public function testGetClientOriginalName() @@ -149,7 +149,7 @@ class UploadedFileTest extends TestCase __DIR__.'/Fixtures/test.gif', 'original.gif', 'image/gif', - UPLOAD_ERR_OK + \UPLOAD_ERR_OK ); $file->move(__DIR__.'/Fixtures/directory'); @@ -157,7 +157,7 @@ class UploadedFileTest extends TestCase public function failedUploadedFile() { - foreach ([UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_EXTENSION, -1] as $error) { + foreach ([\UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_EXTENSION, -1] as $error) { yield [new UploadedFile( __DIR__.'/Fixtures/test.gif', 'original.gif', @@ -173,25 +173,25 @@ class UploadedFileTest extends TestCase public function testMoveFailed(UploadedFile $file) { switch ($file->getError()) { - case UPLOAD_ERR_INI_SIZE: + case \UPLOAD_ERR_INI_SIZE: $exceptionClass = IniSizeFileException::class; break; - case UPLOAD_ERR_FORM_SIZE: + case \UPLOAD_ERR_FORM_SIZE: $exceptionClass = FormSizeFileException::class; break; - case UPLOAD_ERR_PARTIAL: + case \UPLOAD_ERR_PARTIAL: $exceptionClass = PartialFileException::class; break; - case UPLOAD_ERR_NO_FILE: + case \UPLOAD_ERR_NO_FILE: $exceptionClass = NoFileException::class; break; - case UPLOAD_ERR_CANT_WRITE: + case \UPLOAD_ERR_CANT_WRITE: $exceptionClass = CannotWriteFileException::class; break; - case UPLOAD_ERR_NO_TMP_DIR: + case \UPLOAD_ERR_NO_TMP_DIR: $exceptionClass = NoTmpDirFileException::class; break; - case UPLOAD_ERR_EXTENSION: + case \UPLOAD_ERR_EXTENSION: $exceptionClass = ExtensionFileException::class; break; default: @@ -216,7 +216,7 @@ class UploadedFileTest extends TestCase $path, 'original.gif', 'image/gif', - UPLOAD_ERR_OK, + \UPLOAD_ERR_OK, true ); @@ -275,7 +275,7 @@ class UploadedFileTest extends TestCase __DIR__.'/Fixtures/test.gif', 'original.gif', null, - UPLOAD_ERR_OK, + \UPLOAD_ERR_OK, true ); @@ -300,11 +300,11 @@ class UploadedFileTest extends TestCase public function uploadedFileErrorProvider() { return [ - [UPLOAD_ERR_INI_SIZE], - [UPLOAD_ERR_FORM_SIZE], - [UPLOAD_ERR_PARTIAL], - [UPLOAD_ERR_NO_TMP_DIR], - [UPLOAD_ERR_EXTENSION], + [\UPLOAD_ERR_INI_SIZE], + [\UPLOAD_ERR_FORM_SIZE], + [\UPLOAD_ERR_PARTIAL], + [\UPLOAD_ERR_NO_TMP_DIR], + [\UPLOAD_ERR_EXTENSION], ]; } @@ -314,7 +314,7 @@ class UploadedFileTest extends TestCase __DIR__.'/Fixtures/test.gif', 'original.gif', null, - UPLOAD_ERR_OK + \UPLOAD_ERR_OK ); $this->assertFalse($file->isValid()); @@ -328,9 +328,9 @@ class UploadedFileTest extends TestCase $this->assertGreaterThan(0, $size); if (0 === (int) ini_get('post_max_size') && 0 === (int) ini_get('upload_max_filesize')) { - $this->assertSame(PHP_INT_MAX, $size); + $this->assertSame(\PHP_INT_MAX, $size); } else { - $this->assertLessThan(PHP_INT_MAX, $size); + $this->assertLessThan(\PHP_INT_MAX, $size); } } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php index bde664194b..ec6ae40248 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php @@ -51,7 +51,7 @@ class FileBagTest extends TestCase 'name' => '', 'type' => '', 'tmp_name' => '', - 'error' => UPLOAD_ERR_NO_FILE, + 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0, ]]); @@ -64,7 +64,7 @@ class FileBagTest extends TestCase 'name' => [''], 'type' => [''], 'tmp_name' => [''], - 'error' => [UPLOAD_ERR_NO_FILE], + 'error' => [\UPLOAD_ERR_NO_FILE], 'size' => [0], ]]); @@ -77,7 +77,7 @@ class FileBagTest extends TestCase 'name' => ['file1' => ''], 'type' => ['file1' => ''], 'tmp_name' => ['file1' => ''], - 'error' => ['file1' => UPLOAD_ERR_NO_FILE], + 'error' => ['file1' => \UPLOAD_ERR_NO_FILE], 'size' => ['file1' => 0], ]]); diff --git a/src/Symfony/Component/HttpFoundation/Tests/InputBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/InputBagTest.php index 1fb4660ed7..870057e41b 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/InputBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/InputBagTest.php @@ -41,7 +41,7 @@ class InputBagTest extends TestCase 'foo' => ['12', '8'], ]); - $result = $bag->filter('foo', null, FILTER_VALIDATE_INT, FILTER_FORCE_ARRAY); + $result = $bag->filter('foo', null, \FILTER_VALIDATE_INT, \FILTER_FORCE_ARRAY); $this->assertSame([12, 8], $result); } @@ -82,6 +82,6 @@ class InputBagTest extends TestCase { $bag = new InputBag(['foo' => ['bar', 'baz']]); $this->expectDeprecation('Since symfony/http-foundation 5.1: Filtering an array value with "Symfony\Component\HttpFoundation\InputBag::filter()" without passing the FILTER_REQUIRE_ARRAY or FILTER_FORCE_ARRAY flag is deprecated'); - $bag->filter('foo', FILTER_VALIDATE_INT); + $bag->filter('foo', \FILTER_VALIDATE_INT); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index ca9cfb1cee..702f4c7bea 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -213,7 +213,7 @@ class JsonResponseTest extends TestCase { $response = new JsonResponse(); - $this->assertEquals(JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT, $response->getEncodingOptions()); + $this->assertEquals(\JSON_HEX_TAG | \JSON_HEX_APOS | \JSON_HEX_AMP | \JSON_HEX_QUOT, $response->getEncodingOptions()); } public function testSetEncodingOptions() @@ -223,7 +223,7 @@ class JsonResponseTest extends TestCase $this->assertEquals('[[1,2,3]]', $response->getContent()); - $response->setEncodingOptions(JSON_FORCE_OBJECT); + $response->setEncodingOptions(\JSON_FORCE_OBJECT); $this->assertEquals('{"0":{"0":1,"1":2,"2":3}}', $response->getContent()); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php index d7cc3ca249..e5f436e8e7 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php @@ -154,22 +154,22 @@ class ParameterBagTest extends TestCase $this->assertEmpty($bag->filter('nokey'), '->filter() should return empty by default if no key is found'); - $this->assertEquals('0123', $bag->filter('digits', '', FILTER_SANITIZE_NUMBER_INT), '->filter() gets a value of parameter as integer filtering out invalid characters'); + $this->assertEquals('0123', $bag->filter('digits', '', \FILTER_SANITIZE_NUMBER_INT), '->filter() gets a value of parameter as integer filtering out invalid characters'); - $this->assertEquals('example@example.com', $bag->filter('email', '', FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email'); + $this->assertEquals('example@example.com', $bag->filter('email', '', \FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email'); - $this->assertEquals('http://example.com/foo', $bag->filter('url', '', FILTER_VALIDATE_URL, ['flags' => FILTER_FLAG_PATH_REQUIRED]), '->filter() gets a value of parameter as URL with a path'); + $this->assertEquals('http://example.com/foo', $bag->filter('url', '', \FILTER_VALIDATE_URL, ['flags' => \FILTER_FLAG_PATH_REQUIRED]), '->filter() gets a value of parameter as URL with a path'); // This test is repeated for code-coverage - $this->assertEquals('http://example.com/foo', $bag->filter('url', '', FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path'); + $this->assertEquals('http://example.com/foo', $bag->filter('url', '', \FILTER_VALIDATE_URL, \FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path'); - $this->assertFalse($bag->filter('dec', '', FILTER_VALIDATE_INT, [ - 'flags' => FILTER_FLAG_ALLOW_HEX, + $this->assertFalse($bag->filter('dec', '', \FILTER_VALIDATE_INT, [ + 'flags' => \FILTER_FLAG_ALLOW_HEX, 'options' => ['min_range' => 1, 'max_range' => 0xff], ]), '->filter() gets a value of parameter as integer between boundaries'); - $this->assertFalse($bag->filter('hex', '', FILTER_VALIDATE_INT, [ - 'flags' => FILTER_FLAG_ALLOW_HEX, + $this->assertFalse($bag->filter('hex', '', \FILTER_VALIDATE_INT, [ + 'flags' => \FILTER_FLAG_ALLOW_HEX, 'options' => ['min_range' => 1, 'max_range' => 0xff], ]), '->filter() gets a value of parameter as integer between boundaries'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php index 849a1395d3..43b48bad1a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php @@ -49,7 +49,7 @@ class ResponseFunctionalTest extends TestCase public function provideCookie() { foreach (glob(__DIR__.'/Fixtures/response-functional/*.php') as $file) { - yield [pathinfo($file, PATHINFO_FILENAME)]; + yield [pathinfo($file, \PATHINFO_FILENAME)]; } } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 5fcbeee2e9..2fbbb5bd4f 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -257,7 +257,7 @@ class ResponseTest extends ResponseTestCase public function testIsValidateable() { - $response = new Response('', 200, ['Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)]); + $response = new Response('', 200, ['Last-Modified' => $this->createDateTimeOneHourAgo()->format(\DATE_RFC2822)]); $this->assertTrue($response->isValidateable(), '->isValidateable() returns true if Last-Modified is present'); $response = new Response('', 200, ['ETag' => '"12345"']); @@ -270,7 +270,7 @@ class ResponseTest extends ResponseTestCase public function testGetDate() { $oneHourAgo = $this->createDateTimeOneHourAgo(); - $response = new Response('', 200, ['Date' => $oneHourAgo->format(DATE_RFC2822)]); + $response = new Response('', 200, ['Date' => $oneHourAgo->format(\DATE_RFC2822)]); $date = $response->getDate(); $this->assertEquals($oneHourAgo->getTimestamp(), $date->getTimestamp(), '->getDate() returns the Date header if present'); @@ -278,9 +278,9 @@ class ResponseTest extends ResponseTestCase $date = $response->getDate(); $this->assertEquals(time(), $date->getTimestamp(), '->getDate() returns the current Date if no Date header present'); - $response = new Response('', 200, ['Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)]); + $response = new Response('', 200, ['Date' => $this->createDateTimeOneHourAgo()->format(\DATE_RFC2822)]); $now = $this->createDateTimeNow(); - $response->headers->set('Date', $now->format(DATE_RFC2822)); + $response->headers->set('Date', $now->format(\DATE_RFC2822)); $date = $response->getDate(); $this->assertEquals($now->getTimestamp(), $date->getTimestamp(), '->getDate() returns the date when the header has been modified'); @@ -303,7 +303,7 @@ class ResponseTest extends ResponseTestCase $response = new Response(); $response->headers->set('Cache-Control', 'must-revalidate'); - $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); + $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(\DATE_RFC2822)); $this->assertEquals(3600, $response->getMaxAge(), '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); $response = new Response(); @@ -368,7 +368,7 @@ class ResponseTest extends ResponseTestCase $this->assertNull($response->headers->get('Age'), '->expire() does not set the Age when the response is expired'); $response = new Response(); - $response->headers->set('Expires', date(DATE_RFC2822, time() + 600)); + $response->headers->set('Expires', date(\DATE_RFC2822, time() + 600)); $response->expire(); $this->assertNull($response->headers->get('Expires'), '->expire() removes the Expires header when the response is fresh'); } @@ -385,15 +385,15 @@ class ResponseTest extends ResponseTestCase $this->assertNull($response->getTtl(), '->getTtl() returns null when no Expires or Cache-Control headers are present'); $response = new Response(); - $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); + $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(\DATE_RFC2822)); $this->assertEquals(3600, $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present'); $response = new Response(); - $response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)); + $response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(\DATE_RFC2822)); $this->assertLessThan(0, $response->getTtl(), '->getTtl() returns negative values when Expires is in past'); $response = new Response(); - $response->headers->set('Expires', $response->getDate()->format(DATE_RFC2822)); + $response->headers->set('Expires', $response->getDate()->format(\DATE_RFC2822)); $response->headers->set('Age', 0); $this->assertSame(0, $response->getTtl(), '->getTtl() correctly handles zero'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php index b25b68bbb3..4a045f2ad2 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php @@ -52,7 +52,7 @@ class AbstractSessionHandlerTest extends TestCase public function provideSession() { foreach (glob(__DIR__.'/Fixtures/*.php') as $file) { - yield [pathinfo($file, PATHINFO_FILENAME)]; + yield [pathinfo($file, \PATHINFO_FILENAME)]; } } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 03796e66e7..6042b88d27 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -147,7 +147,7 @@ class PdoSessionHandlerTest extends TestCase public function testReadLockedConvertsStreamToString() { - if (filter_var(ini_get('session.use_strict_mode'), FILTER_VALIDATE_BOOLEAN)) { + if (filter_var(ini_get('session.use_strict_mode'), \FILTER_VALIDATE_BOOLEAN)) { $this->markTestSkipped('Strict mode needs no locking for new sessions.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index b546b958e0..472456b720 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -61,12 +61,12 @@ class PhpBridgeSessionStorageTest extends TestCase { $storage = $this->getStorage(); - $this->assertNotSame(PHP_SESSION_ACTIVE, session_status()); + $this->assertNotSame(\PHP_SESSION_ACTIVE, session_status()); $this->assertFalse($storage->isStarted()); session_start(); $this->assertTrue(isset($_SESSION)); - $this->assertSame(PHP_SESSION_ACTIVE, session_status()); + $this->assertSame(\PHP_SESSION_ACTIVE, session_status()); // PHP session might have started, but the storage driver has not, so false is correct here $this->assertFalse($storage->isStarted()); diff --git a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php index cd3f0108a6..5499ef22e8 100644 --- a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php +++ b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php @@ -53,7 +53,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) { $collectedLogs = []; $previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) { - if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { + if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type) { return $previousHandler ? $previousHandler($type, $message, $file, $line) : false; } @@ -63,7 +63,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface return null; } - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); + $backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 3); // Clean the trace by removing first frames added by the error handler itself. for ($i = 0; isset($backtrace[$i]); ++$i) { if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) { diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 0632f92a18..ba0a3eec6e 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -48,13 +48,13 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte 'symfony_state' => 'unknown', 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', - 'php_version' => PHP_VERSION, + 'php_version' => \PHP_VERSION, 'php_architecture' => \PHP_INT_SIZE * 8, 'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), - 'apcu_enabled' => \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN), - 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN), + 'apcu_enabled' => \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), + 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), 'bundles' => [], 'sapi_name' => \PHP_SAPI, ]; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index 732e7aa277..a21317d341 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -153,7 +153,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte } $logs = []; - foreach (file($compilerLogsFilepath, FILE_IGNORE_NEW_LINES) as $log) { + foreach (file($compilerLogsFilepath, \FILE_IGNORE_NEW_LINES) as $log) { $log = explode(': ', $log, 2); if (!isset($log[1]) || !preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $log[0])) { $log = ['Unknown Compiler Pass', implode(': ', $log)]; @@ -226,7 +226,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte return true; } - if ($exception instanceof \ErrorException && \in_array($exception->getSeverity(), [E_DEPRECATED, E_USER_DEPRECATED], true)) { + if ($exception instanceof \ErrorException && \in_array($exception->getSeverity(), [\E_DEPRECATED, \E_USER_DEPRECATED], true)) { return true; } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index b5e3c38d2b..e0389fa3f5 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -70,8 +70,8 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter if ($request->hasSession()) { $session = $request->getSession(); if ($session->isStarted()) { - $sessionMetadata['Created'] = date(DATE_RFC822, $session->getMetadataBag()->getCreated()); - $sessionMetadata['Last used'] = date(DATE_RFC822, $session->getMetadataBag()->getLastUsed()); + $sessionMetadata['Created'] = date(\DATE_RFC822, $session->getMetadataBag()->getCreated()); + $sessionMetadata['Last used'] = date(\DATE_RFC822, $session->getMetadataBag()->getLastUsed()); $sessionMetadata['Lifetime'] = $session->getMetadataBag()->getLifetime(); $sessionAttributes = $session->all(); $flashes = $session->getFlashBag()->peekAll(); @@ -283,7 +283,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter { $decoded = json_decode($this->getContent()); - return JSON_ERROR_NONE === json_last_error() ? json_encode($decoded, JSON_PRETTY_PRINT) : null; + return \JSON_ERROR_NONE === json_last_error() ? json_encode($decoded, \JSON_PRETTY_PRINT) : null; } public function getContentType() @@ -406,7 +406,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter public function collectSessionUsage(): void { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + $trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS); $traceEndIndex = \count($trace) - 1; for ($i = $traceEndIndex; $i > 0; --$i) { diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 74abb81862..87672a9d19 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -37,7 +37,7 @@ class FileLinkFormatter $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if ($fileLinkFormat && !\is_array($fileLinkFormat)) { $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f); - $fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE); + $fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE); } $this->fileLinkFormat = $fileLinkFormat; diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 82d45a8dcf..286f212f9a 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -100,7 +100,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface } foreach (['action', 'argument', 'id'] as $k) { if (!isset($attributes[$k][0])) { - throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "%s" %s for service "%s".', $k, $this->controllerTag, json_encode($attributes, JSON_UNESCAPED_UNICODE), $id)); + throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "%s" %s for service "%s".', $k, $this->controllerTag, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id)); } } if (!isset($methods[$action = strtolower($attributes['action'])])) { diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index 44b1ddb187..6b677edd7c 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -49,12 +49,12 @@ class DebugHandlersListener implements EventSubscriberInterface * @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files * @param bool $scope Enables/disables scoping mode */ - public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, LoggerInterface $deprecationLogger = null) + public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, LoggerInterface $deprecationLogger = null) { $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; - $this->levels = null === $levels ? E_ALL : $levels; - $this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null)); + $this->levels = null === $levels ? \E_ALL : $levels; + $this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null)); $this->scream = $scream; $this->fileLinkFormat = $fileLinkFormat; $this->scope = $scope; @@ -94,7 +94,7 @@ class DebugHandlersListener implements EventSubscriberInterface $handler->screamAt($levels); } if ($this->scope) { - $handler->scopeAt($levels & ~E_USER_DEPRECATED & ~E_DEPRECATED); + $handler->scopeAt($levels & ~\E_USER_DEPRECATED & ~\E_DEPRECATED); } else { $handler->scopeAt(0, true); } @@ -142,15 +142,15 @@ class DebugHandlersListener implements EventSubscriberInterface $levelsDeprecatedOnly = []; $levelsWithoutDeprecated = []; foreach ($this->levels as $type => $log) { - if (E_DEPRECATED == $type || E_USER_DEPRECATED == $type) { + if (\E_DEPRECATED == $type || \E_USER_DEPRECATED == $type) { $levelsDeprecatedOnly[$type] = $log; } else { $levelsWithoutDeprecated[$type] = $log; } } } else { - $levelsDeprecatedOnly = $this->levels & (E_DEPRECATED | E_USER_DEPRECATED); - $levelsWithoutDeprecated = $this->levels & ~E_DEPRECATED & ~E_USER_DEPRECATED; + $levelsDeprecatedOnly = $this->levels & (\E_DEPRECATED | \E_USER_DEPRECATED); + $levelsWithoutDeprecated = $this->levels & ~\E_DEPRECATED & ~\E_USER_DEPRECATED; } $defaultLoggerLevels = $this->levels; diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 618859d0f9..634eabfba5 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -86,7 +86,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer } $renderedAttributes = ''; if (\count($attributes) > 0) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; + $flags = \ENT_QUOTES | \ENT_SUBSTITUTE; foreach ($attributes as $attribute => $value) { $renderedAttributes .= sprintf( ' %s="%s"', diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Esi.php b/src/Symfony/Component/HttpKernel/HttpCache/Esi.php index af67e8ffb8..458b2c5d74 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Esi.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Esi.php @@ -80,13 +80,13 @@ class Esi extends AbstractSurrogate $content = preg_replace('#.*?#s', '', $content); $content = preg_replace('#]+>#s', '', $content); - $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); + $chunks = preg_split('##', $content, -1, \PREG_SPLIT_DELIM_CAPTURE); $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); $i = 1; while (isset($chunks[$i])) { $options = []; - preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); + preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, \PREG_SET_ORDER); foreach ($matches as $set) { $options[$set[1]] = $set[2]; } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php b/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php index 587c43a0eb..0ba351dd12 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php @@ -65,13 +65,13 @@ class Ssi extends AbstractSurrogate // we don't use a proper XML parser here as we can have SSI tags in a plain text response $content = $response->getContent(); - $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); + $chunks = preg_split('##', $content, -1, \PREG_SPLIT_DELIM_CAPTURE); $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); $i = 1; while (isset($chunks[$i])) { $options = []; - preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); + preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, \PREG_SET_ORDER); foreach ($matches as $set) { $options[$set[1]] = $set[2]; } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index 8da4bb992f..7f12978535 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -48,7 +48,7 @@ class Store implements StoreInterface { // unlock everything foreach ($this->locks as $lock) { - flock($lock, LOCK_UN); + flock($lock, \LOCK_UN); fclose($lock); } @@ -70,7 +70,7 @@ class Store implements StoreInterface return $path; } $h = fopen($path, 'cb'); - if (!flock($h, LOCK_EX | LOCK_NB)) { + if (!flock($h, \LOCK_EX | \LOCK_NB)) { fclose($h); return $path; @@ -92,7 +92,7 @@ class Store implements StoreInterface $key = $this->getCacheKey($request); if (isset($this->locks[$key])) { - flock($this->locks[$key], LOCK_UN); + flock($this->locks[$key], \LOCK_UN); fclose($this->locks[$key]); unset($this->locks[$key]); @@ -115,8 +115,8 @@ class Store implements StoreInterface } $h = fopen($path, 'rb'); - flock($h, LOCK_EX | LOCK_NB, $wouldBlock); - flock($h, LOCK_UN); // release the lock we just acquired + flock($h, \LOCK_EX | \LOCK_NB, $wouldBlock); + flock($h, \LOCK_UN); // release the lock we just acquired fclose($h); return (bool) $wouldBlock; @@ -326,7 +326,7 @@ class Store implements StoreInterface { $key = $this->getCacheKey(Request::create($url)); if (isset($this->locks[$key])) { - flock($this->locks[$key], LOCK_UN); + flock($this->locks[$key], \LOCK_UN); fclose($this->locks[$key]); unset($this->locks[$key]); } diff --git a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php index d28be99741..c1f5b4c922 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php +++ b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php @@ -164,7 +164,7 @@ EOF; '', $value->getClientOriginalName(), $value->getClientMimeType(), - UPLOAD_ERR_INI_SIZE, + \UPLOAD_ERR_INI_SIZE, true ); } else { diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index cae420dd12..800ec07878 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -322,7 +322,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ public function getStartTime() { - return $this->debug && null !== $this->startTime ? $this->startTime : -INF; + return $this->debug && null !== $this->startTime ? $this->startTime : -\INF; } /** @@ -439,7 +439,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl $cachePath = $cache->getPath(); // Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors - $errorLevel = error_reporting(E_ALL ^ E_WARNING); + $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); try { if (is_file($cachePath) && \is_object($this->container = include $cachePath) @@ -460,15 +460,15 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl is_dir($buildDir) ?: mkdir($buildDir, 0777, true); if ($lock = fopen($cachePath.'.lock', 'w')) { - flock($lock, LOCK_EX | LOCK_NB, $wouldBlock); + flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock); - if (!flock($lock, $wouldBlock ? LOCK_SH : LOCK_EX)) { + if (!flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) { fclose($lock); $lock = null; } elseif (!\is_object($this->container = include $cachePath)) { $this->container = null; } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { - flock($lock, LOCK_UN); + flock($lock, \LOCK_UN); fclose($lock); $this->container->set('kernel', $this); @@ -483,7 +483,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) { $collectedLogs = []; $previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) { - if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { + if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type) { return $previousHandler ? $previousHandler($type, $message, $file, $line) : false; } @@ -493,7 +493,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl return null; } - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5); + $backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 5); // Clean the trace by removing first frames added by the error handler itself. for ($i = 0; isset($backtrace[$i]); ++$i) { if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) { @@ -550,7 +550,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); if ($lock) { - flock($lock, LOCK_UN); + flock($lock, \LOCK_UN); fclose($lock); } @@ -564,7 +564,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl static $legacyContainers = []; $oldContainerDir = \dirname($oldContainer->getFileName()); $legacyContainers[$oldContainerDir.'.legacy'] = true; - foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', GLOB_NOSORT) as $legacyContainer) { + foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', \GLOB_NOSORT) as $legacyContainer) { if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) { (new Filesystem())->remove(substr($legacyContainer, 0, -7)); } @@ -809,14 +809,14 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl $token = $tokens[$i]; if (!isset($token[1]) || 'b"' === $token) { $rawChunk .= $token; - } elseif (T_START_HEREDOC === $token[0]) { + } elseif (\T_START_HEREDOC === $token[0]) { $output .= $rawChunk.$token[1]; do { $token = $tokens[++$i]; $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; - } while (T_END_HEREDOC !== $token[0]); + } while (\T_END_HEREDOC !== $token[0]); $rawChunk = ''; - } elseif (T_WHITESPACE === $token[0]) { + } elseif (\T_WHITESPACE === $token[0]) { if ($ignoreSpace) { $ignoreSpace = false; @@ -825,13 +825,13 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl // replace multiple new lines with a single newline $rawChunk .= preg_replace(['/\n{2,}/S'], "\n", $token[1]); - } elseif (\in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) { + } elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) { $ignoreSpace = true; } else { $rawChunk .= $token[1]; // The PHP-open tag already has a new-line - if (T_OPEN_TAG === $token[0]) { + if (\T_OPEN_TAG === $token[0]) { $ignoreSpace = true; } } diff --git a/src/Symfony/Component/HttpKernel/Log/Logger.php b/src/Symfony/Component/HttpKernel/Log/Logger.php index 1e6308d6e0..c97673dd89 100644 --- a/src/Symfony/Component/HttpKernel/Log/Logger.php +++ b/src/Symfony/Component/HttpKernel/Log/Logger.php @@ -105,7 +105,7 @@ class Logger extends AbstractLogger $message = strtr($message, $replacements); } - $log = sprintf('[%s] %s', $level, $message).PHP_EOL; + $log = sprintf('[%s] %s', $level, $message).\PHP_EOL; if ($prefixDate) { $log = date(\DateTime::RFC3339).' '.$log; } diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index 3b5dfbf26f..4f63b41889 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -56,7 +56,7 @@ class FileProfilerStorage implements ProfilerStorageInterface } $file = fopen($file, 'r'); - fseek($file, 0, SEEK_END); + fseek($file, 0, \SEEK_END); $result = []; while (\count($result) < $limit && $line = $this->readLineFromFile($file)) { @@ -258,7 +258,7 @@ class FileProfilerStorage implements ProfilerStorageInterface $position += $upTo; $line = substr($buffer, $upTo + 1).$line; - fseek($file, max(0, $position), SEEK_SET); + fseek($file, max(0, $position), \SEEK_SET); if ('' !== $line) { break; diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 9cb75a6051..308a20127a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -30,8 +30,8 @@ class ConfigDataCollectorTest extends TestCase $this->assertSame('test', $c->getEnv()); $this->assertTrue($c->isDebug()); $this->assertSame('config', $c->getName()); - $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); - $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); + $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', \PHP_VERSION); + $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', \PHP_VERSION); $this->assertSame(\PHP_INT_SIZE * 8, $c->getPhpArchitecture()); $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); @@ -39,8 +39,8 @@ class ConfigDataCollectorTest extends TestCase $this->assertSame(4 === Kernel::MINOR_VERSION, $c->isSymfonyLts()); $this->assertNull($c->getToken()); $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); - $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); - $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); + $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); + $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 9c175397fc..de9364bb47 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -157,14 +157,14 @@ class LoggerDataCollectorTest extends TestCase yield 'logs with some deprecations' => [ 1, [ - ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo', 'context' => ['exception' => new \ErrorException('deprecated', 0, E_DEPRECATED)], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo2', 'context' => ['exception' => new \ErrorException('deprecated', 0, E_USER_DEPRECATED)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, \E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo', 'context' => ['exception' => new \ErrorException('deprecated', 0, \E_DEPRECATED)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo2', 'context' => ['exception' => new \ErrorException('deprecated', 0, \E_USER_DEPRECATED)], 'priority' => 100, 'priorityName' => 'DEBUG'], ], [ - ['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo', 'context' => ['exception' => ['deprecated', E_DEPRECATED]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false], - ['message' => 'foo2', 'context' => ['exception' => ['deprecated', E_USER_DEPRECATED]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false], + ['message' => 'foo3', 'context' => ['exception' => ['warning', \E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo', 'context' => ['exception' => ['deprecated', \E_DEPRECATED]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false], + ['message' => 'foo2', 'context' => ['exception' => ['deprecated', \E_USER_DEPRECATED]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false], ], 2, 0, @@ -174,14 +174,14 @@ class LoggerDataCollectorTest extends TestCase yield 'logs with some silent errors' => [ 1, [ - ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => '0', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, \E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(\E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => '0', 'context' => ['exception' => new SilencedErrorContext(\E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], ], [ - ['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo3', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], - ['message' => '0', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], + ['message' => 'foo3', 'context' => ['exception' => ['warning', \E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo3', 'context' => ['exception' => [\E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], + ['message' => '0', 'context' => ['exception' => [\E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], ], 0, 2, diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index abd202f381..12df187571 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -59,8 +59,8 @@ class DebugHandlersListenerTest extends TestCase $loggers = $eHandler->setLoggers([]); - $this->assertArrayHasKey(E_DEPRECATED, $loggers); - $this->assertSame([$logger, LogLevel::INFO], $loggers[E_DEPRECATED]); + $this->assertArrayHasKey(\E_DEPRECATED, $loggers); + $this->assertSame([$logger, LogLevel::INFO], $loggers[\E_DEPRECATED]); } public function testConfigureForHttpKernelWithNoTerminateWithException() @@ -156,28 +156,28 @@ class DebugHandlersListenerTest extends TestCase { return [ [false, false, '0', null, null], - [false, false, E_ALL, null, null], + [false, false, \E_ALL, null, null], [false, false, [], null, null], - [false, false, [E_WARNING => LogLevel::WARNING, E_USER_DEPRECATED => LogLevel::NOTICE], null, null], + [false, false, [\E_WARNING => LogLevel::WARNING, \E_USER_DEPRECATED => LogLevel::NOTICE], null, null], - [true, false, E_ALL, E_ALL, null], - [true, false, E_DEPRECATED, E_DEPRECATED, null], + [true, false, \E_ALL, \E_ALL, null], + [true, false, \E_DEPRECATED, \E_DEPRECATED, null], [true, false, [], null, null], - [true, false, [E_WARNING => LogLevel::WARNING, E_DEPRECATED => LogLevel::NOTICE], [E_WARNING => LogLevel::WARNING, E_DEPRECATED => LogLevel::NOTICE], null], + [true, false, [\E_WARNING => LogLevel::WARNING, \E_DEPRECATED => LogLevel::NOTICE], [\E_WARNING => LogLevel::WARNING, \E_DEPRECATED => LogLevel::NOTICE], null], [false, true, '0', null, null], - [false, true, E_ALL, null, E_DEPRECATED | E_USER_DEPRECATED], - [false, true, E_ERROR, null, null], + [false, true, \E_ALL, null, \E_DEPRECATED | \E_USER_DEPRECATED], + [false, true, \E_ERROR, null, null], [false, true, [], null, null], - [false, true, [E_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::DEBUG], null, [E_DEPRECATED => LogLevel::DEBUG]], + [false, true, [\E_ERROR => LogLevel::ERROR, \E_DEPRECATED => LogLevel::DEBUG], null, [\E_DEPRECATED => LogLevel::DEBUG]], [true, true, '0', null, null], - [true, true, E_ALL, E_ALL & ~(E_DEPRECATED | E_USER_DEPRECATED), E_DEPRECATED | E_USER_DEPRECATED], - [true, true, E_ERROR, E_ERROR, null], - [true, true, E_USER_DEPRECATED, null, E_USER_DEPRECATED], - [true, true, [E_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::DEBUG], [E_ERROR => LogLevel::ERROR], [E_DEPRECATED => LogLevel::DEBUG]], - [true, true, [E_ERROR => LogLevel::ALERT], [E_ERROR => LogLevel::ALERT], null], - [true, true, [E_USER_DEPRECATED => LogLevel::NOTICE], null, [E_USER_DEPRECATED => LogLevel::NOTICE]], + [true, true, \E_ALL, \E_ALL & ~(\E_DEPRECATED | \E_USER_DEPRECATED), \E_DEPRECATED | \E_USER_DEPRECATED], + [true, true, \E_ERROR, \E_ERROR, null], + [true, true, \E_USER_DEPRECATED, null, \E_USER_DEPRECATED], + [true, true, [\E_ERROR => LogLevel::ERROR, \E_DEPRECATED => LogLevel::DEBUG], [\E_ERROR => LogLevel::ERROR], [\E_DEPRECATED => LogLevel::DEBUG]], + [true, true, [\E_ERROR => LogLevel::ALERT], [\E_ERROR => LogLevel::ALERT], null], + [true, true, [\E_USER_DEPRECATED => LogLevel::NOTICE], null, [\E_USER_DEPRECATED => LogLevel::NOTICE]], ]; } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 802f1d1007..6ad64e4791 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -129,8 +129,8 @@ class HttpCacheTest extends HttpCacheTestCase { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822), 'Content-Type' => 'text/plain'], 'Hello World'); - $this->request('GET', '/', ['HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Last-Modified' => $time->format(\DATE_RFC2822), 'Content-Type' => 'text/plain'], 'Hello World'); + $this->request('GET', '/', ['HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]); $this->assertHttpKernelIsCalled(); $this->assertEquals(304, $this->response->getStatusCode()); @@ -161,24 +161,24 @@ class HttpCacheTest extends HttpCacheTestCase $this->setNextResponse(200, [], '', function ($request, $response) use ($time) { $response->setStatusCode(200); $response->headers->set('ETag', '12345'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); $response->headers->set('Content-Type', 'text/plain'); $response->setContent('Hello World'); }); // only ETag matches $t = \DateTime::createFromFormat('U', time() - 3600); - $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $t->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $t->format(\DATE_RFC2822)]); $this->assertHttpKernelIsCalled(); $this->assertEquals(200, $this->response->getStatusCode()); // only Last-Modified matches - $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '1234', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '1234', 'HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]); $this->assertHttpKernelIsCalled(); $this->assertEquals(200, $this->response->getStatusCode()); // Both matches - $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]); $this->assertHttpKernelIsCalled(); $this->assertEquals(304, $this->response->getStatusCode()); } @@ -257,7 +257,7 @@ class HttpCacheTest extends HttpCacheTestCase { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'no-cache']); $this->assertHttpKernelIsCalled(); @@ -393,7 +393,7 @@ class HttpCacheTest extends HttpCacheTestCase public function testFetchesResponseFromBackendWhenCacheMisses() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -405,7 +405,7 @@ class HttpCacheTest extends HttpCacheTestCase { foreach (array_merge(range(201, 202), range(204, 206), range(303, 305), range(400, 403), range(405, 409), range(411, 417), range(500, 505)) as $code) { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse($code, ['Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse($code, ['Expires' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertEquals($code, $this->response->getStatusCode()); @@ -417,7 +417,7 @@ class HttpCacheTest extends HttpCacheTestCase public function testDoesNotCacheResponsesWithExplicitNoStoreDirective() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'no-store']); + $this->setNextResponse(200, ['Expires' => $time->format(\DATE_RFC2822), 'Cache-Control' => 'no-store']); $this->request('GET', '/'); $this->assertTraceNotContains('store'); @@ -436,7 +436,7 @@ class HttpCacheTest extends HttpCacheTestCase public function testCachesResponsesWithExplicitNoCacheDirective() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, no-cache']); + $this->setNextResponse(200, ['Expires' => $time->format(\DATE_RFC2822), 'Cache-Control' => 'public, no-cache']); $this->request('GET', '/'); $this->assertTraceContains('store'); @@ -462,7 +462,7 @@ class HttpCacheTest extends HttpCacheTestCase public function testCachesResponsesWithAnExpirationHeader() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -511,7 +511,7 @@ class HttpCacheTest extends HttpCacheTestCase public function testCachesResponsesWithALastModifiedValidatorButNoFreshnessInformation() { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Last-Modified' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -535,7 +535,7 @@ class HttpCacheTest extends HttpCacheTestCase { $time1 = \DateTime::createFromFormat('U', time() - 5); $time2 = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Date' => $time1->format(DATE_RFC2822), 'Expires' => $time2->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Date' => $time1->format(\DATE_RFC2822), 'Expires' => $time2->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); @@ -559,7 +559,7 @@ class HttpCacheTest extends HttpCacheTestCase public function testHitsCachedResponseWithMaxAgeDirective() { $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, ['Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, max-age=10']); + $this->setNextResponse(200, ['Date' => $time->format(\DATE_RFC2822), 'Cache-Control' => 'public, max-age=10']); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); @@ -623,7 +623,7 @@ class HttpCacheTest extends HttpCacheTestCase public function testHitsCachedResponseWithSMaxAgeDirective() { $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, ['Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 's-maxage=10, max-age=0']); + $this->setNextResponse(200, ['Date' => $time->format(\DATE_RFC2822), 'Cache-Control' => 's-maxage=10, max-age=0']); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); @@ -691,7 +691,7 @@ class HttpCacheTest extends HttpCacheTestCase $this->assertCount(1, $values); $tmp = unserialize($values[0]); $time = \DateTime::createFromFormat('U', time() - 5); - $tmp[0][1]['date'] = $time->format(DATE_RFC2822); + $tmp[0][1]['date'] = $time->format(\DATE_RFC2822); $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $m->setAccessible(true); @@ -741,7 +741,7 @@ class HttpCacheTest extends HttpCacheTestCase $this->assertCount(1, $values); $tmp = unserialize($values[0]); $time = \DateTime::createFromFormat('U', time() - 5); - $tmp[0][1]['date'] = $time->format(DATE_RFC2822); + $tmp[0][1]['date'] = $time->format(\DATE_RFC2822); $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $m->setAccessible(true); @@ -783,7 +783,7 @@ class HttpCacheTest extends HttpCacheTestCase public function testFetchesFullResponseWhenCacheStaleAndNoValidatorsPresent() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(\DATE_RFC2822)]); // build initial request $this->request('GET', '/'); @@ -801,7 +801,7 @@ class HttpCacheTest extends HttpCacheTestCase $this->assertCount(1, $values); $tmp = unserialize($values[0]); $time = \DateTime::createFromFormat('U', time()); - $tmp[0][1]['expires'] = $time->format(DATE_RFC2822); + $tmp[0][1]['expires'] = $time->format(\DATE_RFC2822); $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $m->setAccessible(true); @@ -825,8 +825,8 @@ class HttpCacheTest extends HttpCacheTestCase $time = \DateTime::createFromFormat('U', time()); $this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($time) { $response->headers->set('Cache-Control', 'public'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - if ($time->format(DATE_RFC2822) == $request->headers->get('IF_MODIFIED_SINCE')) { + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); + if ($time->format(\DATE_RFC2822) == $request->headers->get('IF_MODIFIED_SINCE')) { $response->setStatusCode(304); $response->setContent(''); } @@ -912,7 +912,7 @@ class HttpCacheTest extends HttpCacheTestCase $this->setNextResponse(200, [], 'Hello World', function (Request $request, Response $response) use ($time) { $response->setSharedMaxAge(10); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); }); // prime the cache @@ -929,7 +929,7 @@ class HttpCacheTest extends HttpCacheTestCase sleep(15); // expire the cache $this->setNextResponse(304, [], '', function (Request $request, Response $response) use ($time) { - $this->assertEquals($time->format(DATE_RFC2822), $request->headers->get('IF_MODIFIED_SINCE')); + $this->assertEquals($time->format(\DATE_RFC2822), $request->headers->get('IF_MODIFIED_SINCE')); }); $this->request('GET', '/'); @@ -945,7 +945,7 @@ class HttpCacheTest extends HttpCacheTestCase $time = \DateTime::createFromFormat('U', time()); $count = 0; $this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($time, &$count) { - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); $response->headers->set('Cache-Control', 'public'); switch (++$count) { case 1: @@ -1017,14 +1017,14 @@ class HttpCacheTest extends HttpCacheTestCase $time = \DateTime::createFromFormat('U', time()); $this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($time) { $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); }); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); $this->assertEquals('Hello World', $this->response->getContent()); - $this->request('GET', '/', ['HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]); $this->assertHttpKernelIsNotCalled(); $this->assertEquals(304, $this->response->getStatusCode()); $this->assertEquals('', $this->response->getContent()); @@ -1425,7 +1425,7 @@ class HttpCacheTest extends HttpCacheTestCase 'headers' => [ 'Surrogate-Control' => 'content="ESI/1.0"', 'ETag' => 'hey', - 'Last-Modified' => $time->format(DATE_RFC2822), + 'Last-Modified' => $time->format(\DATE_RFC2822), ], ], [ @@ -1453,7 +1453,7 @@ class HttpCacheTest extends HttpCacheTestCase 'headers' => [ 'Surrogate-Control' => 'content="ESI/1.0"', 'ETag' => 'hey', - 'Last-Modified' => $time->format(DATE_RFC2822), + 'Last-Modified' => $time->format(\DATE_RFC2822), ], ], [ diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php index fdcfc26667..4d4fe5ae72 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php @@ -100,8 +100,8 @@ class HttpKernelBrowserTest extends TestCase $client = new HttpKernelBrowser($kernel); $files = [ - ['tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => null, 'error' => UPLOAD_ERR_OK], - new UploadedFile($source, 'original', 'mime/original', UPLOAD_ERR_OK, true), + ['tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => null, 'error' => \UPLOAD_ERR_OK], + new UploadedFile($source, 'original', 'mime/original', \UPLOAD_ERR_OK, true), ]; $file = null; @@ -130,7 +130,7 @@ class HttpKernelBrowserTest extends TestCase $kernel = new TestHttpKernel(); $client = new HttpKernelBrowser($kernel); - $file = ['tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => UPLOAD_ERR_NO_FILE]; + $file = ['tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => \UPLOAD_ERR_NO_FILE]; $client->request('POST', '/', [], ['foo' => $file]); @@ -149,18 +149,18 @@ class HttpKernelBrowserTest extends TestCase $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs([$source, 'original', 'mime/original', UPLOAD_ERR_OK, true]) + ->setConstructorArgs([$source, 'original', 'mime/original', \UPLOAD_ERR_OK, true]) ->setMethods(['getSize', 'getClientSize']) ->getMock() ; /* should be modified when the getClientSize will be removed */ $file->expects($this->any()) ->method('getSize') - ->willReturn(INF) + ->willReturn(\INF) ; $file->expects($this->any()) ->method('getClientSize') - ->willReturn(PHP_INT_MAX) + ->willReturn(\PHP_INT_MAX) ; $client->request('POST', '/', [], [$file]); @@ -172,7 +172,7 @@ class HttpKernelBrowserTest extends TestCase $file = $files[0]; $this->assertFalse($file->isValid()); - $this->assertEquals(UPLOAD_ERR_INI_SIZE, $file->getError()); + $this->assertEquals(\UPLOAD_ERR_INI_SIZE, $file->getError()); $this->assertEquals('mime/original', $file->getClientMimeType()); $this->assertEquals('original', $file->getClientOriginalName()); $this->assertEquals(0, $file->getSize()); diff --git a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php index 5c7da41957..607ab31cb8 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php @@ -59,7 +59,7 @@ class LoggerTest extends TestCase */ public function getLogs(): array { - return file($this->tmpFile, FILE_IGNORE_NEW_LINES); + return file($this->tmpFile, \FILE_IGNORE_NEW_LINES); } public function testImplements() @@ -186,7 +186,7 @@ class LoggerTest extends TestCase public function testFormatter() { $this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile, function ($level, $message, $context) { - return json_encode(['level' => $level, 'message' => $message, 'context' => $context]).PHP_EOL; + return json_encode(['level' => $level, 'message' => $message, 'context' => $context]).\PHP_EOL; }); $this->logger->error('An error', ['foo' => 'bar']); diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php index 2df9a94884..a59d0cbe8e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php @@ -354,7 +354,7 @@ class FileProfilerStorageTest extends TestCase $h = tmpfile(); fwrite($h, "line1\n\n\nline2\n"); - fseek($h, 0, SEEK_END); + fseek($h, 0, \SEEK_END); $this->assertEquals('line2', $r->invoke($this->storage, $h)); $this->assertEquals('line1', $r->invoke($this->storage, $h)); diff --git a/src/Symfony/Component/HttpKernel/UriSigner.php b/src/Symfony/Component/HttpKernel/UriSigner.php index df08dd69fc..4f823966ee 100644 --- a/src/Symfony/Component/HttpKernel/UriSigner.php +++ b/src/Symfony/Component/HttpKernel/UriSigner.php @@ -95,7 +95,7 @@ class UriSigner private function buildUrl(array $url, array $params = []): string { - ksort($params, SORT_STRING); + ksort($params, \SORT_STRING); $url['query'] = http_build_query($params, '', '&'); $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; diff --git a/src/Symfony/Component/Intl/Collator/Collator.php b/src/Symfony/Component/Intl/Collator/Collator.php index ff0d258e1d..a43a4f69bf 100644 --- a/src/Symfony/Component/Intl/Collator/Collator.php +++ b/src/Symfony/Component/Intl/Collator/Collator.php @@ -109,9 +109,9 @@ abstract class Collator public function asort(array &$array, int $sortFlag = self::SORT_REGULAR) { $intlToPlainFlagMap = [ - self::SORT_REGULAR => SORT_REGULAR, - self::SORT_NUMERIC => SORT_NUMERIC, - self::SORT_STRING => SORT_STRING, + self::SORT_REGULAR => \SORT_REGULAR, + self::SORT_NUMERIC => \SORT_NUMERIC, + self::SORT_STRING => \SORT_STRING, ]; $plainSortFlag = isset($intlToPlainFlagMap[$sortFlag]) ? $intlToPlainFlagMap[$sortFlag] : self::SORT_REGULAR; diff --git a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php index 0e114f3844..4ecd4b93ad 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php @@ -35,7 +35,7 @@ class JsonBundleWriter implements BundleWriterInterface } }); - $contents = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)."\n"; + $contents = json_encode($data, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE)."\n"; file_put_contents($path.'/'.$locale.'.json', $contents); } diff --git a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php index f6e9f67779..e234df4093 100644 --- a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php @@ -67,7 +67,7 @@ class LocaleDataGenerator extends AbstractDataGenerator // Write parents locale file for the Translation component 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 7123d5bd32..ff189bc98b 100644 --- a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php +++ b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php @@ -40,7 +40,7 @@ class LocaleScanner */ public function scanLocales(string $sourceDir): array { - $locales = glob($sourceDir.'/*.txt', GLOB_NOSORT); + $locales = glob($sourceDir.'/*.txt', \GLOB_NOSORT); // Remove file extension and sort array_walk($locales, function (&$locale) { $locale = basename($locale, '.txt'); }); diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php index 1a9a3eff3f..2351323946 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php @@ -60,6 +60,6 @@ abstract class Transformer */ protected function padLeft(string $value, int $length): string { - return str_pad($value, $length, '0', STR_PAD_LEFT); + return str_pad($value, $length, '0', \STR_PAD_LEFT); } } diff --git a/src/Symfony/Component/Intl/Intl.php b/src/Symfony/Component/Intl/Intl.php index eb3bd582a8..4f8d4a76ac 100644 --- a/src/Symfony/Component/Intl/Intl.php +++ b/src/Symfony/Component/Intl/Intl.php @@ -85,7 +85,7 @@ final class Intl if (!self::isExtensionLoaded()) { self::$icuVersion = self::getIcuStubVersion(); } elseif (\defined('INTL_ICU_VERSION')) { - self::$icuVersion = INTL_ICU_VERSION; + self::$icuVersion = \INTL_ICU_VERSION; } else { try { $reflector = new \ReflectionExtension('intl'); diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 6d48949ef9..6a89a156a2 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -201,9 +201,9 @@ abstract class NumberFormatter * @see https://php.net/round */ private static $phpRoundingMap = [ - self::ROUND_HALFDOWN => PHP_ROUND_HALF_DOWN, - self::ROUND_HALFEVEN => PHP_ROUND_HALF_EVEN, - self::ROUND_HALFUP => PHP_ROUND_HALF_UP, + self::ROUND_HALFDOWN => \PHP_ROUND_HALF_DOWN, + self::ROUND_HALFEVEN => \PHP_ROUND_HALF_EVEN, + self::ROUND_HALFUP => \PHP_ROUND_HALF_UP, ]; /** @@ -354,7 +354,7 @@ abstract class NumberFormatter { // The original NumberFormatter does not support this format type if (self::TYPE_CURRENCY === $type) { - trigger_error(__METHOD__.'(): Unsupported format type '.$type, E_USER_WARNING); + trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING); return false; } @@ -508,7 +508,7 @@ abstract class NumberFormatter public function parse(string $value, int $type = self::TYPE_DOUBLE, int &$position = 0) { if (self::TYPE_DEFAULT === $type || self::TYPE_CURRENCY === $type) { - trigger_error(__METHOD__.'(): Unsupported format type '.$type, E_USER_WARNING); + trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING); return false; } diff --git a/src/Symfony/Component/Intl/Resources/bin/common.php b/src/Symfony/Component/Intl/Resources/bin/common.php index 5a93e40487..1ed762fee4 100644 --- a/src/Symfony/Component/Intl/Resources/bin/common.php +++ b/src/Symfony/Component/Intl/Resources/bin/common.php @@ -68,7 +68,7 @@ function get_icu_version_from_genrb($genrb) return $matches[1]; } -error_reporting(E_ALL); +error_reporting(\E_ALL); set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php index 39f5cbb813..3106ba3ce4 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php @@ -72,7 +72,7 @@ class Adapter implements AdapterInterface $value = ldap_escape($subject, $ignore, $flags); // Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns. - if ((int) $flags & LDAP_ESCAPE_DN) { + if ((int) $flags & \LDAP_ESCAPE_DN) { if (!empty($value) && ' ' === $value[0]) { $value = '\\20'.substr($value, 1); } diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php index 407783ba15..feaf22319f 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php @@ -50,6 +50,8 @@ class Connection extends AbstractConnection /** * {@inheritdoc} + * + * @param string $password WARNING: When the LDAP server allows unauthenticated binds, a blank $password will always be valid */ public function bind(string $dn = null, string $password = null) { diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index b9c1748b0f..070ef4d775 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -193,14 +193,14 @@ class Query extends AbstractQuery // // This is not supported in PHP < 7.2, so these versions will remain broken. $ctl = []; - ldap_get_option($con, LDAP_OPT_SERVER_CONTROLS, $ctl); + ldap_get_option($con, \LDAP_OPT_SERVER_CONTROLS, $ctl); if (!empty($ctl)) { foreach ($ctl as $idx => $info) { if (static::PAGINATION_OID == $info['oid']) { unset($ctl[$idx]); } } - ldap_set_option($con, LDAP_OPT_SERVER_CONTROLS, $ctl); + ldap_set_option($con, \LDAP_OPT_SERVER_CONTROLS, $ctl); } } } diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php index ca3e5decd9..4ef536efc6 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php @@ -20,10 +20,10 @@ class UpdateOperation private $attribute; private $validOperationTypes = [ - LDAP_MODIFY_BATCH_ADD, - LDAP_MODIFY_BATCH_REMOVE, - LDAP_MODIFY_BATCH_REMOVE_ALL, - LDAP_MODIFY_BATCH_REPLACE, + \LDAP_MODIFY_BATCH_ADD, + \LDAP_MODIFY_BATCH_REMOVE, + \LDAP_MODIFY_BATCH_REMOVE_ALL, + \LDAP_MODIFY_BATCH_REPLACE, ]; /** @@ -37,7 +37,7 @@ class UpdateOperation if (!\in_array($operationType, $this->validOperationTypes, true)) { throw new UpdateOperationException(sprintf('"%s" is not a valid modification type.', $operationType)); } - if (LDAP_MODIFY_BATCH_REMOVE_ALL === $operationType && null !== $values) { + if (\LDAP_MODIFY_BATCH_REMOVE_ALL === $operationType && null !== $values) { throw new UpdateOperationException(sprintf('$values must be null for LDAP_MODIFY_BATCH_REMOVE_ALL operation, "%s" given.', get_debug_type($values))); } diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php index 4c04d031ac..d17b47b1fa 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php @@ -153,7 +153,7 @@ class AdapterTest extends LdapTestCase $this->assertEquals(\count($fully_paged_query->getResources()), 1); $this->assertEquals(\count($paged_query->getResources()), 5); - if (PHP_MAJOR_VERSION > 7 || (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION >= 2)) { + if (\PHP_MAJOR_VERSION > 7 || (\PHP_MAJOR_VERSION == 7 && \PHP_MINOR_VERSION >= 2)) { // This last query is to ensure that we haven't botched the state of our connection // by not resetting pagination properly. extldap <= PHP 7.1 do not implement the necessary // bits to work around an implementation flaw, so we simply can't guarantee this to work there. diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php index ae45097c06..e23e801854 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php @@ -272,7 +272,7 @@ class LdapManagerTest extends LdapTestCase $this->expectException(UpdateOperationException::class); - $entryManager->applyOperations($entry->getDn(), [new UpdateOperation(LDAP_MODIFY_BATCH_REMOVE_ALL, 'mail', [])]); + $entryManager->applyOperations($entry->getDn(), [new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE_ALL, 'mail', [])]); } public function testLdapApplyOperationsWithWrongConstantError() @@ -295,8 +295,8 @@ class LdapManagerTest extends LdapTestCase $entry = $result[0]; $entryManager->applyOperations($entry->getDn(), [ - new UpdateOperation(LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org', 'fabpot2@example.org']), - new UpdateOperation(LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org', 'fabpot2@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']), ]); $result = $this->executeSearchQuery(1); @@ -305,8 +305,8 @@ class LdapManagerTest extends LdapTestCase $this->assertCount(6, $newEntry->getAttribute('mail')); $entryManager->applyOperations($entry->getDn(), [ - new UpdateOperation(LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot@example.org', 'fabpot2@example.org']), - new UpdateOperation(LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot@example.org', 'fabpot2@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']), ]); $result = $this->executeSearchQuery(1); @@ -318,13 +318,13 @@ class LdapManagerTest extends LdapTestCase public function testUpdateOperationsWithIterator() { $iteratorAdd = new \ArrayIterator([ - new UpdateOperation(LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org', 'fabpot2@example.org']), - new UpdateOperation(LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org', 'fabpot2@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']), ]); $iteratorRemove = new \ArrayIterator([ - new UpdateOperation(LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot@example.org', 'fabpot2@example.org']), - new UpdateOperation(LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot@example.org', 'fabpot2@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']), ]); $entryManager = $this->adapter->getEntryManager(); @@ -350,8 +350,8 @@ class LdapManagerTest extends LdapTestCase public function testUpdateOperationsThrowsExceptionWhenAddedDuplicatedValue() { $duplicateIterator = new \ArrayIterator([ - new UpdateOperation(LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org']), - new UpdateOperation(LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org']), + new UpdateOperation(\LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org']), ]); $entryManager = $this->adapter->getEntryManager(); diff --git a/src/Symfony/Component/Lock/Store/FlockStore.php b/src/Symfony/Component/Lock/Store/FlockStore.php index b2a8bc20d5..4f2fca8b50 100644 --- a/src/Symfony/Component/Lock/Store/FlockStore.php +++ b/src/Symfony/Component/Lock/Store/FlockStore.php @@ -95,7 +95,7 @@ class FlockStore implements BlockingStoreInterface // On Windows, even if PHP doc says the contrary, LOCK_NB works, see // https://bugs.php.net/54129 - if (!flock($handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) { + if (!flock($handle, \LOCK_EX | ($blocking ? 0 : \LOCK_NB))) { fclose($handle); throw new LockConflictedException(); } @@ -123,7 +123,7 @@ class FlockStore implements BlockingStoreInterface $handle = $key->getState(__CLASS__); - flock($handle, LOCK_UN | LOCK_NB); + flock($handle, \LOCK_UN | \LOCK_NB); fclose($handle); $key->removeState(__CLASS__); diff --git a/src/Symfony/Component/Lock/Store/MongoDbStore.php b/src/Symfony/Component/Lock/Store/MongoDbStore.php index 76a010fa30..5959c5c16b 100644 --- a/src/Symfony/Component/Lock/Store/MongoDbStore.php +++ b/src/Symfony/Component/Lock/Store/MongoDbStore.php @@ -217,7 +217,7 @@ class MongoDbStore implements BlockingStoreInterface throw new LockAcquiringException('Failed to acquire lock.', 0, $e); } - if ($this->options['gcProbablity'] > 0.0 && (1.0 === $this->options['gcProbablity'] || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->options['gcProbablity'])) { + if ($this->options['gcProbablity'] > 0.0 && (1.0 === $this->options['gcProbablity'] || (random_int(0, \PHP_INT_MAX) / \PHP_INT_MAX) <= $this->options['gcProbablity'])) { $this->createTtlIndex(); } diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php index d1c3ac9037..d76b5db78d 100644 --- a/src/Symfony/Component/Lock/Store/PdoStore.php +++ b/src/Symfony/Component/Lock/Store/PdoStore.php @@ -153,7 +153,7 @@ class PdoStore implements PersistingStoreInterface $this->putOffExpiration($key, $this->initialTtl); } - if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) { + if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, \PHP_INT_MAX) / \PHP_INT_MAX) <= $this->gcProbability)) { $this->prune(); } diff --git a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php index fdb1df65ac..c73ac06f3c 100644 --- a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php +++ b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php @@ -37,7 +37,7 @@ class RetryTillSaveStore implements BlockingStoreInterface, LoggerAwareInterface * @param int $retrySleep Duration in ms between 2 retry * @param int $retryCount Maximum amount of retry */ - public function __construct(PersistingStoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX) + public function __construct(PersistingStoreInterface $decorated, int $retrySleep = 100, int $retryCount = \PHP_INT_MAX) { $this->decorated = $decorated; $this->retrySleep = $retrySleep; diff --git a/src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php index 55d8d34c86..7bcf05a8df 100644 --- a/src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php +++ b/src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php @@ -50,11 +50,11 @@ trait BlockingStoreTestTrait $parentPID = posix_getpid(); // Block SIGHUP signal - pcntl_sigprocmask(SIG_BLOCK, [SIGHUP]); + pcntl_sigprocmask(\SIG_BLOCK, [\SIGHUP]); if ($childPID = pcntl_fork()) { // Wait the start of the child - pcntl_sigwaitinfo([SIGHUP], $info); + pcntl_sigwaitinfo([\SIGHUP], $info); $store = $this->getStore(); try { @@ -66,7 +66,7 @@ trait BlockingStoreTestTrait } // send the ready signal to the child - posix_kill($childPID, SIGHUP); + posix_kill($childPID, \SIGHUP); // This call should be blocked by the child #1 try { @@ -82,23 +82,23 @@ trait BlockingStoreTestTrait } } else { // Block SIGHUP signal - pcntl_sigprocmask(SIG_BLOCK, [SIGHUP]); + pcntl_sigprocmask(\SIG_BLOCK, [\SIGHUP]); try { $store = $this->getStore(); $store->save($key); // send the ready signal to the parent - posix_kill($parentPID, SIGHUP); + posix_kill($parentPID, \SIGHUP); // Wait for the parent to be ready - pcntl_sigwaitinfo([SIGHUP], $info); + pcntl_sigwaitinfo([\SIGHUP], $info); // Wait ClockDelay to let parent assert to finish usleep($clockDelay); $store->delete($key); exit(0); } catch (\Throwable $e) { - posix_kill($parentPID, SIGHUP); + posix_kill($parentPID, \SIGHUP); exit(1); } } diff --git a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php index cf537a4c24..0611e2802c 100644 --- a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php @@ -47,22 +47,22 @@ class SemaphoreStoreTest extends AbstractStoreTest private function getOpenedSemaphores() { - if ('Darwin' === PHP_OS) { - $lines = explode(PHP_EOL, trim(shell_exec('ipcs -s'))); + if ('Darwin' === \PHP_OS) { + $lines = explode(\PHP_EOL, trim(shell_exec('ipcs -s'))); if (-1 === $start = array_search('Semaphores:', $lines)) { - throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore list, got '.implode(PHP_EOL, $lines)); + throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore list, got '.implode(\PHP_EOL, $lines)); } return \count(\array_slice($lines, ++$start)); } - $lines = explode(PHP_EOL, trim(shell_exec('LC_ALL=C ipcs -su'))); + $lines = explode(\PHP_EOL, trim(shell_exec('LC_ALL=C ipcs -su'))); if ('------ Semaphore Status --------' !== $lines[0]) { - throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore status, got '.implode(PHP_EOL, $lines)); + throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore status, got '.implode(\PHP_EOL, $lines)); } list($key, $value) = explode(' = ', $lines[1]); if ('used arrays' !== $key) { - throw new \Exception('Failed to extract list of opened semaphores. Expected a "used arrays" key, got '.implode(PHP_EOL, $lines)); + throw new \Exception('Failed to extract list of opened semaphores. Expected a "used arrays" key, got '.implode(\PHP_EOL, $lines)); } return (int) $value; diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php b/src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php index 636a218de1..76b0356f7f 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php @@ -135,7 +135,7 @@ class MailgunApiTransport extends AbstractApiTransport } else { // fallback to prefix with "h:" to not break BC $headerName = 'h:'.$name; - @trigger_error(sprintf('Not prefixing the Mailgun header name with "h:" is deprecated since Symfony 5.1. Use header name "%s" instead.', $headerName), E_USER_DEPRECATED); + @trigger_error(sprintf('Not prefixing the Mailgun header name with "h:" is deprecated since Symfony 5.1. Use header name "%s" instead.', $headerName), \E_USER_DEPRECATED); } $payload[$headerName] = $header->getBodyAsString(); diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php b/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php index 63b05e51ff..e2a280e49d 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php @@ -29,7 +29,7 @@ final class EsmtpTransportFactory extends AbstractTransportFactory $transport = new EsmtpTransport($host, $port, $tls, $this->dispatcher, $this->logger); - if ('' !== $dsn->getOption('verify_peer') && !filter_var($dsn->getOption('verify_peer', true), FILTER_VALIDATE_BOOLEAN)) { + if ('' !== $dsn->getOption('verify_peer') && !filter_var($dsn->getOption('verify_peer', true), \FILTER_VALIDATE_BOOLEAN)) { /** @var SocketStream $stream */ $stream = $transport->getStream(); $streamOptions = $stream->getStreamOptions(); diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php b/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php index 26f2057f94..365bcd1f8b 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php @@ -103,9 +103,9 @@ class SmtpTransport extends AbstractTransport public function setLocalDomain(string $domain): self { if ('' !== $domain && '[' !== $domain[0]) { - if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + if (filter_var($domain, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { $domain = '['.$domain.']'; - } elseif (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + } elseif (filter_var($domain, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { $domain = '[IPv6:'.$domain.']'; } } diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php index 41e8c368e1..3ff44105d1 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php @@ -131,7 +131,7 @@ final class SocketStream extends AbstractStream $options = array_merge($options, $this->streamContextOptions); } // do it unconditionnally as it will be used by STARTTLS as well if supported - $options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? STREAM_CRYPTO_METHOD_TLS_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; + $options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? \STREAM_CRYPTO_METHOD_TLS_CLIENT | \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; $streamContext = stream_context_create($options); $timeout = $this->getTimeout(); @@ -139,7 +139,7 @@ final class SocketStream extends AbstractStream throw new TransportException(sprintf('Connection could not be established with host "%s": ', $this->url).$msg); }); try { - $this->stream = stream_socket_client($this->url, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); + $this->stream = stream_socket_client($this->url, $errno, $errstr, $timeout, \STREAM_CLIENT_CONNECT, $streamContext); } finally { restore_error_handler(); } diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpReceiverTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpReceiverTest.php index a674c60b47..9116a3682e 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpReceiverTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpReceiverTest.php @@ -67,7 +67,7 @@ class AmqpReceiverTest extends TestCase $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); $connection->method('getQueueNames')->willReturn(['queueName']); $connection->method('get')->with('queueName')->willReturn($amqpEnvelope); - $connection->method('nack')->with($amqpEnvelope, 'queueName', AMQP_NOPARAM)->willThrowException(new \AMQPException()); + $connection->method('nack')->with($amqpEnvelope, 'queueName', \AMQP_NOPARAM)->willThrowException(new \AMQPException()); $receiver = new AmqpReceiver($connection, $serializer); $receiver->reject(new Envelope(new \stdClass(), [new AmqpReceivedStamp($amqpEnvelope, 'queueName')])); diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpSenderTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpSenderTest.php index ff83cd1c0c..47f47eeb7b 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpSenderTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpSenderTest.php @@ -79,7 +79,7 @@ class AmqpSenderTest extends TestCase $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); unset($encoded['headers']['Content-Type']); - $stamp = new AmqpStamp(null, AMQP_NOPARAM, ['content_type' => 'application/json']); + $stamp = new AmqpStamp(null, \AMQP_NOPARAM, ['content_type' => 'application/json']); $connection->expects($this->once())->method('publish')->with($encoded['body'], $encoded['headers'], 0, $stamp); $sender = new AmqpSender($connection, $serializer); @@ -88,7 +88,7 @@ class AmqpSenderTest extends TestCase public function testContentTypeHeaderDoesNotOverwriteAttribute() { - $envelope = (new Envelope(new DummyMessage('Oy')))->with($stamp = new AmqpStamp('rk', AMQP_NOPARAM, ['content_type' => 'custom'])); + $envelope = (new Envelope(new DummyMessage('Oy')))->with($stamp = new AmqpStamp('rk', \AMQP_NOPARAM, ['content_type' => 'custom'])); $encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class, 'Content-Type' => 'application/json']]; $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpStampTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpStampTest.php index 20427b7adb..16bcf027f2 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpStampTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpStampTest.php @@ -23,15 +23,15 @@ class AmqpStampTest extends TestCase { $stamp = new AmqpStamp('routing_key'); $this->assertSame('routing_key', $stamp->getRoutingKey()); - $this->assertSame(AMQP_NOPARAM, $stamp->getFlags()); + $this->assertSame(\AMQP_NOPARAM, $stamp->getFlags()); $this->assertSame([], $stamp->getAttributes()); } public function testFlagsAndAttributes() { - $stamp = new AmqpStamp(null, AMQP_DURABLE, ['delivery_mode' => 'unknown']); + $stamp = new AmqpStamp(null, \AMQP_DURABLE, ['delivery_mode' => 'unknown']); $this->assertNull($stamp->getRoutingKey()); - $this->assertSame(AMQP_DURABLE, $stamp->getFlags()); + $this->assertSame(\AMQP_DURABLE, $stamp->getFlags()); $this->assertSame(['delivery_mode' => 'unknown'], $stamp->getAttributes()); } @@ -49,7 +49,7 @@ class AmqpStampTest extends TestCase $this->assertSame($amqpEnvelope->getDeliveryMode(), $stamp->getAttributes()['delivery_mode']); $this->assertSame($amqpEnvelope->getPriority(), $stamp->getAttributes()['priority']); $this->assertSame($amqpEnvelope->getAppId(), $stamp->getAttributes()['app_id']); - $this->assertSame(AMQP_NOPARAM, $stamp->getFlags()); + $this->assertSame(\AMQP_NOPARAM, $stamp->getFlags()); } public function testCreateFromAmqpEnvelopeWithPreviousStamp() @@ -60,7 +60,7 @@ class AmqpStampTest extends TestCase $amqpEnvelope->method('getPriority')->willReturn(5); $amqpEnvelope->method('getAppId')->willReturn('appid'); - $previousStamp = new AmqpStamp('otherroutingkey', AMQP_MANDATORY, ['priority' => 8]); + $previousStamp = new AmqpStamp('otherroutingkey', \AMQP_MANDATORY, ['priority' => 8]); $stamp = AmqpStamp::createFromAmqpEnvelope($amqpEnvelope, $previousStamp); @@ -68,6 +68,6 @@ class AmqpStampTest extends TestCase $this->assertSame($amqpEnvelope->getDeliveryMode(), $stamp->getAttributes()['delivery_mode']); $this->assertSame(8, $stamp->getAttributes()['priority']); $this->assertSame($amqpEnvelope->getAppId(), $stamp->getAttributes()['app_id']); - $this->assertSame(AMQP_MANDATORY, $stamp->getFlags()); + $this->assertSame(\AMQP_MANDATORY, $stamp->getFlags()); } } diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php index 103d3d0c61..78490469ca 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php @@ -268,7 +268,7 @@ class ConnectionTest extends TestCase ); $amqpExchange->expects($this->once())->method('declareExchange'); - $amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); + $amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); $amqpQueue->expects($this->once())->method('declareQueue'); $amqpQueue->expects($this->once())->method('bind')->with(self::DEFAULT_EXCHANGE_NAME, null); @@ -291,7 +291,7 @@ class ConnectionTest extends TestCase $factory->method('createQueue')->will($this->onConsecutiveCalls($amqpQueue0, $amqpQueue1)); $amqpExchange->expects($this->once())->method('declareExchange'); - $amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key', AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); + $amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); $amqpQueue0->expects($this->once())->method('declareQueue'); $amqpQueue0->expects($this->exactly(2))->method('bind')->withConsecutive( [self::DEFAULT_EXCHANGE_NAME, 'binding_key0'], @@ -328,7 +328,7 @@ class ConnectionTest extends TestCase $factory->method('createQueue')->willReturn($amqpQueue); $amqpExchange->expects($this->once())->method('declareExchange'); - $amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); + $amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); $amqpQueue->expects($this->once())->method('declareQueue'); $amqpQueue->expects($this->exactly(1))->method('bind')->withConsecutive( [self::DEFAULT_EXCHANGE_NAME, null, ['x-match' => 'all']] @@ -441,7 +441,7 @@ class ConnectionTest extends TestCase $delayQueue->expects($this->once())->method('declareQueue'); $delayQueue->expects($this->once())->method('bind')->with('delays', 'delay_messages__5000'); - $delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages__5000', AMQP_NOPARAM, ['headers' => ['x-some-headers' => 'foo'], 'delivery_mode' => 2, 'timestamp' => time()]); + $delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages__5000', \AMQP_NOPARAM, ['headers' => ['x-some-headers' => 'foo'], 'delivery_mode' => 2, 'timestamp' => time()]); $connection = Connection::fromDsn('amqp://localhost', [], $factory); $connection->publish('{}', ['x-some-headers' => 'foo'], 5000); @@ -483,7 +483,7 @@ class ConnectionTest extends TestCase $delayQueue->expects($this->once())->method('declareQueue'); $delayQueue->expects($this->once())->method('bind')->with('delays', 'delay_messages__120000'); - $delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages__120000', AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); + $delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages__120000', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); $connection->publish('{}', [], 120000); } @@ -515,10 +515,10 @@ class ConnectionTest extends TestCase $amqpExchange = $this->createMock(\AMQPExchange::class) ); - $amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => ['Foo' => 'X', 'Bar' => 'Y'], 'delivery_mode' => 2, 'timestamp' => time()]); + $amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => ['Foo' => 'X', 'Bar' => 'Y'], 'delivery_mode' => 2, 'timestamp' => time()]); $connection = Connection::fromDsn('amqp://localhost', [], $factory); - $connection->publish('body', ['Foo' => 'X'], 0, new AmqpStamp(null, AMQP_NOPARAM, ['headers' => ['Bar' => 'Y']])); + $connection->publish('body', ['Foo' => 'X'], 0, new AmqpStamp(null, \AMQP_NOPARAM, ['headers' => ['Bar' => 'Y']])); } public function testAmqpStampDelireryModeIsUsed() @@ -530,10 +530,10 @@ class ConnectionTest extends TestCase $amqpExchange = $this->createMock(\AMQPExchange::class) ); - $amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 1, 'timestamp' => time()]); + $amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 1, 'timestamp' => time()]); $connection = Connection::fromDsn('amqp://localhost', [], $factory); - $connection->publish('body', [], 0, new AmqpStamp(null, AMQP_NOPARAM, ['delivery_mode' => 1])); + $connection->publish('body', [], 0, new AmqpStamp(null, \AMQP_NOPARAM, ['delivery_mode' => 1])); } public function testItCanPublishWithTheDefaultRoutingKey() @@ -602,7 +602,7 @@ class ConnectionTest extends TestCase $delayQueue->expects($this->once())->method('declareQueue'); $delayQueue->expects($this->once())->method('bind')->with('delays', 'delay_messages_routing_key_120000'); - $delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages_routing_key_120000', AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); + $delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages_routing_key_120000', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); $connection->publish('{}', [], 120000, new AmqpStamp('routing_key')); } @@ -618,12 +618,12 @@ class ConnectionTest extends TestCase $amqpExchange->expects($this->once())->method('publish')->with( 'body', 'routing_key', - AMQP_IMMEDIATE, + \AMQP_IMMEDIATE, ['delivery_mode' => 2, 'headers' => ['type' => DummyMessage::class], 'timestamp' => time()] ); $connection = Connection::fromDsn('amqp://localhost', [], $factory); - $connection->publish('body', ['type' => DummyMessage::class], 0, new AmqpStamp('routing_key', AMQP_IMMEDIATE, ['delivery_mode' => 2])); + $connection->publish('body', ['type' => DummyMessage::class], 0, new AmqpStamp('routing_key', \AMQP_IMMEDIATE, ['delivery_mode' => 2])); } } diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpReceiver.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpReceiver.php index a5c89ef138..009e7be8d5 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpReceiver.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpReceiver.php @@ -120,7 +120,7 @@ class AmqpReceiver implements ReceiverInterface, MessageCountAwareInterface private function rejectAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, string $queueName): void { try { - $this->connection->nack($amqpEnvelope, $queueName, AMQP_NOPARAM); + $this->connection->nack($amqpEnvelope, $queueName, \AMQP_NOPARAM); } catch (\AMQPException $exception) { throw new TransportException($exception->getMessage(), 0, $exception); } diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpStamp.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpStamp.php index 9e3f63e0a2..7d013974cc 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpStamp.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpStamp.php @@ -23,7 +23,7 @@ final class AmqpStamp implements NonSendableStampInterface private $flags; private $attributes; - public function __construct(string $routingKey = null, int $flags = AMQP_NOPARAM, array $attributes = []) + public function __construct(string $routingKey = null, int $flags = \AMQP_NOPARAM, array $attributes = []) { $this->routingKey = $routingKey; $this->flags = $flags; @@ -62,14 +62,14 @@ final class AmqpStamp implements NonSendableStampInterface $attr['type'] = $attr['type'] ?? $amqpEnvelope->getType(); $attr['reply_to'] = $attr['reply_to'] ?? $amqpEnvelope->getReplyTo(); - return new self($previousStamp->routingKey ?? $amqpEnvelope->getRoutingKey(), $previousStamp->flags ?? AMQP_NOPARAM, $attr); + return new self($previousStamp->routingKey ?? $amqpEnvelope->getRoutingKey(), $previousStamp->flags ?? \AMQP_NOPARAM, $attr); } public static function createWithAttributes(array $attributes, self $previousStamp = null): self { return new self( $previousStamp->routingKey ?? null, - $previousStamp->flags ?? AMQP_NOPARAM, + $previousStamp->flags ?? \AMQP_NOPARAM, array_merge($previousStamp->attributes ?? [], $attributes) ); } diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php index 7b9f49fa3a..bda105c31a 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php @@ -322,7 +322,7 @@ class Connection $exchange->publish( $body, $routingKey, - $amqpStamp ? $amqpStamp->getFlags() : AMQP_NOPARAM, + $amqpStamp ? $amqpStamp->getFlags() : \AMQP_NOPARAM, $attributes ); } @@ -343,8 +343,8 @@ class Connection if (null === $this->amqpDelayExchange) { $this->amqpDelayExchange = $this->amqpFactory->createExchange($this->channel()); $this->amqpDelayExchange->setName($this->connectionOptions['delay']['exchange_name']); - $this->amqpDelayExchange->setType(AMQP_EX_TYPE_DIRECT); - $this->amqpDelayExchange->setFlags(AMQP_DURABLE); + $this->amqpDelayExchange->setType(\AMQP_EX_TYPE_DIRECT); + $this->amqpDelayExchange->setFlags(\AMQP_DURABLE); } return $this->amqpDelayExchange; @@ -367,7 +367,7 @@ class Connection [$delay, $this->exchangeOptions['name'], $routingKey ?? ''], $this->connectionOptions['delay']['queue_name_pattern'] )); - $queue->setFlags(AMQP_DURABLE); + $queue->setFlags(\AMQP_DURABLE); $queue->setArguments([ 'x-message-ttl' => $delay, // delete the delay queue 10 seconds after the message expires @@ -427,7 +427,7 @@ class Connection return $this->queue($queueName)->ack($message->getDeliveryTag()); } - public function nack(\AMQPEnvelope $message, string $queueName, int $flags = AMQP_NOPARAM): bool + public function nack(\AMQPEnvelope $message, string $queueName, int $flags = \AMQP_NOPARAM): bool { return $this->queue($queueName)->nack($message->getDeliveryTag(), $flags); } @@ -490,7 +490,7 @@ class Connection $amqpQueue = $this->amqpFactory->createQueue($this->channel()); $amqpQueue->setName($queueName); - $amqpQueue->setFlags($queueConfig['flags'] ?? AMQP_DURABLE); + $amqpQueue->setFlags($queueConfig['flags'] ?? \AMQP_DURABLE); if (isset($queueConfig['arguments'])) { $amqpQueue->setArguments($queueConfig['arguments']); @@ -507,8 +507,8 @@ class Connection if (null === $this->amqpExchange) { $this->amqpExchange = $this->amqpFactory->createExchange($this->channel()); $this->amqpExchange->setName($this->exchangeOptions['name']); - $this->amqpExchange->setType($this->exchangeOptions['type'] ?? AMQP_EX_TYPE_FANOUT); - $this->amqpExchange->setFlags($this->exchangeOptions['flags'] ?? AMQP_DURABLE); + $this->amqpExchange->setType($this->exchangeOptions['type'] ?? \AMQP_EX_TYPE_FANOUT); + $this->amqpExchange->setFlags($this->exchangeOptions['flags'] ?? \AMQP_DURABLE); if (isset($this->exchangeOptions['arguments'])) { $this->amqpExchange->setArguments($this->exchangeOptions['arguments']); diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php index 2b7c1fd16b..f2545c1786 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php @@ -91,7 +91,7 @@ class Connection implements ResetInterface $configuration = ['connection' => $components['host']]; $configuration += $query + $options + static::DEFAULT_OPTIONS; - $configuration['auto_setup'] = filter_var($configuration['auto_setup'], FILTER_VALIDATE_BOOLEAN); + $configuration['auto_setup'] = filter_var($configuration['auto_setup'], \FILTER_VALIDATE_BOOLEAN); // check for extra keys in options $optionsExtraKeys = array_diff(array_keys($options), array_keys(static::DEFAULT_OPTIONS)); diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php index d47fae9608..b0a4279ea1 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php @@ -112,43 +112,43 @@ class Connection $autoSetup = null; if (\array_key_exists('auto_setup', $redisOptions)) { - $autoSetup = filter_var($redisOptions['auto_setup'], FILTER_VALIDATE_BOOLEAN); + $autoSetup = filter_var($redisOptions['auto_setup'], \FILTER_VALIDATE_BOOLEAN); unset($redisOptions['auto_setup']); } $maxEntries = null; if (\array_key_exists('stream_max_entries', $redisOptions)) { - $maxEntries = filter_var($redisOptions['stream_max_entries'], FILTER_VALIDATE_INT); + $maxEntries = filter_var($redisOptions['stream_max_entries'], \FILTER_VALIDATE_INT); unset($redisOptions['stream_max_entries']); } $deleteAfterAck = null; if (\array_key_exists('delete_after_ack', $redisOptions)) { - $deleteAfterAck = filter_var($redisOptions['delete_after_ack'], FILTER_VALIDATE_BOOLEAN); + $deleteAfterAck = filter_var($redisOptions['delete_after_ack'], \FILTER_VALIDATE_BOOLEAN); unset($redisOptions['delete_after_ack']); } $dbIndex = null; if (\array_key_exists('dbindex', $redisOptions)) { - $dbIndex = filter_var($redisOptions['dbindex'], FILTER_VALIDATE_INT); + $dbIndex = filter_var($redisOptions['dbindex'], \FILTER_VALIDATE_INT); unset($redisOptions['dbindex']); } $tls = false; if (\array_key_exists('tls', $redisOptions)) { - $tls = filter_var($redisOptions['tls'], FILTER_VALIDATE_BOOLEAN); + $tls = filter_var($redisOptions['tls'], \FILTER_VALIDATE_BOOLEAN); unset($redisOptions['tls']); } $redeliverTimeout = null; if (\array_key_exists('redeliver_timeout', $redisOptions)) { - $redeliverTimeout = filter_var($redisOptions['redeliver_timeout'], FILTER_VALIDATE_INT); + $redeliverTimeout = filter_var($redisOptions['redeliver_timeout'], \FILTER_VALIDATE_INT); unset($redisOptions['redeliver_timeout']); } $claimInterval = null; if (\array_key_exists('claim_interval', $redisOptions)) { - $claimInterval = filter_var($redisOptions['claim_interval'], FILTER_VALIDATE_INT); + $claimInterval = filter_var($redisOptions['claim_interval'], \FILTER_VALIDATE_INT); unset($redisOptions['claim_interval']); } diff --git a/src/Symfony/Component/Messenger/EventListener/StopWorkerOnSigtermSignalListener.php b/src/Symfony/Component/Messenger/EventListener/StopWorkerOnSigtermSignalListener.php index 9054b19176..70b05b18b0 100644 --- a/src/Symfony/Component/Messenger/EventListener/StopWorkerOnSigtermSignalListener.php +++ b/src/Symfony/Component/Messenger/EventListener/StopWorkerOnSigtermSignalListener.php @@ -21,7 +21,7 @@ class StopWorkerOnSigtermSignalListener implements EventSubscriberInterface { public function onWorkerStarted(WorkerStartedEvent $event): void { - pcntl_signal(SIGTERM, static function () use ($event) { + pcntl_signal(\SIGTERM, static function () use ($event) { $event->getWorker()->stop(); }); } diff --git a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php index 54c52d6622..92d6b855d5 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php @@ -30,7 +30,7 @@ class DebugCommandTest extends TestCase { protected function setUp(): void { - putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); + putenv('COLUMNS='.(119 + \strlen(\PHP_EOL))); } protected function tearDown(): void diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php index 516905a960..e73d7b26b2 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/Normalizer/FlattenExceptionNormalizerTest.php @@ -100,14 +100,14 @@ class FlattenExceptionNormalizerTest extends TestCase 'namespace' => '', 'short_class' => '', 'class' => '', 'type' => '', 'function' => '', 'file' => 'foo.php', 'line' => 123, 'args' => [], ], ], - 'trace_as_string' => '#0 foo.php(123): foo()'.PHP_EOL.'#1 bar.php(456): bar()', + 'trace_as_string' => '#0 foo.php(123): foo()'.\PHP_EOL.'#1 bar.php(456): bar()', ], 'trace' => [ [ 'namespace' => '', 'short_class' => '', 'class' => '', 'type' => '', 'function' => '', 'file' => 'foo.php', 'line' => 123, 'args' => [], ], ], - 'trace_as_string' => '#0 foo.php(123): foo()'.PHP_EOL.'#1 bar.php(456): bar()', + 'trace_as_string' => '#0 foo.php(123): foo()'.\PHP_EOL.'#1 bar.php(456): bar()', ]; $exception = $this->normalizer->denormalize($normalized, FlattenException::class); diff --git a/src/Symfony/Component/Messenger/TraceableMessageBus.php b/src/Symfony/Component/Messenger/TraceableMessageBus.php index ed4807199a..39edaa8c5b 100644 --- a/src/Symfony/Component/Messenger/TraceableMessageBus.php +++ b/src/Symfony/Component/Messenger/TraceableMessageBus.php @@ -60,7 +60,7 @@ class TraceableMessageBus implements MessageBusInterface private function getCaller(): array { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 8); + $trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 8); $file = $trace[1]['file']; $line = $trace[1]['line']; diff --git a/src/Symfony/Component/Mime/Crypto/DkimSigner.php b/src/Symfony/Component/Mime/Crypto/DkimSigner.php index 3ddd56d381..299c82a5cc 100644 --- a/src/Symfony/Component/Mime/Crypto/DkimSigner.php +++ b/src/Symfony/Component/Mime/Crypto/DkimSigner.php @@ -53,7 +53,7 @@ final class DkimSigner $this->defaultOptions = $defaultOptions + [ 'algorithm' => self::ALGO_SHA256, 'signature_expiration_delay' => 0, - 'body_max_length' => PHP_INT_MAX, + 'body_max_length' => \PHP_INT_MAX, 'body_show_length' => false, 'header_canon' => self::CANON_RELAXED, 'body_canon' => self::CANON_RELAXED, @@ -117,7 +117,7 @@ final class DkimSigner $header = new UnstructuredHeader('DKIM-Signature', $value); $headerCanonData .= rtrim($this->canonicalizeHeader($header->toString()."\r\n b=", $options['header_canon'])); if (self::ALGO_SHA256 === $options['algorithm']) { - if (!openssl_sign($headerCanonData, $signature, $this->key, OPENSSL_ALGO_SHA256)) { + if (!openssl_sign($headerCanonData, $signature, $this->key, \OPENSSL_ALGO_SHA256)) { throw new RuntimeException('Unable to sign DKIM hash: '.openssl_error_string()); } } else { diff --git a/src/Symfony/Component/Mime/Crypto/SMimeEncrypter.php b/src/Symfony/Component/Mime/Crypto/SMimeEncrypter.php index d6961a6e81..9081860d80 100644 --- a/src/Symfony/Component/Mime/Crypto/SMimeEncrypter.php +++ b/src/Symfony/Component/Mime/Crypto/SMimeEncrypter.php @@ -38,7 +38,7 @@ final class SMimeEncrypter extends SMime $this->certs = $this->normalizeFilePath($certificate); } - $this->cipher = $cipher ?? OPENSSL_CIPHER_AES_256_CBC; + $this->cipher = $cipher ?? \OPENSSL_CIPHER_AES_256_CBC; } public function encrypt(Message $message): Message diff --git a/src/Symfony/Component/Mime/Crypto/SMimeSigner.php b/src/Symfony/Component/Mime/Crypto/SMimeSigner.php index 1b555375ce..5b94a454e8 100644 --- a/src/Symfony/Component/Mime/Crypto/SMimeSigner.php +++ b/src/Symfony/Component/Mime/Crypto/SMimeSigner.php @@ -45,7 +45,7 @@ final class SMimeSigner extends SMime $this->signPrivateKey = $this->normalizeFilePath($privateKey); } - $this->signOptions = $signOptions ?? PKCS7_DETACHED; + $this->signOptions = $signOptions ?? \PKCS7_DETACHED; $this->extraCerts = $extraCerts ? realpath($extraCerts) : null; } diff --git a/src/Symfony/Component/Mime/Encoder/Base64ContentEncoder.php b/src/Symfony/Component/Mime/Encoder/Base64ContentEncoder.php index 881eaab77b..440868af70 100644 --- a/src/Symfony/Component/Mime/Encoder/Base64ContentEncoder.php +++ b/src/Symfony/Component/Mime/Encoder/Base64ContentEncoder.php @@ -24,7 +24,7 @@ final class Base64ContentEncoder extends Base64Encoder implements ContentEncoder throw new \TypeError(sprintf('Method "%s" takes a stream as a first argument.', __METHOD__)); } - $filter = stream_filter_append($stream, 'convert.base64-encode', STREAM_FILTER_READ, [ + $filter = stream_filter_append($stream, 'convert.base64-encode', \STREAM_FILTER_READ, [ 'line-length' => 0 >= $maxLineLength || 76 < $maxLineLength ? 76 : $maxLineLength, 'line-break-chars' => "\r\n", ]); diff --git a/src/Symfony/Component/Mime/Encoder/IdnAddressEncoder.php b/src/Symfony/Component/Mime/Encoder/IdnAddressEncoder.php index 21c7a8df3e..a14035ba79 100644 --- a/src/Symfony/Component/Mime/Encoder/IdnAddressEncoder.php +++ b/src/Symfony/Component/Mime/Encoder/IdnAddressEncoder.php @@ -35,7 +35,7 @@ final class IdnAddressEncoder implements AddressEncoderInterface $domain = substr($address, $i + 1); if (preg_match('/[^\x00-\x7F]/', $domain)) { - $address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)); + $address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, \INTL_IDNA_VARIANT_UTS46)); } } diff --git a/src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php b/src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php index 3028159858..c6c7559af1 100644 --- a/src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php +++ b/src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php @@ -54,7 +54,7 @@ class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface throw new LogicException(sprintf('The "%s" guesser is not supported.', __CLASS__)); } - if (false === $finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) { + if (false === $finfo = new \finfo(\FILEINFO_MIME_TYPE, $this->magicFile)) { return null; } $mimeType = $finfo->file($path); diff --git a/src/Symfony/Component/Mime/Header/AbstractHeader.php b/src/Symfony/Component/Mime/Header/AbstractHeader.php index 548c192692..e93b87aeb7 100644 --- a/src/Symfony/Component/Mime/Header/AbstractHeader.php +++ b/src/Symfony/Component/Mime/Header/AbstractHeader.php @@ -220,7 +220,7 @@ abstract class AbstractHeader implements HeaderInterface */ protected function generateTokenLines(string $token): array { - return preg_split('~(\r\n)~', $token, -1, PREG_SPLIT_DELIM_CAPTURE); + return preg_split('~(\r\n)~', $token, -1, \PREG_SPLIT_DELIM_CAPTURE); } /** diff --git a/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php b/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php index 76c48e46f7..9e3c9a2a85 100644 --- a/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php +++ b/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php @@ -40,7 +40,7 @@ final class FormDataPart extends AbstractMultipartPart $this->fields[$name] = $value; } // HTTP does not support \r\n in header values - $this->getHeaders()->setMaxLineLength(PHP_INT_MAX); + $this->getHeaders()->setMaxLineLength(\PHP_INT_MAX); } public function getMediaSubtype(): string @@ -95,7 +95,7 @@ final class FormDataPart extends AbstractMultipartPart $part->setDisposition('form-data'); $part->setName($name); // HTTP does not support \r\n in header values - $part->getHeaders()->setMaxLineLength(PHP_INT_MAX); + $part->getHeaders()->setMaxLineLength(\PHP_INT_MAX); $r->setValue($part, '8bit'); return $part; diff --git a/src/Symfony/Component/Mime/Part/TextPart.php b/src/Symfony/Component/Mime/Part/TextPart.php index 8772a3367c..20bfd4ae69 100644 --- a/src/Symfony/Component/Mime/Part/TextPart.php +++ b/src/Symfony/Component/Mime/Part/TextPart.php @@ -50,7 +50,7 @@ class TextPart extends AbstractPart $this->body = $body; $this->charset = $charset; $this->subtype = $subtype; - $this->seekable = \is_resource($body) ? stream_get_meta_data($body)['seekable'] && 0 === fseek($body, 0, SEEK_CUR) : null; + $this->seekable = \is_resource($body) ? stream_get_meta_data($body)['seekable'] && 0 === fseek($body, 0, \SEEK_CUR) : null; if (null === $encoding) { $this->encoding = $this->chooseEncoding(); diff --git a/src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php b/src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php index a7dabfad7a..94905dd7be 100644 --- a/src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php +++ b/src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php @@ -119,39 +119,39 @@ EOF; public function getCanonicalizeHeaderData() { yield 'simple_empty' => [ - DkimSigner::CANON_SIMPLE, "\r\n", '', PHP_INT_MAX, + DkimSigner::CANON_SIMPLE, "\r\n", '', \PHP_INT_MAX, ]; yield 'relaxed_empty' => [ - DkimSigner::CANON_RELAXED, "\r\n", '', PHP_INT_MAX, + DkimSigner::CANON_RELAXED, "\r\n", '', \PHP_INT_MAX, ]; yield 'simple_empty_single_ending_CLRF' => [ - DkimSigner::CANON_SIMPLE, "\r\n", "\r\n", PHP_INT_MAX, + DkimSigner::CANON_SIMPLE, "\r\n", "\r\n", \PHP_INT_MAX, ]; yield 'relaxed_empty_single_ending_CLRF' => [ - DkimSigner::CANON_RELAXED, "\r\n", "\r\n", PHP_INT_MAX, + DkimSigner::CANON_RELAXED, "\r\n", "\r\n", \PHP_INT_MAX, ]; yield 'simple_multiple_ending_CLRF' => [ - DkimSigner::CANON_SIMPLE, "Some body\r\n", "Some body\r\n\r\n\r\n\r\n\r\n\r\n", PHP_INT_MAX, + DkimSigner::CANON_SIMPLE, "Some body\r\n", "Some body\r\n\r\n\r\n\r\n\r\n\r\n", \PHP_INT_MAX, ]; yield 'relaxed_multiple_ending_CLRF' => [ - DkimSigner::CANON_RELAXED, "Some body\r\n", "Some body\r\n\r\n\r\n\r\n\r\n\r\n", PHP_INT_MAX, + DkimSigner::CANON_RELAXED, "Some body\r\n", "Some body\r\n\r\n\r\n\r\n\r\n\r\n", \PHP_INT_MAX, ]; yield 'simple_basic' => [ - DkimSigner::CANON_SIMPLE, "Some body\r\n", "Some body\r\n", PHP_INT_MAX, + DkimSigner::CANON_SIMPLE, "Some body\r\n", "Some body\r\n", \PHP_INT_MAX, ]; yield 'relaxed_basic' => [ - DkimSigner::CANON_RELAXED, "Some body\r\n", "Some body\r\n", PHP_INT_MAX, + DkimSigner::CANON_RELAXED, "Some body\r\n", "Some body\r\n", \PHP_INT_MAX, ]; $body = "Some body with whitespaces\r\n"; yield 'simple_with_many_inline_whitespaces' => [ - DkimSigner::CANON_SIMPLE, $body, $body, PHP_INT_MAX, + DkimSigner::CANON_SIMPLE, $body, $body, \PHP_INT_MAX, ]; yield 'relaxed_with_many_inline_whitespaces' => [ - DkimSigner::CANON_RELAXED, "Some body with whitespaces\r\n", $body, PHP_INT_MAX, + DkimSigner::CANON_RELAXED, "Some body with whitespaces\r\n", $body, \PHP_INT_MAX, ]; yield 'simple_basic_with_length' => [ diff --git a/src/Symfony/Component/Mime/Tests/Crypto/SMimeSignerTest.php b/src/Symfony/Component/Mime/Tests/Crypto/SMimeSignerTest.php index 5522bc6f55..ed13d04683 100644 --- a/src/Symfony/Component/Mime/Tests/Crypto/SMimeSignerTest.php +++ b/src/Symfony/Component/Mime/Tests/Crypto/SMimeSignerTest.php @@ -143,7 +143,7 @@ class SMimeSignerTest extends SMimeTestCase $this->samplesDir.'sign.key', null, $this->samplesDir.'intermediate.crt', - PKCS7_DETACHED + \PKCS7_DETACHED ); $signedMessage = $signer->sign($message); diff --git a/src/Symfony/Component/Mime/Tests/EmailTest.php b/src/Symfony/Component/Mime/Tests/EmailTest.php index 117c19e4f8..e5b48fe6ca 100644 --- a/src/Symfony/Component/Mime/Tests/EmailTest.php +++ b/src/Symfony/Component/Mime/Tests/EmailTest.php @@ -447,11 +447,11 @@ EOF; ], [new JsonEncoder()]); $serialized = $serializer->serialize($e, 'json'); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n = $serializer->deserialize($serialized, Email::class, 'json'); $serialized = $serializer->serialize($e, 'json'); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n->from('fabien@symfony.com'); $expected->from('fabien@symfony.com'); diff --git a/src/Symfony/Component/Mime/Tests/MessageTest.php b/src/Symfony/Component/Mime/Tests/MessageTest.php index ed9b8e6142..6ed5aabdbe 100644 --- a/src/Symfony/Component/Mime/Tests/MessageTest.php +++ b/src/Symfony/Component/Mime/Tests/MessageTest.php @@ -254,12 +254,12 @@ EOF; ], [new JsonEncoder()]); $serialized = $serializer->serialize($e, 'json'); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); $n = $serializer->deserialize($serialized, Message::class, 'json'); $this->assertEquals($expected->getHeaders(), $n->getHeaders()); $serialized = $serializer->serialize($e, 'json'); - $this->assertSame($expectedJson, json_encode(json_decode($serialized), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); } } diff --git a/src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php b/src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php index 6f81224c66..417417f054 100644 --- a/src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php +++ b/src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php @@ -35,14 +35,14 @@ class FormDataPartTest extends TestCase $t = new TextPart($content, 'utf-8', 'plain', '8bit'); $t->setDisposition('form-data'); $t->setName('foo'); - $t->getHeaders()->setMaxLineLength(PHP_INT_MAX); + $t->getHeaders()->setMaxLineLength(\PHP_INT_MAX); $b->setDisposition('form-data'); $b->setName('bar'); - $b->getHeaders()->setMaxLineLength(PHP_INT_MAX); + $b->getHeaders()->setMaxLineLength(\PHP_INT_MAX); $r->setValue($b, '8bit'); $c->setDisposition('form-data'); $c->setName('baz'); - $c->getHeaders()->setMaxLineLength(PHP_INT_MAX); + $c->getHeaders()->setMaxLineLength(\PHP_INT_MAX); $r->setValue($c, '8bit'); $this->assertEquals([$t, $b, $c], $f->getParts()); } diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php index 0c26a22997..d86e835606 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php @@ -77,7 +77,7 @@ final class OvhCloudTransport extends AbstractTransport $headers['X-Ovh-Application'] = $this->applicationKey; $headers['X-Ovh-Timestamp'] = $now; - $toSign = $this->applicationSecret.'+'.$this->consumerKey.'+POST+'.$endpoint.'+'.json_encode($content, JSON_UNESCAPED_SLASHES).'+'.$now; + $toSign = $this->applicationSecret.'+'.$this->consumerKey.'+POST+'.$endpoint.'+'.json_encode($content, \JSON_UNESCAPED_SLASHES).'+'.$now; $headers['X-Ovh-Consumer'] = $this->consumerKey; $headers['X-Ovh-Signature'] = '$1$'.sha1($toSign); diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index 4083e5ee6a..eebdc8c24b 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -555,7 +555,7 @@ class OptionsResolverTest extends TestCase }, ['foo' => 'baz'], [ - 'type' => E_USER_DEPRECATED, + 'type' => \E_USER_DEPRECATED, 'message' => 'Since vendor/package 1.1: The option "foo" is deprecated.', ], 1, @@ -573,7 +573,7 @@ class OptionsResolverTest extends TestCase }, ['foo' => 'baz'], [ - 'type' => E_USER_DEPRECATED, + 'type' => \E_USER_DEPRECATED, 'message' => 'Since vendor/package 1.1: The option "foo" is deprecated, use "bar" option instead.', ], 2, @@ -593,7 +593,7 @@ class OptionsResolverTest extends TestCase }, [], [ - 'type' => E_USER_DEPRECATED, + 'type' => \E_USER_DEPRECATED, 'message' => 'Since vendor/package 1.1: The option "foo" is deprecated.', ], 1, @@ -615,7 +615,7 @@ class OptionsResolverTest extends TestCase }, ['foo' => new \stdClass()], [ - 'type' => E_USER_DEPRECATED, + 'type' => \E_USER_DEPRECATED, 'message' => 'Since vendor/package 1.1: Passing an instance of "stdClass" to option "foo" is deprecated, pass its FQCN instead.', ], 1, @@ -651,7 +651,7 @@ class OptionsResolverTest extends TestCase }, ['foo' => null], // It triggers a deprecation [ - 'type' => E_USER_DEPRECATED, + 'type' => \E_USER_DEPRECATED, 'message' => 'Since vendor/package 1.1: Passing a value different than true or false is deprecated.', ], 1, @@ -687,7 +687,7 @@ class OptionsResolverTest extends TestCase }, ['widget' => 'single_text', 'date_format' => 2], [ - 'type' => E_USER_DEPRECATED, + 'type' => \E_USER_DEPRECATED, 'message' => 'Since vendor/package 1.1: Using the "date_format" option when the "widget" option is set to "single_text" is deprecated.', ], 1, @@ -713,7 +713,7 @@ class OptionsResolverTest extends TestCase }, ['foo' => 'baz'], // It triggers a deprecation [ - 'type' => E_USER_DEPRECATED, + 'type' => \E_USER_DEPRECATED, 'message' => 'Since vendor/package 1.1: The option "foo" is deprecated.', ], 4, diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index aa52cf367d..feee4ad49b 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -49,7 +49,7 @@ class ExecutableFinder public function find(string $name, string $default = null, array $extraDirs = []) { if (ini_get('open_basedir')) { - $searchPath = array_merge(explode(PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs); + $searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs); $dirs = []; foreach ($searchPath as $path) { // Silencing against https://bugs.php.net/69240 @@ -63,7 +63,7 @@ class ExecutableFinder } } else { $dirs = array_merge( - explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')), + explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')), $extraDirs ); } @@ -71,7 +71,7 @@ class ExecutableFinder $suffixes = ['']; if ('\\' === \DIRECTORY_SEPARATOR) { $pathExt = getenv('PATHEXT'); - $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes); + $suffixes = array_merge($pathExt ? explode(\PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes); } foreach ($suffixes as $suffix) { foreach ($dirs as $dir) { diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index c09d49a2c2..e4f03f76f1 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -36,7 +36,7 @@ class PhpExecutableFinder if ($php = getenv('PHP_BINARY')) { if (!is_executable($php)) { $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v'; - if ($php = strtok(exec($command.' '.escapeshellarg($php)), PHP_EOL)) { + if ($php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) { if (!is_executable($php)) { return false; } @@ -52,8 +52,8 @@ class PhpExecutableFinder $args = $includeArgs && $args ? ' '.implode(' ', $args) : ''; // PHP_BINARY return the current sapi executable - if (PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) { - return PHP_BINARY.$args; + if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) { + return \PHP_BINARY.$args; } if ($php = getenv('PHP_PATH')) { @@ -70,11 +70,11 @@ class PhpExecutableFinder } } - if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) { + if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) { return $php; } - $dirs = [PHP_BINDIR]; + $dirs = [\PHP_BINDIR]; if ('\\' === \DIRECTORY_SEPARATOR) { $dirs[] = 'C:\xampp\php\\'; } diff --git a/src/Symfony/Component/Process/Pipes/WindowsPipes.php b/src/Symfony/Component/Process/Pipes/WindowsPipes.php index 5ebd5ff3c5..b22171dd4a 100644 --- a/src/Symfony/Component/Process/Pipes/WindowsPipes.php +++ b/src/Symfony/Component/Process/Pipes/WindowsPipes.php @@ -62,17 +62,17 @@ class WindowsPipes extends AbstractPipes restore_error_handler(); throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError); } - if (!flock($h, LOCK_EX | LOCK_NB)) { + if (!flock($h, \LOCK_EX | \LOCK_NB)) { continue 2; } if (isset($this->lockHandles[$pipe])) { - flock($this->lockHandles[$pipe], LOCK_UN); + flock($this->lockHandles[$pipe], \LOCK_UN); fclose($this->lockHandles[$pipe]); } $this->lockHandles[$pipe] = $h; if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) { - flock($this->lockHandles[$pipe], LOCK_UN); + flock($this->lockHandles[$pipe], \LOCK_UN); fclose($this->lockHandles[$pipe]); unset($this->lockHandles[$pipe]); continue 2; @@ -152,7 +152,7 @@ class WindowsPipes extends AbstractPipes if ($close) { ftruncate($fileHandle, 0); fclose($fileHandle); - flock($this->lockHandles[$type], LOCK_UN); + flock($this->lockHandles[$type], \LOCK_UN); fclose($this->lockHandles[$type]); unset($this->fileHandles[$type], $this->lockHandles[$type]); } @@ -186,7 +186,7 @@ class WindowsPipes extends AbstractPipes foreach ($this->fileHandles as $type => $handle) { ftruncate($handle, 0); fclose($handle); - flock($this->lockHandles[$type], LOCK_UN); + flock($this->lockHandles[$type], \LOCK_UN); fclose($this->lockHandles[$type]); } $this->fileHandles = $this->lockHandles = []; diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index e1efb9ccc8..e984e04eef 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -934,7 +934,7 @@ class Process implements \IteratorAggregate { $this->lastOutputTime = microtime(true); - fseek($this->stdout, 0, SEEK_END); + fseek($this->stdout, 0, \SEEK_END); fwrite($this->stdout, $line); fseek($this->stdout, $this->incrementalOutputOffset); } @@ -948,7 +948,7 @@ class Process implements \IteratorAggregate { $this->lastOutputTime = microtime(true); - fseek($this->stderr, 0, SEEK_END); + fseek($this->stderr, 0, \SEEK_END); fwrite($this->stderr, $line); fseek($this->stderr, $this->incrementalErrorOutputOffset); } @@ -1343,7 +1343,7 @@ class Process implements \IteratorAggregate } ob_start(); - phpinfo(INFO_GENERAL); + phpinfo(\INFO_GENERAL); return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild'); } diff --git a/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php b/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php index c37aeb5c8f..37c1e65846 100755 --- a/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php +++ b/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php @@ -25,12 +25,12 @@ try { while (false === strpos($process->getOutput(), 'ready')) { usleep(1000); } - $process->signal(SIGSTOP); + $process->signal(\SIGSTOP); $process->wait(); return $process->getExitCode(); } catch (ProcessTimedOutException $t) { - echo $t->getMessage().PHP_EOL; + echo $t->getMessage().\PHP_EOL; return 1; } diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index 2a0278f8e0..83f263ff35 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -41,12 +41,12 @@ class ExecutableFinderTest extends TestCase $this->markTestSkipped('Cannot test when open_basedir is set'); } - $this->setPath(\dirname(PHP_BINARY)); + $this->setPath(\dirname(\PHP_BINARY)); $finder = new ExecutableFinder(); $result = $finder->find($this->getPhpBinaryName()); - $this->assertSamePath(PHP_BINARY, $result); + $this->assertSamePath(\PHP_BINARY, $result); } public function testFindWithDefault() @@ -88,12 +88,12 @@ class ExecutableFinderTest extends TestCase $this->setPath(''); - $extraDirs = [\dirname(PHP_BINARY)]; + $extraDirs = [\dirname(\PHP_BINARY)]; $finder = new ExecutableFinder(); $result = $finder->find($this->getPhpBinaryName(), null, $extraDirs); - $this->assertSamePath(PHP_BINARY, $result); + $this->assertSamePath(\PHP_BINARY, $result); } public function testFindWithOpenBaseDir() @@ -106,12 +106,12 @@ class ExecutableFinderTest extends TestCase $this->markTestSkipped('Cannot test when open_basedir is set'); } - $this->iniSet('open_basedir', \dirname(PHP_BINARY).PATH_SEPARATOR.'/'); + $this->iniSet('open_basedir', \dirname(\PHP_BINARY).\PATH_SEPARATOR.'/'); $finder = new ExecutableFinder(); $result = $finder->find($this->getPhpBinaryName()); - $this->assertSamePath(PHP_BINARY, $result); + $this->assertSamePath(\PHP_BINARY, $result); } public function testFindProcessInOpenBasedir() @@ -124,12 +124,12 @@ class ExecutableFinderTest extends TestCase } $this->setPath(''); - $this->iniSet('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/'); + $this->iniSet('open_basedir', \PHP_BINARY.\PATH_SEPARATOR.'/'); $finder = new ExecutableFinder(); $result = $finder->find($this->getPhpBinaryName(), false); - $this->assertSamePath(PHP_BINARY, $result); + $this->assertSamePath(\PHP_BINARY, $result); } public function testFindBatchExecutableOnWindows() @@ -170,6 +170,6 @@ class ExecutableFinderTest extends TestCase private function getPhpBinaryName() { - return basename(PHP_BINARY, '\\' === \DIRECTORY_SEPARATOR ? '.exe' : ''); + return basename(\PHP_BINARY, '\\' === \DIRECTORY_SEPARATOR ? '.exe' : ''); } } diff --git a/src/Symfony/Component/Process/Tests/NonStopableProcess.php b/src/Symfony/Component/Process/Tests/NonStopableProcess.php index 5643259657..c695f544d2 100644 --- a/src/Symfony/Component/Process/Tests/NonStopableProcess.php +++ b/src/Symfony/Component/Process/Tests/NonStopableProcess.php @@ -19,10 +19,10 @@ function handleSignal($signal) { switch ($signal) { - case SIGTERM: + case \SIGTERM: $name = 'SIGTERM'; break; - case SIGINT: + case \SIGINT: $name = 'SIGINT'; break; default: @@ -33,8 +33,8 @@ function handleSignal($signal) echo "signal $name\n"; } -pcntl_signal(SIGTERM, 'handleSignal'); -pcntl_signal(SIGINT, 'handleSignal'); +pcntl_signal(\SIGTERM, 'handleSignal'); +pcntl_signal(\SIGINT, 'handleSignal'); echo 'received '; diff --git a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php index b87782526a..cf3ffb55ef 100644 --- a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php @@ -26,7 +26,7 @@ class PhpExecutableFinderTest extends TestCase { $f = new PhpExecutableFinder(); - $current = PHP_BINARY; + $current = \PHP_BINARY; $args = 'phpdbg' === \PHP_SAPI ? ' -qrr' : ''; $this->assertEquals($current.$args, $f->find(), '::find() returns the executable PHP'); @@ -50,7 +50,7 @@ class PhpExecutableFinderTest extends TestCase public function testNotExitsBinaryFile() { $f = new PhpExecutableFinder(); - $phpBinaryEnv = PHP_BINARY; + $phpBinaryEnv = \PHP_BINARY; putenv('PHP_BINARY=/usr/local/php/bin/php-invalid'); $this->assertFalse($f->find(), '::find() returns false because of not exist file'); diff --git a/src/Symfony/Component/Process/Tests/PhpProcessTest.php b/src/Symfony/Component/Process/Tests/PhpProcessTest.php index 5f1e5e6700..111dc4c76b 100644 --- a/src/Symfony/Component/Process/Tests/PhpProcessTest.php +++ b/src/Symfony/Component/Process/Tests/PhpProcessTest.php @@ -45,7 +45,7 @@ PHP $process->wait(); $this->assertStringContainsString($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait'); - $this->assertSame(PHP_VERSION.\PHP_SAPI, $process->getOutput()); + $this->assertSame(\PHP_VERSION.\PHP_SAPI, $process->getOutput()); } public function testPassingPhpExplicitly() diff --git a/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php b/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php index 2e7716de7f..a206d2b8e0 100644 --- a/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php +++ b/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php @@ -14,12 +14,12 @@ define('ERR_TIMEOUT', 2); define('ERR_READ_FAILED', 3); define('ERR_WRITE_FAILED', 4); -$read = [STDIN]; -$write = [STDOUT, STDERR]; +$read = [\STDIN]; +$write = [\STDOUT, \STDERR]; -stream_set_blocking(STDIN, 0); -stream_set_blocking(STDOUT, 0); -stream_set_blocking(STDERR, 0); +stream_set_blocking(\STDIN, 0); +stream_set_blocking(\STDOUT, 0); +stream_set_blocking(\STDERR, 0); $out = $err = ''; while ($read || $write) { @@ -34,37 +34,37 @@ while ($read || $write) { exit(ERR_TIMEOUT); } - if (in_array(STDOUT, $w) && strlen($out) > 0) { - $written = fwrite(STDOUT, (string) $out, 32768); + if (in_array(\STDOUT, $w) && strlen($out) > 0) { + $written = fwrite(\STDOUT, (string) $out, 32768); if (false === $written) { exit(ERR_WRITE_FAILED); } $out = (string) substr($out, $written); } if (null === $read && '' === $out) { - $write = array_diff($write, [STDOUT]); + $write = array_diff($write, [\STDOUT]); } - if (in_array(STDERR, $w) && strlen($err) > 0) { - $written = fwrite(STDERR, (string) $err, 32768); + if (in_array(\STDERR, $w) && strlen($err) > 0) { + $written = fwrite(\STDERR, (string) $err, 32768); if (false === $written) { exit(ERR_WRITE_FAILED); } $err = (string) substr($err, $written); } if (null === $read && '' === $err) { - $write = array_diff($write, [STDERR]); + $write = array_diff($write, [\STDERR]); } if ($r) { - $str = fread(STDIN, 32768); + $str = fread(\STDIN, 32768); if (false !== $str) { $out .= $str; $err .= $str; } - if (false === $str || feof(STDIN)) { + if (false === $str || feof(\STDIN)) { $read = null; - if (!feof(STDIN)) { + if (!feof(\STDIN)) { exit(ERR_READ_FAILED); } } diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 0f4d15f226..6b525d2684 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -35,7 +35,7 @@ class ProcessTest extends TestCase self::$phpBin = getenv('SYMFONY_PROCESS_PHP_TEST_BINARY') ?: ('phpdbg' === \PHP_SAPI ? 'php' : $phpBin->find()); ob_start(); - phpinfo(INFO_GENERAL); + phpinfo(\INFO_GENERAL); self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild'); } @@ -68,12 +68,12 @@ class ProcessTest extends TestCase if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test is transient on Windows'); } - @trigger_error('Test Error', E_USER_NOTICE); + @trigger_error('Test Error', \E_USER_NOTICE); $process = $this->getProcessForCode('sleep(3)'); $process->run(); $actualError = error_get_last(); $this->assertEquals('Test Error', $actualError['message']); - $this->assertEquals(E_USER_NOTICE, $actualError['type']); + $this->assertEquals(\E_USER_NOTICE, $actualError['type']); } public function testNegativeTimeoutFromConstructor() @@ -196,7 +196,7 @@ class ProcessTest extends TestCase $process->wait(); - $this->assertSame('foo'.PHP_EOL, $data); + $this->assertSame('foo'.\PHP_EOL, $data); } /** @@ -401,7 +401,7 @@ class ProcessTest extends TestCase $p = $this->getProcessForCode('file_put_contents($s = \''.$uri.'\', \'foo\'); flock(fopen('.var_export($lock, true).', \'r\'), LOCK_EX); file_put_contents($s, \'bar\');'); $h = fopen($lock, 'w'); - flock($h, LOCK_EX); + flock($h, \LOCK_EX); $p->start(); @@ -413,7 +413,7 @@ class ProcessTest extends TestCase $this->assertSame($s, $p->$getIncrementalOutput()); $this->assertSame('', $p->$getIncrementalOutput()); - flock($h, LOCK_UN); + flock($h, \LOCK_UN); } fclose($h); @@ -536,7 +536,7 @@ class ProcessTest extends TestCase $process = $this->getProcess('echo foo'); $this->assertSame($process, $process->mustRun()); - $this->assertEquals('foo'.PHP_EOL, $process->getOutput()); + $this->assertEquals('foo'.\PHP_EOL, $process->getOutput()); } public function testSuccessfulMustRunHasCorrectExitCode() @@ -899,7 +899,7 @@ class ProcessTest extends TestCase while (false === strpos($process->getOutput(), 'Caught')) { usleep(1000); } - $process->signal(SIGUSR1); + $process->signal(\SIGUSR1); $process->wait(); $this->assertEquals('Caught SIGUSR1', $process->getOutput()); @@ -912,7 +912,7 @@ class ProcessTest extends TestCase { $process = $this->getProcess('sleep 4'); $process->start(); - $process->signal(SIGKILL); + $process->signal(\SIGKILL); while ($process->isRunning()) { usleep(10000); @@ -1370,7 +1370,7 @@ class ProcessTest extends TestCase $process->run(); - $this->assertSame('hello'.PHP_EOL, $process->getOutput()); + $this->assertSame('hello'.\PHP_EOL, $process->getOutput()); $this->assertSame('', $process->getErrorOutput()); } diff --git a/src/Symfony/Component/Process/Tests/SignalListener.php b/src/Symfony/Component/Process/Tests/SignalListener.php index 9e30ce3bbb..618be74050 100644 --- a/src/Symfony/Component/Process/Tests/SignalListener.php +++ b/src/Symfony/Component/Process/Tests/SignalListener.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -pcntl_signal(SIGUSR1, function () { echo 'SIGUSR1'; exit; }); +pcntl_signal(\SIGUSR1, function () { echo 'SIGUSR1'; exit; }); echo 'Caught '; diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index d49ce56199..177cd59811 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -691,7 +691,7 @@ class PropertyAccessor implements PropertyAccessorInterface } $apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $version); - if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { + if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) { $apcu->setLogger(new NullLogger()); } elseif (null !== $logger) { $apcu->setLogger($logger); diff --git a/src/Symfony/Component/Routing/Annotation/Route.php b/src/Symfony/Component/Routing/Annotation/Route.php index 9d74fdd2f7..43e185e6cf 100644 --- a/src/Symfony/Component/Routing/Annotation/Route.php +++ b/src/Symfony/Component/Routing/Annotation/Route.php @@ -65,12 +65,12 @@ class Route } if (isset($data['utf8'])) { - $data['options']['utf8'] = filter_var($data['utf8'], FILTER_VALIDATE_BOOLEAN) ?: false; + $data['options']['utf8'] = filter_var($data['utf8'], \FILTER_VALIDATE_BOOLEAN) ?: false; unset($data['utf8']); } if (isset($data['stateless'])) { - $data['defaults']['_stateless'] = filter_var($data['stateless'], FILTER_VALIDATE_BOOLEAN) ?: false; + $data['defaults']['_stateless'] = filter_var($data['stateless'], \FILTER_VALIDATE_BOOLEAN) ?: false; unset($data['stateless']); } diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index 5473e856e1..b2768f7f53 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -302,7 +302,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt unset($extra['_fragment']); } - if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) { + if ($extra && $query = http_build_query($extra, '', '&', \PHP_QUERY_RFC3986)) { $url .= '?'.strtr($query, self::QUERY_FRAGMENT_DECODED); } diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index 52c72f6c25..540ba0be32 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -75,7 +75,7 @@ class AnnotationFileLoader extends FileLoader */ public function supports($resource, string $type = null) { - return \is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'annotation' === $type); + return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'annotation' === $type); } /** @@ -89,11 +89,11 @@ class AnnotationFileLoader extends FileLoader $namespace = false; $tokens = token_get_all(file_get_contents($file)); - if (1 === \count($tokens) && T_INLINE_HTML === $tokens[0][0]) { + if (1 === \count($tokens) && \T_INLINE_HTML === $tokens[0][0]) { throw new \InvalidArgumentException(sprintf('The file "%s" does not contain PHP code. Did you forgot to add the " true, T_STRING => true]; + $nsTokens = [\T_NS_SEPARATOR => true, \T_STRING => true]; if (\defined('T_NAME_QUALIFIED')) { $nsTokens[T_NAME_QUALIFIED] = true; } @@ -105,7 +105,7 @@ class AnnotationFileLoader extends FileLoader continue; } - if (true === $class && T_STRING === $token[0]) { + if (true === $class && \T_STRING === $token[0]) { return $namespace.'\\'.$token[1]; } @@ -117,7 +117,7 @@ class AnnotationFileLoader extends FileLoader $token = $tokens[$i]; } - if (T_CLASS === $token[0]) { + if (\T_CLASS === $token[0]) { // Skip usage of ::class constant and anonymous classes $skipClassToken = false; for ($j = $i - 1; $j > 0; --$j) { @@ -125,10 +125,10 @@ class AnnotationFileLoader extends FileLoader break; } - if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) { + if (\T_DOUBLE_COLON === $tokens[$j][0] || \T_NEW === $tokens[$j][0]) { $skipClassToken = true; break; - } elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) { + } elseif (!\in_array($tokens[$j][0], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT])) { break; } } @@ -138,7 +138,7 @@ class AnnotationFileLoader extends FileLoader } } - if (T_NAMESPACE === $token[0]) { + if (\T_NAMESPACE === $token[0]) { $namespace = true; } } diff --git a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php index 04d9df6195..e000c5a0eb 100644 --- a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php @@ -64,7 +64,7 @@ class PhpFileLoader extends FileLoader */ public function supports($resource, string $type = null) { - return \is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type); + return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'php' === $type); } protected function callConfigurator(callable $result, string $path, string $file): RouteCollection diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 4599ee75b5..e64089fb30 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -98,7 +98,7 @@ class XmlFileLoader extends FileLoader */ public function supports($resource, string $type = null) { - return \is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type); + return \is_string($resource) && 'xml' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'xml' === $type); } /** @@ -115,8 +115,8 @@ class XmlFileLoader extends FileLoader throw new \InvalidArgumentException(sprintf('The element in file "%s" must have an "id" attribute.', $path)); } - $schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY); - $methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY); + $schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, \PREG_SPLIT_NO_EMPTY); + $methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, \PREG_SPLIT_NO_EMPTY); list($defaults, $requirements, $options, $condition, $paths, /* $prefixes */, $hosts) = $this->parseConfigs($node, $path); @@ -158,8 +158,8 @@ class XmlFileLoader extends FileLoader $type = $node->getAttribute('type'); $prefix = $node->getAttribute('prefix'); - $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null; - $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null; + $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, \PREG_SPLIT_NO_EMPTY) : null; + $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, \PREG_SPLIT_NO_EMPTY) : null; $trailingSlashOnRoot = $node->hasAttribute('trailing-slash-on-root') ? XmlUtils::phpize($node->getAttribute('trailing-slash-on-root')) : true; $namePrefix = $node->getAttribute('name-prefix') ?: null; diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index cd137eea78..8bce201c2f 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -101,7 +101,7 @@ class YamlFileLoader extends FileLoader */ public function supports($resource, string $type = null) { - return \is_string($resource) && \in_array(pathinfo($resource, PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type); + return \is_string($resource) && \in_array(pathinfo($resource, \PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type); } /** diff --git a/src/Symfony/Component/Routing/RouteCompiler.php b/src/Symfony/Component/Routing/RouteCompiler.php index fd09f6ae3c..618757d9ff 100644 --- a/src/Symfony/Component/Routing/RouteCompiler.php +++ b/src/Symfony/Component/Routing/RouteCompiler.php @@ -122,7 +122,7 @@ class RouteCompiler implements RouteCompilerInterface // Match all variables enclosed in "{}" and iterate over them. But we only want to match the innermost variable // in case of nested "{}", e.g. {foo{bar}}. This in ensured because \w does not match "{" or "}" itself. - preg_match_all('#\{(!)?(\w+)\}#', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); + preg_match_all('#\{(!)?(\w+)\}#', $pattern, $matches, \PREG_OFFSET_CAPTURE | \PREG_SET_ORDER); foreach ($matches as $match) { $important = $match[1][1] >= 0; $varName = $match[2][0]; @@ -210,7 +210,7 @@ class RouteCompiler implements RouteCompilerInterface } // find the first optional token - $firstOptional = PHP_INT_MAX; + $firstOptional = \PHP_INT_MAX; if (!$isHost) { for ($i = \count($tokens) - 1; $i >= 0; --$i) { $token = $tokens[$i]; diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index 031749b360..b5360c4b74 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -373,7 +373,7 @@ class Router implements RouterInterface, RequestMatcherInterface private static function getCompiledRoutes(string $path): array { - if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN))) { + if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { self::$cache = null; } diff --git a/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php b/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php index 841430cec5..d07891bf77 100644 --- a/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php +++ b/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php @@ -153,7 +153,7 @@ class EncoderFactory implements EncoderFactoryInterface case 'bcrypt': $config['algorithm'] = 'native'; - $config['native_algorithm'] = PASSWORD_BCRYPT; + $config['native_algorithm'] = \PASSWORD_BCRYPT; return $this->getEncoderConfigFromAlgorithm($config); @@ -181,7 +181,7 @@ class EncoderFactory implements EncoderFactoryInterface $config['algorithm'] = 'sodium'; } elseif (\defined('PASSWORD_ARGON2I')) { $config['algorithm'] = 'native'; - $config['native_algorithm'] = PASSWORD_ARGON2I; + $config['native_algorithm'] = \PASSWORD_ARGON2I; } else { throw new LogicException(sprintf('Algorithm "argon2i" is not available. Either use %s"auto" or upgrade to PHP 7.2+ instead.', \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13') ? '"argon2id", ' : '')); } @@ -193,7 +193,7 @@ class EncoderFactory implements EncoderFactoryInterface $config['algorithm'] = 'sodium'; } elseif (\defined('PASSWORD_ARGON2ID')) { $config['algorithm'] = 'native'; - $config['native_algorithm'] = PASSWORD_ARGON2ID; + $config['native_algorithm'] = \PASSWORD_ARGON2ID; } else { throw new LogicException(sprintf('Algorithm "argon2id" is not available. Either use %s"auto", upgrade to PHP 7.3+ or use libsodium 1.0.15+ instead.', \defined('PASSWORD_ARGON2I') || $hasSodium ? '"argon2i", ' : '')); } diff --git a/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php index b678801f5e..83b7f3f1e8 100644 --- a/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php @@ -24,7 +24,7 @@ final class NativePasswordEncoder implements PasswordEncoderInterface, SelfSalti { private const MAX_PASSWORD_LENGTH = 4096; - private $algo = PASSWORD_BCRYPT; + private $algo = \PASSWORD_BCRYPT; private $options; /** @@ -33,8 +33,8 @@ final class NativePasswordEncoder implements PasswordEncoderInterface, SelfSalti public function __construct(int $opsLimit = null, int $memLimit = null, int $cost = null, string $algo = null) { $cost = $cost ?? 13; - $opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4); - $memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 1024); + $opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4); + $memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 1024); if (3 > $opsLimit) { throw new \InvalidArgumentException('$opsLimit must be 3 or greater.'); @@ -48,14 +48,14 @@ final class NativePasswordEncoder implements PasswordEncoderInterface, SelfSalti throw new \InvalidArgumentException('$cost must be in the range of 4-31.'); } - $algos = [1 => PASSWORD_BCRYPT, '2y' => PASSWORD_BCRYPT]; + $algos = [1 => \PASSWORD_BCRYPT, '2y' => \PASSWORD_BCRYPT]; if (\defined('PASSWORD_ARGON2I')) { - $this->algo = $algos[2] = $algos['argon2i'] = (string) PASSWORD_ARGON2I; + $this->algo = $algos[2] = $algos['argon2i'] = (string) \PASSWORD_ARGON2I; } if (\defined('PASSWORD_ARGON2ID')) { - $this->algo = $algos[3] = $algos['argon2id'] = (string) PASSWORD_ARGON2ID; + $this->algo = $algos[3] = $algos['argon2id'] = (string) \PASSWORD_ARGON2ID; } if (null !== $algo) { @@ -75,7 +75,7 @@ final class NativePasswordEncoder implements PasswordEncoderInterface, SelfSalti */ public function encodePassword(string $raw, ?string $salt): string { - if (\strlen($raw) > self::MAX_PASSWORD_LENGTH || ((string) PASSWORD_BCRYPT === $this->algo && 72 < \strlen($raw))) { + if (\strlen($raw) > self::MAX_PASSWORD_LENGTH || ((string) \PASSWORD_BCRYPT === $this->algo && 72 < \strlen($raw))) { throw new BadCredentialsException('Invalid password.'); } @@ -102,7 +102,7 @@ final class NativePasswordEncoder implements PasswordEncoderInterface, SelfSalti return (72 >= \strlen($raw) || 0 !== strpos($encoded, '$2')) && password_verify($raw, $encoded); } - if (\extension_loaded('sodium') && version_compare(SODIUM_LIBRARY_VERSION, '1.0.14', '>=')) { + if (\extension_loaded('sodium') && version_compare(\SODIUM_LIBRARY_VERSION, '1.0.14', '>=')) { return sodium_crypto_pwhash_str_verify($encoded, $raw); } diff --git a/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php index e6d7e5dbd0..53c6660014 100644 --- a/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php @@ -34,8 +34,8 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti throw new LogicException('Libsodium is not available. You should either install the sodium extension, upgrade to PHP 7.2+ or use a different encoder.'); } - $this->opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4); - $this->memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 1024); + $this->opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4); + $this->memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 1024); if (3 > $this->opsLimit) { throw new \InvalidArgumentException('$opsLimit must be 3 or greater.'); @@ -48,7 +48,7 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti public static function isSupported(): bool { - return version_compare(\extension_loaded('sodium') ? SODIUM_LIBRARY_VERSION : phpversion('libsodium'), '1.0.14', '>='); + return version_compare(\extension_loaded('sodium') ? \SODIUM_LIBRARY_VERSION : phpversion('libsodium'), '1.0.14', '>='); } /** diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php index e77307d65d..eb2dc498b4 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php @@ -150,9 +150,9 @@ class EncoderFactoryTest extends TestCase $this->assertInstanceOf(MigratingPasswordEncoder::class, $encoder); $this->assertTrue($encoder->isPasswordValid((new SodiumPasswordEncoder())->encodePassword('foo', null), 'foo', null)); - $this->assertTrue($encoder->isPasswordValid((new NativePasswordEncoder(null, null, null, PASSWORD_BCRYPT))->encodePassword('foo', null), 'foo', null)); + $this->assertTrue($encoder->isPasswordValid((new NativePasswordEncoder(null, null, null, \PASSWORD_BCRYPT))->encodePassword('foo', null), 'foo', null)); $this->assertTrue($encoder->isPasswordValid($digest->encodePassword('foo', null), 'foo', null)); - $this->assertStringStartsWith(SODIUM_CRYPTO_PWHASH_STRPREFIX, $encoder->encodePassword('foo', null)); + $this->assertStringStartsWith(\SODIUM_CRYPTO_PWHASH_STRPREFIX, $encoder->encodePassword('foo', null)); } public function testDefaultMigratingEncoders() diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php index 9388e9c2c5..7ee256f040 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php @@ -67,7 +67,7 @@ class NativePasswordEncoderTest extends TestCase public function testConfiguredAlgorithm() { - $encoder = new NativePasswordEncoder(null, null, null, PASSWORD_BCRYPT); + $encoder = new NativePasswordEncoder(null, null, null, \PASSWORD_BCRYPT); $result = $encoder->encodePassword('password', null); $this->assertTrue($encoder->isPasswordValid($result, 'password', null)); $this->assertStringStartsWith('$2', $result); @@ -84,7 +84,7 @@ class NativePasswordEncoderTest extends TestCase public function testCheckPasswordLength() { $encoder = new NativePasswordEncoder(null, null, 4); - $result = password_hash(str_repeat('a', 72), PASSWORD_BCRYPT, ['cost' => 4]); + $result = password_hash(str_repeat('a', 72), \PASSWORD_BCRYPT, ['cost' => 4]); $this->assertFalse($encoder->isPasswordValid($result, str_repeat('a', 73), 'salt')); $this->assertTrue($encoder->isPasswordValid($result, str_repeat('a', 72), 'salt')); diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php index dd353515fe..ead3978997 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php @@ -47,11 +47,11 @@ class NativeSessionTokenStorageTest extends TestCase { session_id('foobar'); - $this->assertSame(PHP_SESSION_NONE, session_status()); + $this->assertSame(\PHP_SESSION_NONE, session_status()); $this->storage->setToken('token_id', 'TOKEN'); - $this->assertSame(PHP_SESSION_ACTIVE, session_status()); + $this->assertSame(\PHP_SESSION_ACTIVE, session_status()); $this->assertSame([self::SESSION_NAMESPACE => ['token_id' => 'TOKEN']], $_SESSION); } diff --git a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php index 75f03df7bb..2670072cfb 100644 --- a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php +++ b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php @@ -112,7 +112,7 @@ class NativeSessionTokenStorage implements ClearableTokenStorageInterface private function startSession() { - if (PHP_SESSION_NONE === session_status()) { + if (\PHP_SESSION_NONE === session_status()) { session_start(); } diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 7cf19dbb85..66b54d325b 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -96,7 +96,7 @@ class ContextListener extends AbstractListener if (null !== $session) { $usageIndexValue = $session instanceof Session ? $usageIndexReference = &$session->getUsageIndex() : 0; - $usageIndexReference = PHP_INT_MIN; + $usageIndexReference = \PHP_INT_MIN; $sessionId = $request->cookies->all()[$session->getName()] ?? null; $token = $session->get($this->sessionKey); @@ -104,7 +104,7 @@ class ContextListener extends AbstractListener if ($this->sessionTrackerEnabler && \in_array($sessionId, [true, $session->getId()], true)) { $usageIndexReference = $usageIndexValue; } else { - $usageIndexReference = $usageIndexReference - PHP_INT_MIN + $usageIndexValue; + $usageIndexReference = $usageIndexReference - \PHP_INT_MIN + $usageIndexValue; } } diff --git a/src/Symfony/Component/Security/Http/HttpUtils.php b/src/Symfony/Component/Security/Http/HttpUtils.php index 70416b6e42..9b96832bbb 100644 --- a/src/Symfony/Component/Security/Http/HttpUtils.php +++ b/src/Symfony/Component/Security/Http/HttpUtils.php @@ -167,7 +167,7 @@ class HttpUtils // fortunately, they all are, so we have to remove entire query string $position = strpos($url, '?'); if (false !== $position) { - $fragment = parse_url($url, PHP_URL_FRAGMENT); + $fragment = parse_url($url, \PHP_URL_FRAGMENT); $url = substr($url, 0, $position); // fragment must be preserved if ($fragment) { diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index af268f75ef..dda813d7ae 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -84,11 +84,11 @@ class JsonDecode implements DecoderInterface throw new NotEncodableValueException($e->getMessage(), 0, $e); } - if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) { + if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $options)) { return $decodedData; } - if (JSON_ERROR_NONE !== json_last_error()) { + if (\JSON_ERROR_NONE !== json_last_error()) { throw new NotEncodableValueException(json_last_error_msg()); } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index 2349e8ed5b..93c359eaf7 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -46,11 +46,11 @@ class JsonEncode implements EncoderInterface throw new NotEncodableValueException($e->getMessage(), 0, $e); } - if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) { + if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $options)) { return $encodedJson; } - if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & JSON_PARTIAL_OUTPUT_ON_ERROR))) { + if (\JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & \JSON_PARTIAL_OUTPUT_ON_ERROR))) { throw new NotEncodableValueException(json_last_error_msg()); } diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index bd79694ef4..9e4902c7cd 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -57,9 +57,9 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa private $defaultContext = [ self::AS_COLLECTION => false, - self::DECODER_IGNORED_NODE_TYPES => [XML_PI_NODE, XML_COMMENT_NODE], + self::DECODER_IGNORED_NODE_TYPES => [\XML_PI_NODE, \XML_COMMENT_NODE], self::ENCODER_IGNORED_NODE_TYPES => [], - self::LOAD_OPTIONS => LIBXML_NONET | LIBXML_NOBLANKS, + self::LOAD_OPTIONS => \LIBXML_NONET | \LIBXML_NOBLANKS, self::REMOVE_EMPTY_TAGS => false, self::ROOT_NODE_NAME => 'response', self::TYPE_CAST_ATTRIBUTES => true, @@ -83,7 +83,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa public function encode($data, string $format, array $context = []) { $encoderIgnoredNodeTypes = $context[self::ENCODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::ENCODER_IGNORED_NODE_TYPES]; - $ignorePiNode = \in_array(XML_PI_NODE, $encoderIgnoredNodeTypes, true); + $ignorePiNode = \in_array(\XML_PI_NODE, $encoderIgnoredNodeTypes, true); if ($data instanceof \DOMDocument) { return $data->saveXML($ignorePiNode ? $data->documentElement : null); } @@ -115,7 +115,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa } $internalErrors = libxml_use_internal_errors(true); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(true); } libxml_clear_errors(); @@ -124,7 +124,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa $dom->loadXML($data, $context[self::LOAD_OPTIONS] ?? $this->defaultContext[self::LOAD_OPTIONS]); libxml_use_internal_errors($internalErrors); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } @@ -137,7 +137,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa $rootNode = null; $decoderIgnoredNodeTypes = $context[self::DECODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::DECODER_IGNORED_NODE_TYPES]; foreach ($dom->childNodes as $child) { - if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) { + if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) { throw new NotEncodableValueException('Document types are not allowed.'); } if (!$rootNode && !\in_array($child->nodeType, $decoderIgnoredNodeTypes, true)) { @@ -307,7 +307,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa continue; } - if (false !== $val = filter_var($attr->nodeValue, FILTER_VALIDATE_INT)) { + if (false !== $val = filter_var($attr->nodeValue, \FILTER_VALIDATE_INT)) { $data['@'.$attr->nodeName] = $val; continue; @@ -330,7 +330,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa return $node->nodeValue; } - if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, [XML_TEXT_NODE, XML_CDATA_SECTION_NODE])) { + if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, [\XML_TEXT_NODE, \XML_CDATA_SECTION_NODE])) { return $node->firstChild->nodeValue; } @@ -384,7 +384,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa } elseif ('#' === $key) { $append = $this->selectNodeType($parentNode, $data); } elseif ('#comment' === $key) { - if (!\in_array(XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) { + if (!\in_array(\XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) { $append = $this->appendComment($parentNode, $data); } } elseif (\is_array($data) && false === is_numeric($key)) { diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 79117f0298..aa1be48cfb 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -414,11 +414,11 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer switch ($data) { case 'NaN': - return NAN; + return \NAN; case 'INF': - return INF; + return \INF; case '-INF': - return -INF; + return -\INF; default: throw new NotNormalizableValueException(sprintf('The type of the "%s" attribute for class "%s" must be float ("%s" given).', $attribute, $currentClass, $data)); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php index 0ddaf79e95..157b3999ea 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php @@ -45,7 +45,7 @@ class JsonEncodeTest extends TestCase { return [ [[], '[]', []], - [[], '{}', ['json_encode_options' => JSON_FORCE_OBJECT]], + [[], '{}', ['json_encode_options' => \JSON_FORCE_OBJECT]], [new \ArrayObject(), '{}', []], [new \ArrayObject(['foo' => 'bar']), '{"foo":"bar"}', []], ]; diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php index 75187b9748..b74d10bfca 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php @@ -48,7 +48,7 @@ class JsonEncoderTest extends TestCase public function testOptions() { - $context = ['json_encode_options' => JSON_NUMERIC_CHECK]; + $context = ['json_encode_options' => \JSON_NUMERIC_CHECK]; $arr = []; $arr['foo'] = '3'; @@ -78,7 +78,7 @@ class JsonEncoderTest extends TestCase public function testEncodeNotUtf8WithPartialOnError() { - $context = ['json_encode_options' => JSON_PARTIAL_OUTPUT_ON_ERROR]; + $context = ['json_encode_options' => \JSON_PARTIAL_OUTPUT_ON_ERROR]; $arr = [ 'utf8' => 'Hello World!', @@ -88,16 +88,16 @@ class JsonEncoderTest extends TestCase $result = $this->encoder->encode($arr, 'json', $context); $jsonLastError = json_last_error(); - $this->assertSame(JSON_ERROR_UTF8, $jsonLastError); + $this->assertSame(\JSON_ERROR_UTF8, $jsonLastError); $this->assertEquals('{"utf8":"Hello World!","notUtf8":null}', $result); - $this->assertEquals('0', $this->serializer->serialize(NAN, 'json', $context)); + $this->assertEquals('0', $this->serializer->serialize(\NAN, 'json', $context)); } public function testDecodeFalseString() { $result = $this->encoder->decode('false', 'json'); - $this->assertSame(JSON_ERROR_NONE, json_last_error()); + $this->assertSame(\JSON_ERROR_NONE, json_last_error()); $this->assertFalse($result); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index 4150652502..c1bb517ab0 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -580,7 +580,7 @@ XML; $this->encoder = new XmlEncoder([ XmlEncoder::ROOT_NODE_NAME => 'people', - XmlEncoder::DECODER_IGNORED_NODE_TYPES => [XML_PI_NODE], + XmlEncoder::DECODER_IGNORED_NODE_TYPES => [\XML_PI_NODE], ]); $serializer = new Serializer([new CustomNormalizer()], ['xml' => new XmlEncoder()]); $this->encoder->setSerializer($serializer); @@ -813,7 +813,7 @@ XML; { $encoder = new XmlEncoder([ XmlEncoder::ROOT_NODE_NAME => 'response', - XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [XML_PI_NODE], + XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [\XML_PI_NODE], ]); $expected = ''; @@ -825,7 +825,7 @@ XML; { $encoder = new XmlEncoder([ XmlEncoder::ROOT_NODE_NAME => 'response', - XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [XML_COMMENT_NODE], + XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [\XML_COMMENT_NODE], ]); $expected = <<<'XML' diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index b08e74660c..71d999a466 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -315,7 +315,7 @@ class AbstractObjectNormalizerTest extends TestCase $this->assertEqualsWithDelta(45E-6, $objectWithBooleanProperties->float3, 1); $this->assertNan($objectWithBooleanProperties->floatNaN); $this->assertInfinite($objectWithBooleanProperties->floatInf); - $this->assertEquals(-INF, $objectWithBooleanProperties->floatNegInf); + $this->assertEquals(-\INF, $objectWithBooleanProperties->floatNegInf); } private function getDenormalizerForObjectWithBasicProperties() diff --git a/src/Symfony/Component/String/AbstractString.php b/src/Symfony/Component/String/AbstractString.php index 31e78d19d4..c87f1506fb 100644 --- a/src/Symfony/Component/String/AbstractString.php +++ b/src/Symfony/Component/String/AbstractString.php @@ -29,15 +29,15 @@ use Symfony\Component\String\Exception\RuntimeException; */ abstract class AbstractString implements \Stringable, \JsonSerializable { - public const PREG_PATTERN_ORDER = PREG_PATTERN_ORDER; - public const PREG_SET_ORDER = PREG_SET_ORDER; - public const PREG_OFFSET_CAPTURE = PREG_OFFSET_CAPTURE; - public const PREG_UNMATCHED_AS_NULL = PREG_UNMATCHED_AS_NULL; + public const PREG_PATTERN_ORDER = \PREG_PATTERN_ORDER; + public const PREG_SET_ORDER = \PREG_SET_ORDER; + public const PREG_OFFSET_CAPTURE = \PREG_OFFSET_CAPTURE; + public const PREG_UNMATCHED_AS_NULL = \PREG_UNMATCHED_AS_NULL; public const PREG_SPLIT = 0; - public const PREG_SPLIT_NO_EMPTY = PREG_SPLIT_NO_EMPTY; - public const PREG_SPLIT_DELIM_CAPTURE = PREG_SPLIT_DELIM_CAPTURE; - public const PREG_SPLIT_OFFSET_CAPTURE = PREG_SPLIT_OFFSET_CAPTURE; + public const PREG_SPLIT_NO_EMPTY = \PREG_SPLIT_NO_EMPTY; + public const PREG_SPLIT_DELIM_CAPTURE = \PREG_SPLIT_DELIM_CAPTURE; + public const PREG_SPLIT_OFFSET_CAPTURE = \PREG_SPLIT_OFFSET_CAPTURE; protected $string = ''; protected $ignoreCase = false; @@ -99,7 +99,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable { $str = clone $this; $str->string = ''; - $i = PHP_INT_MAX; + $i = \PHP_INT_MAX; foreach ((array) $needle as $n) { $n = (string) $n; @@ -111,7 +111,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable } } - if (PHP_INT_MAX === $i) { + if (\PHP_INT_MAX === $i) { return $str; } @@ -168,7 +168,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable { $str = clone $this; $str->string = ''; - $i = PHP_INT_MAX; + $i = \PHP_INT_MAX; foreach ((array) $needle as $n) { $n = (string) $n; @@ -180,7 +180,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable } } - if (PHP_INT_MAX === $i) { + if (\PHP_INT_MAX === $i) { return $str; } @@ -360,7 +360,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); } - $i = PHP_INT_MAX; + $i = \PHP_INT_MAX; foreach ($needle as $n) { $j = $this->indexOf((string) $n, $offset); @@ -370,7 +370,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable } } - return PHP_INT_MAX === $i ? null : $i; + return \PHP_INT_MAX === $i ? null : $i; } /** diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index 9605eacc85..258407959c 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -137,7 +137,7 @@ abstract class AbstractUnicodeString extends AbstractString } } elseif (!\function_exists('iconv')) { $s = preg_replace('/[^\x00-\x7F]/u', '?', $s); - } elseif (ICONV_IMPL === 'glibc') { + } elseif (\ICONV_IMPL === 'glibc') { $s = iconv('UTF-8', 'ASCII//TRANSLIT', $s); } else { $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) { @@ -159,7 +159,7 @@ abstract class AbstractUnicodeString extends AbstractString { $str = clone $this; $str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function ($m) use (&$i) { - return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], MB_CASE_TITLE, 'UTF-8'); + return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8'); }, preg_replace('/[^\pL0-9]++/u', ' ', $this->string))); return $str; @@ -178,7 +178,7 @@ abstract class AbstractUnicodeString extends AbstractString $codePoints = []; - foreach (preg_split('//u', $str->string, -1, PREG_SPLIT_NO_EMPTY) as $c) { + foreach (preg_split('//u', $str->string, -1, \PREG_SPLIT_NO_EMPTY) as $c) { $codePoints[] = mb_ord($c, 'UTF-8'); } @@ -223,7 +223,7 @@ abstract class AbstractUnicodeString extends AbstractString public function match(string $regexp, int $flags = 0, int $offset = 0): array { - $match = ((PREG_PATTERN_ORDER | PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; + $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; if ($this->ignoreCase) { $regexp .= 'i'; @@ -232,7 +232,7 @@ abstract class AbstractUnicodeString extends AbstractString set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); try { - if (false === $match($regexp.'u', $this->string, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset)) { + if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { $lastError = preg_last_error(); foreach (get_defined_constants(true)['pcre'] as $k => $v) { @@ -274,7 +274,7 @@ abstract class AbstractUnicodeString extends AbstractString $pad = clone $this; $pad->string = $padStr; - return $this->pad($length, $pad, STR_PAD_BOTH); + return $this->pad($length, $pad, \STR_PAD_BOTH); } public function padEnd(int $length, string $padStr = ' '): parent @@ -286,7 +286,7 @@ abstract class AbstractUnicodeString extends AbstractString $pad = clone $this; $pad->string = $padStr; - return $this->pad($length, $pad, STR_PAD_RIGHT); + return $this->pad($length, $pad, \STR_PAD_RIGHT); } public function padStart(int $length, string $padStr = ' '): parent @@ -298,7 +298,7 @@ abstract class AbstractUnicodeString extends AbstractString $pad = clone $this; $pad->string = $padStr; - return $this->pad($length, $pad, STR_PAD_LEFT); + return $this->pad($length, $pad, \STR_PAD_LEFT); } public function replaceMatches(string $fromRegexp, $to): parent @@ -355,7 +355,7 @@ abstract class AbstractUnicodeString extends AbstractString public function reverse(): parent { $str = clone $this; - $str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY))); + $str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY))); return $str; } @@ -375,7 +375,7 @@ abstract class AbstractUnicodeString extends AbstractString $limit = $allWords ? -1 : 1; $str->string = preg_replace_callback('/\b./u', static function (array $m): string { - return mb_convert_case($m[0], MB_CASE_TITLE, 'UTF-8'); + return mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8'); }, $str->string, $limit); return $str; @@ -477,13 +477,13 @@ abstract class AbstractUnicodeString extends AbstractString $len = $freeLen % $padLen; switch ($type) { - case STR_PAD_RIGHT: + case \STR_PAD_RIGHT: return $this->append(str_repeat($pad->string, $freeLen / $padLen).($len ? $pad->slice(0, $len) : '')); - case STR_PAD_LEFT: + case \STR_PAD_LEFT: return $this->prepend(str_repeat($pad->string, $freeLen / $padLen).($len ? $pad->slice(0, $len) : '')); - case STR_PAD_BOTH: + case \STR_PAD_BOTH: $freeLen /= 2; $rightLen = ceil($freeLen); @@ -507,7 +507,7 @@ abstract class AbstractUnicodeString extends AbstractString { $width = 0; - foreach (preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY) as $c) { + foreach (preg_split('//u', $string, -1, \PREG_SPLIT_NO_EMPTY) as $c) { $codePoint = mb_ord($c, 'UTF-8'); if (0 === $codePoint // NULL diff --git a/src/Symfony/Component/String/ByteString.php b/src/Symfony/Component/String/ByteString.php index 2be03e49d4..bbf8614cf7 100644 --- a/src/Symfony/Component/String/ByteString.php +++ b/src/Symfony/Component/String/ByteString.php @@ -235,7 +235,7 @@ class ByteString extends AbstractString public function match(string $regexp, int $flags = 0, int $offset = 0): array { - $match = ((PREG_PATTERN_ORDER | PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; + $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; if ($this->ignoreCase) { $regexp .= 'i'; @@ -244,7 +244,7 @@ class ByteString extends AbstractString set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); try { - if (false === $match($regexp, $this->string, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset)) { + if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { $lastError = preg_last_error(); foreach (get_defined_constants(true)['pcre'] as $k => $v) { @@ -265,7 +265,7 @@ class ByteString extends AbstractString public function padBoth(int $length, string $padStr = ' '): parent { $str = clone $this; - $str->string = str_pad($this->string, $length, $padStr, STR_PAD_BOTH); + $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH); return $str; } @@ -273,7 +273,7 @@ class ByteString extends AbstractString public function padEnd(int $length, string $padStr = ' '): parent { $str = clone $this; - $str->string = str_pad($this->string, $length, $padStr, STR_PAD_RIGHT); + $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT); return $str; } @@ -281,7 +281,7 @@ class ByteString extends AbstractString public function padStart(int $length, string $padStr = ' '): parent { $str = clone $this; - $str->string = str_pad($this->string, $length, $padStr, STR_PAD_LEFT); + $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT); return $str; } @@ -356,7 +356,7 @@ class ByteString extends AbstractString public function slice(int $start = 0, int $length = null): parent { $str = clone $this; - $str->string = (string) substr($this->string, $start, $length ?? PHP_INT_MAX); + $str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX); return $str; } @@ -372,14 +372,14 @@ class ByteString extends AbstractString public function splice(string $replacement, int $start = 0, int $length = null): parent { $str = clone $this; - $str->string = substr_replace($this->string, $replacement, $start, $length ?? PHP_INT_MAX); + $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX); return $str; } public function split(string $delimiter, int $limit = null, int $flags = null): array { - if (1 > $limit = $limit ?? PHP_INT_MAX) { + if (1 > $limit = $limit ?? \PHP_INT_MAX) { throw new InvalidArgumentException('Split limit must be a positive integer.'); } diff --git a/src/Symfony/Component/String/CodePointString.php b/src/Symfony/Component/String/CodePointString.php index 9cc585fe14..8ab9209413 100644 --- a/src/Symfony/Component/String/CodePointString.php +++ b/src/Symfony/Component/String/CodePointString.php @@ -65,7 +65,7 @@ class CodePointString extends AbstractUnicodeString $str = clone $this; $chunks = []; - foreach (preg_split($rx, $this->string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $chunk) { + foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) { $str->string = $chunk; $chunks[] = clone $str; } @@ -211,14 +211,14 @@ class CodePointString extends AbstractUnicodeString $str = clone $this; $start = $start ? \strlen(mb_substr($this->string, 0, $start, 'UTF-8')) : 0; $length = $length ? \strlen(mb_substr($this->string, $start, $length, 'UTF-8')) : $length; - $str->string = substr_replace($this->string, $replacement, $start, $length ?? PHP_INT_MAX); + $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX); return $str; } public function split(string $delimiter, int $limit = null, int $flags = null): array { - if (1 > $limit = $limit ?? PHP_INT_MAX) { + if (1 > $limit = $limit ?? \PHP_INT_MAX) { throw new InvalidArgumentException('Split limit must be a positive integer.'); } diff --git a/src/Symfony/Component/String/LazyString.php b/src/Symfony/Component/String/LazyString.php index 9b9c667cfb..b3801db771 100644 --- a/src/Symfony/Component/String/LazyString.php +++ b/src/Symfony/Component/String/LazyString.php @@ -113,7 +113,7 @@ class LazyString implements \Stringable, \JsonSerializable if (\PHP_VERSION_ID < 70400) { // leverage the ErrorHandler component with graceful fallback when it's not available - return trigger_error($e, E_USER_ERROR); + return trigger_error($e, \E_USER_ERROR); } throw $e; diff --git a/src/Symfony/Component/String/Resources/WcswidthDataGenerator.php b/src/Symfony/Component/String/Resources/WcswidthDataGenerator.php index cd507350d6..69d32e292a 100644 --- a/src/Symfony/Component/String/Resources/WcswidthDataGenerator.php +++ b/src/Symfony/Component/String/Resources/WcswidthDataGenerator.php @@ -46,7 +46,7 @@ final class WcswidthDataGenerator $version = $matches[1]; - if (!preg_match_all('/^([A-H\d]{4,})(?:\.\.([A-H\d]{4,}))?;[W|F]/m', $content, $matches, PREG_SET_ORDER)) { + if (!preg_match_all('/^([A-H\d]{4,})(?:\.\.([A-H\d]{4,}))?;[W|F]/m', $content, $matches, \PREG_SET_ORDER)) { throw new RuntimeException('The wide width pattern did not match anything.'); } @@ -61,7 +61,7 @@ final class WcswidthDataGenerator $version = $matches[1]; - if (!preg_match_all('/^([A-H\d]{4,})(?:\.\.([A-H\d]{4,}))? *; (?:Me|Mn)/m', $content, $matches, PREG_SET_ORDER)) { + if (!preg_match_all('/^([A-H\d]{4,})(?:\.\.([A-H\d]{4,}))? *; (?:Me|Mn)/m', $content, $matches, \PREG_SET_ORDER)) { throw new RuntimeException('The zero width pattern did not match anything.'); } diff --git a/src/Symfony/Component/String/Resources/bin/update-data.php b/src/Symfony/Component/String/Resources/bin/update-data.php index 0fd5567f88..3f66be2b76 100644 --- a/src/Symfony/Component/String/Resources/bin/update-data.php +++ b/src/Symfony/Component/String/Resources/bin/update-data.php @@ -11,7 +11,7 @@ use Symfony\Component\String\Resources\WcswidthDataGenerator; -error_reporting(E_ALL); +error_reporting(\E_ALL); set_error_handler(static function (int $type, string $msg, string $file, int $line): void { throw new \ErrorException($msg, 0, $type, $file, $line); diff --git a/src/Symfony/Component/String/Tests/LazyStringTest.php b/src/Symfony/Component/String/Tests/LazyStringTest.php index a714537c98..f65f454b2b 100644 --- a/src/Symfony/Component/String/Tests/LazyStringTest.php +++ b/src/Symfony/Component/String/Tests/LazyStringTest.php @@ -105,7 +105,7 @@ class LazyStringTest extends TestCase { $this->assertFalse(LazyString::isStringable(null)); $this->assertFalse(LazyString::isStringable([])); - $this->assertFalse(LazyString::isStringable(STDIN)); + $this->assertFalse(LazyString::isStringable(\STDIN)); $this->assertFalse(LazyString::isStringable(new \StdClass())); } } diff --git a/src/Symfony/Component/String/UnicodeString.php b/src/Symfony/Component/String/UnicodeString.php index 54df3c0397..f1e952ecd1 100644 --- a/src/Symfony/Component/String/UnicodeString.php +++ b/src/Symfony/Component/String/UnicodeString.php @@ -74,7 +74,7 @@ class UnicodeString extends AbstractUnicodeString $str = clone $this; $chunks = []; - foreach (preg_split($rx, $this->string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $chunk) { + foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) { $str->string = $chunk; $chunks[] = clone $str; } @@ -100,10 +100,10 @@ class UnicodeString extends AbstractUnicodeString } if ($this->ignoreCase) { - return 0 === mb_stripos(grapheme_extract($this->string, \strlen($suffix), GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)), $suffix, 0, 'UTF-8'); + return 0 === mb_stripos(grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)), $suffix, 0, 'UTF-8'); } - return $suffix === grapheme_extract($this->string, \strlen($suffix), GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)); + return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)); } public function equalsTo($string): bool @@ -263,7 +263,7 @@ class UnicodeString extends AbstractUnicodeString public function slice(int $start = 0, int $length = null): AbstractString { $str = clone $this; - $str->string = (string) grapheme_substr($this->string, $start, $length ?? PHP_INT_MAX); + $str->string = (string) grapheme_substr($this->string, $start, $length ?? \PHP_INT_MAX); return $str; } @@ -272,8 +272,8 @@ class UnicodeString extends AbstractUnicodeString { $str = clone $this; $start = $start ? \strlen(grapheme_substr($this->string, 0, $start)) : 0; - $length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? PHP_INT_MAX)) : $length; - $str->string = substr_replace($this->string, $replacement, $start, $length ?? PHP_INT_MAX); + $length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? \PHP_INT_MAX)) : $length; + $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX); normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string); if (false === $str->string) { @@ -285,7 +285,7 @@ class UnicodeString extends AbstractUnicodeString public function split(string $delimiter, int $limit = null, int $flags = null): array { - if (1 > $limit = $limit ?? PHP_INT_MAX) { + if (1 > $limit = $limit ?? \PHP_INT_MAX) { throw new InvalidArgumentException('Split limit must be a positive integer.'); } @@ -339,10 +339,10 @@ class UnicodeString extends AbstractUnicodeString } if ($this->ignoreCase) { - return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8'); + return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8'); } - return $prefix === grapheme_extract($this->string, \strlen($prefix), GRAPHEME_EXTR_MAXBYTES); + return $prefix === grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES); } public function __wakeup() diff --git a/src/Symfony/Component/Templating/Loader/FilesystemLoader.php b/src/Symfony/Component/Templating/Loader/FilesystemLoader.php index 66aa3ca77f..0a37d06939 100644 --- a/src/Symfony/Component/Templating/Loader/FilesystemLoader.php +++ b/src/Symfony/Component/Templating/Loader/FilesystemLoader.php @@ -103,7 +103,7 @@ class FilesystemLoader extends Loader && ':' == $file[1] && ('\\' == $file[2] || '/' == $file[2]) ) - || null !== parse_url($file, PHP_URL_SCHEME) + || null !== parse_url($file, \PHP_URL_SCHEME) ) { return true; } diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 37d44ffda9..ab6b7d30e3 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -138,7 +138,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess // the view variable is exposed to the require file below $view = $this; if ($this->evalTemplate instanceof FileStorage) { - extract($this->evalParameters, EXTR_SKIP); + extract($this->evalParameters, \EXTR_SKIP); $this->evalParameters = null; ob_start(); @@ -148,7 +148,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess return ob_get_clean(); } elseif ($this->evalTemplate instanceof StringStorage) { - extract($this->evalParameters, EXTR_SKIP); + extract($this->evalParameters, \EXTR_SKIP); $this->evalParameters = null; ob_start(); @@ -393,7 +393,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess */ protected function initializeEscapers() { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; + $flags = \ENT_QUOTES | \ENT_SUBSTITUTE; $this->escapers = [ 'html' => diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php index 4376804296..dc2e9a9d93 100644 --- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php +++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php @@ -202,7 +202,7 @@ EOF } }); - $io->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $io->writeln(json_encode($filesInfo, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); return min($errors, 1); } diff --git a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php index c6700ae153..34c0b56942 100644 --- a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php @@ -25,7 +25,7 @@ class JsonFileDumper extends FileDumper */ public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) { - $flags = $options['json_encoding'] ?? JSON_PRETTY_PRINT; + $flags = $options['json_encoding'] ?? \JSON_PRETTY_PRINT; return json_encode($messages->all($domain), $flags); } diff --git a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php index 57d2642858..00d1670f42 100644 --- a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php @@ -160,7 +160,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface { for (; $tokenIterator->valid(); $tokenIterator->next()) { $t = $tokenIterator->current(); - if (T_WHITESPACE !== $t[0]) { + if (\T_WHITESPACE !== $t[0]) { break; } } @@ -208,23 +208,23 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface } switch ($t[0]) { - case T_START_HEREDOC: + case \T_START_HEREDOC: $docToken = $t[1]; break; - case T_ENCAPSED_AND_WHITESPACE: - case T_CONSTANT_ENCAPSED_STRING: + case \T_ENCAPSED_AND_WHITESPACE: + case \T_CONSTANT_ENCAPSED_STRING: if ('' === $docToken) { $message .= PhpStringTokenParser::parse($t[1]); } else { $docPart = $t[1]; } break; - case T_END_HEREDOC: + case \T_END_HEREDOC: $message .= PhpStringTokenParser::parseDocString($docToken, $docPart); $docToken = ''; $docPart = ''; break; - case T_WHITESPACE: + case \T_WHITESPACE: break; default: break 2; @@ -292,7 +292,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface */ protected function canBeExtracted(string $file) { - return $this->isFile($file) && 'php' === pathinfo($file, PATHINFO_EXTENSION); + return $this->isFile($file) && 'php' === pathinfo($file, \PATHINFO_EXTENSION); } /** diff --git a/src/Symfony/Component/Translation/Loader/JsonFileLoader.php b/src/Symfony/Component/Translation/Loader/JsonFileLoader.php index 9f15dbc628..8a8996b0d2 100644 --- a/src/Symfony/Component/Translation/Loader/JsonFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/JsonFileLoader.php @@ -43,15 +43,15 @@ class JsonFileLoader extends FileLoader private function getJSONErrorMessage(int $errorCode): string { switch ($errorCode) { - case JSON_ERROR_DEPTH: + case \JSON_ERROR_DEPTH: return 'Maximum stack depth exceeded'; - case JSON_ERROR_STATE_MISMATCH: + case \JSON_ERROR_STATE_MISMATCH: return 'Underflow or the modes mismatch'; - case JSON_ERROR_CTRL_CHAR: + case \JSON_ERROR_CTRL_CHAR: return 'Unexpected control character found'; - case JSON_ERROR_SYNTAX: + case \JSON_ERROR_SYNTAX: return 'Syntax error, malformed JSON'; - case JSON_ERROR_UTF8: + case \JSON_ERROR_UTF8: return 'Malformed UTF-8 characters, possibly incorrectly encoded'; default: return 'Unknown error'; diff --git a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php index 0991c3d3a2..c361d5293c 100644 --- a/src/Symfony/Component/Translation/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PhpFileLoader.php @@ -25,7 +25,7 @@ class PhpFileLoader extends FileLoader */ protected function loadResource($resource) { - if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN))) { + if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) { self::$cache = null; } diff --git a/src/Symfony/Component/Translation/PseudoLocalizationTranslator.php b/src/Symfony/Component/Translation/PseudoLocalizationTranslator.php index b43af27f2a..01f8314f41 100644 --- a/src/Symfony/Component/Translation/PseudoLocalizationTranslator.php +++ b/src/Symfony/Component/Translation/PseudoLocalizationTranslator.php @@ -145,7 +145,7 @@ final class PseudoLocalizationTranslator implements TranslatorInterface $parts[] = [false, false, ' '.$attribute->nodeName.'="']; $localizableAttribute = \in_array($attribute->nodeName, $this->localizableHTMLAttributes, true); - foreach (preg_split('/(&(?:amp|quot|#039|lt|gt);+)/', htmlspecialchars($attribute->nodeValue, ENT_QUOTES, 'UTF-8'), -1, PREG_SPLIT_DELIM_CAPTURE) as $i => $match) { + foreach (preg_split('/(&(?:amp|quot|#039|lt|gt);+)/', htmlspecialchars($attribute->nodeValue, \ENT_QUOTES, 'UTF-8'), -1, \PREG_SPLIT_DELIM_CAPTURE) as $i => $match) { if ('' === $match) { continue; } @@ -285,7 +285,7 @@ final class PseudoLocalizationTranslator implements TranslatorInterface $words = []; $wordsCount = 0; - foreach (preg_split('/ +/', $visibleText, -1, PREG_SPLIT_NO_EMPTY) as $word) { + foreach (preg_split('/ +/', $visibleText, -1, \PREG_SPLIT_NO_EMPTY) as $word) { $wordLength = $this->strlen($word); if ($wordLength >= $missingLength) { @@ -306,7 +306,7 @@ final class PseudoLocalizationTranslator implements TranslatorInterface return; } - arsort($words, SORT_NUMERIC); + arsort($words, \SORT_NUMERIC); $longestWordLength = max(array_keys($words)); diff --git a/src/Symfony/Component/Translation/Resources/bin/translation-status.php b/src/Symfony/Component/Translation/Resources/bin/translation-status.php index 44918c92ec..e3e6449630 100644 --- a/src/Symfony/Component/Translation/Resources/bin/translation-status.php +++ b/src/Symfony/Component/Translation/Resources/bin/translation-status.php @@ -61,7 +61,7 @@ foreach (array_slice($argv, 1) as $argumentOrOption) { foreach ($config['original_files'] as $originalFilePath) { if (!file_exists($originalFilePath)) { - echo sprintf('The following file does not exist. Make sure that you execute this command at the root dir of the Symfony code repository.%s %s', PHP_EOL, $originalFilePath); + echo sprintf('The following file does not exist. Make sure that you execute this command at the root dir of the Symfony code repository.%s %s', \PHP_EOL, $originalFilePath); exit(1); } } @@ -89,7 +89,7 @@ function findTranslationFiles($originalFilePath, $localeToAnalyze) $originalFileName = basename($originalFilePath); $translationFileNamePattern = str_replace('.en.', '.*.', $originalFileName); - $translationFiles = glob($translationsDir.'/'.$translationFileNamePattern, GLOB_NOSORT); + $translationFiles = glob($translationsDir.'/'.$translationFileNamePattern, \GLOB_NOSORT); sort($translationFiles); foreach ($translationFiles as $filePath) { $locale = extractLocaleFromFilePath($filePath); @@ -127,7 +127,7 @@ function printTranslationStatus($originalFilePath, $translationStatus, $verboseO { printTitle($originalFilePath); printTable($translationStatus, $verboseOutput); - echo PHP_EOL.PHP_EOL; + echo \PHP_EOL.\PHP_EOL; } function extractLocaleFromFilePath($filePath) @@ -154,8 +154,8 @@ function extractTranslationKeys($filePath) function printTitle($title) { - echo $title.PHP_EOL; - echo str_repeat('=', strlen($title)).PHP_EOL.PHP_EOL; + echo $title.\PHP_EOL; + echo str_repeat('=', strlen($title)).\PHP_EOL.\PHP_EOL; } function printTable($translations, $verboseOutput) @@ -174,19 +174,19 @@ function printTable($translations, $verboseOutput) textColorGreen(); } - echo sprintf('| Locale: %-'.$longestLocaleNameLength.'s | Translated: %d/%d', $locale, $translation['translated'], $translation['total']).PHP_EOL; + echo sprintf('| Locale: %-'.$longestLocaleNameLength.'s | Translated: %d/%d', $locale, $translation['translated'], $translation['total']).\PHP_EOL; textColorNormal(); if (true === $verboseOutput && count($translation['missingKeys']) > 0) { - echo str_repeat('-', 80).PHP_EOL; - echo '| Missing Translations:'.PHP_EOL; + echo str_repeat('-', 80).\PHP_EOL; + echo '| Missing Translations:'.\PHP_EOL; foreach ($translation['missingKeys'] as $id => $content) { - echo sprintf('| (id=%s) %s', $id, $content).PHP_EOL; + echo sprintf('| (id=%s) %s', $id, $content).\PHP_EOL; } - echo str_repeat('-', 80).PHP_EOL; + echo str_repeat('-', 80).\PHP_EOL; } } } diff --git a/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php index 04e3d86bec..e353f85d99 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php @@ -34,6 +34,6 @@ class JsonFileDumperTest extends TestCase $dumper = new JsonFileDumper(); - $this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.dump.json', $dumper->formatCatalogue($catalogue, 'messages', ['json_encoding' => JSON_HEX_QUOT])); + $this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.dump.json', $dumper->formatCatalogue($catalogue, 'messages', ['json_encoding' => \JSON_HEX_QUOT])); } } diff --git a/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php b/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php index 37d982cf29..b904c8fc76 100644 --- a/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php +++ b/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php @@ -36,7 +36,7 @@ class IntlFormatterTest extends \PHPUnit\Framework\TestCase public function testFormatWithNamedArguments() { - if (version_compare(INTL_ICU_VERSION, '4.8', '<')) { + if (version_compare(\INTL_ICU_VERSION, '4.8', '<')) { $this->markTestSkipped('Format with named arguments can only be run with ICU 4.8 or higher and PHP >= 5.5'); } diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php index b3d77474a1..28c91229b0 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php @@ -49,7 +49,7 @@ class XliffFileLoaderTest extends TestCase public function testLoadWithExternalEntitiesDisabled() { - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(true); } @@ -57,7 +57,7 @@ class XliffFileLoaderTest extends TestCase $resource = __DIR__.'/../fixtures/resources.xlf'; $catalogue = $loader->load($resource, 'en', 'domain1'); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } diff --git a/src/Symfony/Component/Translation/Util/XliffUtils.php b/src/Symfony/Component/Translation/Util/XliffUtils.php index 072b2671cb..a8c05c2244 100644 --- a/src/Symfony/Component/Translation/Util/XliffUtils.php +++ b/src/Symfony/Component/Translation/Util/XliffUtils.php @@ -61,20 +61,20 @@ class XliffUtils { $xliffVersion = static::getVersionNumber($dom); $internalErrors = libxml_use_internal_errors(true); - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { $disableEntities = libxml_disable_entity_loader(false); } $isValid = @$dom->schemaValidateSource(self::getSchema($xliffVersion)); if (!$isValid) { - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } return self::getXmlErrors($internalErrors); } - if (LIBXML_VERSION < 20900) { + if (\LIBXML_VERSION < 20900) { libxml_disable_entity_loader($disableEntities); } @@ -92,7 +92,7 @@ class XliffUtils foreach ($xmlErrors as $error) { $errorsAsString .= sprintf("[%s %s] %s (in %s - line %d, column %d)\n", - LIBXML_ERR_WARNING === $error['level'] ? 'WARNING' : 'ERROR', + \LIBXML_ERR_WARNING === $error['level'] ? 'WARNING' : 'ERROR', $error['code'], $error['message'], $error['file'], @@ -152,7 +152,7 @@ class XliffUtils $errors = []; foreach (libxml_get_errors() as $error) { $errors[] = [ - 'level' => LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', + 'level' => \LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', 'code' => $error->code, 'message' => trim($error->message), 'file' => $error->file ?: 'n/a', diff --git a/src/Symfony/Component/Uid/BinaryUtil.php b/src/Symfony/Component/Uid/BinaryUtil.php index 3418d59ee1..082346cd15 100644 --- a/src/Symfony/Component/Uid/BinaryUtil.php +++ b/src/Symfony/Component/Uid/BinaryUtil.php @@ -120,7 +120,7 @@ class BinaryUtil return (hexdec($time) - self::TIME_OFFSET_INT) / 10000000; } - $time = str_pad(hex2bin($time), 8, "\0", STR_PAD_LEFT); + $time = str_pad(hex2bin($time), 8, "\0", \STR_PAD_LEFT); $time = self::add($time, self::TIME_OFFSET_COM); $time[0] = $time[0] & "\x7F"; diff --git a/src/Symfony/Component/Uid/NilUuid.php b/src/Symfony/Component/Uid/NilUuid.php index c3b5db16d4..b5ff73a476 100644 --- a/src/Symfony/Component/Uid/NilUuid.php +++ b/src/Symfony/Component/Uid/NilUuid.php @@ -18,7 +18,7 @@ namespace Symfony\Component\Uid; */ class NilUuid extends Uuid { - protected const TYPE = UUID_TYPE_NULL; + protected const TYPE = \UUID_TYPE_NULL; public function __construct() { diff --git a/src/Symfony/Component/Uid/Uuid.php b/src/Symfony/Component/Uid/Uuid.php index 1fe335e4bb..2719d20b1b 100644 --- a/src/Symfony/Component/Uid/Uuid.php +++ b/src/Symfony/Component/Uid/Uuid.php @@ -18,13 +18,13 @@ namespace Symfony\Component\Uid; */ class Uuid extends AbstractUid { - protected const TYPE = UUID_TYPE_DEFAULT; + protected const TYPE = \UUID_TYPE_DEFAULT; public function __construct(string $uuid) { $type = uuid_type($uuid); - if (false === $type || UUID_TYPE_INVALID === $type || (static::TYPE ?: $type) !== $type) { + if (false === $type || \UUID_TYPE_INVALID === $type || (static::TYPE ?: $type) !== $type) { throw new \InvalidArgumentException(sprintf('Invalid UUID%s: "%s".', static::TYPE ? 'v'.static::TYPE : '', $uuid)); } diff --git a/src/Symfony/Component/Uid/UuidV1.php b/src/Symfony/Component/Uid/UuidV1.php index 12ed39a6ff..5f2d7e6a8a 100644 --- a/src/Symfony/Component/Uid/UuidV1.php +++ b/src/Symfony/Component/Uid/UuidV1.php @@ -20,7 +20,7 @@ namespace Symfony\Component\Uid; */ class UuidV1 extends Uuid { - protected const TYPE = UUID_TYPE_TIME; + protected const TYPE = \UUID_TYPE_TIME; public function __construct(string $uuid = null) { diff --git a/src/Symfony/Component/Uid/UuidV3.php b/src/Symfony/Component/Uid/UuidV3.php index cfdf3e48fc..d5d0d8fe86 100644 --- a/src/Symfony/Component/Uid/UuidV3.php +++ b/src/Symfony/Component/Uid/UuidV3.php @@ -22,5 +22,5 @@ namespace Symfony\Component\Uid; */ class UuidV3 extends Uuid { - protected const TYPE = UUID_TYPE_MD5; + protected const TYPE = \UUID_TYPE_MD5; } diff --git a/src/Symfony/Component/Uid/UuidV4.php b/src/Symfony/Component/Uid/UuidV4.php index 97ed1acf78..d338f1eb0c 100644 --- a/src/Symfony/Component/Uid/UuidV4.php +++ b/src/Symfony/Component/Uid/UuidV4.php @@ -20,7 +20,7 @@ namespace Symfony\Component\Uid; */ class UuidV4 extends Uuid { - protected const TYPE = UUID_TYPE_RANDOM; + protected const TYPE = \UUID_TYPE_RANDOM; public function __construct(string $uuid = null) { diff --git a/src/Symfony/Component/Uid/UuidV5.php b/src/Symfony/Component/Uid/UuidV5.php index a36f2c94c2..59a6a2082c 100644 --- a/src/Symfony/Component/Uid/UuidV5.php +++ b/src/Symfony/Component/Uid/UuidV5.php @@ -22,5 +22,5 @@ namespace Symfony\Component\Uid; */ class UuidV5 extends Uuid { - protected const TYPE = UUID_TYPE_SHA1; + protected const TYPE = \UUID_TYPE_SHA1; } diff --git a/src/Symfony/Component/Uid/UuidV6.php b/src/Symfony/Component/Uid/UuidV6.php index 2d30d8820d..9d0ca9fdc0 100644 --- a/src/Symfony/Component/Uid/UuidV6.php +++ b/src/Symfony/Component/Uid/UuidV6.php @@ -25,7 +25,7 @@ class UuidV6 extends Uuid public function __construct(string $uuid = null) { if (null === $uuid) { - $uuid = uuid_create(UUID_TYPE_TIME); + $uuid = uuid_create(\UUID_TYPE_TIME); $this->uid = substr($uuid, 15, 3).substr($uuid, 9, 4).$uuid[0].'-'.substr($uuid, 1, 4).'-6'.substr($uuid, 5, 3).substr($uuid, 18); } else { parent::__construct($uuid); diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index 31218c2020..3c946ff96c 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -53,7 +53,7 @@ class FileValidator extends ConstraintValidator if ($value instanceof UploadedFile && !$value->isValid()) { switch ($value->getError()) { - case UPLOAD_ERR_INI_SIZE: + case \UPLOAD_ERR_INI_SIZE: $iniLimitSize = UploadedFile::getMaxFilesize(); if ($constraint->maxSize && $constraint->maxSize < $iniLimitSize) { $limitInBytes = $constraint->maxSize; @@ -67,43 +67,43 @@ class FileValidator extends ConstraintValidator $this->context->buildViolation($constraint->uploadIniSizeErrorMessage) ->setParameter('{{ limit }}', $limitAsString) ->setParameter('{{ suffix }}', $suffix) - ->setCode((string) UPLOAD_ERR_INI_SIZE) + ->setCode((string) \UPLOAD_ERR_INI_SIZE) ->addViolation(); return; - case UPLOAD_ERR_FORM_SIZE: + case \UPLOAD_ERR_FORM_SIZE: $this->context->buildViolation($constraint->uploadFormSizeErrorMessage) - ->setCode((string) UPLOAD_ERR_FORM_SIZE) + ->setCode((string) \UPLOAD_ERR_FORM_SIZE) ->addViolation(); return; - case UPLOAD_ERR_PARTIAL: + case \UPLOAD_ERR_PARTIAL: $this->context->buildViolation($constraint->uploadPartialErrorMessage) - ->setCode((string) UPLOAD_ERR_PARTIAL) + ->setCode((string) \UPLOAD_ERR_PARTIAL) ->addViolation(); return; - case UPLOAD_ERR_NO_FILE: + case \UPLOAD_ERR_NO_FILE: $this->context->buildViolation($constraint->uploadNoFileErrorMessage) - ->setCode((string) UPLOAD_ERR_NO_FILE) + ->setCode((string) \UPLOAD_ERR_NO_FILE) ->addViolation(); return; - case UPLOAD_ERR_NO_TMP_DIR: + case \UPLOAD_ERR_NO_TMP_DIR: $this->context->buildViolation($constraint->uploadNoTmpDirErrorMessage) - ->setCode((string) UPLOAD_ERR_NO_TMP_DIR) + ->setCode((string) \UPLOAD_ERR_NO_TMP_DIR) ->addViolation(); return; - case UPLOAD_ERR_CANT_WRITE: + case \UPLOAD_ERR_CANT_WRITE: $this->context->buildViolation($constraint->uploadCantWriteErrorMessage) - ->setCode((string) UPLOAD_ERR_CANT_WRITE) + ->setCode((string) \UPLOAD_ERR_CANT_WRITE) ->addViolation(); return; - case UPLOAD_ERR_EXTENSION: + case \UPLOAD_ERR_EXTENSION: $this->context->buildViolation($constraint->uploadExtensionErrorMessage) - ->setCode((string) UPLOAD_ERR_EXTENSION) + ->setCode((string) \UPLOAD_ERR_EXTENSION) ->addViolation(); return; diff --git a/src/Symfony/Component/Validator/Constraints/HostnameValidator.php b/src/Symfony/Component/Validator/Constraints/HostnameValidator.php index c9af0977e9..144d57e37d 100644 --- a/src/Symfony/Component/Validator/Constraints/HostnameValidator.php +++ b/src/Symfony/Component/Validator/Constraints/HostnameValidator.php @@ -59,7 +59,7 @@ class HostnameValidator extends ConstraintValidator private function isValid(string $domain): bool { - return false !== filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); + return false !== filter_var($domain, \FILTER_VALIDATE_DOMAIN, \FILTER_FLAG_HOSTNAME); } private function hasValidTld(string $domain): bool diff --git a/src/Symfony/Component/Validator/Constraints/IpValidator.php b/src/Symfony/Component/Validator/Constraints/IpValidator.php index f965a31d4b..11d3f52cd3 100644 --- a/src/Symfony/Component/Validator/Constraints/IpValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IpValidator.php @@ -49,47 +49,47 @@ class IpValidator extends ConstraintValidator switch ($constraint->version) { case Ip::V4: - $flag = FILTER_FLAG_IPV4; + $flag = \FILTER_FLAG_IPV4; break; case Ip::V6: - $flag = FILTER_FLAG_IPV6; + $flag = \FILTER_FLAG_IPV6; break; case Ip::V4_NO_PRIV: - $flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE; + $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE; break; case Ip::V6_NO_PRIV: - $flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE; + $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE; break; case Ip::ALL_NO_PRIV: - $flag = FILTER_FLAG_NO_PRIV_RANGE; + $flag = \FILTER_FLAG_NO_PRIV_RANGE; break; case Ip::V4_NO_RES: - $flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE; + $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_RES_RANGE; break; case Ip::V6_NO_RES: - $flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_RES_RANGE; + $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_RES_RANGE; break; case Ip::ALL_NO_RES: - $flag = FILTER_FLAG_NO_RES_RANGE; + $flag = \FILTER_FLAG_NO_RES_RANGE; break; case Ip::V4_ONLY_PUBLIC: - $flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE; + $flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; break; case Ip::V6_ONLY_PUBLIC: - $flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE; + $flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; break; case Ip::ALL_ONLY_PUBLIC: - $flag = FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE; + $flag = \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; break; default: @@ -97,7 +97,7 @@ class IpValidator extends ConstraintValidator break; } - if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) { + if (!filter_var($value, \FILTER_VALIDATE_IP, $flag)) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) ->setCode(Ip::INVALID_IP_ERROR) diff --git a/src/Symfony/Component/Validator/Constraints/JsonValidator.php b/src/Symfony/Component/Validator/Constraints/JsonValidator.php index 850bbfbcbf..e553ae359b 100644 --- a/src/Symfony/Component/Validator/Constraints/JsonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/JsonValidator.php @@ -41,7 +41,7 @@ class JsonValidator extends ConstraintValidator json_decode($value); - if (JSON_ERROR_NONE !== json_last_error()) { + if (\JSON_ERROR_NONE !== json_last_error()) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) ->setCode(Json::INVALID_JSON_ERROR) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php index 623ac4c192..7612ada32b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php @@ -72,7 +72,7 @@ class DivisibleByValidatorTest extends AbstractComparisonValidatorTestCase [1, '1', 2, '2', 'int'], [10, '10', 3, '3', 'int'], [10, '10', 0, '0', 'int'], - [42, '42', INF, 'INF', 'float'], + [42, '42', \INF, 'INF', 'float'], [4.15, '4.15', 0.1, '0.1', 'float'], ['22', '"22"', '10', '"10"', 'string'], ]; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 0bbac3c6b7..f517baea87 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -159,7 +159,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase */ public function testMaxSizeExceeded($bytesWritten, $limit, $sizeAsString, $limitAsString, $suffix) { - fseek($this->file, $bytesWritten - 1, SEEK_SET); + fseek($this->file, $bytesWritten - 1, \SEEK_SET); fwrite($this->file, '0'); fclose($this->file); @@ -208,7 +208,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase */ public function testMaxSizeNotExceeded($bytesWritten, $limit) { - fseek($this->file, $bytesWritten - 1, SEEK_SET); + fseek($this->file, $bytesWritten - 1, \SEEK_SET); fwrite($this->file, '0'); fclose($this->file); @@ -259,7 +259,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase */ public function testBinaryFormat($bytesWritten, $limit, $binaryFormat, $sizeAsString, $limitAsString, $suffix) { - fseek($this->file, $bytesWritten - 1, SEEK_SET); + fseek($this->file, $bytesWritten - 1, \SEEK_SET); fwrite($this->file, '0'); fclose($this->file); @@ -431,23 +431,23 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase public function uploadedFileErrorProvider() { $tests = [ - [(string) UPLOAD_ERR_FORM_SIZE, 'uploadFormSizeErrorMessage'], - [(string) UPLOAD_ERR_PARTIAL, 'uploadPartialErrorMessage'], - [(string) UPLOAD_ERR_NO_FILE, 'uploadNoFileErrorMessage'], - [(string) UPLOAD_ERR_NO_TMP_DIR, 'uploadNoTmpDirErrorMessage'], - [(string) UPLOAD_ERR_CANT_WRITE, 'uploadCantWriteErrorMessage'], - [(string) UPLOAD_ERR_EXTENSION, 'uploadExtensionErrorMessage'], + [(string) \UPLOAD_ERR_FORM_SIZE, 'uploadFormSizeErrorMessage'], + [(string) \UPLOAD_ERR_PARTIAL, 'uploadPartialErrorMessage'], + [(string) \UPLOAD_ERR_NO_FILE, 'uploadNoFileErrorMessage'], + [(string) \UPLOAD_ERR_NO_TMP_DIR, 'uploadNoTmpDirErrorMessage'], + [(string) \UPLOAD_ERR_CANT_WRITE, 'uploadCantWriteErrorMessage'], + [(string) \UPLOAD_ERR_EXTENSION, 'uploadExtensionErrorMessage'], ]; if (class_exists('Symfony\Component\HttpFoundation\File\UploadedFile')) { // when no maxSize is specified on constraint, it should use the ini value - $tests[] = [(string) UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ + $tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ '{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576, '{{ suffix }}' => 'MiB', ]]; // it should use the smaller limitation (maxSize option in this case) - $tests[] = [(string) UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ + $tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ '{{ limit }}' => 1, '{{ suffix }}' => 'bytes', ], '1']; @@ -460,14 +460,14 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase // it correctly parses the maxSize option and not only uses simple string comparison // 1000M should be bigger than the ini value - $tests[] = [(string) UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ + $tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ '{{ limit }}' => $limit, '{{ suffix }}' => $suffix, ], '1000M']; // it correctly parses the maxSize option and not only uses simple string comparison // 1000M should be bigger than the ini value - $tests[] = [(string) UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ + $tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ '{{ limit }}' => '0.1', '{{ suffix }}' => 'MB', ], '100K']; diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php index f81868b5b8..57033884d7 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -132,7 +132,7 @@ class YamlFileLoaderTest extends TestCase $loader->loadClassMetadata($metadata); $expected = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity'); - $expected->addPropertyConstraint('firstName', new Range(['max' => PHP_INT_MAX])); + $expected->addPropertyConstraint('firstName', new Range(['max' => \PHP_INT_MAX])); $this->assertEquals($expected, $metadata); } diff --git a/src/Symfony/Component/Validator/Validator/TraceableValidator.php b/src/Symfony/Component/Validator/Validator/TraceableValidator.php index be7daf48c8..74a922fa4e 100644 --- a/src/Symfony/Component/Validator/Validator/TraceableValidator.php +++ b/src/Symfony/Component/Validator/Validator/TraceableValidator.php @@ -65,7 +65,7 @@ class TraceableValidator implements ValidatorInterface, ResetInterface { $violations = $this->validator->validate($value, $constraints, $groups); - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 7); + $trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 7); $file = $trace[0]['file']; $line = $trace[0]['line']; diff --git a/src/Symfony/Component/VarDumper/Caster/AmqpCaster.php b/src/Symfony/Component/VarDumper/Caster/AmqpCaster.php index 883d02b4e6..daa0d4f798 100644 --- a/src/Symfony/Component/VarDumper/Caster/AmqpCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/AmqpCaster.php @@ -23,27 +23,27 @@ use Symfony\Component\VarDumper\Cloner\Stub; class AmqpCaster { private static $flags = [ - AMQP_DURABLE => 'AMQP_DURABLE', - AMQP_PASSIVE => 'AMQP_PASSIVE', - AMQP_EXCLUSIVE => 'AMQP_EXCLUSIVE', - AMQP_AUTODELETE => 'AMQP_AUTODELETE', - AMQP_INTERNAL => 'AMQP_INTERNAL', - AMQP_NOLOCAL => 'AMQP_NOLOCAL', - AMQP_AUTOACK => 'AMQP_AUTOACK', - AMQP_IFEMPTY => 'AMQP_IFEMPTY', - AMQP_IFUNUSED => 'AMQP_IFUNUSED', - AMQP_MANDATORY => 'AMQP_MANDATORY', - AMQP_IMMEDIATE => 'AMQP_IMMEDIATE', - AMQP_MULTIPLE => 'AMQP_MULTIPLE', - AMQP_NOWAIT => 'AMQP_NOWAIT', - AMQP_REQUEUE => 'AMQP_REQUEUE', + \AMQP_DURABLE => 'AMQP_DURABLE', + \AMQP_PASSIVE => 'AMQP_PASSIVE', + \AMQP_EXCLUSIVE => 'AMQP_EXCLUSIVE', + \AMQP_AUTODELETE => 'AMQP_AUTODELETE', + \AMQP_INTERNAL => 'AMQP_INTERNAL', + \AMQP_NOLOCAL => 'AMQP_NOLOCAL', + \AMQP_AUTOACK => 'AMQP_AUTOACK', + \AMQP_IFEMPTY => 'AMQP_IFEMPTY', + \AMQP_IFUNUSED => 'AMQP_IFUNUSED', + \AMQP_MANDATORY => 'AMQP_MANDATORY', + \AMQP_IMMEDIATE => 'AMQP_IMMEDIATE', + \AMQP_MULTIPLE => 'AMQP_MULTIPLE', + \AMQP_NOWAIT => 'AMQP_NOWAIT', + \AMQP_REQUEUE => 'AMQP_REQUEUE', ]; private static $exchangeTypes = [ - AMQP_EX_TYPE_DIRECT => 'AMQP_EX_TYPE_DIRECT', - AMQP_EX_TYPE_FANOUT => 'AMQP_EX_TYPE_FANOUT', - AMQP_EX_TYPE_TOPIC => 'AMQP_EX_TYPE_TOPIC', - AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS', + \AMQP_EX_TYPE_DIRECT => 'AMQP_EX_TYPE_DIRECT', + \AMQP_EX_TYPE_FANOUT => 'AMQP_EX_TYPE_FANOUT', + \AMQP_EX_TYPE_TOPIC => 'AMQP_EX_TYPE_TOPIC', + \AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS', ]; public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, bool $isNested) diff --git a/src/Symfony/Component/VarDumper/Caster/DOMCaster.php b/src/Symfony/Component/VarDumper/Caster/DOMCaster.php index 98359ff41f..499aca1f56 100644 --- a/src/Symfony/Component/VarDumper/Caster/DOMCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DOMCaster.php @@ -23,44 +23,44 @@ use Symfony\Component\VarDumper\Cloner\Stub; class DOMCaster { private static $errorCodes = [ - DOM_PHP_ERR => 'DOM_PHP_ERR', - DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR', - DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR', - DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR', - DOM_WRONG_DOCUMENT_ERR => 'DOM_WRONG_DOCUMENT_ERR', - DOM_INVALID_CHARACTER_ERR => 'DOM_INVALID_CHARACTER_ERR', - DOM_NO_DATA_ALLOWED_ERR => 'DOM_NO_DATA_ALLOWED_ERR', - DOM_NO_MODIFICATION_ALLOWED_ERR => 'DOM_NO_MODIFICATION_ALLOWED_ERR', - DOM_NOT_FOUND_ERR => 'DOM_NOT_FOUND_ERR', - DOM_NOT_SUPPORTED_ERR => 'DOM_NOT_SUPPORTED_ERR', - DOM_INUSE_ATTRIBUTE_ERR => 'DOM_INUSE_ATTRIBUTE_ERR', - DOM_INVALID_STATE_ERR => 'DOM_INVALID_STATE_ERR', - DOM_SYNTAX_ERR => 'DOM_SYNTAX_ERR', - DOM_INVALID_MODIFICATION_ERR => 'DOM_INVALID_MODIFICATION_ERR', - DOM_NAMESPACE_ERR => 'DOM_NAMESPACE_ERR', - DOM_INVALID_ACCESS_ERR => 'DOM_INVALID_ACCESS_ERR', - DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR', + \DOM_PHP_ERR => 'DOM_PHP_ERR', + \DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR', + \DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR', + \DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR', + \DOM_WRONG_DOCUMENT_ERR => 'DOM_WRONG_DOCUMENT_ERR', + \DOM_INVALID_CHARACTER_ERR => 'DOM_INVALID_CHARACTER_ERR', + \DOM_NO_DATA_ALLOWED_ERR => 'DOM_NO_DATA_ALLOWED_ERR', + \DOM_NO_MODIFICATION_ALLOWED_ERR => 'DOM_NO_MODIFICATION_ALLOWED_ERR', + \DOM_NOT_FOUND_ERR => 'DOM_NOT_FOUND_ERR', + \DOM_NOT_SUPPORTED_ERR => 'DOM_NOT_SUPPORTED_ERR', + \DOM_INUSE_ATTRIBUTE_ERR => 'DOM_INUSE_ATTRIBUTE_ERR', + \DOM_INVALID_STATE_ERR => 'DOM_INVALID_STATE_ERR', + \DOM_SYNTAX_ERR => 'DOM_SYNTAX_ERR', + \DOM_INVALID_MODIFICATION_ERR => 'DOM_INVALID_MODIFICATION_ERR', + \DOM_NAMESPACE_ERR => 'DOM_NAMESPACE_ERR', + \DOM_INVALID_ACCESS_ERR => 'DOM_INVALID_ACCESS_ERR', + \DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR', ]; private static $nodeTypes = [ - XML_ELEMENT_NODE => 'XML_ELEMENT_NODE', - XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE', - XML_TEXT_NODE => 'XML_TEXT_NODE', - XML_CDATA_SECTION_NODE => 'XML_CDATA_SECTION_NODE', - XML_ENTITY_REF_NODE => 'XML_ENTITY_REF_NODE', - XML_ENTITY_NODE => 'XML_ENTITY_NODE', - XML_PI_NODE => 'XML_PI_NODE', - XML_COMMENT_NODE => 'XML_COMMENT_NODE', - XML_DOCUMENT_NODE => 'XML_DOCUMENT_NODE', - XML_DOCUMENT_TYPE_NODE => 'XML_DOCUMENT_TYPE_NODE', - XML_DOCUMENT_FRAG_NODE => 'XML_DOCUMENT_FRAG_NODE', - XML_NOTATION_NODE => 'XML_NOTATION_NODE', - XML_HTML_DOCUMENT_NODE => 'XML_HTML_DOCUMENT_NODE', - XML_DTD_NODE => 'XML_DTD_NODE', - XML_ELEMENT_DECL_NODE => 'XML_ELEMENT_DECL_NODE', - XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE', - XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE', - XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE', + \XML_ELEMENT_NODE => 'XML_ELEMENT_NODE', + \XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE', + \XML_TEXT_NODE => 'XML_TEXT_NODE', + \XML_CDATA_SECTION_NODE => 'XML_CDATA_SECTION_NODE', + \XML_ENTITY_REF_NODE => 'XML_ENTITY_REF_NODE', + \XML_ENTITY_NODE => 'XML_ENTITY_NODE', + \XML_PI_NODE => 'XML_PI_NODE', + \XML_COMMENT_NODE => 'XML_COMMENT_NODE', + \XML_DOCUMENT_NODE => 'XML_DOCUMENT_NODE', + \XML_DOCUMENT_TYPE_NODE => 'XML_DOCUMENT_TYPE_NODE', + \XML_DOCUMENT_FRAG_NODE => 'XML_DOCUMENT_FRAG_NODE', + \XML_NOTATION_NODE => 'XML_NOTATION_NODE', + \XML_HTML_DOCUMENT_NODE => 'XML_HTML_DOCUMENT_NODE', + \XML_DTD_NODE => 'XML_DTD_NODE', + \XML_ELEMENT_DECL_NODE => 'XML_ELEMENT_DECL_NODE', + \XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE', + \XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE', + \XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE', ]; public static function castException(\DOMException $e, array $a, Stub $stub, bool $isNested) diff --git a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php index c2eb6be433..8f72276824 100644 --- a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php @@ -27,21 +27,21 @@ class ExceptionCaster public static $srcContext = 1; public static $traceArgs = true; public static $errorTypes = [ - E_DEPRECATED => 'E_DEPRECATED', - E_USER_DEPRECATED => 'E_USER_DEPRECATED', - E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', - E_ERROR => 'E_ERROR', - E_WARNING => 'E_WARNING', - E_PARSE => 'E_PARSE', - E_NOTICE => 'E_NOTICE', - E_CORE_ERROR => 'E_CORE_ERROR', - E_CORE_WARNING => 'E_CORE_WARNING', - E_COMPILE_ERROR => 'E_COMPILE_ERROR', - E_COMPILE_WARNING => 'E_COMPILE_WARNING', - E_USER_ERROR => 'E_USER_ERROR', - E_USER_WARNING => 'E_USER_WARNING', - E_USER_NOTICE => 'E_USER_NOTICE', - E_STRICT => 'E_STRICT', + \E_DEPRECATED => 'E_DEPRECATED', + \E_USER_DEPRECATED => 'E_USER_DEPRECATED', + \E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', + \E_ERROR => 'E_ERROR', + \E_WARNING => 'E_WARNING', + \E_PARSE => 'E_PARSE', + \E_NOTICE => 'E_NOTICE', + \E_CORE_ERROR => 'E_CORE_ERROR', + \E_CORE_WARNING => 'E_CORE_WARNING', + \E_COMPILE_ERROR => 'E_COMPILE_ERROR', + \E_COMPILE_WARNING => 'E_COMPILE_WARNING', + \E_USER_ERROR => 'E_USER_ERROR', + \E_USER_WARNING => 'E_USER_WARNING', + \E_USER_NOTICE => 'E_USER_NOTICE', + \E_STRICT => 'E_STRICT', ]; private static $framesCache = []; diff --git a/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php b/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php index f9f3c6f78c..c153cf9fd6 100644 --- a/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php @@ -36,37 +36,37 @@ class PgSqlCaster ]; private static $transactionStatus = [ - PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE', - PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE', - PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS', - PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR', - PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN', + \PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE', + \PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE', + \PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS', + \PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR', + \PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN', ]; private static $resultStatus = [ - PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY', - PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK', - PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK', - PGSQL_COPY_OUT => 'PGSQL_COPY_OUT', - PGSQL_COPY_IN => 'PGSQL_COPY_IN', - PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE', - PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR', - PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR', + \PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY', + \PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK', + \PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK', + \PGSQL_COPY_OUT => 'PGSQL_COPY_OUT', + \PGSQL_COPY_IN => 'PGSQL_COPY_IN', + \PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE', + \PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR', + \PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR', ]; private static $diagCodes = [ - 'severity' => PGSQL_DIAG_SEVERITY, - 'sqlstate' => PGSQL_DIAG_SQLSTATE, - 'message' => PGSQL_DIAG_MESSAGE_PRIMARY, - 'detail' => PGSQL_DIAG_MESSAGE_DETAIL, - 'hint' => PGSQL_DIAG_MESSAGE_HINT, - 'statement position' => PGSQL_DIAG_STATEMENT_POSITION, - 'internal position' => PGSQL_DIAG_INTERNAL_POSITION, - 'internal query' => PGSQL_DIAG_INTERNAL_QUERY, - 'context' => PGSQL_DIAG_CONTEXT, - 'file' => PGSQL_DIAG_SOURCE_FILE, - 'line' => PGSQL_DIAG_SOURCE_LINE, - 'function' => PGSQL_DIAG_SOURCE_FUNCTION, + 'severity' => \PGSQL_DIAG_SEVERITY, + 'sqlstate' => \PGSQL_DIAG_SQLSTATE, + 'message' => \PGSQL_DIAG_MESSAGE_PRIMARY, + 'detail' => \PGSQL_DIAG_MESSAGE_DETAIL, + 'hint' => \PGSQL_DIAG_MESSAGE_HINT, + 'statement position' => \PGSQL_DIAG_STATEMENT_POSITION, + 'internal position' => \PGSQL_DIAG_INTERNAL_POSITION, + 'internal query' => \PGSQL_DIAG_INTERNAL_QUERY, + 'context' => \PGSQL_DIAG_CONTEXT, + 'file' => \PGSQL_DIAG_SOURCE_FILE, + 'line' => \PGSQL_DIAG_SOURCE_LINE, + 'function' => \PGSQL_DIAG_SOURCE_FUNCTION, ]; public static function castLargeObject($lo, array $a, Stub $stub, bool $isNested) @@ -79,7 +79,7 @@ class PgSqlCaster public static function castLink($link, array $a, Stub $stub, bool $isNested) { $a['status'] = pg_connection_status($link); - $a['status'] = new ConstStub(PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']); + $a['status'] = new ConstStub(\PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']); $a['busy'] = pg_connection_busy($link); $a['transaction'] = pg_transaction_status($link); @@ -115,7 +115,7 @@ class PgSqlCaster if (isset(self::$resultStatus[$a['status']])) { $a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']); } - $a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING); + $a['command-completion tag'] = pg_result_status($result, \PGSQL_STATUS_STRING); if (-1 === $a['num rows']) { foreach (self::$diagCodes as $k => $v) { diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 470229b5b5..d9b43ae730 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -120,7 +120,7 @@ class ReflectionCaster 'file' => $c->getExecutingFile(), 'line' => $c->getExecutingLine(), ]; - if ($trace = $c->getTrace(DEBUG_BACKTRACE_IGNORE_ARGS)) { + if ($trace = $c->getTrace(\DEBUG_BACKTRACE_IGNORE_ARGS)) { $function = new \ReflectionGenerator($c->getExecutingGenerator()); array_unshift($trace, [ 'function' => 'yield', diff --git a/src/Symfony/Component/VarDumper/Caster/XmlResourceCaster.php b/src/Symfony/Component/VarDumper/Caster/XmlResourceCaster.php index edece30b6e..42b25696fe 100644 --- a/src/Symfony/Component/VarDumper/Caster/XmlResourceCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/XmlResourceCaster.php @@ -23,28 +23,28 @@ use Symfony\Component\VarDumper\Cloner\Stub; class XmlResourceCaster { private static $xmlErrors = [ - XML_ERROR_NONE => 'XML_ERROR_NONE', - XML_ERROR_NO_MEMORY => 'XML_ERROR_NO_MEMORY', - XML_ERROR_SYNTAX => 'XML_ERROR_SYNTAX', - XML_ERROR_NO_ELEMENTS => 'XML_ERROR_NO_ELEMENTS', - XML_ERROR_INVALID_TOKEN => 'XML_ERROR_INVALID_TOKEN', - XML_ERROR_UNCLOSED_TOKEN => 'XML_ERROR_UNCLOSED_TOKEN', - XML_ERROR_PARTIAL_CHAR => 'XML_ERROR_PARTIAL_CHAR', - XML_ERROR_TAG_MISMATCH => 'XML_ERROR_TAG_MISMATCH', - XML_ERROR_DUPLICATE_ATTRIBUTE => 'XML_ERROR_DUPLICATE_ATTRIBUTE', - XML_ERROR_JUNK_AFTER_DOC_ELEMENT => 'XML_ERROR_JUNK_AFTER_DOC_ELEMENT', - XML_ERROR_PARAM_ENTITY_REF => 'XML_ERROR_PARAM_ENTITY_REF', - XML_ERROR_UNDEFINED_ENTITY => 'XML_ERROR_UNDEFINED_ENTITY', - XML_ERROR_RECURSIVE_ENTITY_REF => 'XML_ERROR_RECURSIVE_ENTITY_REF', - XML_ERROR_ASYNC_ENTITY => 'XML_ERROR_ASYNC_ENTITY', - XML_ERROR_BAD_CHAR_REF => 'XML_ERROR_BAD_CHAR_REF', - XML_ERROR_BINARY_ENTITY_REF => 'XML_ERROR_BINARY_ENTITY_REF', - XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF => 'XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF', - XML_ERROR_MISPLACED_XML_PI => 'XML_ERROR_MISPLACED_XML_PI', - XML_ERROR_UNKNOWN_ENCODING => 'XML_ERROR_UNKNOWN_ENCODING', - XML_ERROR_INCORRECT_ENCODING => 'XML_ERROR_INCORRECT_ENCODING', - XML_ERROR_UNCLOSED_CDATA_SECTION => 'XML_ERROR_UNCLOSED_CDATA_SECTION', - XML_ERROR_EXTERNAL_ENTITY_HANDLING => 'XML_ERROR_EXTERNAL_ENTITY_HANDLING', + \XML_ERROR_NONE => 'XML_ERROR_NONE', + \XML_ERROR_NO_MEMORY => 'XML_ERROR_NO_MEMORY', + \XML_ERROR_SYNTAX => 'XML_ERROR_SYNTAX', + \XML_ERROR_NO_ELEMENTS => 'XML_ERROR_NO_ELEMENTS', + \XML_ERROR_INVALID_TOKEN => 'XML_ERROR_INVALID_TOKEN', + \XML_ERROR_UNCLOSED_TOKEN => 'XML_ERROR_UNCLOSED_TOKEN', + \XML_ERROR_PARTIAL_CHAR => 'XML_ERROR_PARTIAL_CHAR', + \XML_ERROR_TAG_MISMATCH => 'XML_ERROR_TAG_MISMATCH', + \XML_ERROR_DUPLICATE_ATTRIBUTE => 'XML_ERROR_DUPLICATE_ATTRIBUTE', + \XML_ERROR_JUNK_AFTER_DOC_ELEMENT => 'XML_ERROR_JUNK_AFTER_DOC_ELEMENT', + \XML_ERROR_PARAM_ENTITY_REF => 'XML_ERROR_PARAM_ENTITY_REF', + \XML_ERROR_UNDEFINED_ENTITY => 'XML_ERROR_UNDEFINED_ENTITY', + \XML_ERROR_RECURSIVE_ENTITY_REF => 'XML_ERROR_RECURSIVE_ENTITY_REF', + \XML_ERROR_ASYNC_ENTITY => 'XML_ERROR_ASYNC_ENTITY', + \XML_ERROR_BAD_CHAR_REF => 'XML_ERROR_BAD_CHAR_REF', + \XML_ERROR_BINARY_ENTITY_REF => 'XML_ERROR_BINARY_ENTITY_REF', + \XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF => 'XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF', + \XML_ERROR_MISPLACED_XML_PI => 'XML_ERROR_MISPLACED_XML_PI', + \XML_ERROR_UNKNOWN_ENCODING => 'XML_ERROR_UNKNOWN_ENCODING', + \XML_ERROR_INCORRECT_ENCODING => 'XML_ERROR_INCORRECT_ENCODING', + \XML_ERROR_UNCLOSED_CDATA_SECTION => 'XML_ERROR_UNCLOSED_CDATA_SECTION', + \XML_ERROR_EXTERNAL_ENTITY_HANDLING => 'XML_ERROR_EXTERNAL_ENTITY_HANDLING', ]; public static function castXml($h, array $a, Stub $stub, bool $isNested) diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index ee36e9f8e7..938bd03856 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -251,7 +251,7 @@ abstract class AbstractCloner implements ClonerInterface public function cloneVar($var, int $filter = 0) { $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) { - if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) { + if (\E_RECOVERABLE_ERROR === $type || \E_USER_ERROR === $type) { // Cloner never dies throw new \ErrorException($msg, 0, $type, $file, $line); } diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index e4a588714d..74f8f945db 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -324,7 +324,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate } } elseif (Stub::TYPE_REF === $item->type) { if ($item->handle) { - if (!isset($refs[$r = $item->handle - (PHP_INT_MAX >> 1)])) { + if (!isset($refs[$r = $item->handle - (\PHP_INT_MAX >> 1)])) { $cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0]; } else { $firstSeen = false; diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index 1a00038786..c3497e32a1 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -123,8 +123,8 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface $this->decimalPoint = localeconv(); $this->decimalPoint = $this->decimalPoint['decimal_point']; - if ($locale = $this->flags & (self::DUMP_COMMA_SEPARATOR | self::DUMP_TRAILING_COMMA) ? setlocale(LC_NUMERIC, 0) : null) { - setlocale(LC_NUMERIC, 'C'); + if ($locale = $this->flags & (self::DUMP_COMMA_SEPARATOR | self::DUMP_TRAILING_COMMA) ? setlocale(\LC_NUMERIC, 0) : null) { + setlocale(\LC_NUMERIC, 'C'); } if ($returnDump = true === $output) { @@ -148,7 +148,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface $this->setOutput($prevOutput); } if ($locale) { - setlocale(LC_NUMERIC, $locale); + setlocale(\LC_NUMERIC, $locale); } } diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 59c40bdb86..9fbe056a51 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -145,8 +145,8 @@ class CliDumper extends AbstractDumper $style = 'num'; switch (true) { - case INF === $value: $value = 'INF'; break; - case -INF === $value: $value = '-INF'; break; + case \INF === $value: $value = 'INF'; break; + case -\INF === $value: $value = '-INF'; break; case is_nan($value): $value = 'NAN'; break; default: $value = (string) $value; diff --git a/src/Symfony/Component/VarDumper/Dumper/ContextProvider/SourceContextProvider.php b/src/Symfony/Component/VarDumper/Dumper/ContextProvider/SourceContextProvider.php index 6f4caba63b..c3cd3221a8 100644 --- a/src/Symfony/Component/VarDumper/Dumper/ContextProvider/SourceContextProvider.php +++ b/src/Symfony/Component/VarDumper/Dumper/ContextProvider/SourceContextProvider.php @@ -40,7 +40,7 @@ final class SourceContextProvider implements ContextProviderInterface public function getContext(): ?array { - $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, $this->limit); + $trace = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, $this->limit); $file = $trace[1]['file']; $line = $trace[1]['line']; diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index ee1a0b0089..0c2108eda2 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -159,7 +159,7 @@ class HtmlDumper extends CliDumper return $this->dumpHeader; } - $line = str_replace('{$options}', json_encode($this->displayOptions, JSON_FORCE_OBJECT), <<<'EOHTML' + $line = str_replace('{$options}', json_encode($this->displayOptions, \JSON_FORCE_OBJECT), <<<'EOHTML'