diff --git a/composer.json b/composer.json index 793dd5a9c..8d15b44d9 100644 --- a/composer.json +++ b/composer.json @@ -40,12 +40,12 @@ "scssphp/scssphp": "1.0.3", "stecman/symfony-console-completion": "^0.11.0", "swiftmailer/swiftmailer": "^6.0", - "symfony/console": "4.4.10", - "symfony/event-dispatcher": "4.4.10", + "symfony/console": "4.4.15", + "symfony/event-dispatcher": "4.4.15", "symfony/event-dispatcher-contracts": "1.1.7", - "symfony/process": "4.4.10", - "symfony/routing": "4.4.10", - "symfony/translation": "4.4.10", + "symfony/process": "4.4.15", + "symfony/routing": "4.4.15", + "symfony/translation": "4.4.15", "php-http/guzzle6-adapter": "^2.0", "web-auth/webauthn-lib": "^3.1" }, diff --git a/composer.lock b/composer.lock index 17047c6e8..c8d1fa186 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b4764fd6a98b2b95475d06d646177637", + "content-hash": "aa66f332f35d50da27647a3ce9c2b038", "packages": [ { "name": "aws/aws-sdk-php", @@ -4200,16 +4200,16 @@ }, { "name": "symfony/console", - "version": "v4.4.10", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "326b064d804043005526f5a0494cfb49edb59bb0" + "reference": "90933b39c7b312fc3ceaa1ddeac7eb48cb953124" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/326b064d804043005526f5a0494cfb49edb59bb0", - "reference": "326b064d804043005526f5a0494cfb49edb59bb0", + "url": "https://api.github.com/repos/symfony/console/zipball/90933b39c7b312fc3ceaa1ddeac7eb48cb953124", + "reference": "90933b39c7b312fc3ceaa1ddeac7eb48cb953124", "shasum": "" }, "require": { @@ -4287,20 +4287,20 @@ "type": "tidelift" } ], - "time": "2020-05-30T20:06:45+00:00" + "time": "2020-09-15T07:58:55+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.4.10", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "a5370aaa7807c7a439b21386661ffccf3dff2866" + "reference": "e17bb5e0663dc725f7cdcafc932132735b4725cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a5370aaa7807c7a439b21386661ffccf3dff2866", - "reference": "a5370aaa7807c7a439b21386661ffccf3dff2866", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/e17bb5e0663dc725f7cdcafc932132735b4725cd", + "reference": "e17bb5e0663dc725f7cdcafc932132735b4725cd", "shasum": "" }, "require": { @@ -4318,6 +4318,7 @@ "psr/log": "~1.0", "symfony/config": "^3.4|^4.0|^5.0", "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/error-handler": "~3.4|~4.4", "symfony/expression-language": "^3.4|^4.0|^5.0", "symfony/http-foundation": "^3.4|^4.0|^5.0", "symfony/service-contracts": "^1.1|^2", @@ -4371,7 +4372,7 @@ "type": "tidelift" } ], - "time": "2020-05-20T08:37:50+00:00" + "time": "2020-09-18T14:07:46+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -4972,20 +4973,20 @@ }, { "name": "symfony/process", - "version": "v4.4.10", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "c714958428a85c86ab97e3a0c96db4c4f381b7f5" + "reference": "9b887acc522935f77555ae8813495958c7771ba7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c714958428a85c86ab97e3a0c96db4c4f381b7f5", - "reference": "c714958428a85c86ab97e3a0c96db4c4f381b7f5", + "url": "https://api.github.com/repos/symfony/process/zipball/9b887acc522935f77555ae8813495958c7771ba7", + "reference": "9b887acc522935f77555ae8813495958c7771ba7", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=7.1.3" }, "type": "library", "extra": { @@ -5031,24 +5032,24 @@ "type": "tidelift" } ], - "time": "2020-05-30T20:06:45+00:00" + "time": "2020-09-02T16:08:58+00:00" }, { "name": "symfony/routing", - "version": "v4.4.10", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "0f557911dde75c2a9652b8097bd7c9f54507f646" + "reference": "006b2d06672b8650998f328fc603eb6f3feb979f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/0f557911dde75c2a9652b8097bd7c9f54507f646", - "reference": "0f557911dde75c2a9652b8097bd7c9f54507f646", + "url": "https://api.github.com/repos/symfony/routing/zipball/006b2d06672b8650998f328fc603eb6f3feb979f", + "reference": "006b2d06672b8650998f328fc603eb6f3feb979f", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=7.1.3" }, "conflict": { "symfony/config": "<4.2", @@ -5121,7 +5122,7 @@ "type": "tidelift" } ], - "time": "2020-05-30T20:07:26+00:00" + "time": "2020-10-01T16:25:17+00:00" }, { "name": "symfony/service-contracts", @@ -5183,16 +5184,16 @@ }, { "name": "symfony/translation", - "version": "v4.4.10", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "79d3ef9096a6a6047dbc69218b68c7b7f63193af" + "reference": "8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/79d3ef9096a6a6047dbc69218b68c7b7f63193af", - "reference": "79d3ef9096a6a6047dbc69218b68c7b7f63193af", + "url": "https://api.github.com/repos/symfony/translation/zipball/8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd", + "reference": "8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd", "shasum": "" }, "require": { @@ -5269,7 +5270,7 @@ "type": "tidelift" } ], - "time": "2020-05-30T20:06:45+00:00" + "time": "2020-10-02T07:34:48+00:00" }, { "name": "symfony/translation-contracts", diff --git a/composer/ClassLoader.php b/composer/ClassLoader.php index fce8549f0..03b9bb9c4 100644 --- a/composer/ClassLoader.php +++ b/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/composer/installed.json b/composer/installed.json index 5223d2a02..d1e2d4f46 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -4331,17 +4331,17 @@ }, { "name": "symfony/console", - "version": "v4.4.10", - "version_normalized": "4.4.10.0", + "version": "v4.4.15", + "version_normalized": "4.4.15.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "326b064d804043005526f5a0494cfb49edb59bb0" + "reference": "90933b39c7b312fc3ceaa1ddeac7eb48cb953124" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/326b064d804043005526f5a0494cfb49edb59bb0", - "reference": "326b064d804043005526f5a0494cfb49edb59bb0", + "url": "https://api.github.com/repos/symfony/console/zipball/90933b39c7b312fc3ceaa1ddeac7eb48cb953124", + "reference": "90933b39c7b312fc3ceaa1ddeac7eb48cb953124", "shasum": "" }, "require": { @@ -4375,7 +4375,7 @@ "symfony/lock": "", "symfony/process": "" }, - "time": "2020-05-30T20:06:45+00:00", + "time": "2020-09-15T07:58:55+00:00", "type": "library", "extra": { "branch-alias": { @@ -4424,17 +4424,17 @@ }, { "name": "symfony/event-dispatcher", - "version": "v4.4.10", - "version_normalized": "4.4.10.0", + "version": "v4.4.15", + "version_normalized": "4.4.15.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "a5370aaa7807c7a439b21386661ffccf3dff2866" + "reference": "e17bb5e0663dc725f7cdcafc932132735b4725cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a5370aaa7807c7a439b21386661ffccf3dff2866", - "reference": "a5370aaa7807c7a439b21386661ffccf3dff2866", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/e17bb5e0663dc725f7cdcafc932132735b4725cd", + "reference": "e17bb5e0663dc725f7cdcafc932132735b4725cd", "shasum": "" }, "require": { @@ -4452,6 +4452,7 @@ "psr/log": "~1.0", "symfony/config": "^3.4|^4.0|^5.0", "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/error-handler": "~3.4|~4.4", "symfony/expression-language": "^3.4|^4.0|^5.0", "symfony/http-foundation": "^3.4|^4.0|^5.0", "symfony/service-contracts": "^1.1|^2", @@ -4461,7 +4462,7 @@ "symfony/dependency-injection": "", "symfony/http-kernel": "" }, - "time": "2020-05-20T08:37:50+00:00", + "time": "2020-09-18T14:07:46+00:00", "type": "library", "extra": { "branch-alias": { @@ -5127,23 +5128,23 @@ }, { "name": "symfony/process", - "version": "v4.4.10", - "version_normalized": "4.4.10.0", + "version": "v4.4.15", + "version_normalized": "4.4.15.0", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "c714958428a85c86ab97e3a0c96db4c4f381b7f5" + "reference": "9b887acc522935f77555ae8813495958c7771ba7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c714958428a85c86ab97e3a0c96db4c4f381b7f5", - "reference": "c714958428a85c86ab97e3a0c96db4c4f381b7f5", + "url": "https://api.github.com/repos/symfony/process/zipball/9b887acc522935f77555ae8813495958c7771ba7", + "reference": "9b887acc522935f77555ae8813495958c7771ba7", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=7.1.3" }, - "time": "2020-05-30T20:06:45+00:00", + "time": "2020-09-02T16:08:58+00:00", "type": "library", "extra": { "branch-alias": { @@ -5192,21 +5193,21 @@ }, { "name": "symfony/routing", - "version": "v4.4.10", - "version_normalized": "4.4.10.0", + "version": "v4.4.15", + "version_normalized": "4.4.15.0", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "0f557911dde75c2a9652b8097bd7c9f54507f646" + "reference": "006b2d06672b8650998f328fc603eb6f3feb979f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/0f557911dde75c2a9652b8097bd7c9f54507f646", - "reference": "0f557911dde75c2a9652b8097bd7c9f54507f646", + "url": "https://api.github.com/repos/symfony/routing/zipball/006b2d06672b8650998f328fc603eb6f3feb979f", + "reference": "006b2d06672b8650998f328fc603eb6f3feb979f", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=7.1.3" }, "conflict": { "symfony/config": "<4.2", @@ -5229,7 +5230,7 @@ "symfony/http-foundation": "For using a Symfony Request object", "symfony/yaml": "For using the YAML loader" }, - "time": "2020-05-30T20:07:26+00:00", + "time": "2020-10-01T16:25:17+00:00", "type": "library", "extra": { "branch-alias": { @@ -5344,17 +5345,17 @@ }, { "name": "symfony/translation", - "version": "v4.4.10", - "version_normalized": "4.4.10.0", + "version": "v4.4.15", + "version_normalized": "4.4.15.0", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "79d3ef9096a6a6047dbc69218b68c7b7f63193af" + "reference": "8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/79d3ef9096a6a6047dbc69218b68c7b7f63193af", - "reference": "79d3ef9096a6a6047dbc69218b68c7b7f63193af", + "url": "https://api.github.com/repos/symfony/translation/zipball/8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd", + "reference": "8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd", "shasum": "" }, "require": { @@ -5387,7 +5388,7 @@ "symfony/config": "", "symfony/yaml": "" }, - "time": "2020-05-30T20:06:45+00:00", + "time": "2020-10-02T07:34:48+00:00", "type": "library", "extra": { "branch-alias": { diff --git a/symfony/console/Application.php b/symfony/console/Application.php index 199ed6804..bc3f23b5e 100644 --- a/symfony/console/Application.php +++ b/symfony/console/Application.php @@ -114,8 +114,10 @@ public function setCommandLoader(CommandLoaderInterface $commandLoader) */ public function run(InputInterface $input = null, OutputInterface $output = null) { - putenv('LINES='.$this->terminal->getHeight()); - putenv('COLUMNS='.$this->terminal->getWidth()); + if (\function_exists('putenv')) { + @putenv('LINES='.$this->terminal->getHeight()); + @putenv('COLUMNS='.$this->terminal->getWidth()); + } if (null === $input) { $input = new ArgvInput(); @@ -513,6 +515,11 @@ public function get($name) throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name)); } + // When the command has a different name than the one used at the command loader level + if (!isset($this->commands[$name])) { + throw new CommandNotFoundException(sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name)); + } + $command = $this->commands[$name]; if ($this->wantHelps) { @@ -714,7 +721,7 @@ public function find($name) $command = $this->get(reset($commands)); if ($command->isHidden()) { - @trigger_error(sprintf('Command "%s" is hidden, finding it using an abbreviation is deprecated since Symfony 4.4, use its full name instead.', $command->getName()), E_USER_DEPRECATED); + @trigger_error(sprintf('Command "%s" is hidden, finding it using an abbreviation is deprecated since Symfony 4.4, use its full name instead.', $command->getName()), \E_USER_DEPRECATED); } return $command; @@ -793,7 +800,7 @@ public static function getAbbreviations($names) */ public function renderException(\Exception $e, OutputInterface $output) { - @trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), \E_USER_DEPRECATED); $output->writeln('', OutputInterface::VERBOSITY_QUIET); @@ -805,10 +812,10 @@ public function renderException(\Exception $e, OutputInterface $output) public function renderThrowable(\Throwable $e, OutputInterface $output): void { if (__CLASS__ !== static::class && __CLASS__ === (new \ReflectionMethod($this, 'renderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'renderException'))->getDeclaringClass()->getName()) { - @trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), \E_USER_DEPRECATED); if (!$e instanceof \Exception) { - $e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + $e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine()); } $this->renderException($e, $output); @@ -836,7 +843,7 @@ private function finishRenderThrowableOrException(OutputInterface $output): void */ protected function doRenderException(\Exception $e, OutputInterface $output) { - @trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), \E_USER_DEPRECATED); $this->doActuallyRenderThrowable($e, $output); } @@ -844,10 +851,10 @@ protected function doRenderException(\Exception $e, OutputInterface $output) protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void { if (__CLASS__ !== static::class && __CLASS__ === (new \ReflectionMethod($this, 'doRenderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'doRenderException'))->getDeclaringClass()->getName()) { - @trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), \E_USER_DEPRECATED); if (!$e instanceof \Exception) { - $e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + $e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine()); } $this->doRenderException($e, $output); @@ -876,7 +883,7 @@ private function doActuallyRenderThrowable(\Throwable $e, OutputInterface $outpu }, $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) { @@ -975,7 +982,9 @@ protected function configureIO(InputInterface $input, OutputInterface $output) $input->setInteractive(false); } - putenv('SHELL_VERBOSITY='.$shellVerbosity); + if (\function_exists('putenv')) { + @putenv('SHELL_VERBOSITY='.$shellVerbosity); + } $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; } @@ -1162,7 +1171,7 @@ private function findAlternatives(string $name, iterable $collection): array } $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/symfony/console/Command/Command.php b/symfony/console/Command/Command.php index 3a520c1b4..c2b1f4c7e 100644 --- a/symfony/console/Command/Command.php +++ b/symfony/console/Command/Command.php @@ -223,7 +223,7 @@ public function run(InputInterface $input, OutputInterface $output) 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); @@ -255,7 +255,7 @@ public function run(InputInterface $input, OutputInterface $output) $statusCode = $this->execute($input, $output); if (!\is_int($statusCode)) { - @trigger_error(sprintf('Return value of "%s::execute()" should always be of the type int since Symfony 4.4, %s returned.', static::class, \gettype($statusCode)), E_USER_DEPRECATED); + @trigger_error(sprintf('Return value of "%s::execute()" should always be of the type int since Symfony 4.4, %s returned.', static::class, \gettype($statusCode)), \E_USER_DEPRECATED); } } @@ -433,8 +433,6 @@ public function setName($name) * This feature should be used only when creating a long process command, * like a daemon. * - * PHP 5.5+ or the proctitle PECL library is required - * * @param string $title The process title * * @return $this diff --git a/symfony/console/Descriptor/JsonDescriptor.php b/symfony/console/Descriptor/JsonDescriptor.php index 131fef1f1..5ba588ee9 100644 --- a/symfony/console/Descriptor/JsonDescriptor.php +++ b/symfony/console/Descriptor/JsonDescriptor.php @@ -107,7 +107,7 @@ private function getInputArgumentData(InputArgument $argument): array '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 @@ private function getInputOptionData(InputOption $option): array '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/symfony/console/Descriptor/TextDescriptor.php b/symfony/console/Descriptor/TextDescriptor.php index ef6d8afe1..05a32443d 100644 --- a/symfony/console/Descriptor/TextDescriptor.php +++ b/symfony/console/Descriptor/TextDescriptor.php @@ -212,7 +212,7 @@ protected function describeApplication(Application $application, array $options // calculate max. width based on available commands per namespace $width = $this->getColumnWidth(array_merge(...array_values(array_map(function ($namespace) use ($commands) { return array_intersect($namespace['commands'], array_keys($commands)); - }, $namespaces)))); + }, array_values($namespaces))))); if ($describedNamespace) { $this->writeText(sprintf('Available commands for the "%s" namespace:', $describedNamespace), $options); @@ -280,7 +280,7 @@ private function getCommandAliasesText(Command $command): string */ private function formatDefaultValue($default): string { - if (INF === $default) { + if (\INF === $default) { return 'INF'; } @@ -294,7 +294,7 @@ private function formatDefaultValue($default): string } } - 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/symfony/console/Formatter/OutputFormatter.php b/symfony/console/Formatter/OutputFormatter.php index 27b608585..5d52896ac 100644 --- a/symfony/console/Formatter/OutputFormatter.php +++ b/symfony/console/Formatter/OutputFormatter.php @@ -138,7 +138,7 @@ public function formatAndWrap(string $message, int $width) $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]; @@ -196,7 +196,7 @@ private function createStyleFromString(string $string): ?OutputFormatterStyleInt 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/symfony/console/Helper/ProcessHelper.php b/symfony/console/Helper/ProcessHelper.php index f519919a7..d580357b9 100644 --- a/symfony/console/Helper/ProcessHelper.php +++ b/symfony/console/Helper/ProcessHelper.php @@ -53,7 +53,7 @@ public function run(OutputInterface $output, $cmd, $error = null, callable $call } if (!\is_array($cmd)) { - @trigger_error(sprintf('Passing a command as a string to "%s()" is deprecated since Symfony 4.2, pass it the command as an array of arguments instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing a command as a string to "%s()" is deprecated since Symfony 4.2, pass it the command as an array of arguments instead.', __METHOD__), \E_USER_DEPRECATED); $cmd = [method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd)]; } diff --git a/symfony/console/Helper/ProgressBar.php b/symfony/console/Helper/ProgressBar.php index e4f0a9936..afabf7c52 100644 --- a/symfony/console/Helper/ProgressBar.php +++ b/symfony/console/Helper/ProgressBar.php @@ -454,7 +454,7 @@ private function overwrite(string $message): void } } } elseif ($this->step > 0) { - $message = PHP_EOL.$message; + $message = \PHP_EOL.$message; } $this->previousMessage = $originalMessage; @@ -525,7 +525,7 @@ private static function initPlaceholderFormatters(): array 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/symfony/console/Helper/QuestionHelper.php b/symfony/console/Helper/QuestionHelper.php index 134f6231e..18a222db3 100644 --- a/symfony/console/Helper/QuestionHelper.php +++ b/symfony/console/Helper/QuestionHelper.php @@ -34,6 +34,7 @@ class QuestionHelper extends Helper private $inputStream; private static $shell; private static $stty = true; + private static $stdinIsInteractive; /** * Asks a question to the user. @@ -104,9 +105,14 @@ private function doAsk(OutputInterface $output, Question $question) { $this->writePrompt($output, $question); - $inputStream = $this->inputStream ?: STDIN; + $inputStream = $this->inputStream ?: \STDIN; $autocomplete = $question->getAutocompleterCallback(); + if (\function_exists('sapi_windows_cp_set')) { + // Codepage used by cmd.exe on Windows to allow special characters (éàüñ). + @sapi_windows_cp_set(1252); + } + if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) { $ret = false; if ($question->isHidden()) { @@ -419,33 +425,26 @@ private function getHiddenResponse(OutputInterface $output, $inputStream, bool $ if (self::$stty && Terminal::hasSttyAvailable()) { $sttyMode = shell_exec('stty -g'); - shell_exec('stty -echo'); - $value = fgets($inputStream, 4096); - shell_exec(sprintf('stty %s', $sttyMode)); + } elseif ($this->isInteractiveInput($inputStream)) { + throw new RuntimeException('Unable to hide the response.'); + } - if (false === $value) { - throw new MissingInputException('Aborted.'); - } - if ($trimmable) { - $value = trim($value); - } - $output->writeln(''); + $value = fgets($inputStream, 4096); - return $value; + if (self::$stty && Terminal::hasSttyAvailable()) { + shell_exec(sprintf('stty %s', $sttyMode)); } - if (false !== $shell = $this->getShell()) { - $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword'; - $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword' 2> /dev/null", $shell, $readCmd); - $sCommand = shell_exec($command); - $value = $trimmable ? rtrim($sCommand) : $sCommand; - $output->writeln(''); - - return $value; + if (false === $value) { + throw new MissingInputException('Aborted.'); } + if ($trimmable) { + $value = trim($value); + } + $output->writeln(''); - throw new RuntimeException('Unable to hide the response.'); + return $value; } /** @@ -473,52 +472,35 @@ private function validateAttempts(callable $interviewer, OutputInterface $output throw $e; } catch (\Exception $error) { } - - $attempts = $attempts ?? -(int) $this->isTty(); } throw $error; } - /** - * Returns a valid unix shell. - * - * @return string|bool The valid shell name, false in case no valid shell is found - */ - private function getShell() + private function isInteractiveInput($inputStream): bool { - if (null !== self::$shell) { - return self::$shell; + if ('php://stdin' !== (stream_get_meta_data($inputStream)['uri'] ?? null)) { + return false; } - self::$shell = false; - - if (file_exists('/usr/bin/env')) { - // handle other OSs with bash/zsh/ksh/csh if available to hide the answer - $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; - foreach (['bash', 'zsh', 'ksh', 'csh'] as $sh) { - if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { - self::$shell = $sh; - break; - } - } + if (null !== self::$stdinIsInteractive) { + return self::$stdinIsInteractive; } - return self::$shell; - } - - private function isTty(): bool - { - $inputStream = !$this->inputStream && \defined('STDIN') ? STDIN : $this->inputStream; - if (\function_exists('stream_isatty')) { - return stream_isatty($inputStream); + return self::$stdinIsInteractive = stream_isatty(fopen('php://stdin', 'r')); } if (\function_exists('posix_isatty')) { - return posix_isatty($inputStream); + return self::$stdinIsInteractive = posix_isatty(fopen('php://stdin', 'r')); } - return true; + if (!\function_exists('exec')) { + return self::$stdinIsInteractive = true; + } + + exec('stty 2> /dev/null', $output, $status); + + return self::$stdinIsInteractive = 1 !== $status; } } diff --git a/symfony/console/Helper/Table.php b/symfony/console/Helper/Table.php index 756b8465b..82aeb3fc8 100644 --- a/symfony/console/Helper/Table.php +++ b/symfony/console/Helper/Table.php @@ -574,6 +574,9 @@ private function buildTableRows(array $rows): TableRows if (0 === $lineKey) { $rows[$rowKey][$column] = $line; } else { + if (!\array_key_exists($rowKey, $unmergedRows) || !\array_key_exists($lineKey, $unmergedRows[$rowKey])) { + $unmergedRows[$rowKey][$lineKey] = $this->copyRow($rows, $rowKey); + } $unmergedRows[$rowKey][$lineKey][$column] = $line; } } @@ -585,8 +588,8 @@ private function buildTableRows(array $rows): TableRows yield $this->fillCells($row); if (isset($unmergedRows[$rowKey])) { - foreach ($unmergedRows[$rowKey] as $row) { - yield $row; + foreach ($unmergedRows[$rowKey] as $unmergedRow) { + yield $this->fillCells($unmergedRow); } } } @@ -670,6 +673,7 @@ private function fillNextRows(array $rows, int $line): array private function fillCells($row) { $newRow = []; + foreach ($row as $column => $cell) { $newRow[] = $cell; if ($cell instanceof TableCell && $cell->getColspan() > 1) { diff --git a/symfony/console/Helper/TableStyle.php b/symfony/console/Helper/TableStyle.php index 6166f11dc..a8df59b3a 100644 --- a/symfony/console/Helper/TableStyle.php +++ b/symfony/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. @@ -112,7 +112,7 @@ public function setHorizontalBorderChars(string $outside, string $inside = null) */ public function setHorizontalBorderChar($horizontalBorderChar) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->setHorizontalBorderChars($horizontalBorderChar, $horizontalBorderChar); } @@ -126,7 +126,7 @@ public function setHorizontalBorderChar($horizontalBorderChar) */ public function getHorizontalBorderChar() { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->horizontalOutsideBorderChar; } @@ -168,7 +168,7 @@ public function setVerticalBorderChars(string $outside, string $inside = null): */ public function setVerticalBorderChar($verticalBorderChar) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setVerticalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setVerticalBorderChars() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->setVerticalBorderChars($verticalBorderChar, $verticalBorderChar); } @@ -182,7 +182,7 @@ public function setVerticalBorderChar($verticalBorderChar) */ public function getVerticalBorderChar() { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->verticalOutsideBorderChar; } @@ -270,7 +270,7 @@ public function setDefaultCrossingChar(string $char): self */ public function setCrossingChar($crossingChar) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use setDefaultCrossingChar() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use setDefaultCrossingChar() instead.', __METHOD__), \E_USER_DEPRECATED); return $this->setDefaultCrossingChar($crossingChar); } @@ -413,7 +413,7 @@ public function getBorderFormat() */ public function setPadType($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/symfony/console/Input/ArgvInput.php b/symfony/console/Input/ArgvInput.php index 3bc205553..6d2946926 100644 --- a/symfony/console/Input/ArgvInput.php +++ b/symfony/console/Input/ArgvInput.php @@ -48,9 +48,7 @@ class ArgvInput extends Input */ public function __construct(array $argv = null, InputDefinition $definition = null) { - if (null === $argv) { - $argv = $_SERVER['argv']; - } + $argv = $argv ?? $_SERVER['argv'] ?? []; // strip the application name array_shift($argv); diff --git a/symfony/console/Input/InputDefinition.php b/symfony/console/Input/InputDefinition.php index 75a975213..db55315a8 100644 --- a/symfony/console/Input/InputDefinition.php +++ b/symfony/console/Input/InputDefinition.php @@ -171,7 +171,7 @@ public function getArguments() */ public function getArgumentCount() { - return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments); + return $this->hasAnArrayArgument ? \PHP_INT_MAX : \count($this->arguments); } /** diff --git a/symfony/console/Output/BufferedOutput.php b/symfony/console/Output/BufferedOutput.php index 8afc8931e..fefaac271 100644 --- a/symfony/console/Output/BufferedOutput.php +++ b/symfony/console/Output/BufferedOutput.php @@ -39,7 +39,7 @@ protected function doWrite($message, $newline) $this->buffer .= $message; if ($newline) { - $this->buffer .= PHP_EOL; + $this->buffer .= \PHP_EOL; } } } diff --git a/symfony/console/Output/ConsoleOutput.php b/symfony/console/Output/ConsoleOutput.php index 9684ad67b..ff02f8694 100644 --- a/symfony/console/Output/ConsoleOutput.php +++ b/symfony/console/Output/ConsoleOutput.php @@ -131,7 +131,7 @@ private function isRunningOS400(): bool $checks = [ \function_exists('php_uname') ? php_uname('s') : '', getenv('OSTYPE'), - PHP_OS, + \PHP_OS, ]; return false !== stripos(implode(';', $checks), 'OS400'); diff --git a/symfony/console/Output/ConsoleSectionOutput.php b/symfony/console/Output/ConsoleSectionOutput.php index 024d99d96..c19edbf95 100644 --- a/symfony/console/Output/ConsoleSectionOutput.php +++ b/symfony/console/Output/ConsoleSectionOutput.php @@ -82,10 +82,10 @@ public function getContent(): string */ 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/symfony/console/Output/StreamOutput.php b/symfony/console/Output/StreamOutput.php index f39422a57..9c2243644 100644 --- a/symfony/console/Output/StreamOutput.php +++ b/symfony/console/Output/StreamOutput.php @@ -70,7 +70,7 @@ public function getStream() protected function doWrite($message, $newline) { if ($newline) { - $message .= PHP_EOL; + $message .= \PHP_EOL; } @fwrite($this->stream, $message); diff --git a/symfony/console/Question/Question.php b/symfony/console/Question/Question.php index c28e0bf55..2d46d1a98 100644 --- a/symfony/console/Question/Question.php +++ b/symfony/console/Question/Question.php @@ -220,8 +220,11 @@ public function getValidator() */ public function setMaxAttempts($attempts) { - if (null !== $attempts && $attempts < 1) { - throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); + if (null !== $attempts) { + $attempts = (int) $attempts; + if ($attempts < 1) { + throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); + } } $this->attempts = $attempts; diff --git a/symfony/console/Style/OutputStyle.php b/symfony/console/Style/OutputStyle.php index b1262b55d..14d2d60b2 100644 --- a/symfony/console/Style/OutputStyle.php +++ b/symfony/console/Style/OutputStyle.php @@ -35,7 +35,7 @@ public function __construct(OutputInterface $output) */ public function newLine($count = 1) { - $this->output->write(str_repeat(PHP_EOL, $count)); + $this->output->write(str_repeat(\PHP_EOL, $count)); } /** diff --git a/symfony/console/Style/SymfonyStyle.php b/symfony/console/Style/SymfonyStyle.php index 5efe2d4b1..b40c16e99 100644 --- a/symfony/console/Style/SymfonyStyle.php +++ b/symfony/console/Style/SymfonyStyle.php @@ -427,7 +427,7 @@ private function getProgressBar(): ProgressBar 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. @@ -472,7 +472,7 @@ private function createBlock(iterable $messages, string $type = null, string $st $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/symfony/console/Terminal.php b/symfony/console/Terminal.php index b8cc04e2e..5e5a3c2f7 100644 --- a/symfony/console/Terminal.php +++ b/symfony/console/Terminal.php @@ -66,6 +66,11 @@ public static function hasSttyAvailable() return self::$stty; } + // skip check if exec function is disabled + if (!\function_exists('exec')) { + return false; + } + exec('stty 2>&1', $output, $exitcode); return self::$stty = 0 === $exitcode; diff --git a/symfony/console/Tester/TesterTrait.php b/symfony/console/Tester/TesterTrait.php index a5c2088ae..14b65ec00 100644 --- a/symfony/console/Tester/TesterTrait.php +++ b/symfony/console/Tester/TesterTrait.php @@ -44,7 +44,7 @@ public function getDisplay($normalize = false) $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 @@ public function getErrorOutput($normalize = false) $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; @@ -170,7 +170,7 @@ private static function createStream(array $inputs) $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/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php b/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php index 4c556c8a4..d320a2620 100644 --- a/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php +++ b/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php @@ -145,7 +145,7 @@ public function dispatch($event/*, string $eventName = null*/) if (\is_object($event)) { $eventName = $eventName ?? \get_class($event); } else { - @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), \E_USER_DEPRECATED); $swap = $event; $event = $eventName ?? new Event(); $eventName = $swap; diff --git a/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php b/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php index 3ae1136c4..4b27d3b23 100644 --- a/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php +++ b/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php @@ -138,7 +138,7 @@ private function getEventFromTypeDeclaration(ContainerBuilder $container, string || !($r = $container->getReflectionClass($class, false)) || !$r->hasMethod($method) || 1 > ($m = $r->getMethod($method))->getNumberOfParameters() - || !($type = $m->getParameters()[0]->getType()) + || !($type = $m->getParameters()[0]->getType()) instanceof \ReflectionNamedType || $type->isBuiltin() || Event::class === ($name = $type->getName()) || LegacyEvent::class === $name diff --git a/symfony/event-dispatcher/EventDispatcher.php b/symfony/event-dispatcher/EventDispatcher.php index 9f523dca3..d22bcea1f 100644 --- a/symfony/event-dispatcher/EventDispatcher.php +++ b/symfony/event-dispatcher/EventDispatcher.php @@ -55,7 +55,7 @@ public function dispatch($event/*, string $eventName = null*/) if (\is_object($event)) { $eventName = $eventName ?? \get_class($event); } elseif (\is_string($event) && (null === $eventName || $eventName instanceof ContractsEvent || $eventName instanceof Event)) { - @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.', EventDispatcherInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.', EventDispatcherInterface::class), \E_USER_DEPRECATED); $swap = $event; $event = $eventName ?? new Event(); $eventName = $swap; diff --git a/symfony/event-dispatcher/LegacyEventDispatcherProxy.php b/symfony/event-dispatcher/LegacyEventDispatcherProxy.php index 0a8fa16d3..8ee6cba1b 100644 --- a/symfony/event-dispatcher/LegacyEventDispatcherProxy.php +++ b/symfony/event-dispatcher/LegacyEventDispatcherProxy.php @@ -38,7 +38,7 @@ public static function decorate(?ContractsEventDispatcherInterface $dispatcher): return $dispatcher; } - @trigger_error(sprintf('The signature of the "%s::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3.', $r->class), E_USER_DEPRECATED); + @trigger_error(sprintf('The signature of the "%s::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3.', $r->class), \E_USER_DEPRECATED); $self = new self(); $self->dispatcher = $dispatcher; @@ -60,7 +60,7 @@ public function dispatch($event/*, string $eventName = null*/) if (\is_object($event)) { $eventName = $eventName ?? \get_class($event); } elseif (\is_string($event) && (null === $eventName || $eventName instanceof ContractsEvent || $eventName instanceof Event)) { - @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.', ContractsEventDispatcherInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.', ContractsEventDispatcherInterface::class), \E_USER_DEPRECATED); $swap = $event; $event = $eventName ?? new Event(); $eventName = $swap; diff --git a/symfony/event-dispatcher/composer.json b/symfony/event-dispatcher/composer.json index 62bea6cb1..d86b1184a 100644 --- a/symfony/event-dispatcher/composer.json +++ b/symfony/event-dispatcher/composer.json @@ -23,6 +23,7 @@ "symfony/dependency-injection": "^3.4|^4.0|^5.0", "symfony/expression-language": "^3.4|^4.0|^5.0", "symfony/config": "^3.4|^4.0|^5.0", + "symfony/error-handler": "~3.4|~4.4", "symfony/http-foundation": "^3.4|^4.0|^5.0", "symfony/service-contracts": "^1.1|^2", "symfony/stopwatch": "^3.4|^4.0|^5.0", diff --git a/symfony/process/ExecutableFinder.php b/symfony/process/ExecutableFinder.php index cb4345e7b..ff68ed331 100644 --- a/symfony/process/ExecutableFinder.php +++ b/symfony/process/ExecutableFinder.php @@ -51,7 +51,7 @@ public function addSuffix($suffix) public function find($name, $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 @@ -65,7 +65,7 @@ public function find($name, $default = null, array $extraDirs = []) } } else { $dirs = array_merge( - explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')), + explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')), $extraDirs ); } @@ -73,7 +73,7 @@ public function find($name, $default = null, array $extraDirs = []) $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/symfony/process/PhpExecutableFinder.php b/symfony/process/PhpExecutableFinder.php index 5b8f1fcf1..3d5eabd99 100644 --- a/symfony/process/PhpExecutableFinder.php +++ b/symfony/process/PhpExecutableFinder.php @@ -38,7 +38,7 @@ public function find($includeArgs = true) 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; } @@ -54,8 +54,8 @@ public function find($includeArgs = true) $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')) { @@ -72,11 +72,11 @@ public function find($includeArgs = true) } } - 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/symfony/process/PhpProcess.php b/symfony/process/PhpProcess.php index 22fc1b385..dc064e0b8 100644 --- a/symfony/process/PhpProcess.php +++ b/symfony/process/PhpProcess.php @@ -65,7 +65,7 @@ public static function fromShellCommandline(string $command, string $cwd = null, */ public function setPhpBinary($php) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the $php argument of the constructor instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the $php argument of the constructor instead.', __METHOD__), \E_USER_DEPRECATED); $this->setCommandLine($php); } diff --git a/symfony/process/Pipes/WindowsPipes.php b/symfony/process/Pipes/WindowsPipes.php index c548092c5..b22171dd4 100644 --- a/symfony/process/Pipes/WindowsPipes.php +++ b/symfony/process/Pipes/WindowsPipes.php @@ -56,20 +56,23 @@ public function __construct($input, bool $haveReadSupport) $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name); if (!$h = fopen($file.'.lock', 'w')) { + if (file_exists($file.'.lock')) { + continue 2; + } 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; @@ -149,7 +152,7 @@ public function readAndWrite(bool $blocking, bool $close = false): array 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]); } @@ -183,7 +186,7 @@ public function close() 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/symfony/process/Process.php b/symfony/process/Process.php index 4db00eb4b..4e2968e4c 100644 --- a/symfony/process/Process.php +++ b/symfony/process/Process.php @@ -144,7 +144,7 @@ public function __construct($command, string $cwd = null, array $env = null, $in } if (!\is_array($command)) { - @trigger_error(sprintf('Passing a command as string when creating a "%s" instance is deprecated since Symfony 4.2, pass it as an array of its arguments instead, or use the "Process::fromShellCommandline()" constructor if you need features provided by the shell.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing a command as string when creating a "%s" instance is deprecated since Symfony 4.2, pass it as an array of its arguments instead, or use the "Process::fromShellCommandline()" constructor if you need features provided by the shell.', __CLASS__), \E_USER_DEPRECATED); } $this->commandline = $command; @@ -938,7 +938,7 @@ public function addOutput(string $line) { $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); } @@ -952,7 +952,7 @@ public function addErrorOutput(string $line) { $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); } @@ -988,7 +988,7 @@ public function getCommandLine() */ public function setCommandLine($commandline) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED); $this->commandline = $commandline; @@ -1224,7 +1224,7 @@ public function setInput($input) */ public function inheritEnvironmentVariables($inheritEnv = true) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, env variables are always inherited.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, env variables are always inherited.', __METHOD__), \E_USER_DEPRECATED); if (!$inheritEnv) { throw new InvalidArgumentException('Not inheriting environment variables is not supported.'); @@ -1383,7 +1383,7 @@ protected function isSigchildEnabled() } ob_start(); - phpinfo(INFO_GENERAL); + phpinfo(\INFO_GENERAL); return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild'); } diff --git a/symfony/process/composer.json b/symfony/process/composer.json index e0174de75..4a7d8f4bf 100644 --- a/symfony/process/composer.json +++ b/symfony/process/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": ">=7.1.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Process\\": "" }, diff --git a/symfony/routing/Annotation/Route.php b/symfony/routing/Annotation/Route.php index 52b208c41..dc1cee319 100644 --- a/symfony/routing/Annotation/Route.php +++ b/symfony/routing/Annotation/Route.php @@ -64,7 +64,7 @@ public function __construct(array $data) } 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']); } diff --git a/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php b/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php index 3602525f7..23081f917 100644 --- a/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php +++ b/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Routing\Generator\Dumper; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "CompiledUrlGeneratorDumper" instead.', PhpGeneratorDumper::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "CompiledUrlGeneratorDumper" instead.', PhpGeneratorDumper::class), \E_USER_DEPRECATED); use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper; diff --git a/symfony/routing/Generator/UrlGenerator.php b/symfony/routing/Generator/UrlGenerator.php index 728706699..7adf2ed27 100644 --- a/symfony/routing/Generator/UrlGenerator.php +++ b/symfony/routing/Generator/UrlGenerator.php @@ -302,7 +302,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa 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/symfony/routing/Loader/AnnotationClassLoader.php b/symfony/routing/Loader/AnnotationClassLoader.php index d8449c950..ca7f46b16 100644 --- a/symfony/routing/Loader/AnnotationClassLoader.php +++ b/symfony/routing/Loader/AnnotationClassLoader.php @@ -147,7 +147,7 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl foreach ($requirements as $placeholder => $requirement) { if (\is_int($placeholder)) { - @trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s::%s()"?', $placeholder, $requirement, $name, $class->getName(), $method->getName()), E_USER_DEPRECATED); + @trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s::%s()"?', $placeholder, $requirement, $name, $class->getName(), $method->getName()), \E_USER_DEPRECATED); } } @@ -305,7 +305,7 @@ protected function getGlobals(\ReflectionClass $class) foreach ($globals['requirements'] as $placeholder => $requirement) { if (\is_int($placeholder)) { - @trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" in "%s"?', $placeholder, $requirement, $class->getName()), E_USER_DEPRECATED); + @trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" in "%s"?', $placeholder, $requirement, $class->getName()), \E_USER_DEPRECATED); } } } diff --git a/symfony/routing/Loader/AnnotationFileLoader.php b/symfony/routing/Loader/AnnotationFileLoader.php index eafd614d4..8f9af3a8f 100644 --- a/symfony/routing/Loader/AnnotationFileLoader.php +++ b/symfony/routing/Loader/AnnotationFileLoader.php @@ -75,7 +75,7 @@ public function load($file, $type = null) */ public function supports($resource, $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); } /** @@ -91,10 +91,15 @@ protected function findClass($file) $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]; + if (\defined('T_NAME_QUALIFIED')) { + $nsTokens[T_NAME_QUALIFIED] = true; + } + for ($i = 0; isset($tokens[$i]); ++$i) { $token = $tokens[$i]; @@ -102,19 +107,19 @@ protected function findClass($file) continue; } - if (true === $class && T_STRING === $token[0]) { + if (true === $class && \T_STRING === $token[0]) { return $namespace.'\\'.$token[1]; } - if (true === $namespace && T_STRING === $token[0]) { + if (true === $namespace && isset($nsTokens[$token[0]])) { $namespace = $token[1]; - while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_NS_SEPARATOR, T_STRING])) { + while (isset($tokens[++$i][1], $nsTokens[$tokens[$i][0]])) { $namespace .= $tokens[$i][1]; } $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) { @@ -122,10 +127,10 @@ protected function findClass($file) 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; } } @@ -135,7 +140,7 @@ protected function findClass($file) } } - if (T_NAMESPACE === $token[0]) { + if (\T_NAMESPACE === $token[0]) { $namespace = true; } } diff --git a/symfony/routing/Loader/DependencyInjection/ServiceRouterLoader.php b/symfony/routing/Loader/DependencyInjection/ServiceRouterLoader.php index a04a19c3c..ab2be1026 100644 --- a/symfony/routing/Loader/DependencyInjection/ServiceRouterLoader.php +++ b/symfony/routing/Loader/DependencyInjection/ServiceRouterLoader.php @@ -15,7 +15,7 @@ use Symfony\Component\Routing\Loader\ContainerLoader; use Symfony\Component\Routing\Loader\ObjectRouteLoader; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ServiceRouterLoader::class, ContainerLoader::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ServiceRouterLoader::class, ContainerLoader::class), \E_USER_DEPRECATED); /** * A route loader that executes a service to load the routes. diff --git a/symfony/routing/Loader/ObjectLoader.php b/symfony/routing/Loader/ObjectLoader.php index b700929bd..344a79b70 100644 --- a/symfony/routing/Loader/ObjectLoader.php +++ b/symfony/routing/Loader/ObjectLoader.php @@ -48,7 +48,7 @@ public function load($resource, $type = null) if (1 === substr_count($resource, ':')) { $resource = str_replace(':', '::', $resource); - @trigger_error(sprintf('Referencing object route loaders with a single colon is deprecated since Symfony 4.1. Use %s instead.', $resource), E_USER_DEPRECATED); + @trigger_error(sprintf('Referencing object route loaders with a single colon is deprecated since Symfony 4.1. Use %s instead.', $resource), \E_USER_DEPRECATED); } $parts = explode('::', $resource); diff --git a/symfony/routing/Loader/ObjectRouteLoader.php b/symfony/routing/Loader/ObjectRouteLoader.php index 39833d9ce..44f28fb8a 100644 --- a/symfony/routing/Loader/ObjectRouteLoader.php +++ b/symfony/routing/Loader/ObjectRouteLoader.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Routing\Loader; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ObjectRouteLoader::class, ObjectLoader::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ObjectRouteLoader::class, ObjectLoader::class), \E_USER_DEPRECATED); /** * A route loader that calls a method on an object to load the routes. diff --git a/symfony/routing/Loader/PhpFileLoader.php b/symfony/routing/Loader/PhpFileLoader.php index a5cf95156..054290bff 100644 --- a/symfony/routing/Loader/PhpFileLoader.php +++ b/symfony/routing/Loader/PhpFileLoader.php @@ -63,7 +63,7 @@ public function load($file, $type = null) */ public function supports($resource, $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); } } diff --git a/symfony/routing/Loader/XmlFileLoader.php b/symfony/routing/Loader/XmlFileLoader.php index 31c614950..e8732b3d6 100644 --- a/symfony/routing/Loader/XmlFileLoader.php +++ b/symfony/routing/Loader/XmlFileLoader.php @@ -93,7 +93,7 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, $pa */ public function supports($resource, $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); } /** @@ -110,8 +110,8 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $p 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) = $this->parseConfigs($node, $path); @@ -155,8 +155,8 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $ $type = $node->getAttribute('type'); $prefix = $node->getAttribute('prefix'); $host = $node->hasAttribute('host') ? $node->getAttribute('host') : 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; + $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; list($defaults, $requirements, $options, $condition, /* $paths */, $prefixes) = $this->parseConfigs($node, $path); diff --git a/symfony/routing/Loader/YamlFileLoader.php b/symfony/routing/Loader/YamlFileLoader.php index 611055e7c..c7aa00e17 100644 --- a/symfony/routing/Loader/YamlFileLoader.php +++ b/symfony/routing/Loader/YamlFileLoader.php @@ -96,7 +96,7 @@ public function load($file, $type = null) */ public function supports($resource, $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); } /** @@ -118,7 +118,7 @@ protected function parseRoute(RouteCollection $collection, $name, array $config, foreach ($requirements as $placeholder => $requirement) { if (\is_int($placeholder)) { - @trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s"?', $placeholder, $requirement, $name, $path), E_USER_DEPRECATED); + @trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s"?', $placeholder, $requirement, $name, $path), \E_USER_DEPRECATED); } } diff --git a/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php b/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php index 936dd16ad..73e2e1e0a 100644 --- a/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php +++ b/symfony/routing/Matcher/Dumper/CompiledUrlMatcherDumper.php @@ -244,7 +244,7 @@ private function compileStaticRoutes(array $staticRoutes, array &$conditions): a * Last but not least: * - Because it is not possibe to mix unicode/non-unicode patterns in a single regexp, several of them can be generated. * - The same regexp can be used several times when the logic in the switch rejects the match. When this happens, the - * matching-but-failing subpattern is blacklisted by replacing its name by "(*F)", which forces a failure-to-match. + * matching-but-failing subpattern is excluded by replacing its name by "(*F)", which forces a failure-to-match. * To ease this backlisting operation, the name of subpatterns is also the string offset where the replacement should occur. */ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHost, int $chunkLimit, array &$conditions): array diff --git a/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php b/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php index ee505e164..09404efaa 100644 --- a/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Routing\Matcher\Dumper; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "CompiledUrlMatcherDumper" instead.', PhpMatcherDumper::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "CompiledUrlMatcherDumper" instead.', PhpMatcherDumper::class), \E_USER_DEPRECATED); /** * PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes. diff --git a/symfony/routing/Route.php b/symfony/routing/Route.php index de98e1d76..7f20c794c 100644 --- a/symfony/routing/Route.php +++ b/symfony/routing/Route.php @@ -137,7 +137,7 @@ public function getPath() public function setPath($pattern) { if (false !== strpbrk($pattern, '?<')) { - $pattern = preg_replace_callback('#\{(\w++)(<.*?>)?(\?[^\}]*+)?\}#', function ($m) { + $pattern = preg_replace_callback('#\{(!?\w++)(<.*?>)?(\?[^\}]*+)?\}#', function ($m) { if (isset($m[3][0])) { $this->setDefault($m[1], '?' !== $m[3] ? substr($m[3], 1) : null); } diff --git a/symfony/routing/RouteCollection.php b/symfony/routing/RouteCollection.php index b52c6832f..6537bbae9 100644 --- a/symfony/routing/RouteCollection.php +++ b/symfony/routing/RouteCollection.php @@ -140,7 +140,7 @@ public function addCollection(self $collection) public function addPrefix($prefix, array $defaults = [], array $requirements = []) { if (null === $prefix) { - @trigger_error(sprintf('Passing null as $prefix to %s is deprecated in Symfony 4.4 and will trigger a TypeError in 5.0.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing null as $prefix to %s is deprecated in Symfony 4.4 and will trigger a TypeError in 5.0.', __METHOD__), \E_USER_DEPRECATED); } $prefix = trim(trim($prefix), '/'); diff --git a/symfony/routing/RouteCompiler.php b/symfony/routing/RouteCompiler.php index aac2ee893..fa63df488 100644 --- a/symfony/routing/RouteCompiler.php +++ b/symfony/routing/RouteCompiler.php @@ -119,7 +119,7 @@ private static function compilePattern(Route $route, string $pattern, bool $isHo // 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]; @@ -207,7 +207,7 @@ private static function compilePattern(Route $route, string $pattern, bool $isHo } // 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/symfony/routing/Router.php b/symfony/routing/Router.php index 9351fa097..8bc6f21af 100644 --- a/symfony/routing/Router.php +++ b/symfony/routing/Router.php @@ -433,13 +433,13 @@ private function checkDeprecatedOption(string $key) case 'generator_cache_class': case 'matcher_base_class': case 'matcher_cache_class': - @trigger_error(sprintf('Option "%s" given to router %s is deprecated since Symfony 4.3.', $key, static::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Option "%s" given to router %s is deprecated since Symfony 4.3.', $key, static::class), \E_USER_DEPRECATED); } } 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/symfony/routing/composer.json b/symfony/routing/composer.json index 21fe8ee10..73b2ae932 100644 --- a/symfony/routing/composer.json +++ b/symfony/routing/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": ">=7.1.3" }, "require-dev": { "symfony/config": "^4.2|^5.0", diff --git a/symfony/translation/Command/XliffLintCommand.php b/symfony/translation/Command/XliffLintCommand.php index 3f8fe7321..e96effbcd 100644 --- a/symfony/translation/Command/XliffLintCommand.php +++ b/symfony/translation/Command/XliffLintCommand.php @@ -91,11 +91,11 @@ protected function execute(InputInterface $input, OutputInterface $output) // @deprecated to be removed in 5.0 if (!$filenames) { - if (0 !== ftell(STDIN)) { + if (0 !== ftell(\STDIN)) { throw new RuntimeException('Please provide a filename or pipe file content to STDIN.'); } - @trigger_error('Piping content from STDIN to the "lint:xliff" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', E_USER_DEPRECATED); + @trigger_error('Piping content from STDIN to the "lint:xliff" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', \E_USER_DEPRECATED); return $this->display($io, [$this->validate(file_get_contents('php://stdin'))]); } @@ -209,7 +209,7 @@ private function displayJson(SymfonyStyle $io, array $filesInfo) } }); - $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/symfony/translation/Dumper/FileDumper.php b/symfony/translation/Dumper/FileDumper.php index 2009c5340..87d0c69d7 100644 --- a/symfony/translation/Dumper/FileDumper.php +++ b/symfony/translation/Dumper/FileDumper.php @@ -51,7 +51,7 @@ public function setRelativePathTemplate($relativePathTemplate) */ public function setBackup($backup) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1.', __METHOD__), \E_USER_DEPRECATED); if (false !== $backup) { throw new \LogicException('The backup feature is no longer supported.'); diff --git a/symfony/translation/Dumper/JsonFileDumper.php b/symfony/translation/Dumper/JsonFileDumper.php index 2af8231bd..c6c3163b2 100644 --- a/symfony/translation/Dumper/JsonFileDumper.php +++ b/symfony/translation/Dumper/JsonFileDumper.php @@ -25,7 +25,7 @@ class JsonFileDumper extends FileDumper */ public function formatCatalogue(MessageCatalogue $messages, $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/symfony/translation/Dumper/PoFileDumper.php b/symfony/translation/Dumper/PoFileDumper.php index 2cc9e8895..1a723f2d0 100644 --- a/symfony/translation/Dumper/PoFileDumper.php +++ b/symfony/translation/Dumper/PoFileDumper.php @@ -53,7 +53,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti $sourceRules = $this->getStandardRules($source); $targetRules = $this->getStandardRules($target); - if (2 == \count($sourceRules) && $targetRules !== []) { + if (2 == \count($sourceRules) && [] !== $targetRules) { $output .= sprintf('msgid "%s"'."\n", $this->escape($sourceRules[0])); $output .= sprintf('msgid_plural "%s"'."\n", $this->escape($sourceRules[1])); foreach ($targetRules as $i => $targetRule) { diff --git a/symfony/translation/Extractor/PhpExtractor.php b/symfony/translation/Extractor/PhpExtractor.php index 5237bf662..edea36769 100644 --- a/symfony/translation/Extractor/PhpExtractor.php +++ b/symfony/translation/Extractor/PhpExtractor.php @@ -118,7 +118,7 @@ private function seekToNextRelevantToken(\Iterator $tokenIterator) { for (; $tokenIterator->valid(); $tokenIterator->next()) { $t = $tokenIterator->current(); - if (T_WHITESPACE !== $t[0]) { + if (\T_WHITESPACE !== $t[0]) { break; } } @@ -166,23 +166,23 @@ private function getValue(\Iterator $tokenIterator) } 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; @@ -200,8 +200,8 @@ private function getValue(\Iterator $tokenIterator) */ protected function parseTokens($tokens, MessageCatalogue $catalog/*, string $filename*/) { - if (\func_num_args() < 3 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { - @trigger_error(sprintf('The "%s()" method will have a new "string $filename" argument in version 5.0, not defining it is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED); + if (\func_num_args() < 3 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) { + @trigger_error(sprintf('The "%s()" method will have a new "string $filename" argument in version 5.0, not defining it is deprecated since Symfony 4.3.', __METHOD__), \E_USER_DEPRECATED); } $filename = 2 < \func_num_args() ? func_get_arg(2) : ''; @@ -260,7 +260,7 @@ protected function parseTokens($tokens, MessageCatalogue $catalog/*, string $fil */ protected function canBeExtracted($file) { - return $this->isFile($file) && 'php' === pathinfo($file, PATHINFO_EXTENSION); + return $this->isFile($file) && 'php' === pathinfo($file, \PATHINFO_EXTENSION); } /** diff --git a/symfony/translation/Formatter/MessageFormatter.php b/symfony/translation/Formatter/MessageFormatter.php index a16764069..785d6f226 100644 --- a/symfony/translation/Formatter/MessageFormatter.php +++ b/symfony/translation/Formatter/MessageFormatter.php @@ -69,7 +69,7 @@ public function formatIntl(string $message, string $locale, array $parameters = */ public function choiceFormat($message, $number, $locale, array $parameters = []) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the format() one instead with a %%count%% parameter.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the format() one instead with a %%count%% parameter.', __METHOD__), \E_USER_DEPRECATED); $parameters = ['%count%' => $number] + $parameters; diff --git a/symfony/translation/IdentityTranslator.php b/symfony/translation/IdentityTranslator.php index 87b40bf8f..7316148e5 100644 --- a/symfony/translation/IdentityTranslator.php +++ b/symfony/translation/IdentityTranslator.php @@ -34,7 +34,7 @@ public function __construct(MessageSelector $selector = null) $this->selector = $selector; if (__CLASS__ !== static::class) { - @trigger_error(sprintf('Calling "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Calling "%s()" is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED); } } @@ -61,7 +61,7 @@ public function setLocale($locale) */ public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), \E_USER_DEPRECATED); if ($this->selector) { return strtr($this->selector->choose((string) $id, $number, $locale ?: $this->getLocale()), $parameters); diff --git a/symfony/translation/Interval.php b/symfony/translation/Interval.php index 1adc43fbd..bb6b164e8 100644 --- a/symfony/translation/Interval.php +++ b/symfony/translation/Interval.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Translation; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use IdentityTranslator instead.', Interval::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use IdentityTranslator instead.', Interval::class), \E_USER_DEPRECATED); use Symfony\Component\Translation\Exception\InvalidArgumentException; diff --git a/symfony/translation/Loader/JsonFileLoader.php b/symfony/translation/Loader/JsonFileLoader.php index 9f15dbc62..8a8996b0d 100644 --- a/symfony/translation/Loader/JsonFileLoader.php +++ b/symfony/translation/Loader/JsonFileLoader.php @@ -43,15 +43,15 @@ protected function loadResource($resource) 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/symfony/translation/Loader/PhpFileLoader.php b/symfony/translation/Loader/PhpFileLoader.php index 0991c3d3a..c361d5293 100644 --- a/symfony/translation/Loader/PhpFileLoader.php +++ b/symfony/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/symfony/translation/LoggingTranslator.php b/symfony/translation/LoggingTranslator.php index a00119295..d7b6fc4b3 100644 --- a/symfony/translation/LoggingTranslator.php +++ b/symfony/translation/LoggingTranslator.php @@ -63,7 +63,7 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul */ public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), \E_USER_DEPRECATED); if ($this->translator instanceof TranslatorInterface) { $trans = $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale); diff --git a/symfony/translation/MessageCatalogue.php b/symfony/translation/MessageCatalogue.php index 75ec5b46c..f2fc9a926 100644 --- a/symfony/translation/MessageCatalogue.php +++ b/symfony/translation/MessageCatalogue.php @@ -33,7 +33,7 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf public function __construct(?string $locale, array $messages = []) { if (null === $locale) { - @trigger_error(sprintf('Passing "null" to the first argument of the "%s" method has been deprecated since Symfony 4.4 and will throw an error in 5.0.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing "null" to the first argument of the "%s" method has been deprecated since Symfony 4.4 and will throw an error in 5.0.', __METHOD__), \E_USER_DEPRECATED); } $this->locale = $locale; diff --git a/symfony/translation/MessageSelector.php b/symfony/translation/MessageSelector.php index 0f0febb8b..38de357a5 100644 --- a/symfony/translation/MessageSelector.php +++ b/symfony/translation/MessageSelector.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Translation; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use IdentityTranslator instead.', MessageSelector::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use IdentityTranslator instead.', MessageSelector::class), \E_USER_DEPRECATED); use Symfony\Component\Translation\Exception\InvalidArgumentException; diff --git a/symfony/translation/PluralizationRules.php b/symfony/translation/PluralizationRules.php index 77c276073..f5fba4039 100644 --- a/symfony/translation/PluralizationRules.php +++ b/symfony/translation/PluralizationRules.php @@ -33,7 +33,7 @@ class PluralizationRules public static function get($number, $locale/*, bool $triggerDeprecation = true*/) { if (3 > \func_num_args() || func_get_arg(2)) { - @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', __CLASS__), \E_USER_DEPRECATED); } if ('pt_BR' === $locale) { @@ -202,7 +202,7 @@ public static function get($number, $locale/*, bool $triggerDeprecation = true*/ */ public static function set(callable $rule, $locale) { - @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', __CLASS__), \E_USER_DEPRECATED); if ('pt_BR' === $locale) { // temporary set a locale for brazilian diff --git a/symfony/translation/Translator.php b/symfony/translation/Translator.php index b404b5491..f3d8d620e 100644 --- a/symfony/translation/Translator.php +++ b/symfony/translation/Translator.php @@ -91,7 +91,7 @@ class Translator implements LegacyTranslatorInterface, TranslatorInterface, Tran public function __construct(?string $locale, MessageFormatterInterface $formatter = null, string $cacheDir = null, bool $debug = false, array $cacheVary = []) { if (null === $locale) { - @trigger_error(sprintf('Passing "null" as the $locale argument to %s() is deprecated since Symfony 4.4.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing "null" as the $locale argument to %s() is deprecated since Symfony 4.4.', __METHOD__), \E_USER_DEPRECATED); } $this->setLocale($locale, false); @@ -139,7 +139,7 @@ public function addResource($format, $resource, $locale, $domain = null) } if (null === $locale) { - @trigger_error(sprintf('Passing "null" to the third argument of the "%s" method has been deprecated since Symfony 4.4 and will throw an error in 5.0.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing "null" to the third argument of the "%s" method has been deprecated since Symfony 4.4 and will throw an error in 5.0.', __METHOD__), \E_USER_DEPRECATED); } $this->assertValidLocale($locale); @@ -159,11 +159,11 @@ public function addResource($format, $resource, $locale, $domain = null) public function setLocale($locale) { if (null === $locale && (2 > \func_num_args() || func_get_arg(1))) { - @trigger_error(sprintf('Passing "null" as the $locale argument to %s() is deprecated since Symfony 4.4.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing "null" as the $locale argument to %s() is deprecated since Symfony 4.4.', __METHOD__), \E_USER_DEPRECATED); } $this->assertValidLocale($locale); - $this->locale = $locale; + $this->locale = $locale ?? (class_exists(\Locale::class) ? \Locale::getDefault() : 'en'); } /** @@ -188,7 +188,7 @@ public function setFallbackLocales(array $locales) foreach ($locales as $locale) { if (null === $locale) { - @trigger_error(sprintf('Passing "null" as the $locale argument to %s() is deprecated since Symfony 4.4.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing "null" as the $locale argument to %s() is deprecated since Symfony 4.4.', __METHOD__), \E_USER_DEPRECATED); } $this->assertValidLocale($locale); } @@ -246,7 +246,7 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul */ public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), \E_USER_DEPRECATED); if ('' === $id = (string) $id) { return ''; @@ -460,7 +460,7 @@ private function loadFallbackCatalogues(string $locale): void protected function computeFallbackLocales($locale) { if (null === $this->parentLocales) { - $parentLocales = json_decode(file_get_contents(__DIR__.'/Resources/data/parents.json'), true); + $this->parentLocales = json_decode(file_get_contents(__DIR__.'/Resources/data/parents.json'), true); } $locales = []; @@ -473,7 +473,7 @@ protected function computeFallbackLocales($locale) } while ($locale) { - $parent = $parentLocales[$locale] ?? null; + $parent = $this->parentLocales[$locale] ?? null; if ($parent) { $locale = 'root' !== $parent ? $parent : null; diff --git a/symfony/translation/Util/XliffUtils.php b/symfony/translation/Util/XliffUtils.php index b5ff4ef4a..a8c05c224 100644 --- a/symfony/translation/Util/XliffUtils.php +++ b/symfony/translation/Util/XliffUtils.php @@ -61,16 +61,22 @@ public static function validateSchema(\DOMDocument $dom): array { $xliffVersion = static::getVersionNumber($dom); $internalErrors = libxml_use_internal_errors(true); - $disableEntities = libxml_disable_entity_loader(false); + if (\LIBXML_VERSION < 20900) { + $disableEntities = libxml_disable_entity_loader(false); + } $isValid = @$dom->schemaValidateSource(self::getSchema($xliffVersion)); if (!$isValid) { - libxml_disable_entity_loader($disableEntities); + if (\LIBXML_VERSION < 20900) { + libxml_disable_entity_loader($disableEntities); + } return self::getXmlErrors($internalErrors); } - libxml_disable_entity_loader($disableEntities); + if (\LIBXML_VERSION < 20900) { + libxml_disable_entity_loader($disableEntities); + } $dom->normalizeDocument(); @@ -86,7 +92,7 @@ public static function getErrorsAsString(array $xmlErrors): string 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'], @@ -146,7 +152,7 @@ private static function getXmlErrors(bool $internalErrors): array $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/symfony/translation/Writer/TranslationWriter.php b/symfony/translation/Writer/TranslationWriter.php index a981b8d62..83f6fd615 100644 --- a/symfony/translation/Writer/TranslationWriter.php +++ b/symfony/translation/Writer/TranslationWriter.php @@ -42,7 +42,7 @@ public function addDumper($format, DumperInterface $dumper) */ public function disableBackup() { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1.', __METHOD__), \E_USER_DEPRECATED); foreach ($this->dumpers as $dumper) { if (method_exists($dumper, 'setBackup')) {