From 56900d2b24da18539378b888a53a488a9540d289 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 26 Jun 2021 20:16:56 +0200 Subject: [PATCH 001/100] [Form] better form doc types to support static analysis --- src/Symfony/Component/Form/FormBuilderInterface.php | 10 +++++++--- src/Symfony/Component/Form/FormConfigInterface.php | 2 +- src/Symfony/Component/Form/FormTypeInterface.php | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/FormBuilderInterface.php b/src/Symfony/Component/Form/FormBuilderInterface.php index 902fa0f9505e5..36386bb001e55 100644 --- a/src/Symfony/Component/Form/FormBuilderInterface.php +++ b/src/Symfony/Component/Form/FormBuilderInterface.php @@ -13,6 +13,8 @@ /** * @author Bernhard Schussek + * + * @extends \Traversable */ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface { @@ -25,6 +27,7 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild * * @param string|FormBuilderInterface $child * @param string|null $type + * @param array $options * * @return self */ @@ -33,8 +36,9 @@ public function add($child, $type = null, array $options = []); /** * Creates a form builder. * - * @param string $name The name of the form or the name of the property - * @param string|null $type The type of the form or null if name is a property + * @param string $name The name of the form or the name of the property + * @param string|null $type The type of the form or null if name is a property + * @param array $options * * @return self */ @@ -72,7 +76,7 @@ public function has($name); /** * Returns the children. * - * @return array + * @return array */ public function all(); diff --git a/src/Symfony/Component/Form/FormConfigInterface.php b/src/Symfony/Component/Form/FormConfigInterface.php index 7dbda33033b55..43fef38911306 100644 --- a/src/Symfony/Component/Form/FormConfigInterface.php +++ b/src/Symfony/Component/Form/FormConfigInterface.php @@ -229,7 +229,7 @@ public function getAutoInitialize(); /** * Returns all options passed during the construction of the form. * - * @return array The passed options + * @return array The passed options */ public function getOptions(); diff --git a/src/Symfony/Component/Form/FormTypeInterface.php b/src/Symfony/Component/Form/FormTypeInterface.php index 6850d54968105..9727a2e569aa1 100644 --- a/src/Symfony/Component/Form/FormTypeInterface.php +++ b/src/Symfony/Component/Form/FormTypeInterface.php @@ -24,6 +24,8 @@ interface FormTypeInterface * This method is called for each type in the hierarchy starting from the * top most type. Type extensions can further modify the form. * + * @param array $options + * * @see FormTypeExtensionInterface::buildForm() */ public function buildForm(FormBuilderInterface $builder, array $options); @@ -38,6 +40,8 @@ public function buildForm(FormBuilderInterface $builder, array $options); * This means that you cannot access child views in this method. If you need * to do so, move your logic to {@link finishView()} instead. * + * @param array $options + * * @see FormTypeExtensionInterface::buildView() */ public function buildView(FormView $view, FormInterface $form, array $options); @@ -53,6 +57,8 @@ public function buildView(FormView $view, FormInterface $form, array $options); * such logic in this method that actually accesses child views. For everything * else you are recommended to implement {@link buildView()} instead. * + * @param array $options + * * @see FormTypeExtensionInterface::finishView() */ public function finishView(FormView $view, FormInterface $form, array $options); From ffb4795104ba4cfacbc84c47b8f76c5cd32ab07e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 Jun 2021 10:22:49 +0200 Subject: [PATCH 002/100] Bump Symfony version to 4.4.27 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 1275f12e7ac31..1c46d1cbb5d77 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.26'; - public const VERSION_ID = 40426; + public const VERSION = '4.4.27-DEV'; + public const VERSION_ID = 40427; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 26; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 27; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 31e1a978f5d2b7899eb2edff8a6f9b2bc4863b0f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 Jun 2021 15:02:00 +0200 Subject: [PATCH 003/100] CS fixes --- .php-cs-fixer.dist.php | 1 + src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php | 3 --- .../Tests/Functional/app/CachePools/bundles.php | 1 - .../Component/Cache/Tests/Adapter/ArrayAdapterTest.php | 2 +- .../Config/Tests/Definition/Builder/ExprBuilderTest.php | 2 +- .../Config/Tests/Resource/ReflectionClassResourceTest.php | 2 +- .../Storage/Handler/MemcachedSessionHandlerTest.php | 2 +- src/Symfony/Component/Mailer/Transport/Dsn.php | 2 +- src/Symfony/Component/Yaml/Exception/ParseException.php | 8 ++++---- 9 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 583be2ac59363..fdb481fd190a8 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -11,6 +11,7 @@ '@Symfony' => true, '@Symfony:risky' => true, 'protected_to_private' => false, + 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => false], ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php index 5ddd60df8e857..a004935a6afdc 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php @@ -19,9 +19,6 @@ class ManagerRegistryTest extends TestCase { public static function setUpBeforeClass(): void { - if (!class_exists(\PHPUnit_Framework_TestCase::class)) { - self::markTestSkipped('proxy-manager-bridge is not yet compatible with namespaced phpunit versions.'); - } $test = new PhpDumperTest(); $test->testDumpContainerWithProxyServiceWillShareProxies(); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php index 2e46e896bca7c..13ab9fddee4a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php @@ -10,7 +10,6 @@ */ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; return [ new FrameworkBundle(), diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php index 9292b1c962f04..5ed33cee77977 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php @@ -49,7 +49,7 @@ public function testGetValuesHitAndMiss() // Fail (should be missing from $values) $item = $cache->getItem('buz'); - $cache->save($item->set(function() {})); + $cache->save($item->set(function () {})); $values = $cache->getValues(); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index 74ae972e54aab..bec4275404c75 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -225,7 +225,7 @@ protected function getTestBuilder(): ExprBuilder * * @return array The finalized config values */ - protected function finalizeTestBuilder(NodeDefinition $nodeDefinition, ?array $config = null): array + protected function finalizeTestBuilder(NodeDefinition $nodeDefinition, array $config = null): array { return $nodeDefinition ->end() diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php index 8ba3a8c2c93cf..e097205e8c413 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php @@ -64,7 +64,7 @@ public function testIsFreshForDeletedResources() /** * @dataProvider provideHashedSignature */ - public function testHashedSignature(bool $changeExpected, int $changedLine, ?string $changedCode, ?\Closure $setContext = null) + public function testHashedSignature(bool $changeExpected, int $changedLine, ?string $changedCode, \Closure $setContext = null) { if ($setContext) { $setContext(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index a7f7e8f81751e..200567a29d4ac 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -40,7 +40,7 @@ protected function setUp(): void $r = new \ReflectionClass(\Memcached::class); $methodsToMock = array_map(function ($m) { return $m->name; }, $r->getMethods(\ReflectionMethod::IS_PUBLIC)); - $methodsToMock = array_diff($methodsToMock, ['getDelayed','getDelayedByKey']); + $methodsToMock = array_diff($methodsToMock, ['getDelayed', 'getDelayedByKey']); $this->memcached = $this->getMockBuilder(\Memcached::class) ->disableOriginalConstructor() diff --git a/src/Symfony/Component/Mailer/Transport/Dsn.php b/src/Symfony/Component/Mailer/Transport/Dsn.php index cc25f7a237832..04d3540f7b002 100644 --- a/src/Symfony/Component/Mailer/Transport/Dsn.php +++ b/src/Symfony/Component/Mailer/Transport/Dsn.php @@ -25,7 +25,7 @@ final class Dsn private $port; private $options; - public function __construct(string $scheme, string $host, ?string $user = null, ?string $password = null, ?int $port = null, array $options = []) + public function __construct(string $scheme, string $host, string $user = null, string $password = null, int $port = null, array $options = []) { $this->scheme = $scheme; $this->host = $host; diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index c75066da2d4f5..82c05a714f4fb 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -24,10 +24,10 @@ class ParseException extends RuntimeException private $rawMessage; /** - * @param string $message The error message - * @param int $parsedLine The line where the error occurred - * @param string|null $snippet The snippet of code near the problem - * @param string|null $parsedFile The file name where the error occurred + * @param string $message The error message + * @param int $parsedLine The line where the error occurred + * @param string|null $snippet The snippet of code near the problem + * @param string|null $parsedFile The file name where the error occurred */ public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Throwable $previous = null) { From 780e746adb583df7d6ff69f06c4e5c5a07462ce0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 Jun 2021 15:27:08 +0200 Subject: [PATCH 004/100] CS fix --- .../Component/Cache/Adapter/AbstractAdapter.php | 6 +++--- src/Symfony/Component/Cache/Adapter/Psr16Adapter.php | 4 ++-- .../Component/Cache/Adapter/TagAwareAdapter.php | 4 ++-- src/Symfony/Component/Cache/Simple/AbstractCache.php | 10 +++++----- .../Loader/Configurator/AliasConfigurator.php | 4 ++-- .../Loader/Configurator/DefaultsConfigurator.php | 4 ++-- .../Loader/Configurator/InlineServiceConfigurator.php | 4 ++-- .../Loader/Configurator/InstanceofConfigurator.php | 4 ++-- .../Loader/Configurator/PrototypeConfigurator.php | 4 ++-- .../Loader/Configurator/ServiceConfigurator.php | 4 ++-- .../Validator/Constraints/ExpressionValidator.php | 5 ++++- 11 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index d5156ad5f73fe..fa6d366a7064d 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -25,14 +25,14 @@ */ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface { + use AbstractAdapterTrait; + use ContractsTrait; + /** * @internal */ protected const NS_SEPARATOR = ':'; - use AbstractAdapterTrait; - use ContractsTrait; - private static $apcuSupported; private static $phpFilesSupported; diff --git a/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php b/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php index 4cbe35c43f1ff..e959d7849837b 100644 --- a/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php +++ b/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php @@ -23,13 +23,13 @@ */ class Psr16Adapter extends AbstractAdapter implements PruneableInterface, ResettableInterface { + use ProxyTrait; + /** * @internal */ protected const NS_SEPARATOR = '_'; - use ProxyTrait; - private $miss; public function __construct(CacheInterface $pool, string $namespace = '', int $defaultLifetime = 0) diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 52ad1e5e54e0d..23a0e87a74951 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -27,12 +27,12 @@ */ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface, PruneableInterface, ResettableInterface, LoggerAwareInterface { - public const TAGS_PREFIX = "\0tags\0"; - use ContractsTrait; use LoggerAwareTrait; use ProxyTrait; + public const TAGS_PREFIX = "\0tags\0"; + private $deferred = []; private $createCacheItem; private $setCacheItemTags; diff --git a/src/Symfony/Component/Cache/Simple/AbstractCache.php b/src/Symfony/Component/Cache/Simple/AbstractCache.php index b0488075918e4..c3d8b38cc8821 100644 --- a/src/Symfony/Component/Cache/Simple/AbstractCache.php +++ b/src/Symfony/Component/Cache/Simple/AbstractCache.php @@ -27,17 +27,17 @@ */ abstract class AbstractCache implements Psr16CacheInterface, LoggerAwareInterface, ResettableInterface { - /** - * @internal - */ - protected const NS_SEPARATOR = ':'; - use AbstractTrait { deleteItems as private; AbstractTrait::deleteItem as delete; AbstractTrait::hasItem as has; } + /** + * @internal + */ + protected const NS_SEPARATOR = ':'; + private $defaultLifetime; protected function __construct(string $namespace = '', int $defaultLifetime = 0) diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AliasConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AliasConfigurator.php index c77653c74494a..650a9568dfdd7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AliasConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AliasConfigurator.php @@ -18,11 +18,11 @@ */ class AliasConfigurator extends AbstractServiceConfigurator { - public const FACTORY = 'alias'; - use Traits\DeprecateTrait; use Traits\PublicTrait; + public const FACTORY = 'alias'; + public function __construct(ServicesConfigurator $parent, Alias $alias) { $this->parent = $parent; diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php index c80bc1fd0caeb..49a92e5ce3a76 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php @@ -19,13 +19,13 @@ */ class DefaultsConfigurator extends AbstractServiceConfigurator { - public const FACTORY = 'defaults'; - use Traits\AutoconfigureTrait; use Traits\AutowireTrait; use Traits\BindTrait; use Traits\PublicTrait; + public const FACTORY = 'defaults'; + private $path; public function __construct(ServicesConfigurator $parent, Definition $definition, string $path = null) diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/InlineServiceConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/InlineServiceConfigurator.php index 594d5ea3a0148..32a703d29d640 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/InlineServiceConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/InlineServiceConfigurator.php @@ -18,8 +18,6 @@ */ class InlineServiceConfigurator extends AbstractConfigurator { - public const FACTORY = 'inline'; - use Traits\ArgumentTrait; use Traits\AutowireTrait; use Traits\BindTrait; @@ -29,6 +27,8 @@ class InlineServiceConfigurator extends AbstractConfigurator use Traits\ParentTrait; use Traits\TagTrait; + public const FACTORY = 'inline'; + private $id = '[inline]'; private $allowParent = true; private $path = null; diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/InstanceofConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/InstanceofConfigurator.php index dba8b43e92c09..fbba62304d28e 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/InstanceofConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/InstanceofConfigurator.php @@ -18,8 +18,6 @@ */ class InstanceofConfigurator extends AbstractServiceConfigurator { - public const FACTORY = 'instanceof'; - use Traits\AutowireTrait; use Traits\BindTrait; use Traits\CallTrait; @@ -30,6 +28,8 @@ class InstanceofConfigurator extends AbstractServiceConfigurator use Traits\ShareTrait; use Traits\TagTrait; + public const FACTORY = 'instanceof'; + private $path; public function __construct(ServicesConfigurator $parent, Definition $definition, string $id, string $path = null) diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php index 43b154907f90a..e1b3702aaf24f 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php @@ -19,8 +19,6 @@ */ class PrototypeConfigurator extends AbstractServiceConfigurator { - public const FACTORY = 'load'; - use Traits\AbstractTrait; use Traits\ArgumentTrait; use Traits\AutoconfigureTrait; @@ -37,6 +35,8 @@ class PrototypeConfigurator extends AbstractServiceConfigurator use Traits\ShareTrait; use Traits\TagTrait; + public const FACTORY = 'load'; + private $loader; private $resource; private $excludes; diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php index b097bbc220a3a..71fa30c4e04c1 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php @@ -20,8 +20,6 @@ */ class ServiceConfigurator extends AbstractServiceConfigurator { - public const FACTORY = 'services'; - use Traits\AbstractTrait; use Traits\ArgumentTrait; use Traits\AutoconfigureTrait; @@ -42,6 +40,8 @@ class ServiceConfigurator extends AbstractServiceConfigurator use Traits\SyntheticTrait; use Traits\TagTrait; + public const FACTORY = 'services'; + private $container; private $instanceof; private $allowParent; diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php index be0613ce2c10b..048434cf06193 100644 --- a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -25,7 +25,10 @@ class ExpressionValidator extends ConstraintValidator { private $expressionLanguage; - public function __construct(/*ExpressionLanguage */$expressionLanguage = null) + /** + * @param ExpressionLanguage|null $expressionLanguage + */ + public function __construct($expressionLanguage = null) { if (\func_num_args() > 1) { @trigger_error(sprintf('The "%s" instance should be passed as "%s" first argument instead of second argument since 4.4.', ExpressionLanguage::class, __METHOD__), \E_USER_DEPRECATED); From 7c6c7b033156abb41728f08762887e5198eb84a1 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 Jun 2021 16:07:32 +0200 Subject: [PATCH 005/100] Fix tests --- .github/composer-config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/composer-config.json b/.github/composer-config.json index 752047dbb681d..6e17bc21e4582 100644 --- a/.github/composer-config.json +++ b/.github/composer-config.json @@ -4,6 +4,7 @@ "preferred-install": { "symfony/form": "source", "symfony/http-kernel": "source", + "symfony/proxy-manager-bridge": "source", "symfony/validator": "source", "*": "dist" } From 44ca13ef409c6248dbbb2faebc895885f81317b1 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 1 Jul 2021 16:52:12 +0200 Subject: [PATCH 006/100] Revert CI workaround for masterminds/html5 Signed-off-by: Alexander M. Turek --- .github/workflows/unit-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index ceffbe310240c..6ce52878ac93a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -41,7 +41,6 @@ jobs: run: | echo "extensions=mbstring" >> $GITHUB_ENV composer config platform.php 8.0.99 - composer require --dev --no-update masterminds/html5:~2.7.5@dev - name: Setup PHP uses: shivammathur/setup-php@v2 From 5f90fb0fd6b5c5fe7e866f12ae9f617c0a28c578 Mon Sep 17 00:00:00 2001 From: YaFou <33806646+YaFou@users.noreply.github.com> Date: Mon, 28 Jun 2021 18:04:37 +0200 Subject: [PATCH 007/100] [PhpUnitBridge] Fix deprecation handler with PHPUnit 10 --- .../PhpUnit/DeprecationErrorHandler.php | 20 +++++++++++++------ .../DeprecationErrorHandler/Deprecation.php | 5 ++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 19c6691dbec3e..518a76425377e 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\PhpUnit; use PHPUnit\Framework\TestResult; +use PHPUnit\Util\Error\Handler; use PHPUnit\Util\ErrorHandler; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation; @@ -51,7 +52,7 @@ class DeprecationErrorHandler ]; private static $isRegistered = false; - private static $isAtLeastPhpUnit83; + private static $errorHandler; /** * Registers and configures the deprecation handler. @@ -335,16 +336,23 @@ private function displayDeprecations($groups, $configuration) private static function getPhpUnitErrorHandler() { - if (!isset(self::$isAtLeastPhpUnit83)) { - self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke'); + if (!$eh = self::$errorHandler) { + if (class_exists(Handler::class)) { + $eh = self::$errorHandler = Handler::class; + } elseif (method_exists(ErrorHandler::class, '__invoke')) { + $eh = self::$errorHandler = ErrorHandler::class; + } else { + return self::$errorHandler = 'PHPUnit\Util\ErrorHandler::handleError'; + } } - if (!self::$isAtLeastPhpUnit83) { - return 'PHPUnit\Util\ErrorHandler::handleError'; + + if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) { + return $eh; } foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) { if (isset($frame['object']) && $frame['object'] instanceof TestResult) { - return new ErrorHandler( + return new $eh( $frame['object']->getConvertDeprecationsToExceptions(), $frame['object']->getConvertErrorsToExceptions(), $frame['object']->getConvertNoticesToExceptions(), diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index fdc898a9316f5..254b84f729927 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; +use PHPUnit\Metadata\Api\Groups; +use PHPUnit\Util\Error\Handler; use PHPUnit\Util\Test; use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor; use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader; @@ -192,12 +194,13 @@ public function isLegacy() } $method = $this->originatingMethod(); + $groups = class_exists(Groups::class) ? [new Groups(), 'groups'] : [Test::class, 'getGroups']; return 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($this->originClass, '\Legacy') - || \in_array('legacy', Test::getGroups($this->originClass, $method), true); + || \in_array('legacy', $groups($this->originClass, $method), true); } /** From 936e399ff9c30e621c8dcaa9b1bd54d4897e4a0c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 1 Jul 2021 23:28:50 +0200 Subject: [PATCH 008/100] [DependencyInjection] Turn $defaultDeprecationTemplate into a constant Signed-off-by: Alexander M. Turek --- src/Symfony/Component/DependencyInjection/Alias.php | 6 +++--- src/Symfony/Component/DependencyInjection/Definition.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Alias.php b/src/Symfony/Component/DependencyInjection/Alias.php index 3e74fd92c8308..ca8a45a69cb9c 100644 --- a/src/Symfony/Component/DependencyInjection/Alias.php +++ b/src/Symfony/Component/DependencyInjection/Alias.php @@ -15,14 +15,14 @@ class Alias { + private const DEFAULT_DEPRECATION_TEMPLATE = 'The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.'; + private $id; private $public; private $private; private $deprecated; private $deprecationTemplate; - private static $defaultDeprecationTemplate = 'The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.'; - public function __construct(string $id, bool $public = true) { $this->id = $id; @@ -122,7 +122,7 @@ public function isDeprecated(): bool public function getDeprecationMessage(string $id): string { - return str_replace('%alias_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate); + return str_replace('%alias_id%', $id, $this->deprecationTemplate ?: self::DEFAULT_DEPRECATION_TEMPLATE); } /** diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 9ce01cea473fe..4b3cf31938654 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -22,6 +22,8 @@ */ class Definition { + private const DEFAULT_DEPRECATION_TEMPLATE = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'; + private $class; private $file; private $factory; @@ -47,8 +49,6 @@ class Definition protected $arguments = []; - private static $defaultDeprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'; - /** * @internal * @@ -799,7 +799,7 @@ public function isDeprecated() */ public function getDeprecationMessage($id) { - return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate); + return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::DEFAULT_DEPRECATION_TEMPLATE); } /** From 950b2e780c4b448046b89027462929ec1589b95c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 1 Jul 2021 23:39:28 +0200 Subject: [PATCH 009/100] [DependencyInjection] Fix doc blocks Signed-off-by: Alexander M. Turek --- .../Exception/ParameterNotFoundException.php | 12 ++++++------ .../Component/DependencyInjection/TypedReference.php | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php b/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php index 7c0c5e3087a13..8af993b8a4898 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php @@ -27,12 +27,12 @@ class ParameterNotFoundException extends InvalidArgumentException implements Not private $nonNestedAlternative; /** - * @param string $key The requested parameter key - * @param string $sourceId The service id that references the non-existent parameter - * @param string $sourceKey The parameter key that references the non-existent parameter - * @param \Throwable $previous The previous exception - * @param string[] $alternatives Some parameter name alternatives - * @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters + * @param string $key The requested parameter key + * @param string|null $sourceId The service id that references the non-existent parameter + * @param string|null $sourceKey The parameter key that references the non-existent parameter + * @param \Throwable|null $previous The previous exception + * @param string[] $alternatives Some parameter name alternatives + * @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters */ public function __construct(string $key, string $sourceId = null, string $sourceKey = null, \Throwable $previous = null, array $alternatives = [], string $nonNestedAlternative = null) { diff --git a/src/Symfony/Component/DependencyInjection/TypedReference.php b/src/Symfony/Component/DependencyInjection/TypedReference.php index 3d98d8c2270f8..3ec4035b9f226 100644 --- a/src/Symfony/Component/DependencyInjection/TypedReference.php +++ b/src/Symfony/Component/DependencyInjection/TypedReference.php @@ -23,10 +23,10 @@ class TypedReference extends Reference private $requiringClass; /** - * @param string $id The service identifier - * @param string $type The PHP type of the identified service - * @param int $invalidBehavior The behavior when the service does not exist - * @param string $name The name of the argument targeting the service + * @param string $id The service identifier + * @param string $type The PHP type of the identified service + * @param int $invalidBehavior The behavior when the service does not exist + * @param string|null $name The name of the argument targeting the service */ public function __construct(string $id, string $type, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name = null) { From d73cd5071e89402c8b4829872d52287c3af29757 Mon Sep 17 00:00:00 2001 From: shakhobiddin Date: Fri, 2 Jul 2021 12:15:12 +0500 Subject: [PATCH 010/100] uzb translation --- .../Validator/Resources/translations/validators.uz.xlf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.uz.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.uz.xlf index 31e5d5444d0c9..04860def8a949 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.uz.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.uz.xlf @@ -386,6 +386,10 @@ This value is not a valid International Securities Identification Number (ISIN). Qiymat Qimmatli qog'ozlarning xalqaro identifikatsiya raqami (ISIN) ga mos emas. + + This value should be a valid expression. + Ushbu qiymat to'g'ri ifoda bo'lishi kerak. + From e1afcb6de1444a320f0190a4b1184ea8bb729f29 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 2 Jul 2021 16:28:33 +0200 Subject: [PATCH 011/100] Backport type fixes --- .../Controller/ControllerResolver.php | 5 +- .../DataCollector/RouterDataCollector.php | 2 - .../AnnotatedRouteControllerLoader.php | 2 +- .../Translation/Translator.php | 2 - .../Resource/ClassExistenceResource.php | 3 - .../Config/Resource/ComposerResource.php | 3 - .../Config/Resource/DirectoryResource.php | 3 - .../Config/Resource/FileExistenceResource.php | 3 - .../Config/Resource/FileResource.php | 3 - .../Config/Resource/GlobResource.php | 3 - .../Config/Resource/ResourceInterface.php | 2 - .../Definition/Builder/ExprBuilderTest.php | 4 +- .../Component/Console/Command/Command.php | 18 +++--- .../Component/Console/Helper/Table.php | 8 +-- .../Component/Console/Input/InputArgument.php | 12 ++-- .../Console/Input/InputInterface.php | 12 ++-- .../Component/Console/Input/InputOption.php | 14 ++--- .../Component/Console/Output/Output.php | 2 +- .../CssSelector/Node/AttributeNode.php | 3 - .../Component/CssSelector/Node/ClassNode.php | 3 - .../CssSelector/Node/CombinedSelectorNode.php | 3 - .../CssSelector/Node/ElementNode.php | 3 - .../CssSelector/Node/FunctionNode.php | 3 - .../Component/CssSelector/Node/HashNode.php | 3 - .../CssSelector/Node/NegationNode.php | 3 - .../Component/CssSelector/Node/PseudoNode.php | 3 - .../CssSelector/Node/SelectorNode.php | 3 - .../Compiler/AutowirePass.php | 2 +- .../Config/ContainerParametersResource.php | 3 - .../DependencyInjection/Container.php | 2 +- .../DependencyInjection/ContainerBuilder.php | 2 - .../ContainerInterface.php | 4 +- .../DependencyInjection/Definition.php | 2 +- .../Configurator/ServiceConfigurator.php | 2 +- .../Loader/YamlFileLoader.php | 6 -- .../ParameterBag/ContainerBag.php | 4 ++ .../ParameterBag/ParameterBag.php | 18 ++---- .../ParameterBag/ParameterBagInterface.php | 2 - .../ResolveChildDefinitionsPassTest.php | 6 +- .../Component/ErrorHandler/ErrorHandler.php | 2 +- .../Exception/FlattenException.php | 6 ++ .../Tests/EventDispatcherTest.php | 4 ++ .../Component/Filesystem/Filesystem.php | 2 +- .../Tests/Fixtures/MockStream/MockStream.php | 2 +- .../Finder/Iterator/SortableIterator.php | 3 +- .../Tests/Iterator/SortableIteratorTest.php | 2 +- .../HttpClient/Response/CurlResponse.php | 2 +- .../HttpFoundation/File/UploadedFile.php | 2 +- .../Component/HttpFoundation/FileBag.php | 28 +++++----- .../Component/HttpFoundation/HeaderBag.php | 14 ++--- .../HttpFoundation/Tests/JsonResponseTest.php | 2 +- .../AbstractRedisSessionHandlerTestCase.php | 2 +- .../ArgumentMetadataFactoryInterface.php | 2 +- .../DataCollector/LoggerDataCollector.php | 2 - .../DataCollector/RequestDataCollector.php | 2 +- .../HttpKernel/Debug/FileLinkFormatter.php | 2 +- .../Component/Intl/Resources/bin/common.php | 14 ++--- .../Transport/Serialization/PhpSerializer.php | 2 +- src/Symfony/Component/Mime/Header/Headers.php | 4 +- .../Mime/MimeTypeGuesserInterface.php | 2 - src/Symfony/Component/Mime/Part/DataPart.php | 6 +- .../OptionsResolver/OptionsResolver.php | 13 +---- .../Component/Process/Pipes/AbstractPipes.php | 2 +- .../Routing/Loader/AnnotationFileLoader.php | 3 - .../Routing/Loader/ContainerLoader.php | 2 +- .../Matcher/Dumper/StaticPrefixCollection.php | 2 +- src/Symfony/Component/Routing/Route.php | 56 ------------------- .../Constraints/UserPasswordValidator.php | 4 ++ .../Http/Firewall/ContextListener.php | 2 +- .../Serializer/Annotation/Groups.php | 4 +- .../ConstraintViolationListNormalizer.php | 2 +- .../Extractor/ExtractorInterface.php | 2 +- .../Translation/MessageCatalogue.php | 3 +- .../Component/Translation/Translator.php | 2 - .../Validator/Constraints/RangeValidator.php | 2 +- .../Test/ConstraintValidatorTestCase.php | 2 - .../Component/VarDumper/Caster/LinkStub.php | 2 +- .../VarDumper/Caster/ResourceCaster.php | 2 +- .../Component/VarDumper/Caster/SplCaster.php | 2 +- .../Component/VarDumper/Dumper/HtmlDumper.php | 2 +- .../Component/VarDumper/Server/Connection.php | 2 +- 81 files changed, 127 insertions(+), 272 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php index 5cb655d942bdb..3c746b996ee9f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php @@ -67,11 +67,8 @@ protected function createController($controller) */ protected function instantiateController($class) { - return $this->configureController(parent::instantiateController($class), $class); - } + $controller = parent::instantiateController($class); - private function configureController($controller, string $class) - { if ($controller instanceof ContainerAwareInterface) { $controller->setContainer($this->container); } diff --git a/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php b/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php index 58fcc68e8e84c..60681f7291f55 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php +++ b/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php @@ -16,8 +16,6 @@ use Symfony\Component\HttpKernel\DataCollector\RouterDataCollector as BaseRouterDataCollector; /** - * RouterDataCollector. - * * @author Fabien Potencier * * @final since Symfony 4.4 diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php index 51419c8914988..6e5a71b8fadfd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php @@ -25,7 +25,7 @@ class AnnotatedRouteControllerLoader extends AnnotationClassLoader /** * Configures the _controller default parameter of a given Route instance. * - * @param mixed $annot The annotation class instance + * @param object $annot The annotation class instance */ protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index e11e515aba1d6..cd5444034ba7c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -20,8 +20,6 @@ use Symfony\Component\Translation\Translator as BaseTranslator; /** - * Translator. - * * @author Fabien Potencier */ class Translator extends BaseTranslator implements WarmableInterface diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index c77e343b5c306..8179ce7fb4f1e 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -42,9 +42,6 @@ public function __construct(string $resource, bool $exists = null) } } - /** - * {@inheritdoc} - */ public function __toString() { return $this->resource; diff --git a/src/Symfony/Component/Config/Resource/ComposerResource.php b/src/Symfony/Component/Config/Resource/ComposerResource.php index 822766b75b1cb..eefce22a3f4fd 100644 --- a/src/Symfony/Component/Config/Resource/ComposerResource.php +++ b/src/Symfony/Component/Config/Resource/ComposerResource.php @@ -35,9 +35,6 @@ public function getVendors() return array_keys($this->vendors); } - /** - * {@inheritdoc} - */ public function __toString() { return __CLASS__; diff --git a/src/Symfony/Component/Config/Resource/DirectoryResource.php b/src/Symfony/Component/Config/Resource/DirectoryResource.php index 3d703db7f6ebe..e6b0d318bd462 100644 --- a/src/Symfony/Component/Config/Resource/DirectoryResource.php +++ b/src/Symfony/Component/Config/Resource/DirectoryResource.php @@ -39,9 +39,6 @@ public function __construct(string $resource, string $pattern = null) } } - /** - * {@inheritdoc} - */ public function __toString() { return md5(serialize([$this->resource, $this->pattern])); diff --git a/src/Symfony/Component/Config/Resource/FileExistenceResource.php b/src/Symfony/Component/Config/Resource/FileExistenceResource.php index 57234161588c7..760c061bf49da 100644 --- a/src/Symfony/Component/Config/Resource/FileExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/FileExistenceResource.php @@ -36,9 +36,6 @@ public function __construct(string $resource) $this->exists = file_exists($resource); } - /** - * {@inheritdoc} - */ public function __toString() { return $this->resource; diff --git a/src/Symfony/Component/Config/Resource/FileResource.php b/src/Symfony/Component/Config/Resource/FileResource.php index 95fe8a0bf802c..96d7d97317eb9 100644 --- a/src/Symfony/Component/Config/Resource/FileResource.php +++ b/src/Symfony/Component/Config/Resource/FileResource.php @@ -41,9 +41,6 @@ public function __construct(string $resource) } } - /** - * {@inheritdoc} - */ public function __toString() { return $this->resource; diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index f825a92911558..f65a019befd2c 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -60,9 +60,6 @@ public function getPrefix() return $this->prefix; } - /** - * {@inheritdoc} - */ public function __toString() { return 'glob.'.$this->prefix.(int) $this->recursive.$this->pattern.(int) $this->forExclusion.implode("\0", $this->excludedPrefixes); diff --git a/src/Symfony/Component/Config/Resource/ResourceInterface.php b/src/Symfony/Component/Config/Resource/ResourceInterface.php index d98fd427a25eb..9a0cd9a47fe72 100644 --- a/src/Symfony/Component/Config/Resource/ResourceInterface.php +++ b/src/Symfony/Component/Config/Resource/ResourceInterface.php @@ -26,8 +26,6 @@ interface ResourceInterface * to be identical for different ResourceInterface instances referring to the same * resource; and it should be unlikely to collide with that of other, unrelated * resource instances. - * - * @return string A string representation unique to the underlying Resource */ public function __toString(); } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index bec4275404c75..e96c57c409f8f 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -222,8 +222,6 @@ protected function getTestBuilder(): ExprBuilder * * @param array|null $config The config you want to use for the finalization, if nothing provided * a simple ['key'=>'value'] will be used - * - * @return array The finalized config values */ protected function finalizeTestBuilder(NodeDefinition $nodeDefinition, array $config = null): array { @@ -254,7 +252,7 @@ protected function returnClosure($val): \Closure * @param mixed $value The value to test * @param mixed $config The config values that new to be finalized */ - protected function assertFinalizedValueIs($value, NodeDefinition $nodeDefinition, $config = null) + protected function assertFinalizedValueIs($value, NodeDefinition $nodeDefinition, $config = null): void { $this->assertEquals(['key' => $value], $this->finalizeTestBuilder($nodeDefinition, $config)); } diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index d4ab2eb8df3da..722e9428d9f0a 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -375,10 +375,10 @@ public function getNativeDefinition() /** * Adds an argument. * - * @param string $name The argument name - * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL - * @param string $description A description text - * @param string|string[]|null $default The default value (for InputArgument::OPTIONAL mode only) + * @param string $name The argument name + * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL + * @param string $description A description text + * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) * * @throws InvalidArgumentException When argument mode is not valid * @@ -394,11 +394,11 @@ public function addArgument($name, $mode = null, $description = '', $default = n /** * Adds an option. * - * @param string $name The option name - * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int|null $mode The option mode: One of the InputOption::VALUE_* constants - * @param string $description A description text - * @param string|string[]|bool|null $default The default value (must be null for InputOption::VALUE_NONE) + * @param string $name The option name + * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param int|null $mode The option mode: One of the InputOption::VALUE_* constants + * @param string $description A description text + * @param mixed $default The default value (must be null for InputOption::VALUE_NONE) * * @throws InvalidArgumentException If option mode is invalid or incompatible * diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index d51aee98908b3..8f9e972408540 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -585,11 +585,11 @@ private function buildTableRows(array $rows): TableRows return new TableRows(function () use ($rows, $unmergedRows): \Traversable { foreach ($rows as $rowKey => $row) { - yield $this->fillCells($row); + yield $row instanceof TableSeparator ? $row : $this->fillCells($row); if (isset($unmergedRows[$rowKey])) { - foreach ($unmergedRows[$rowKey] as $unmergedRow) { - yield $this->fillCells($unmergedRow); + foreach ($unmergedRows[$rowKey] as $row) { + yield $row instanceof TableSeparator ? $row : $this->fillCells($row); } } } @@ -670,7 +670,7 @@ private function fillNextRows(array $rows, int $line): array /** * fill cells for a row that contains colspan > 1. */ - private function fillCells($row) + private function fillCells(iterable $row) { $newRow = []; diff --git a/src/Symfony/Component/Console/Input/InputArgument.php b/src/Symfony/Component/Console/Input/InputArgument.php index 140c86d0e6cb2..11de14fe68922 100644 --- a/src/Symfony/Component/Console/Input/InputArgument.php +++ b/src/Symfony/Component/Console/Input/InputArgument.php @@ -31,10 +31,10 @@ class InputArgument private $description; /** - * @param string $name The argument name - * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL - * @param string $description A description text - * @param string|string[]|null $default The default value (for self::OPTIONAL mode only) + * @param string $name The argument name + * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL + * @param string $description A description text + * @param mixed $default The default value (for self::OPTIONAL mode only) * * @throws InvalidArgumentException When argument mode is not valid */ @@ -86,7 +86,7 @@ public function isArray() /** * Sets the default value. * - * @param string|string[]|null $default The default value + * @param mixed $default The default value * * @throws LogicException When incorrect default value is given */ @@ -110,7 +110,7 @@ public function setDefault($default = null) /** * Returns the default value. * - * @return string|string[]|null The default value + * @return mixed */ public function getDefault() { diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index b9bcf3bbcd96d..4ecab0f4fb10e 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -85,7 +85,7 @@ public function getArguments(); * * @param string $name The argument name * - * @return string|string[]|null The argument value + * @return mixed * * @throws InvalidArgumentException When argument given doesn't exist */ @@ -94,8 +94,8 @@ public function getArgument($name); /** * Sets an argument value by name. * - * @param string $name The argument name - * @param string|string[]|null $value The argument value + * @param string $name The argument name + * @param mixed $value The argument value * * @throws InvalidArgumentException When argument given doesn't exist */ @@ -122,7 +122,7 @@ public function getOptions(); * * @param string $name The option name * - * @return string|string[]|bool|null The option value + * @return mixed * * @throws InvalidArgumentException When option given doesn't exist */ @@ -131,8 +131,8 @@ public function getOption($name); /** * Sets an option value by name. * - * @param string $name The option name - * @param string|string[]|bool|null $value The option value + * @param string $name The option name + * @param mixed $value The option value * * @throws InvalidArgumentException When option given doesn't exist */ diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 5e48f88b81cb6..2bb86cd2b0701 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -48,11 +48,11 @@ class InputOption private $description; /** - * @param string $name The option name - * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int|null $mode The option mode: One of the VALUE_* constants - * @param string $description A description text - * @param string|string[]|bool|null $default The default value (must be null for self::VALUE_NONE) + * @param string $name The option name + * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param int|null $mode The option mode: One of the VALUE_* constants + * @param string $description A description text + * @param mixed $default The default value (must be null for self::VALUE_NONE) * * @throws InvalidArgumentException If option mode is invalid or incompatible */ @@ -164,7 +164,7 @@ public function isArray() /** * Sets the default value. * - * @param string|string[]|bool|null $default The default value + * @param mixed $default The default value * * @throws LogicException When incorrect default value is given */ @@ -188,7 +188,7 @@ public function setDefault($default = null) /** * Returns the default value. * - * @return string|string[]|bool|null The default value + * @return mixed */ public function getDefault() { diff --git a/src/Symfony/Component/Console/Output/Output.php b/src/Symfony/Component/Console/Output/Output.php index 8572481330025..fb838f053224a 100644 --- a/src/Symfony/Component/Console/Output/Output.php +++ b/src/Symfony/Component/Console/Output/Output.php @@ -163,7 +163,7 @@ public function write($messages, $newline = false, $options = self::OUTPUT_NORMA break; } - $this->doWrite($message, $newline); + $this->doWrite($message ?? '', $newline); } } diff --git a/src/Symfony/Component/CssSelector/Node/AttributeNode.php b/src/Symfony/Component/CssSelector/Node/AttributeNode.php index bf702d9ce44e4..0b6e0ee0a1b84 100644 --- a/src/Symfony/Component/CssSelector/Node/AttributeNode.php +++ b/src/Symfony/Component/CssSelector/Node/AttributeNode.php @@ -71,9 +71,6 @@ public function getSpecificity(): Specificity return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; diff --git a/src/Symfony/Component/CssSelector/Node/ClassNode.php b/src/Symfony/Component/CssSelector/Node/ClassNode.php index 1998b4bd5b0ec..1efca808dc452 100644 --- a/src/Symfony/Component/CssSelector/Node/ClassNode.php +++ b/src/Symfony/Component/CssSelector/Node/ClassNode.php @@ -50,9 +50,6 @@ public function getSpecificity(): Specificity return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); diff --git a/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php b/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php index f97fd21aebba7..a217a45edd60c 100644 --- a/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php +++ b/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php @@ -57,9 +57,6 @@ public function getSpecificity(): Specificity return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); } - /** - * {@inheritdoc} - */ public function __toString(): string { $combinator = ' ' === $this->combinator ? '' : $this->combinator; diff --git a/src/Symfony/Component/CssSelector/Node/ElementNode.php b/src/Symfony/Component/CssSelector/Node/ElementNode.php index 7949ed9198368..fbf8ea0f99096 100644 --- a/src/Symfony/Component/CssSelector/Node/ElementNode.php +++ b/src/Symfony/Component/CssSelector/Node/ElementNode.php @@ -50,9 +50,6 @@ public function getSpecificity(): Specificity return new Specificity(0, 0, $this->element ? 1 : 0); } - /** - * {@inheritdoc} - */ public function __toString(): string { $element = $this->element ?: '*'; diff --git a/src/Symfony/Component/CssSelector/Node/FunctionNode.php b/src/Symfony/Component/CssSelector/Node/FunctionNode.php index d3e9b4fc7cbb0..c464cf7c056b6 100644 --- a/src/Symfony/Component/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Component/CssSelector/Node/FunctionNode.php @@ -65,9 +65,6 @@ public function getSpecificity(): Specificity return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { $arguments = implode(', ', array_map(function (Token $token) { diff --git a/src/Symfony/Component/CssSelector/Node/HashNode.php b/src/Symfony/Component/CssSelector/Node/HashNode.php index f73fa2e7402bd..94114c095e13f 100644 --- a/src/Symfony/Component/CssSelector/Node/HashNode.php +++ b/src/Symfony/Component/CssSelector/Node/HashNode.php @@ -50,9 +50,6 @@ public function getSpecificity(): Specificity return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id); diff --git a/src/Symfony/Component/CssSelector/Node/NegationNode.php b/src/Symfony/Component/CssSelector/Node/NegationNode.php index afa47cf878c6b..f00522fb96a85 100644 --- a/src/Symfony/Component/CssSelector/Node/NegationNode.php +++ b/src/Symfony/Component/CssSelector/Node/NegationNode.php @@ -50,9 +50,6 @@ public function getSpecificity(): Specificity return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector); diff --git a/src/Symfony/Component/CssSelector/Node/PseudoNode.php b/src/Symfony/Component/CssSelector/Node/PseudoNode.php index 7d4a011e1faf3..12b7bd26662af 100644 --- a/src/Symfony/Component/CssSelector/Node/PseudoNode.php +++ b/src/Symfony/Component/CssSelector/Node/PseudoNode.php @@ -50,9 +50,6 @@ public function getSpecificity(): Specificity return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier); diff --git a/src/Symfony/Component/CssSelector/Node/SelectorNode.php b/src/Symfony/Component/CssSelector/Node/SelectorNode.php index a76aa5bb5f48a..6e52b2fa720cf 100644 --- a/src/Symfony/Component/CssSelector/Node/SelectorNode.php +++ b/src/Symfony/Component/CssSelector/Node/SelectorNode.php @@ -50,9 +50,6 @@ public function getSpecificity(): Specificity return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : ''); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 0fbcbbf0d0df0..b222d5787e4a0 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -374,7 +374,7 @@ private function set(string $type, string $id) $this->ambiguousServiceTypes[$type][] = $id; } - private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): callable + private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): \Closure { if (null === $this->typesClone->container) { $this->typesClone->container = new ContainerBuilder($this->container->getParameterBag()); diff --git a/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php b/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php index e9a4fffe2ad1c..d2a74eb50f701 100644 --- a/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php +++ b/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php @@ -32,9 +32,6 @@ public function __construct(array $parameters) $this->parameters = $parameters; } - /** - * {@inheritdoc} - */ public function __toString() { return 'container_parameters_'.md5(serialize($this->parameters)); diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 55183cb5e1fd7..e17c1caa956c2 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -109,7 +109,7 @@ public function getParameterBag() * * @param string $name The parameter name * - * @return array|bool|float|int|string|null The parameter value + * @return mixed * * @throws InvalidArgumentException if the parameter is not defined */ diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 3cfe4e4cfe49c..ef3af7165dec2 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -883,8 +883,6 @@ public function hasAlias($id) } /** - * Gets all defined aliases. - * * @return Alias[] An array of aliases */ public function getAliases() diff --git a/src/Symfony/Component/DependencyInjection/ContainerInterface.php b/src/Symfony/Component/DependencyInjection/ContainerInterface.php index 92eeb1f13f849..3123e2d13b45c 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerInterface.php @@ -54,8 +54,6 @@ public function set($id, $service); public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE); /** - * Returns true if the given service is defined. - * * @param string $id The service identifier * * @return bool true if the service is defined, false otherwise @@ -76,7 +74,7 @@ public function initialized($id); * * @param string $name The parameter name * - * @return array|bool|float|int|string|null The parameter value + * @return mixed The parameter value * * @throws InvalidArgumentException if the parameter is not defined */ diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 4b3cf31938654..727594dcb4090 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -805,7 +805,7 @@ public function getDeprecationMessage($id) /** * Sets a configurator to call after the service is fully initialized. * - * @param string|array|Reference $configurator A PHP function, reference or an array containing a class/Reference and a method to call + * @param string|array|Reference|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call * * @return $this */ diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php index 71fa30c4e04c1..1dbc0a9a2441f 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php @@ -47,7 +47,7 @@ class ServiceConfigurator extends AbstractServiceConfigurator private $allowParent; private $path; - public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, $id, array $defaultTags, string $path = null) + public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, ?string $id, array $defaultTags, string $path = null) { $this->container = $container; $this->instanceof = $instanceof; diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 310aa351f2550..20780ad6facad 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -850,9 +850,6 @@ private function resolveServices($value, string $file, bool $isParameter = false return $value; } - /** - * Loads from Extensions. - */ private function loadFromExtensions(array $content) { foreach ($content as $namespace => $values) { @@ -868,9 +865,6 @@ private function loadFromExtensions(array $content) } } - /** - * Checks the keywords used to define a service. - */ private function checkDefinition(string $id, array $definition, string $file) { if ($this->isLoadingInstanceof) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php index 7671dfc6cabd9..42855d237603c 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php @@ -35,6 +35,8 @@ public function all() /** * {@inheritdoc} + * + * @return mixed */ public function get($name) { @@ -43,6 +45,8 @@ public function get($name) /** * {@inheritdoc} + * + * @return bool */ public function has($name) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index ae63e67ad9231..a2de1a4f542fe 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -25,16 +25,13 @@ class ParameterBag implements ParameterBagInterface protected $parameters = []; protected $resolved = false; - /** - * @param array $parameters An array of parameters - */ public function __construct(array $parameters = []) { $this->add($parameters); } /** - * Clears all parameters. + * {@inheritdoc} */ public function clear() { @@ -42,9 +39,7 @@ public function clear() } /** - * Adds parameters to the service container parameters. - * - * @param array $parameters An array of parameters + * {@inheritdoc} */ public function add(array $parameters) { @@ -104,10 +99,7 @@ public function get($name) } /** - * Sets a service container parameter. - * - * @param string $name The parameter name - * @param mixed $value The parameter value + * {@inheritdoc} */ public function set($name, $value) { @@ -123,9 +115,7 @@ public function has($name) } /** - * Removes a parameter. - * - * @param string $name The parameter name + * {@inheritdoc} */ public function remove($name) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php index 6a4e0fa4acc0a..75a7020660580 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php @@ -31,8 +31,6 @@ public function clear(); /** * Adds parameters to the service container parameters. * - * @param array $parameters An array of parameters - * * @throws LogicException if the parameter can not be added */ public function add(array $parameters); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php index 7dea34d75c8bf..f14cbb01968b9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php @@ -250,7 +250,7 @@ public function testDeepDefinitionsResolving() $container->register('parent', 'parentClass'); $container->register('sibling', 'siblingClass') - ->setConfigurator(new ChildDefinition('parent'), 'foo') + ->setConfigurator([new ChildDefinition('parent'), 'foo']) ->setFactory([new ChildDefinition('parent'), 'foo']) ->addArgument(new ChildDefinition('parent')) ->setProperty('prop', new ChildDefinition('parent')) @@ -260,8 +260,8 @@ public function testDeepDefinitionsResolving() $this->process($container); $configurator = $container->getDefinition('sibling')->getConfigurator(); - $this->assertSame('Symfony\Component\DependencyInjection\Definition', \get_class($configurator)); - $this->assertSame('parentClass', $configurator->getClass()); + $this->assertSame('Symfony\Component\DependencyInjection\Definition', \get_class($configurator[0])); + $this->assertSame('parentClass', $configurator[0]->getClass()); $factory = $container->getDefinition('sibling')->getFactory(); $this->assertSame('Symfony\Component\DependencyInjection\Definition', \get_class($factory[0])); diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index d357658ac1eb9..e6e21d601700e 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -196,7 +196,7 @@ public function __construct(BufferingLogger $bootstrappingLogger = null, bool $d * Sets a logger to non assigned errors levels. * * @param LoggerInterface $logger A PSR-3 logger to put as default for the given levels - * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants + * @param array|int|null $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 diff --git a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php index 18e9b5ac1b7f4..330b5cc3f4bd0 100644 --- a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php +++ b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php @@ -62,11 +62,17 @@ class FlattenException extends LegacyFlattenException /** @var string|null */ private $asString; + /** + * @return static + */ public static function create(\Exception $exception, $statusCode = null, array $headers = []): self { return static::createFromThrowable($exception, $statusCode, $headers); } + /** + * @return static + */ public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): self { $e = new static(); diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index 32f242e6f100b..62097774cd38e 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -476,6 +476,10 @@ public function postFoo($e) $e->stopPropagation(); } } + + public function __invoke() + { + } } class TestWithDispatcher diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index da43d2fbd48df..e80b895649a36 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -761,7 +761,7 @@ private static function box(callable $func, ...$args) /** * @internal */ - public static function handleError($type, $msg) + public static function handleError(int $type, string $msg) { self::$lastError = $msg; } diff --git a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php index a1d410b1987be..3c66d8b9ac452 100644 --- a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php +++ b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php @@ -33,7 +33,7 @@ public function stream_open($path, $mode, $options, &$opened_path): bool /** * @param string $path The file path or URL to stat - * @param array $flags Holds additional flags set by the streams API + * @param int $flags Holds additional flags set by the streams API * * @return array File stats */ diff --git a/src/Symfony/Component/Finder/Iterator/SortableIterator.php b/src/Symfony/Component/Finder/Iterator/SortableIterator.php index dd9ae4ae41830..8559ba51cd794 100644 --- a/src/Symfony/Component/Finder/Iterator/SortableIterator.php +++ b/src/Symfony/Component/Finder/Iterator/SortableIterator.php @@ -30,8 +30,7 @@ class SortableIterator implements \IteratorAggregate private $sort; /** - * @param \Traversable $iterator The Iterator to filter - * @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback) + * @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback) * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php index 12eacb8661d18..098cd75674f3f 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php @@ -18,7 +18,7 @@ class SortableIteratorTest extends RealIteratorTestCase public function testConstructor() { try { - new SortableIterator(new Iterator([]), 'foobar'); + new SortableIterator(new Iterator([]), -255); $this->fail('__construct() throws an \InvalidArgumentException exception if the mode is not valid'); } catch (\Exception $e) { $this->assertInstanceOf(\InvalidArgumentException::class, $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid'); diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 9709a189f5926..cc5bf4f0b25c6 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -316,7 +316,7 @@ private static function select(ClientState $multi, float $timeout): int /** * Parses header lines as curl yields them to us. */ - 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 + private static function parseHeaderLine($ch, string $data, array &$info, array &$headers, ?array $options, CurlClientState $multi, int $id, ?string &$location, ?callable $resolveRedirect, ?LoggerInterface $logger): int { $waitFor = @curl_getinfo($ch, \CURLINFO_PRIVATE) ?: '_0'; diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 575d5087dfb34..89764c3a0f7a6 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -254,7 +254,7 @@ public static function getMaxFilesize() * * @return int|float Returns float if size > PHP_INT_MAX */ - private static function parseFilesize($size) + private static function parseFilesize(string $size) { if ('' === $size) { return 0; diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php index bb187f7207ef3..3c3612ef253e3 100644 --- a/src/Symfony/Component/HttpFoundation/FileBag.php +++ b/src/Symfony/Component/HttpFoundation/FileBag.php @@ -75,22 +75,20 @@ protected function convertFileInformation($file) return $file; } - if (\is_array($file)) { - $file = $this->fixPhpFilesArray($file); - $keys = array_keys($file); - sort($keys); - - if (self::FILE_KEYS == $keys) { - if (\UPLOAD_ERR_NO_FILE == $file['error']) { - $file = null; - } else { - $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false); - } + $file = $this->fixPhpFilesArray($file); + $keys = array_keys($file); + sort($keys); + + if (self::FILE_KEYS == $keys) { + if (\UPLOAD_ERR_NO_FILE == $file['error']) { + $file = null; } else { - $file = array_map([$this, 'convertFileInformation'], $file); - if (array_keys($keys) === $keys) { - $file = array_filter($file); - } + $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false); + } + } else { + $file = array_map(function ($v) { return $v instanceof UploadedFile || \is_array($v) ? $this->convertFileInformation($v) : $v; }, $file); + if (array_keys($keys) === $keys) { + $file = array_filter($file); } } diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index cb280b98729b0..15393544fcbfe 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -133,9 +133,9 @@ public function get($key, $default = null) /** * Sets a header by name. * - * @param string $key The key - * @param string|string[] $values The value or an array of values - * @param bool $replace Whether to replace the actual value or not (true by default) + * @param string $key The key + * @param string|string[]|null $values The value or an array of values + * @param bool $replace Whether to replace the actual value or not (true by default) */ public function set($key, $values, $replace = true) { @@ -228,8 +228,8 @@ public function getDate($key, \DateTime $default = null) /** * Adds a custom Cache-Control directive. * - * @param string $key The Cache-Control directive name - * @param mixed $value The Cache-Control directive value + * @param string $key The Cache-Control directive name + * @param bool|string $value The Cache-Control directive value */ public function addCacheControlDirective($key, $value = true) { @@ -255,11 +255,11 @@ public function hasCacheControlDirective($key) * * @param string $key The directive name * - * @return mixed The directive value if defined, null otherwise + * @return bool|string|null The directive value if defined, null otherwise */ public function getCacheControlDirective($key) { - return \array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; + return $this->cacheControl[$key] ?? null; } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index 9cd63da728f84..bd26ef3413b33 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -257,7 +257,7 @@ public function testfromJsonStringConstructorWithNullAsDataThrowsAnUnexpectedVal public function testConstructorWithObjectWithToStringMethod() { $class = new class() { - public function __toString() + public function __toString(): string { return '{}'; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php index 3f3982ff4562c..de5188d42ce91 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php @@ -122,7 +122,7 @@ public function testUpdateTimestamp() $lowTtl = 10; $this->redisClient->setex(self::PREFIX.'id', $lowTtl, 'foo'); - $this->storage->updateTimestamp('id', []); + $this->storage->updateTimestamp('id', 'data'); $this->assertGreaterThan($lowTtl, $this->redisClient->ttl(self::PREFIX.'id')); } diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php index 6ea179d783ef0..a34befc22d6aa 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php @@ -19,7 +19,7 @@ interface ArgumentMetadataFactoryInterface { /** - * @param mixed $controller The controller to resolve the arguments for + * @param string|object|array $controller The controller to resolve the arguments for * * @return ArgumentMetadata[] */ diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index 2797a347c8b26..0e25f8960fe54 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -18,8 +18,6 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; /** - * LogDataCollector. - * * @author Fabien Potencier * * @final since Symfony 4.4 diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 0e3c13ba066b5..f40c2fb9f6a5b 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -388,7 +388,7 @@ public function getName() /** * Parse a controller. * - * @param mixed $controller The controller to parse + * @param string|object|array|null $controller The controller to parse * * @return array|string An array of controller data or a simple string */ diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 6d7c1e942e616..79755a8ad74bd 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -32,7 +32,7 @@ class FileLinkFormatter /** * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand */ - public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) + public function __construct(string $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) { $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if ($fileLinkFormat && !\is_array($fileLinkFormat)) { diff --git a/src/Symfony/Component/Intl/Resources/bin/common.php b/src/Symfony/Component/Intl/Resources/bin/common.php index 1ed762fee432e..cf47fa448b034 100644 --- a/src/Symfony/Component/Intl/Resources/bin/common.php +++ b/src/Symfony/Component/Intl/Resources/bin/common.php @@ -13,35 +13,35 @@ define('LINE', str_repeat('-', LINE_WIDTH)."\n"); -function bailout($message) +function bailout(string $message) { echo wordwrap($message, LINE_WIDTH)." Aborting.\n"; exit(1); } -function strip_minor_versions($version) +function strip_minor_versions(string $version) { preg_match('/^(?P[0-9]\.[0-9]|[0-9]{2,})/', $version, $matches); return $matches['version']; } -function centered($text) +function centered(string $text) { $padding = (int) ((LINE_WIDTH - strlen($text)) / 2); return str_repeat(' ', $padding).$text; } -function cd($dir) +function cd(string $dir) { if (false === chdir($dir)) { bailout("Could not switch to directory $dir."); } } -function run($command) +function run(string $command) { exec($command, $output, $status); @@ -53,7 +53,7 @@ function run($command) } } -function get_icu_version_from_genrb($genrb) +function get_icu_version_from_genrb(string $genrb) { exec($genrb.' --version - 2>&1', $output, $status); @@ -70,7 +70,7 @@ function get_icu_version_from_genrb($genrb) error_reporting(\E_ALL); -set_error_handler(function ($type, $msg, $file, $line) { +set_error_handler(function (int $type, string $msg, string $file, int $line) { throw new \ErrorException($msg, 0, $type, $file, $line); }); diff --git a/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php b/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php index 42e00560229ab..7fde86aa2b7fe 100644 --- a/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php +++ b/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php @@ -81,7 +81,7 @@ private function safelyUnserialize(string $contents) /** * @internal */ - public static function handleUnserializeCallback($class) + public static function handleUnserializeCallback(string $class) { throw new MessageDecodingFailedException(sprintf('Message class "%s" not found during decoding.', $class)); } diff --git a/src/Symfony/Component/Mime/Header/Headers.php b/src/Symfony/Component/Mime/Header/Headers.php index 53ce8f94ae538..1a7b4b276eee2 100644 --- a/src/Symfony/Component/Mime/Header/Headers.php +++ b/src/Symfony/Component/Mime/Header/Headers.php @@ -229,7 +229,7 @@ public function toArray(): array /** * @internal */ - public function getHeaderBody($name) + public function getHeaderBody(string $name) { return $this->has($name) ? $this->get($name)->getBody() : null; } @@ -266,7 +266,7 @@ public function getHeaderParameter(string $name, string $parameter): ?string /** * @internal */ - public function setHeaderParameter(string $name, string $parameter, $value): void + public function setHeaderParameter(string $name, string $parameter, ?string $value): void { if (!$this->has($name)) { throw new LogicException(sprintf('Unable to set parameter "%s" on header "%s" as the header is not defined.', $parameter, $name)); diff --git a/src/Symfony/Component/Mime/MimeTypeGuesserInterface.php b/src/Symfony/Component/Mime/MimeTypeGuesserInterface.php index 68b05055e6fbf..6eded54c63df3 100644 --- a/src/Symfony/Component/Mime/MimeTypeGuesserInterface.php +++ b/src/Symfony/Component/Mime/MimeTypeGuesserInterface.php @@ -26,8 +26,6 @@ public function isGuesserSupported(): bool; /** * Guesses the MIME type of the file with the given path. * - * @param string $path The path to the file - * * @return string|null The MIME type or null, if none could be guessed * * @throws \LogicException If the guesser is not supported diff --git a/src/Symfony/Component/Mime/Part/DataPart.php b/src/Symfony/Component/Mime/Part/DataPart.php index bbe8eca10b321..18e474df65bcb 100644 --- a/src/Symfony/Component/Mime/Part/DataPart.php +++ b/src/Symfony/Component/Mime/Part/DataPart.php @@ -39,8 +39,10 @@ public function __construct($body, string $filename = null, string $contentType parent::__construct($body, null, $subtype, $encoding); - $this->filename = $filename; - $this->setName($filename); + if (null !== $filename) { + $this->filename = $filename; + $this->setName($filename); + } $this->setDisposition('attachment'); } diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index f63efbddf4e79..759883d418a78 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -232,10 +232,6 @@ public function setDefault($option, $value) } /** - * Sets a list of default values. - * - * @param array $defaults The default values to set - * * @return $this * * @throws AccessException If called from a lazy option or normalizer @@ -468,8 +464,7 @@ public function isDeprecated(string $option): bool * * The resolved option value is set to the return value of the closure. * - * @param string $option The option name - * @param \Closure $normalizer The normalizer + * @param string $option The option name * * @return $this * @@ -512,10 +507,6 @@ public function setNormalizer($option, \Closure $normalizer) * * The resolved option value is set to the return value of the closure. * - * @param string $option The option name - * @param \Closure $normalizer The normalizer - * @param bool $forcePrepend If set to true, prepend instead of appending - * * @return $this * * @throws UndefinedOptionsException If the option is undefined @@ -767,8 +758,6 @@ public function clear() * - Options have invalid types; * - Options have invalid values. * - * @param array $options A map of option names to values - * * @return array The merged and validated options * * @throws UndefinedOptionsException If an option name is undefined diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index 6b72aed7d0d34..21ab3e389c5be 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -171,7 +171,7 @@ protected function write(): ?array /** * @internal */ - public function handleError($type, $msg) + public function handleError(int $type, string $msg) { $this->lastError = $msg; } diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index cd262f1ad1ebb..6db5a22f0427f 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -26,9 +26,6 @@ class AnnotationFileLoader extends FileLoader { protected $loader; - /** - * @throws \RuntimeException - */ public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader) { if (!\function_exists('token_get_all')) { diff --git a/src/Symfony/Component/Routing/Loader/ContainerLoader.php b/src/Symfony/Component/Routing/Loader/ContainerLoader.php index 948da7b101c0a..f248011baf76f 100644 --- a/src/Symfony/Component/Routing/Loader/ContainerLoader.php +++ b/src/Symfony/Component/Routing/Loader/ContainerLoader.php @@ -32,7 +32,7 @@ public function __construct(ContainerInterface $container) */ public function supports($resource, $type = null) { - return 'service' === $type; + return 'service' === $type && \is_string($resource); } /** diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php index 1c5c5fdeb0c99..d50925c66124c 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php @@ -195,7 +195,7 @@ private function getCommonPrefix(string $prefix, string $anotherPrefix): array return [substr($prefix, 0, $i), substr($prefix, 0, $staticLength ?? $i)]; } - public static function handleError($type, $msg) + public static function handleError(int $type, string $msg) { return false !== strpos($msg, 'Compilation failed: lookbehind assertion is not fixed length'); } diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index 63d1f6fe3d3b5..473fbd4c150ab 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -116,8 +116,6 @@ public function unserialize($serialized) } /** - * Returns the pattern for the path. - * * @return string The path pattern */ public function getPath() @@ -128,8 +126,6 @@ public function getPath() /** * Sets the pattern for the path. * - * This method implements a fluent interface. - * * @param string $pattern The path pattern * * @return $this @@ -158,8 +154,6 @@ public function setPath($pattern) } /** - * Returns the pattern for the host. - * * @return string The host pattern */ public function getHost() @@ -170,8 +164,6 @@ public function getHost() /** * Sets the pattern for the host. * - * This method implements a fluent interface. - * * @param string $pattern The host pattern * * @return $this @@ -199,8 +191,6 @@ public function getSchemes() * Sets the schemes (e.g. 'https') this route is restricted to. * So an empty array means that any scheme is allowed. * - * This method implements a fluent interface. - * * @param string|string[] $schemes The scheme or an array of schemes * * @return $this @@ -240,8 +230,6 @@ public function getMethods() * Sets the HTTP methods (e.g. 'POST') this route is restricted to. * So an empty array means that any method is allowed. * - * This method implements a fluent interface. - * * @param string|string[] $methods The method or an array of methods * * @return $this @@ -255,8 +243,6 @@ public function setMethods($methods) } /** - * Returns the options. - * * @return array The options */ public function getOptions() @@ -265,10 +251,6 @@ public function getOptions() } /** - * Sets the options. - * - * This method implements a fluent interface. - * * @return $this */ public function setOptions(array $options) @@ -281,10 +263,6 @@ public function setOptions(array $options) } /** - * Adds options. - * - * This method implements a fluent interface. - * * @return $this */ public function addOptions(array $options) @@ -300,8 +278,6 @@ public function addOptions(array $options) /** * Sets an option value. * - * This method implements a fluent interface. - * * @param string $name An option name * @param mixed $value The option value * @@ -340,8 +316,6 @@ public function hasOption($name) } /** - * Returns the defaults. - * * @return array The defaults */ public function getDefaults() @@ -350,12 +324,6 @@ public function getDefaults() } /** - * Sets the defaults. - * - * This method implements a fluent interface. - * - * @param array $defaults The defaults - * * @return $this */ public function setDefaults(array $defaults) @@ -366,12 +334,6 @@ public function setDefaults(array $defaults) } /** - * Adds defaults. - * - * This method implements a fluent interface. - * - * @param array $defaults The defaults - * * @return $this */ public function addDefaults(array $defaults) @@ -433,8 +395,6 @@ public function setDefault($name, $default) } /** - * Returns the requirements. - * * @return array The requirements */ public function getRequirements() @@ -443,12 +403,6 @@ public function getRequirements() } /** - * Sets the requirements. - * - * This method implements a fluent interface. - * - * @param array $requirements The requirements - * * @return $this */ public function setRequirements(array $requirements) @@ -459,12 +413,6 @@ public function setRequirements(array $requirements) } /** - * Adds requirements. - * - * This method implements a fluent interface. - * - * @param array $requirements The requirements - * * @return $this */ public function addRequirements(array $requirements) @@ -526,8 +474,6 @@ public function setRequirement($key, $regex) } /** - * Returns the condition. - * * @return string The condition */ public function getCondition() @@ -538,8 +484,6 @@ public function getCondition() /** * Sets the condition. * - * This method implements a fluent interface. - * * @param string $condition The condition * * @return $this diff --git a/src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php b/src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php index 24b032484fa1a..f93aa7eb6c20c 100644 --- a/src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php +++ b/src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php @@ -45,6 +45,10 @@ public function validate($password, Constraint $constraint) return; } + if (!\is_string($password)) { + throw new UnexpectedTypeException($password, 'string'); + } + $user = $this->tokenStorage->getToken()->getUser(); if (!$user instanceof UserInterface) { diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 90d6d7eafa611..47990f811b4d6 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -328,7 +328,7 @@ private function safelyUnserialize(string $serializedToken) /** * @internal */ - public static function handleUnserializeCallback($class) + public static function handleUnserializeCallback(string $class) { throw new \ErrorException('Class not found: '.$class, 0x37313bc); } diff --git a/src/Symfony/Component/Serializer/Annotation/Groups.php b/src/Symfony/Component/Serializer/Annotation/Groups.php index 4358a3e26dcb9..29953eec0370e 100644 --- a/src/Symfony/Component/Serializer/Annotation/Groups.php +++ b/src/Symfony/Component/Serializer/Annotation/Groups.php @@ -29,7 +29,7 @@ class Groups private $groups; /** - * @throws InvalidArgumentException + * @param string[] $groups */ public function __construct(array $data) { @@ -48,8 +48,6 @@ public function __construct(array $data) } /** - * Gets groups. - * * @return string[] */ public function getGroups() diff --git a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php index 3b373c288aabe..d7fb3bc04368e 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php @@ -32,7 +32,7 @@ class ConstraintViolationListNormalizer implements NormalizerInterface, Cacheabl private $defaultContext; private $nameConverter; - public function __construct($defaultContext = [], NameConverterInterface $nameConverter = null) + public function __construct(array $defaultContext = [], NameConverterInterface $nameConverter = null) { $this->defaultContext = $defaultContext; $this->nameConverter = $nameConverter; diff --git a/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php b/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php index 91de20192eee9..1adc7570038c6 100644 --- a/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php +++ b/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php @@ -24,7 +24,7 @@ interface ExtractorInterface /** * Extracts translation messages from files, a file or a directory to the catalogue. * - * @param string|array $resource Files, a file or a directory + * @param string|iterable $resource Files, a file or a directory */ public function extract($resource, MessageCatalogue $catalogue); diff --git a/src/Symfony/Component/Translation/MessageCatalogue.php b/src/Symfony/Component/Translation/MessageCatalogue.php index cc8d3ceef366c..c146ec00742e3 100644 --- a/src/Symfony/Component/Translation/MessageCatalogue.php +++ b/src/Symfony/Component/Translation/MessageCatalogue.php @@ -27,8 +27,7 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf private $parent; /** - * @param string $locale The locale - * @param array $messages An array of messages classified by domain + * @param array $messages An array of messages classified by domain */ public function __construct(?string $locale, array $messages = []) { diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 0f03b5afc3ad1..5e5d9570ca4ca 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -177,8 +177,6 @@ public function getLocale() /** * Sets the fallback locales. * - * @param array $locales The fallback locales - * * @throws InvalidArgumentException If a locale contains invalid characters */ public function setFallbackLocales(array $locales) diff --git a/src/Symfony/Component/Validator/Constraints/RangeValidator.php b/src/Symfony/Component/Validator/Constraints/RangeValidator.php index 5f165107512fd..9f9e46e115286 100644 --- a/src/Symfony/Component/Validator/Constraints/RangeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RangeValidator.php @@ -157,7 +157,7 @@ public function validate($value, Constraint $constraint) } } - private function getLimit($propertyPath, $default, Constraint $constraint) + private function getLimit(?string $propertyPath, $default, Constraint $constraint) { if (null === $propertyPath) { return $default; diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index b5c263aca7298..7e18d71fa607d 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -233,8 +233,6 @@ protected function assertNoViolation() } /** - * @param $message - * * @return ConstraintViolationAssertion */ protected function buildViolation($message) diff --git a/src/Symfony/Component/VarDumper/Caster/LinkStub.php b/src/Symfony/Component/VarDumper/Caster/LinkStub.php index 6360716d7bc52..9b678369267e2 100644 --- a/src/Symfony/Component/VarDumper/Caster/LinkStub.php +++ b/src/Symfony/Component/VarDumper/Caster/LinkStub.php @@ -23,7 +23,7 @@ class LinkStub extends ConstStub private static $vendorRoots; private static $composerRoots; - public function __construct($label, int $line = 0, $href = null) + public function __construct(string $label, int $line = 0, string $href = null) { $this->value = $label; diff --git a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php index 5a7c4285252cb..a3278a886e0e3 100644 --- a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php @@ -48,7 +48,7 @@ public static function castProcess($process, array $a, Stub $stub, $isNested) public static function castStream($stream, array $a, Stub $stub, $isNested) { $a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested); - if (isset($a['uri'])) { + if ($a['uri'] ?? false) { $a['uri'] = new LinkStub($a['uri']); } diff --git a/src/Symfony/Component/VarDumper/Caster/SplCaster.php b/src/Symfony/Component/VarDumper/Caster/SplCaster.php index 5abc51a9f323d..be9d66bdd7a73 100644 --- a/src/Symfony/Component/VarDumper/Caster/SplCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SplCaster.php @@ -129,7 +129,7 @@ public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, $isNe } } - if (isset($a[$prefix.'realPath'])) { + if ($a[$prefix.'realPath'] ?? false) { $a[$prefix.'realPath'] = new LinkStub($a[$prefix.'realPath']); } diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 6b205a73738d2..f1dedf6ac9f23 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -998,7 +998,7 @@ private function getSourceLink(string $file, int $line) } } -function esc($str) +function esc(string $str) { return htmlspecialchars($str, \ENT_QUOTES, 'UTF-8'); } diff --git a/src/Symfony/Component/VarDumper/Server/Connection.php b/src/Symfony/Component/VarDumper/Server/Connection.php index d8be23587e764..ae4e76f7efdd3 100644 --- a/src/Symfony/Component/VarDumper/Server/Connection.php +++ b/src/Symfony/Component/VarDumper/Server/Connection.php @@ -78,7 +78,7 @@ public function write(Data $data): bool return false; } - private static function nullErrorHandler($t, $m) + private static function nullErrorHandler(int $t, string $m) { // no-op } From b95dfede5f06147dd08ed0056c5a21b9f1e16db8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 2 Jul 2021 17:57:26 +0200 Subject: [PATCH 012/100] Avoid triggering the autoloader in Deprecation::isLegacy() Signed-off-by: Alexander M. Turek --- .../Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index 254b84f729927..e41a192f51413 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -20,6 +20,8 @@ use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader; use Symfony\Component\ErrorHandler\DebugClassLoader; +class_exists(Groups::class); + /** * @internal */ @@ -194,7 +196,7 @@ public function isLegacy() } $method = $this->originatingMethod(); - $groups = class_exists(Groups::class) ? [new Groups(), 'groups'] : [Test::class, 'getGroups']; + $groups = class_exists(Groups::class, false) ? [new Groups(), 'groups'] : [Test::class, 'getGroups']; return 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') From 0e5db3dcfa588db9c726d24e32518f6b386715d9 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 2 Jul 2021 18:06:08 +0200 Subject: [PATCH 013/100] Fix CS Signed-off-by: Alexander M. Turek --- .../Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index e41a192f51413..d122de44090a8 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -14,7 +14,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; use PHPUnit\Metadata\Api\Groups; -use PHPUnit\Util\Error\Handler; use PHPUnit\Util\Test; use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor; use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader; From ab76477012309731d4de2f4a0f4cc3dfe30f6efc Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 2 Jul 2021 18:25:02 +0200 Subject: [PATCH 014/100] [Console] fix type annotations on InputInterface --- src/Symfony/Component/Console/Input/InputInterface.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index 4ecab0f4fb10e..b96a0c6278f31 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -83,7 +83,7 @@ public function getArguments(); /** * Returns the argument value for a given argument name. * - * @param string $name The argument name + * @param string|int $name The InputArgument name or position * * @return mixed * @@ -94,8 +94,8 @@ public function getArgument($name); /** * Sets an argument value by name. * - * @param string $name The argument name - * @param mixed $value The argument value + * @param string|int $name The InputArgument name or position + * @param mixed $value The argument value * * @throws InvalidArgumentException When argument given doesn't exist */ From 7e78fb1197dfc6626ff2a1490fa2865fba4ee313 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 2 Jul 2021 18:39:34 +0200 Subject: [PATCH 015/100] fix annot --- .../Component/Translation/Extractor/ExtractorInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php b/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php index 1adc7570038c6..34e6b2d6ef1a6 100644 --- a/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php +++ b/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php @@ -24,7 +24,7 @@ interface ExtractorInterface /** * Extracts translation messages from files, a file or a directory to the catalogue. * - * @param string|iterable $resource Files, a file or a directory + * @param string|iterable $resource Files, a file or a directory */ public function extract($resource, MessageCatalogue $catalogue); From a812cea58af81175071ed59ac8050f1536c992c5 Mon Sep 17 00:00:00 2001 From: Ivo Valchev Date: Fri, 2 Jul 2021 21:08:39 +0200 Subject: [PATCH 016/100] Add Bulgarian translation for the validator --- .../Validator/Resources/translations/validators.bg.xlf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf index 8a4b0d606af66..aa136b92e3f06 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf @@ -386,6 +386,10 @@ This value is not a valid International Securities Identification Number (ISIN). Стойността не е валиден Международен идентификационен номер на ценни книжа (ISIN). + + This value should be a valid expression. + Стойността трябва да бъде валиден израз. + From 4526a709693b9210b5f8a9e2959292c7d715d4f8 Mon Sep 17 00:00:00 2001 From: Adrian Nguyen Date: Sat, 3 Jul 2021 11:04:05 +0700 Subject: [PATCH 017/100] [Validator] add translation for Vietnamese --- .../Validator/Resources/translations/validators.vi.xlf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf index 952195172a6d6..09dd68036f930 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf @@ -386,6 +386,10 @@ This value is not a valid International Securities Identification Number (ISIN). Giá trị này không phải là mã số chứng khoán quốc tế (ISIN) hợp lệ. + + This value should be a valid expression. + Giá trị này phải là một biểu thức hợp lệ. + From fad17a95eab25460d5aea81a3dded01ad980ae32 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 2 Jul 2021 19:03:33 +0200 Subject: [PATCH 018/100] [Console] fix handling positional arguments --- src/Symfony/Component/Console/Input/Input.php | 4 ++++ src/Symfony/Component/Console/Tests/Input/InputTest.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/Symfony/Component/Console/Input/Input.php b/src/Symfony/Component/Console/Input/Input.php index 6e4c01e95f851..6b093e7506bf4 100644 --- a/src/Symfony/Component/Console/Input/Input.php +++ b/src/Symfony/Component/Console/Input/Input.php @@ -110,6 +110,8 @@ public function getArgument($name) throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } + $name = \is_int($name) ? key(\array_slice($this->definition->getArguments(), $name, 1, true)) : $name; + return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault(); } @@ -122,6 +124,8 @@ public function setArgument($name, $value) throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } + $name = \is_int($name) ? key(\array_slice($this->definition->getArguments(), $name, 1, true)) : $name; + $this->arguments[$name] = $value; } diff --git a/src/Symfony/Component/Console/Tests/Input/InputTest.php b/src/Symfony/Component/Console/Tests/Input/InputTest.php index 48c287cd9d3b3..3441351b4b7e5 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputTest.php @@ -75,6 +75,11 @@ public function testArguments() $input = new ArrayInput(['name' => 'foo'], new InputDefinition([new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')])); $this->assertEquals('default', $input->getArgument('bar'), '->getArgument() returns the default value for optional arguments'); $this->assertEquals(['name' => 'foo', 'bar' => 'default'], $input->getArguments(), '->getArguments() returns all argument values, even optional ones'); + + $input = new ArrayInput(['arg1' => 'foo'], new InputDefinition([new InputArgument('arg1'), new InputArgument('arg2')])); + $input->setArgument(1, 'bar'); + $this->assertEquals('bar', $input->getArgument(1)); + $this->assertEquals(['arg1' => 'foo', 'arg2' => 'bar'], $input->getArguments()); } public function testSetInvalidArgument() From 46309e581431630783d98156571dbd8de2262086 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 3 Jul 2021 21:19:39 +0200 Subject: [PATCH 019/100] [DI] CS fix --- src/Symfony/Component/DependencyInjection/Container.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index e17c1caa956c2..b731a70bc9d8a 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -404,9 +404,7 @@ protected function getEnv($name) $this->set($id, new ServiceLocator([])); } if (!$this->getEnv) { - $this->getEnv = new \ReflectionMethod($this, __FUNCTION__); - $this->getEnv->setAccessible(true); - $this->getEnv = $this->getEnv->getClosure($this); + $this->getEnv = \Closure::fromCallable([$this, 'getEnv']); } $processors = $this->get($id); From 629e6987e6b55178d1df7000bd14a6010e84a108 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sat, 3 Jul 2021 23:17:34 +0200 Subject: [PATCH 020/100] [Security] Don't skip UserPasswordValidatorTest --- .../Validator/Constraints/UserPasswordValidatorTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php index ecead3d111605..0459e821fd2aa 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Security\Core\Tests\Validator\Constraints; -use Foo\Bar\User; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; @@ -25,7 +24,7 @@ /** * @author Bernhard Schussek */ -abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase +class UserPasswordValidatorTest extends ConstraintValidatorTestCase { private const PASSWORD = 's3Cr3t'; private const SALT = '^S4lt$'; @@ -119,7 +118,7 @@ public function emptyPasswordData() public function testUserIsNotValid() { $this->expectException(ConstraintDefinitionException::class); - $user = $this->createMock(User::class); + $user = new \stdClass(); $this->tokenStorage = $this->createTokenStorage($user); $this->validator = $this->createValidator(); From 8fc58aaa4576b054ad668d96df15dc49f778cbac Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 4 Jul 2021 00:48:29 +0200 Subject: [PATCH 021/100] Revert "bug #41952 [Console] fix handling positional arguments (nicolas-grekas)" This reverts commit e93f8c0ad37dbd6d14a3dbc615b2a198f6354006, reversing changes made to eb83be474cd54115f0cb7ad72d60fe06e4ee36de. --- src/Symfony/Component/Console/Input/Input.php | 4 ---- src/Symfony/Component/Console/Tests/Input/InputTest.php | 5 ----- 2 files changed, 9 deletions(-) diff --git a/src/Symfony/Component/Console/Input/Input.php b/src/Symfony/Component/Console/Input/Input.php index 6b093e7506bf4..6e4c01e95f851 100644 --- a/src/Symfony/Component/Console/Input/Input.php +++ b/src/Symfony/Component/Console/Input/Input.php @@ -110,8 +110,6 @@ public function getArgument($name) throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } - $name = \is_int($name) ? key(\array_slice($this->definition->getArguments(), $name, 1, true)) : $name; - return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault(); } @@ -124,8 +122,6 @@ public function setArgument($name, $value) throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } - $name = \is_int($name) ? key(\array_slice($this->definition->getArguments(), $name, 1, true)) : $name; - $this->arguments[$name] = $value; } diff --git a/src/Symfony/Component/Console/Tests/Input/InputTest.php b/src/Symfony/Component/Console/Tests/Input/InputTest.php index 3441351b4b7e5..48c287cd9d3b3 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputTest.php @@ -75,11 +75,6 @@ public function testArguments() $input = new ArrayInput(['name' => 'foo'], new InputDefinition([new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')])); $this->assertEquals('default', $input->getArgument('bar'), '->getArgument() returns the default value for optional arguments'); $this->assertEquals(['name' => 'foo', 'bar' => 'default'], $input->getArguments(), '->getArguments() returns all argument values, even optional ones'); - - $input = new ArrayInput(['arg1' => 'foo'], new InputDefinition([new InputArgument('arg1'), new InputArgument('arg2')])); - $input->setArgument(1, 'bar'); - $this->assertEquals('bar', $input->getArgument(1)); - $this->assertEquals(['arg1' => 'foo', 'arg2' => 'bar'], $input->getArguments()); } public function testSetInvalidArgument() From 603ea6af14db1a33b6cda427c83a13eda21807a4 Mon Sep 17 00:00:00 2001 From: Ippei Sumida Date: Sun, 4 Jul 2021 16:13:25 +0900 Subject: [PATCH 022/100] Add missing translations for Japanese. --- .../Validator/Resources/translations/validators.ja.xlf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf index 1a99117f930ad..c3b33657016c1 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf @@ -386,6 +386,10 @@ This value is not a valid International Securities Identification Number (ISIN). この値は有効な国際証券識別番号(ISIN)ではありません。 + + This value should be a valid expression. + 式でなければなりません。 + From 29b4b7641609f6010ae63fae25df16c15e3edf79 Mon Sep 17 00:00:00 2001 From: jaggle Date: Tue, 29 Jun 2021 23:55:19 +0800 Subject: [PATCH 023/100] [EventDispatcher] Correct the called event listener method case --- .../DependencyInjection/RegisterListenersPass.php | 2 +- .../DependencyInjection/RegisterListenersPassTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php index 1a52c3e865c9d..1c4e12ec86493 100644 --- a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php +++ b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php @@ -81,7 +81,7 @@ public function process(ContainerBuilder $container) if (!isset($event['method'])) { $event['method'] = 'on'.preg_replace_callback([ - '/(?<=\b)[a-z]/i', + '/(?<=\b|_)[a-z]/i', '/[^a-z0-9]/i', ], function ($matches) { return strtoupper($matches[0]); }, $event['event']); $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']); diff --git a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php index c4623bdbcbe64..e0afe2c72b6ca 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -175,6 +175,7 @@ public function testInvokableEventListener() $container->register('foo', \stdClass::class)->addTag('kernel.event_listener', ['event' => 'foo.bar']); $container->register('bar', InvokableListenerService::class)->addTag('kernel.event_listener', ['event' => 'foo.bar']); $container->register('baz', InvokableListenerService::class)->addTag('kernel.event_listener', ['event' => 'event']); + $container->register('zar', \stdClass::class)->addTag('kernel.event_listener', ['event' => 'foo.bar_zar']); $container->register('event_dispatcher', \stdClass::class); $registerListenersPass = new RegisterListenersPass(); @@ -206,6 +207,14 @@ public function testInvokableEventListener() 0, ], ], + [ + 'addListener', + [ + 'foo.bar_zar', + [new ServiceClosureArgument(new Reference('zar')), 'onFooBarZar'], + 0, + ], + ], ]; $this->assertEquals($expectedCalls, $definition->getMethodCalls()); } From 9928be05fee46a664bacf3beaa7afed9eba779a2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 4 Jul 2021 11:02:18 +0200 Subject: [PATCH 024/100] Revert "minor #41949 [Console] fix type annotations on InputInterface (nicolas-grekas)" This reverts commit ed09dc138e2be63303eaf6ddacabdb1ad6e2965e, reversing changes made to 7e78fb1197dfc6626ff2a1490fa2865fba4ee313. --- src/Symfony/Component/Console/Input/InputInterface.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index b96a0c6278f31..4ecab0f4fb10e 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -83,7 +83,7 @@ public function getArguments(); /** * Returns the argument value for a given argument name. * - * @param string|int $name The InputArgument name or position + * @param string $name The argument name * * @return mixed * @@ -94,8 +94,8 @@ public function getArgument($name); /** * Sets an argument value by name. * - * @param string|int $name The InputArgument name or position - * @param mixed $value The argument value + * @param string $name The argument name + * @param mixed $value The argument value * * @throws InvalidArgumentException When argument given doesn't exist */ From 6ac2776c470fb0e3d7207987ccd9c464a7e52dad Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 4 Jul 2021 11:08:18 +0200 Subject: [PATCH 025/100] [Console] Fix type annotation on InputInterface::hasArgument() --- src/Symfony/Component/Console/Input/Input.php | 6 +++--- src/Symfony/Component/Console/Input/InputInterface.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Input/Input.php b/src/Symfony/Component/Console/Input/Input.php index 6e4c01e95f851..d7f29073e50d5 100644 --- a/src/Symfony/Component/Console/Input/Input.php +++ b/src/Symfony/Component/Console/Input/Input.php @@ -106,7 +106,7 @@ public function getArguments() */ public function getArgument($name) { - if (!$this->definition->hasArgument($name)) { + if (!$this->definition->hasArgument((string) $name)) { throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } @@ -118,7 +118,7 @@ public function getArgument($name) */ public function setArgument($name, $value) { - if (!$this->definition->hasArgument($name)) { + if (!$this->definition->hasArgument((string) $name)) { throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); } @@ -130,7 +130,7 @@ public function setArgument($name, $value) */ public function hasArgument($name) { - return $this->definition->hasArgument($name); + return $this->definition->hasArgument((string) $name); } /** diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index 4ecab0f4fb10e..5d0db5c18872a 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -104,7 +104,7 @@ public function setArgument($name, $value); /** * Returns true if an InputArgument object exists by name or position. * - * @param string|int $name The InputArgument name or position + * @param string $name The InputArgument name or position * * @return bool true if the InputArgument object exists, false otherwise */ From 6f2aa6d245a645bdddf3c04d7cae2f55ee62930c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sun, 23 May 2021 15:08:14 +0200 Subject: [PATCH 026/100] Fix SkippedTestSuite --- .../Cache/Tests/Adapter/AbstractRedisAdapterTest.php | 5 +++-- .../Component/Cache/Tests/Adapter/MemcachedAdapterTest.php | 5 +++-- .../Component/Cache/Tests/Adapter/PdoAdapterTest.php | 3 ++- .../Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php | 3 ++- .../Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php | 3 ++- .../Cache/Tests/Adapter/RedisAdapterSentinelTest.php | 7 ++++--- .../Cache/Tests/Adapter/RedisArrayAdapterTest.php | 4 +++- .../Cache/Tests/Adapter/RedisClusterAdapterTest.php | 5 +++-- .../Cache/Tests/Simple/AbstractRedisCacheTest.php | 5 +++-- .../Component/Cache/Tests/Simple/MemcachedCacheTest.php | 5 +++-- src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php | 3 ++- .../Component/Cache/Tests/Simple/PdoDbalCacheTest.php | 3 ++- .../Component/Cache/Tests/Simple/RedisArrayCacheTest.php | 4 +++- .../Component/Cache/Tests/Simple/RedisClusterCacheTest.php | 6 ++++-- .../HttpFoundation/Tests/ResponseFunctionalTest.php | 3 ++- .../Session/Storage/Handler/AbstractSessionHandlerTest.php | 3 ++- .../Storage/Handler/RedisClusterSessionHandlerTest.php | 6 ++++-- .../Component/Lock/Tests/Store/MemcachedStoreTest.php | 3 ++- src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php | 4 +++- .../Component/Lock/Tests/Store/RedisArrayStoreTest.php | 6 ++++-- .../Component/Lock/Tests/Store/RedisClusterStoreTest.php | 6 ++++-- src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php | 3 ++- .../Messenger/Tests/Transport/RedisExt/ConnectionTest.php | 5 +++-- .../PersistentTokenBasedRememberMeServicesTest.php | 3 ++- 24 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php index 9d14007fde75f..cb0876d541b3e 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisAdapter; @@ -32,12 +33,12 @@ public function createCachePool(int $defaultLifetime = 0, string $testMethod = n public static function setUpBeforeClass(): void { if (!\extension_loaded('redis')) { - self::markTestSkipped('Extension redis required.'); + throw new SkippedTestSuiteError('Extension redis required.'); } try { (new \Redis())->connect(getenv('REDIS_HOST')); } catch (\Exception $e) { - self::markTestSkipped($e->getMessage()); + throw new SkippedTestSuiteError($e->getMessage()); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php index 0a67ea18467cc..1a1faed9e7379 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\MemcachedAdapter; @@ -32,14 +33,14 @@ class MemcachedAdapterTest extends AdapterTestCase public static function setUpBeforeClass(): void { if (!MemcachedAdapter::isSupported()) { - self::markTestSkipped('Extension memcached >=2.2.0 required.'); + throw new SkippedTestSuiteError('Extension memcached >=2.2.0 required.'); } self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]); self::$client->get('foo'); $code = self::$client->getResultCode(); if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) { - self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage())); + throw new SkippedTestSuiteError('Memcached error: '.strtolower(self::$client->getResultMessage())); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php index 3540155685e81..95c0fd6f8a596 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\PdoAdapter; @@ -26,7 +27,7 @@ class PdoAdapterTest extends AdapterTestCase public static function setUpBeforeClass(): void { if (!\extension_loaded('pdo_sqlite')) { - self::markTestSkipped('Extension pdo_sqlite required.'); + throw new SkippedTestSuiteError('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php index 5c5f60a51bd67..c31f96dda5ffc 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Doctrine\DBAL\DriverManager; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\PdoAdapter; @@ -27,7 +28,7 @@ class PdoDbalAdapterTest extends AdapterTestCase public static function setUpBeforeClass(): void { if (!\extension_loaded('pdo_sqlite')) { - self::markTestSkipped('Extension pdo_sqlite required.'); + throw new SkippedTestSuiteError('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php index 9db83c0db4126..4367ce0bfa510 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisClusterAdapterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\SkippedTestSuiteError; use Symfony\Component\Cache\Adapter\RedisAdapter; /** @@ -21,7 +22,7 @@ class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest public static function setUpBeforeClass(): void { if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { - self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.'); } self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['class' => \Predis\Client::class, 'redis_cluster' => true, 'prefix' => 'prefix_']); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php index 20f0811863aaa..c8b3ce9b9da62 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\SkippedTestSuiteError; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Exception\InvalidArgumentException; @@ -23,13 +24,13 @@ class RedisAdapterSentinelTest extends AbstractRedisAdapterTest public static function setUpBeforeClass(): void { if (!class_exists(\Predis\Client::class)) { - self::markTestSkipped('The Predis\Client class is required.'); + throw new SkippedTestSuiteError('The Predis\Client class is required.'); } if (!$hosts = getenv('REDIS_SENTINEL_HOSTS')) { - self::markTestSkipped('REDIS_SENTINEL_HOSTS env var is not defined.'); + throw new SkippedTestSuiteError('REDIS_SENTINEL_HOSTS env var is not defined.'); } if (!$service = getenv('REDIS_SENTINEL_SERVICE')) { - self::markTestSkipped('REDIS_SENTINEL_SERVICE env var is not defined.'); + throw new SkippedTestSuiteError('REDIS_SENTINEL_SERVICE env var is not defined.'); } self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['redis_sentinel' => $service, 'prefix' => 'prefix_']); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php index 6e0b448746e86..f9d481dba781f 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\SkippedTestSuiteError; + /** * @group integration */ @@ -20,7 +22,7 @@ public static function setUpBeforeClass(): void { parent::setupBeforeClass(); if (!class_exists(\RedisArray::class)) { - self::markTestSkipped('The RedisArray class is required.'); + throw new SkippedTestSuiteError('The RedisArray class is required.'); } self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); self::$redis->setOption(\Redis::OPT_PREFIX, 'prefix_'); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php index 011a36b338229..fca50690aef5e 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; @@ -25,10 +26,10 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest public static function setUpBeforeClass(): void { if (!class_exists(\RedisCluster::class)) { - self::markTestSkipped('The RedisCluster class is required.'); + throw new SkippedTestSuiteError('The RedisCluster class is required.'); } if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { - self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.'); } self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['lazy' => true, 'redis_cluster' => true]); diff --git a/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php index 21b56e98c8e3b..40830fc7fba1f 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Simple; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Simple\RedisCache; @@ -35,12 +36,12 @@ public function createSimpleCache(int $defaultLifetime = 0): CacheInterface public static function setUpBeforeClass(): void { if (!\extension_loaded('redis')) { - self::markTestSkipped('Extension redis required.'); + throw new SkippedTestSuiteError('Extension redis required.'); } try { (new \Redis())->connect(getenv('REDIS_HOST')); } catch (\Exception $e) { - self::markTestSkipped($e->getMessage()); + throw new SkippedTestSuiteError($e->getMessage()); } } diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php index a76eeaafa1db9..1f47faa16cf30 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Simple; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Exception\CacheException; @@ -33,14 +34,14 @@ class MemcachedCacheTest extends CacheTestCase public static function setUpBeforeClass(): void { if (!MemcachedCache::isSupported()) { - self::markTestSkipped('Extension memcached >=2.2.0 required.'); + throw new SkippedTestSuiteError('Extension memcached >=2.2.0 required.'); } self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')); self::$client->get('foo'); $code = self::$client->getResultCode(); if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) { - self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage())); + throw new SkippedTestSuiteError('Memcached error: '.strtolower(self::$client->getResultMessage())); } } diff --git a/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php index cf0ba1e52c011..a32a6f4a7b498 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Cache\Tests\Simple; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Simple\PdoCache; use Symfony\Component\Cache\Tests\Adapter\PdoPruneableTrait; @@ -28,7 +29,7 @@ class PdoCacheTest extends CacheTestCase public static function setUpBeforeClass(): void { if (!\extension_loaded('pdo_sqlite')) { - self::markTestSkipped('Extension pdo_sqlite required.'); + throw new SkippedTestSuiteError('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); diff --git a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php index e35ab567340d5..a74c702a19ec7 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Simple; use Doctrine\DBAL\DriverManager; +use PHPUnit\Framework\SkippedTestSuiteError; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\Simple\PdoCache; use Symfony\Component\Cache\Tests\Adapter\PdoPruneableTrait; @@ -29,7 +30,7 @@ class PdoDbalCacheTest extends CacheTestCase public static function setUpBeforeClass(): void { if (!\extension_loaded('pdo_sqlite')) { - self::markTestSkipped('Extension pdo_sqlite required.'); + throw new SkippedTestSuiteError('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php index 8173bcf1016f3..6cd0d25b502c5 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Cache\Tests\Simple; +use PHPUnit\Framework\SkippedTestSuiteError; + /** * @group legacy * @group integration @@ -21,7 +23,7 @@ public static function setUpBeforeClass(): void { parent::setupBeforeClass(); if (!class_exists(\RedisArray::class)) { - self::markTestSkipped('The RedisArray class is required.'); + throw new SkippedTestSuiteError('The RedisArray class is required.'); } self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php index bf20819df52a2..647d6e625e48e 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Cache\Tests\Simple; +use PHPUnit\Framework\SkippedTestSuiteError; + /** * @group legacy * @group integration @@ -20,10 +22,10 @@ class RedisClusterCacheTest extends AbstractRedisCacheTest public static function setUpBeforeClass(): void { if (!class_exists(\RedisCluster::class)) { - self::markTestSkipped('The RedisCluster class is required.'); + throw new SkippedTestSuiteError('The RedisCluster class is required.'); } if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { - self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.'); } self::$redis = new \RedisCluster(null, explode(' ', $hosts)); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php index 49acff5abc21a..471455d708753 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\HttpFoundation\Tests; +use PHPUnit\Framework\SkippedTestSuiteError; use PHPUnit\Framework\TestCase; class ResponseFunctionalTest extends TestCase @@ -24,7 +25,7 @@ public static function setUpBeforeClass(): void 2 => ['file', '/dev/null', 'w'], ]; if (!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8054', $spec, $pipes, __DIR__.'/Fixtures/response-functional')) { - self::markTestSkipped('PHP server unable to start.'); + throw new SkippedTestSuiteError('PHP server unable to start.'); } sleep(1); } 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 45257abb98819..f6417720d27aa 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; +use PHPUnit\Framework\SkippedTestSuiteError; use PHPUnit\Framework\TestCase; class AbstractSessionHandlerTest extends TestCase @@ -24,7 +25,7 @@ public static function setUpBeforeClass(): void 2 => ['file', '/dev/null', 'w'], ]; if (!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8053', $spec, $pipes, __DIR__.'/Fixtures')) { - self::markTestSkipped('PHP server unable to start.'); + throw new SkippedTestSuiteError('PHP server unable to start.'); } sleep(1); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php index af5d9b2c7389a..55d3a028cc7b3 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; +use PHPUnit\Framework\SkippedTestSuiteError; + /** * @group integration */ @@ -19,11 +21,11 @@ class RedisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase public static function setUpBeforeClass(): void { if (!class_exists(\RedisCluster::class)) { - self::markTestSkipped('The RedisCluster class is required.'); + throw new SkippedTestSuiteError('The RedisCluster class is required.'); } if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { - self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.'); } } diff --git a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php index fa93d0c5701cb..a0b308d2ab835 100644 --- a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Lock\Tests\Store; +use PHPUnit\Framework\SkippedTestSuiteError; use Symfony\Component\Lock\Exception\InvalidTtlException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\PersistingStoreInterface; @@ -34,7 +35,7 @@ public static function setUpBeforeClass(): void $code = $memcached->getResultCode(); if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) { - self::markTestSkipped('Unable to connect to the memcache host'); + throw new SkippedTestSuiteError('Unable to connect to the memcache host'); } } diff --git a/src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php index 9771d6e00d217..179a8246f7b78 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PredisStoreTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Lock\Tests\Store; +use PHPUnit\Framework\SkippedTestSuiteError; + /** * @author Jérémy Derussé * @group integration @@ -23,7 +25,7 @@ public static function setUpBeforeClass(): void try { $redis->connect(); } catch (\Exception $e) { - self::markTestSkipped($e->getMessage()); + throw new SkippedTestSuiteError($e->getMessage()); } } diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php index d5074a3eb2353..3b194d7c92f57 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Lock\Tests\Store; +use PHPUnit\Framework\SkippedTestSuiteError; + /** * @author Jérémy Derussé * @@ -22,12 +24,12 @@ class RedisArrayStoreTest extends AbstractRedisStoreTest public static function setUpBeforeClass(): void { if (!class_exists(\RedisArray::class)) { - self::markTestSkipped('The RedisArray class is required.'); + throw new SkippedTestSuiteError('The RedisArray class is required.'); } try { (new \Redis())->connect(getenv('REDIS_HOST')); } catch (\Exception $e) { - self::markTestSkipped($e->getMessage()); + throw new SkippedTestSuiteError($e->getMessage()); } } diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php index a6f2107fbd268..9a565f58d96a1 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Lock\Tests\Store; +use PHPUnit\Framework\SkippedTestSuiteError; + /** * @author Jérémy Derussé * @@ -22,10 +24,10 @@ class RedisClusterStoreTest extends AbstractRedisStoreTest public static function setUpBeforeClass(): void { if (!class_exists(\RedisCluster::class)) { - self::markTestSkipped('The RedisCluster class is required.'); + throw new SkippedTestSuiteError('The RedisCluster class is required.'); } if (!getenv('REDIS_CLUSTER_HOSTS')) { - self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.'); } } diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php index acec9c4029820..0f01e26407bae 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Lock\Tests\Store; +use PHPUnit\Framework\SkippedTestSuiteError; use Symfony\Component\Lock\Exception\InvalidTtlException; use Symfony\Component\Lock\Store\RedisStore; @@ -27,7 +28,7 @@ public static function setUpBeforeClass(): void try { (new \Redis())->connect(getenv('REDIS_HOST')); } catch (\Exception $e) { - self::markTestSkipped($e->getMessage()); + throw new SkippedTestSuiteError($e->getMessage()); } } diff --git a/src/Symfony/Component/Messenger/Tests/Transport/RedisExt/ConnectionTest.php b/src/Symfony/Component/Messenger/Tests/Transport/RedisExt/ConnectionTest.php index 26a79b58b771c..50fd5cf737471 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/RedisExt/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/RedisExt/ConnectionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Messenger\Tests\Transport\RedisExt; +use PHPUnit\Framework\SkippedTestSuiteError; use PHPUnit\Framework\TestCase; use Symfony\Component\Messenger\Exception\TransportException; use Symfony\Component\Messenger\Transport\RedisExt\Connection; @@ -28,12 +29,12 @@ public static function setUpBeforeClass(): void $redis->get(); } catch (TransportException $e) { if (0 === strpos($e->getMessage(), 'ERR unknown command \'X')) { - self::markTestSkipped('Redis server >= 5 is required'); + throw new SkippedTestSuiteError('Redis server >= 5 is required'); } throw $e; } catch (\RedisException $e) { - self::markTestSkipped($e->getMessage()); + throw new SkippedTestSuiteError($e->getMessage()); } } diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index a3249e940ed12..c297c41010287 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Security\Http\Tests\RememberMe; +use PHPUnit\Framework\SkippedTestSuiteError; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Request; @@ -35,7 +36,7 @@ public static function setUpBeforeClass(): void try { random_bytes(1); } catch (\Exception $e) { - self::markTestSkipped($e->getMessage()); + throw new SkippedTestSuiteError($e->getMessage()); } } From 0d8737ff16238dfae2961c2bf6a17b24479e213d Mon Sep 17 00:00:00 2001 From: "Exploit.cz" Date: Sat, 20 Mar 2021 18:44:57 +0100 Subject: [PATCH 027/100] Missing translations from traits --- .../Translation/DependencyInjection/TranslatorPathsPass.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php index a91aef6175f44..37c8c5719daed 100644 --- a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php +++ b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php @@ -60,6 +60,9 @@ public function process(ContainerBuilder $container) foreach ($this->paths as $class => $_) { if (($r = $container->getReflectionClass($class)) && !$r->isInterface()) { $paths[] = $r->getFileName(); + foreach ($r->getTraits() as $trait) { + $paths[] = $trait->getFileName(); + } } } if ($paths) { From 44f08fa121846e4997def51536250727758846f6 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 4 Jul 2021 11:31:36 +0200 Subject: [PATCH 028/100] CS fix --- src/Symfony/Component/Console/Input/InputInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index 5d0db5c18872a..86353ab607556 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -104,7 +104,7 @@ public function setArgument($name, $value); /** * Returns true if an InputArgument object exists by name or position. * - * @param string $name The InputArgument name or position + * @param string $name The argument name * * @return bool true if the InputArgument object exists, false otherwise */ From d9dea8d7617e6ff70da437074ebb26fd1c954d0c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Jul 2021 13:39:04 +0200 Subject: [PATCH 029/100] [Lock] fix derivating semaphore from key --- src/Symfony/Component/Lock/Store/SemaphoreStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Lock/Store/SemaphoreStore.php b/src/Symfony/Component/Lock/Store/SemaphoreStore.php index cee2d6f6aae99..6fd48a4c2807e 100644 --- a/src/Symfony/Component/Lock/Store/SemaphoreStore.php +++ b/src/Symfony/Component/Lock/Store/SemaphoreStore.php @@ -63,7 +63,7 @@ private function lock(Key $key, bool $blocking) return; } - $keyId = crc32($key); + $keyId = unpack('i', md5($key, true))[1]; $resource = sem_get($keyId); $acquired = @sem_acquire($resource, !$blocking); From a35a9bb7a0c3c04a1c1837dde5ecec68443e0aac Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Jul 2021 08:27:11 +0200 Subject: [PATCH 030/100] [DependencyInjection][Console] tighten types --- .../Component/Console/Input/InputArgument.php | 12 +++++----- .../Console/Input/InputDefinition.php | 8 ++----- .../Console/Input/InputInterface.php | 10 ++++---- .../Component/Console/Input/InputOption.php | 16 ++++--------- .../Component/Console/Question/Question.php | 6 ++--- .../DependencyInjection/Container.php | 6 ++--- .../ContainerInterface.php | 6 ++--- .../ParameterBag/ContainerBag.php | 2 +- .../ParameterBag/ParameterBagInterface.php | 6 ++--- .../Tests/Dumper/PhpDumperTest.php | 23 ------------------- 10 files changed, 31 insertions(+), 64 deletions(-) diff --git a/src/Symfony/Component/Console/Input/InputArgument.php b/src/Symfony/Component/Console/Input/InputArgument.php index 11de14fe68922..085aca5a7443e 100644 --- a/src/Symfony/Component/Console/Input/InputArgument.php +++ b/src/Symfony/Component/Console/Input/InputArgument.php @@ -31,10 +31,10 @@ class InputArgument private $description; /** - * @param string $name The argument name - * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL - * @param string $description A description text - * @param mixed $default The default value (for self::OPTIONAL mode only) + * @param string $name The argument name + * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL + * @param string $description A description text + * @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only) * * @throws InvalidArgumentException When argument mode is not valid */ @@ -86,7 +86,7 @@ public function isArray() /** * Sets the default value. * - * @param mixed $default The default value + * @param string|bool|int|float|array|null $default * * @throws LogicException When incorrect default value is given */ @@ -110,7 +110,7 @@ public function setDefault($default = null) /** * Returns the default value. * - * @return mixed + * @return string|bool|int|float|array|null */ public function getDefault() { diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index db55315a83a6c..e2cd6d714f9d2 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -185,9 +185,7 @@ public function getArgumentRequiredCount() } /** - * Gets the default values. - * - * @return array An array of default values + * @return array */ public function getArgumentDefaults() { @@ -316,9 +314,7 @@ public function getOptionForShortcut($shortcut) } /** - * Gets an array of default values. - * - * @return array An array of all default values + * @return array */ public function getOptionDefaults() { diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index 86353ab607556..8efc623268209 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -51,9 +51,9 @@ public function hasParameterOption($values, $onlyParams = false); * Does not necessarily return the correct result for short options * when multiple flags are combined in the same option. * - * @param string|array $values The value(s) to look for in the raw parameters (can be an array) - * @param mixed $default The default value to return if no result is found - * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal + * @param string|array $values The value(s) to look for in the raw parameters (can be an array) + * @param string|bool|int|float|array|null $default The default value to return if no result is found + * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal * * @return mixed The option value */ @@ -76,7 +76,7 @@ public function validate(); /** * Returns all the given arguments merged with the default values. * - * @return array + * @return array */ public function getArguments(); @@ -113,7 +113,7 @@ public function hasArgument($name); /** * Returns all the given options merged with the default values. * - * @return array + * @return array */ public function getOptions(); diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 2bb86cd2b0701..710e9a8095efc 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -48,11 +48,9 @@ class InputOption private $description; /** - * @param string $name The option name - * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int|null $mode The option mode: One of the VALUE_* constants - * @param string $description A description text - * @param mixed $default The default value (must be null for self::VALUE_NONE) + * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param int|null $mode The option mode: One of the VALUE_* constants + * @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE) * * @throws InvalidArgumentException If option mode is invalid or incompatible */ @@ -162,11 +160,7 @@ public function isArray() } /** - * Sets the default value. - * - * @param mixed $default The default value - * - * @throws LogicException When incorrect default value is given + * @param string|bool|int|float|array|null $default */ public function setDefault($default = null) { @@ -188,7 +182,7 @@ public function setDefault($default = null) /** * Returns the default value. * - * @return mixed + * @return string|bool|int|float|array|null */ public function getDefault() { diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 2d46d1a980a0c..cc108018f6914 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -32,8 +32,8 @@ class Question private $trimmable = true; /** - * @param string $question The question to ask to the user - * @param mixed $default The default answer to return if the user enters nothing + * @param string $question The question to ask to the user + * @param string|bool|int|float|null $default The default answer to return if the user enters nothing */ public function __construct(string $question, $default = null) { @@ -54,7 +54,7 @@ public function getQuestion() /** * Returns the default answer. * - * @return mixed + * @return string|bool|int|float|null */ public function getDefault() { diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index b731a70bc9d8a..ce44885b881d4 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -109,7 +109,7 @@ public function getParameterBag() * * @param string $name The parameter name * - * @return mixed + * @return array|bool|string|int|float|null * * @throws InvalidArgumentException if the parameter is not defined */ @@ -133,8 +133,8 @@ public function hasParameter($name) /** * Sets a parameter. * - * @param string $name The parameter name - * @param mixed $value The parameter value + * @param string $name The parameter name + * @param array|bool|string|int|float|null $value The parameter value */ public function setParameter($name, $value) { diff --git a/src/Symfony/Component/DependencyInjection/ContainerInterface.php b/src/Symfony/Component/DependencyInjection/ContainerInterface.php index 3123e2d13b45c..a3acbbde28785 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerInterface.php @@ -74,7 +74,7 @@ public function initialized($id); * * @param string $name The parameter name * - * @return mixed The parameter value + * @return array|bool|string|int|float|null * * @throws InvalidArgumentException if the parameter is not defined */ @@ -92,8 +92,8 @@ public function hasParameter($name); /** * Sets a parameter. * - * @param string $name The parameter name - * @param mixed $value The parameter value + * @param string $name The parameter name + * @param array|bool|string|int|float|null $value The parameter value */ public function setParameter($name, $value); } diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php index 42855d237603c..724a94e6dcc9a 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php @@ -36,7 +36,7 @@ public function all() /** * {@inheritdoc} * - * @return mixed + * @return array|bool|string|int|float|null */ public function get($name) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php index 75a7020660580..eb033bf4f245f 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php @@ -47,7 +47,7 @@ public function all(); * * @param string $name The parameter name * - * @return mixed The parameter value + * @return array|bool|string|int|float|null * * @throws ParameterNotFoundException if the parameter is not defined */ @@ -63,8 +63,8 @@ public function remove($name); /** * Sets a service container parameter. * - * @param string $name The parameter name - * @param mixed $value The parameter value + * @param string $name The parameter name + * @param array|bool|string|int|float|null $value The parameter value * * @throws LogicException if the parameter can not be set */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 3468e35a944c1..f11858fcf9dd3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -47,7 +47,6 @@ use Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1; use Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber; use Symfony\Component\DependencyInjection\TypedReference; -use Symfony\Component\DependencyInjection\Variable; use Symfony\Component\ExpressionLanguage\Expression; require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php'; @@ -164,28 +163,6 @@ public function testDumpCustomContainerClassWithMandatoryArgumentLessConstructor $this->assertStringEqualsFile(self::$fixturesPath.'/php/custom_container_class_with_mandatory_constructor_arguments.php', $dumper->dump(['base_class' => 'ConstructorWithMandatoryArgumentsContainer', 'namespace' => 'Symfony\Component\DependencyInjection\Tests\Fixtures\Container'])); } - /** - * @dataProvider provideInvalidParameters - */ - public function testExportParameters($parameters) - { - $this->expectException(\InvalidArgumentException::class); - $container = new ContainerBuilder(new ParameterBag($parameters)); - $container->compile(); - $dumper = new PhpDumper($container); - $dumper->dump(); - } - - public function provideInvalidParameters() - { - return [ - [['foo' => new Definition('stdClass')]], - [['foo' => new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")')]], - [['foo' => new Reference('foo')]], - [['foo' => new Variable('foo')]], - ]; - } - public function testAddParameters() { $container = include self::$fixturesPath.'/containers/container8.php'; From ad48f2c00f96ae5e71310c0e023553561ccce1db Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Jul 2021 08:31:06 +0200 Subject: [PATCH 031/100] cs fix --- .../Component/Console/Output/TrimmedBufferOutput.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Symfony/Component/Console/Output/TrimmedBufferOutput.php b/src/Symfony/Component/Console/Output/TrimmedBufferOutput.php index a03aa835f0086..4ca63c49b9f65 100644 --- a/src/Symfony/Component/Console/Output/TrimmedBufferOutput.php +++ b/src/Symfony/Component/Console/Output/TrimmedBufferOutput.php @@ -24,12 +24,7 @@ class TrimmedBufferOutput extends Output private $maxLength; private $buffer = ''; - public function __construct( - int $maxLength, - ?int $verbosity = self::VERBOSITY_NORMAL, - bool $decorated = false, - OutputFormatterInterface $formatter = null - ) { + public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) { if ($maxLength <= 0) { throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength)); } From 9ba0a9118a9e3088fc32b7fa98736a62d7afe724 Mon Sep 17 00:00:00 2001 From: Yup Date: Mon, 5 Jul 2021 20:03:53 +0300 Subject: [PATCH 032/100] Declare returned type. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes Method getSubscribedEvents() return type has no value type specified in iterable type array. 💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type --- .../Component/EventDispatcher/EventSubscriberInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php index 741590b1bf3a3..a0fc96dfe2aff 100644 --- a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php @@ -43,7 +43,7 @@ interface EventSubscriberInterface * The code must not depend on runtime state as it will only be called at compile time. * All logic depending on runtime state must be put into the individual methods handling the events. * - * @return array The event names to listen to + * @return array The event names to listen to */ public static function getSubscribedEvents(); } From ff08dcaca65b8ef98eebdcd71c14f4da9576a635 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Tue, 6 Jul 2021 17:45:30 +0200 Subject: [PATCH 033/100] [GHA] Clarify some bits in the deps=high script --- .github/workflows/unit-tests.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6ce52878ac93a..6066b9b8b7d48 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -184,10 +184,12 @@ jobs: # matrix.mode = high-deps echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1 + # get a list of the patched components (relies on .github/build-packages.php being called in the previous step) (cd src/Symfony/Component/HttpFoundation; mv composer.bak composer.json) - COMPONENTS=$(git diff --name-only src/ | grep composer.json || true) + PATCHED_COMPONENTS=$(git diff --name-only src/ | grep composer.json || true) - if [[ $COMPONENTS && $SYMFONY_VERSION = *.4 ]]; then + # for x.4 branches, checkout and test previous major with the patched components (only for patched components) + if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = *.4 ]]; then export FLIP='^' SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}') echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m" @@ -195,13 +197,13 @@ jobs: export SYMFONY_REQUIRE=">=$SYMFONY_VERSION" git fetch --depth=2 origin $SYMFONY_VERSION git checkout -m FETCH_HEAD - COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true) + PATCHED_COMPONENTS=$(echo "$PATCHED_COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true) (cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb) - if [[ $COMPONENTS ]]; then + if [[ $PATCHED_COMPONENTS ]]; then echo "::group::install phpunit" ./phpunit install echo "::endgroup::" - echo "$COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1 + echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1 fi fi From a6a00915c36fda69d4c15db66c45691d83f97fa5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 7 Jul 2021 14:12:06 +0200 Subject: [PATCH 034/100] [Cache] backport type fixes --- .github/workflows/integration-tests.yml | 2 +- .github/workflows/unit-tests.yml | 2 +- .../Component/Cache/Adapter/RedisAdapter.php | 12 ++++++----- .../Cache/Adapter/RedisTagAwareAdapter.php | 20 ++++++++++--------- src/Symfony/Component/Cache/CacheItem.php | 2 +- .../Component/Cache/Simple/RedisCache.php | 8 +++++--- .../Component/Cache/Traits/RedisTrait.php | 16 +++++++-------- .../Tests/ExpressionLanguageTest.php | 5 ++++- .../Component/Lock/Store/RedisStore.php | 12 +++++------ 9 files changed, 44 insertions(+), 35 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 97946446e959b..fac26491cb90d 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -72,7 +72,7 @@ jobs: with: coverage: "none" extensions: "memcached,redis,xsl,ldap" - ini-values: "memory_limit=-1" + ini-values: date.timezone=Europe/Paris,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1 php-version: "${{ matrix.php }}" - name: Load fixtures diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6ce52878ac93a..82499b9140b9e 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -46,7 +46,7 @@ jobs: uses: shivammathur/setup-php@v2 with: coverage: "none" - ini-values: date.timezone=Europe/Paris,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1 + ini-values: date.timezone=Europe/Paris,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1 php-version: "${{ matrix.php }}" extensions: "${{ env.extensions }}" tools: flex diff --git a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php index 5c49f7afe1cb2..eb5950e531677 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Cache\Adapter; use Symfony\Component\Cache\Marshaller\MarshallerInterface; +use Symfony\Component\Cache\Traits\RedisClusterProxy; +use Symfony\Component\Cache\Traits\RedisProxy; use Symfony\Component\Cache\Traits\RedisTrait; class RedisAdapter extends AbstractAdapter @@ -19,12 +21,12 @@ class RedisAdapter extends AbstractAdapter use RedisTrait; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client - * @param string $namespace The default namespace - * @param int $defaultLifetime The default lifetime + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy $redis The redis client + * @param string $namespace The default namespace + * @param int $defaultLifetime The default lifetime */ - public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) + public function __construct($redis, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) { - $this->init($redisClient, $namespace, $defaultLifetime, $marshaller); + $this->init($redis, $namespace, $defaultLifetime, $marshaller); } } diff --git a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php index 6f4b75d313d72..6ac5f87a52ce9 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php @@ -20,6 +20,8 @@ use Symfony\Component\Cache\Marshaller\DeflateMarshaller; use Symfony\Component\Cache\Marshaller\MarshallerInterface; use Symfony\Component\Cache\Marshaller\TagAwareMarshaller; +use Symfony\Component\Cache\Traits\RedisClusterProxy; +use Symfony\Component\Cache\Traits\RedisProxy; use Symfony\Component\Cache\Traits\RedisTrait; /** @@ -57,18 +59,18 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter private $redisEvictionPolicy; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client - * @param string $namespace The default namespace - * @param int $defaultLifetime The default lifetime + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy $redis The redis client + * @param string $namespace The default namespace + * @param int $defaultLifetime The default lifetime */ - public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) + public function __construct($redis, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) { - if ($redisClient instanceof \Predis\ClientInterface && $redisClient->getConnection() instanceof ClusterInterface && !$redisClient->getConnection() instanceof PredisCluster) { - throw new InvalidArgumentException(sprintf('Unsupported Predis cluster connection: only "%s" is, "%s" given.', PredisCluster::class, \get_class($redisClient->getConnection()))); + if ($redis instanceof \Predis\ClientInterface && $redis->getConnection() instanceof ClusterInterface && !$redis->getConnection() instanceof PredisCluster) { + throw new InvalidArgumentException(sprintf('Unsupported Predis cluster connection: only "%s" is, "%s" given.', PredisCluster::class, \get_class($redis->getConnection()))); } - if (\defined('Redis::OPT_COMPRESSION') && ($redisClient instanceof \Redis || $redisClient instanceof \RedisArray || $redisClient instanceof \RedisCluster)) { - $compression = $redisClient->getOption(\Redis::OPT_COMPRESSION); + if (\defined('Redis::OPT_COMPRESSION') && ($redis instanceof \Redis || $redis instanceof \RedisArray || $redis instanceof \RedisCluster)) { + $compression = $redis->getOption(\Redis::OPT_COMPRESSION); foreach (\is_array($compression) ? $compression : [$compression] as $c) { if (\Redis::COMPRESSION_NONE !== $c) { @@ -77,7 +79,7 @@ public function __construct($redisClient, string $namespace = '', int $defaultLi } } - $this->init($redisClient, $namespace, $defaultLifetime, new TagAwareMarshaller($marshaller)); + $this->init($redis, $namespace, $defaultLifetime, new TagAwareMarshaller($marshaller)); } /** diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index fe688c5f0cb83..1bb1d22427ac6 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -163,7 +163,7 @@ public function getPreviousTags(): array /** * Validates a cache key according to PSR-6. * - * @param string $key The key to validate + * @param mixed $key The key to validate * * @throws InvalidArgumentException When $key is not valid */ diff --git a/src/Symfony/Component/Cache/Simple/RedisCache.php b/src/Symfony/Component/Cache/Simple/RedisCache.php index a1b59e696569b..e0a76fd62a54d 100644 --- a/src/Symfony/Component/Cache/Simple/RedisCache.php +++ b/src/Symfony/Component/Cache/Simple/RedisCache.php @@ -13,6 +13,8 @@ use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Marshaller\MarshallerInterface; +use Symfony\Component\Cache\Traits\RedisClusterProxy; +use Symfony\Component\Cache\Traits\RedisProxy; use Symfony\Component\Cache\Traits\RedisTrait; use Symfony\Contracts\Cache\CacheInterface; @@ -26,10 +28,10 @@ class RedisCache extends AbstractCache use RedisTrait; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy $redis */ - public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) + public function __construct($redis, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) { - $this->init($redisClient, $namespace, $defaultLifetime, $marshaller); + $this->init($redis, $namespace, $defaultLifetime, $marshaller); } } diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index aaf4f1bd00e46..517650b2d9644 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -47,9 +47,9 @@ trait RedisTrait private $marshaller; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy $redis */ - private function init($redisClient, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller) + private function init($redis, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller) { parent::__construct($namespace, $defaultLifetime); @@ -57,17 +57,17 @@ private function init($redisClient, string $namespace, int $defaultLifetime, ?Ma throw new InvalidArgumentException(sprintf('RedisAdapter namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0])); } - if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) { - throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient))); + if (!$redis instanceof \Redis && !$redis instanceof \RedisArray && !$redis instanceof \RedisCluster && !$redis instanceof \Predis\ClientInterface && !$redis instanceof RedisProxy && !$redis instanceof RedisClusterProxy) { + throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis))); } - if ($redisClient instanceof \Predis\ClientInterface && $redisClient->getOptions()->exceptions) { - $options = clone $redisClient->getOptions(); + if ($redis instanceof \Predis\ClientInterface && $redis->getOptions()->exceptions) { + $options = clone $redis->getOptions(); \Closure::bind(function () { $this->options['exceptions'] = false; }, $options, $options)(); - $redisClient = new $redisClient($redisClient->getConnection(), $options); + $redis = new $redis($redis->getConnection(), $options); } - $this->redis = $redisClient; + $this->redis = $redis; $this->marshaller = $marshaller ?? new DefaultMarshaller(); } diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php index 5db40cf58afc7..e8bdc24b08dba 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php @@ -182,8 +182,10 @@ public function testCachingWithDifferentNamesOrder() ->expects($this->exactly(1)) ->method('set') ->with($this->isInstanceOf(ParsedExpression::class)) - ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) { + ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression, $cacheItemMock) { $savedParsedExpression = $parsedExpression; + + return $cacheItemMock; }) ; @@ -191,6 +193,7 @@ public function testCachingWithDifferentNamesOrder() ->expects($this->exactly(1)) ->method('save') ->with($cacheItemMock) + ->willReturn(true) ; $expression = 'a + b'; diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 46c2bb861317e..5d8f807df4a92 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -33,20 +33,20 @@ class RedisStore implements StoreInterface private $initialTtl; /** - * @param \Redis|\RedisArray|\RedisCluster|RedisProxy|RedisClusterProxy|\Predis\ClientInterface $redisClient - * @param float $initialTtl the expiration delay of locks in seconds + * @param \Redis|\RedisArray|\RedisCluster|RedisProxy|RedisClusterProxy|\Predis\ClientInterface $redis + * @param float $initialTtl The expiration delay of locks in seconds */ - public function __construct($redisClient, float $initialTtl = 300.0) + public function __construct($redis, float $initialTtl = 300.0) { - if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) { - throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster, RedisProxy, RedisClusterProxy or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient))); + if (!$redis instanceof \Redis && !$redis instanceof \RedisArray && !$redis instanceof \RedisCluster && !$redis instanceof \Predis\ClientInterface && !$redis instanceof RedisProxy && !$redis instanceof RedisClusterProxy) { + throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster, RedisProxy, RedisClusterProxy or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis))); } if ($initialTtl <= 0) { throw new InvalidTtlException(sprintf('"%s()" expects a strictly positive TTL. Got %d.', __METHOD__, $initialTtl)); } - $this->redis = $redisClient; + $this->redis = $redis; $this->initialTtl = $initialTtl; } From 45411891f213a666339e45607980b34225ccf504 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 7 Jul 2021 15:22:05 +0200 Subject: [PATCH 035/100] [ExpressionLanguage] Fix test case --- .../ExpressionLanguage/Tests/ExpressionLanguageTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php index e8bdc24b08dba..c0bd560d31ba1 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php @@ -48,8 +48,10 @@ public function testCachedParse() ->expects($this->exactly(1)) ->method('set') ->with($this->isInstanceOf(ParsedExpression::class)) - ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) { + ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression, $cacheItemMock) { $savedParsedExpression = $parsedExpression; + + return $cacheItemMock; }) ; @@ -57,6 +59,7 @@ public function testCachedParse() ->expects($this->exactly(1)) ->method('save') ->with($cacheItemMock) + ->willReturn(true) ; $parsedExpression = $expressionLanguage->parse('1 + 1', []); From 6996988fe552e1917ed2690e80cb22e816dba372 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 7 Jul 2021 16:41:18 +0100 Subject: [PATCH 036/100] [DomCrawler] Backport type fixes Signed-off-by: Alexander M. Turek --- .../DomCrawler/AbstractUriElement.php | 2 +- src/Symfony/Component/DomCrawler/Crawler.php | 19 ++++++++++++++----- src/Symfony/Component/DomCrawler/Form.php | 6 +++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/AbstractUriElement.php b/src/Symfony/Component/DomCrawler/AbstractUriElement.php index 83b2433c8fe98..6db5b7403970c 100644 --- a/src/Symfony/Component/DomCrawler/AbstractUriElement.php +++ b/src/Symfony/Component/DomCrawler/AbstractUriElement.php @@ -35,7 +35,7 @@ abstract class AbstractUriElement /** * @param \DOMElement $node A \DOMElement instance - * @param string $currentUri The URI of the page where the link is embedded (or the base href) + * @param string|null $currentUri The URI of the page where the link is embedded (or the base href) * @param string|null $method The method to use for the link (GET by default) * * @throws \InvalidArgumentException if the node is not a link diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 8f12764474d90..f8839e875b157 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -21,20 +21,29 @@ */ class Crawler implements \Countable, \IteratorAggregate { + /** + * @var string|null + */ protected $uri; /** - * @var string The default namespace prefix to be used with XPath and CSS expressions + * The default namespace prefix to be used with XPath and CSS expressions. + * + * @var string */ private $defaultNamespacePrefix = 'default'; /** - * @var array A map of manually registered namespaces + * A map of manually registered namespaces. + * + * @var array */ private $namespaces = []; /** - * @var string The base href value + * The base href value. + * + * @var string|null */ private $baseHref; @@ -75,7 +84,7 @@ public function __construct($node = null, string $uri = null, string $baseHref = /** * Returns the current URI. * - * @return string + * @return string|null */ public function getUri() { @@ -85,7 +94,7 @@ public function getUri() /** * Returns base href. * - * @return string + * @return string|null */ public function getBaseHref() { diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index f3cee8669a52c..02f9869122d38 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -38,9 +38,9 @@ class Form extends Link implements \ArrayAccess /** * @param \DOMElement $node A \DOMElement instance - * @param string $currentUri The URI of the page where the form is embedded - * @param string $method The method to use for the link (if null, it defaults to the method defined by the form) - * @param string $baseHref The URI of the used for relative links, but not for empty action + * @param string|null $currentUri The URI of the page where the form is embedded + * @param string|null $method The method to use for the link (if null, it defaults to the method defined by the form) + * @param string|null $baseHref The URI of the used for relative links, but not for empty action * * @throws \LogicException if the node is not a button inside a form tag */ From b3c28ca02ceb67a055285410a265d3042df48d38 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Thu, 8 Jul 2021 11:30:06 +0300 Subject: [PATCH 037/100] [Validator] Added Ukrainian translations --- .../Validator/Resources/translations/validators.uk.xlf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf index 7ea908e75706d..e8845ec005db5 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf @@ -386,6 +386,10 @@ This value is not a valid International Securities Identification Number (ISIN). Це значення не є дійсним міжнародним ідентифікаційним номером цінних паперів (ISIN). + + This value should be a valid expression. + Це значення має бути дійсним виразом. + From 387254ff5abd923f9407ded5da9335c5e2480956 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 8 Jul 2021 10:41:14 +0200 Subject: [PATCH 038/100] [ErrorHandle] Remove a link from the exception page --- .../TwigBundle/Resources/views/images/icon-support.svg | 1 - .../Bundle/TwigBundle/Resources/views/layout.html.twig | 7 ------- .../ErrorHandler/Resources/views/exception_full.html.php | 7 ------- 3 files changed, 15 deletions(-) delete mode 100644 src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-support.svg diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-support.svg b/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-support.svg deleted file mode 100644 index 03fd8e7678baf..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/images/icon-support.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig index 5bcd82a2009a1..9324a4f0c2ba6 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/layout.html.twig @@ -22,13 +22,6 @@ Symfony Docs - - diff --git a/src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php b/src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php index 6898ce028d249..cb5a56754e66b 100644 --- a/src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php +++ b/src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php @@ -22,13 +22,6 @@ Symfony Docs - - From d10b3a63e5d38ae80a5d265eb6e6aff755c4ad9c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 8 Jul 2021 13:32:35 +0200 Subject: [PATCH 039/100] recover from failed deserializations --- src/Symfony/Component/HttpKernel/HttpCache/Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index 7dfdc491dda8d..eeb7a6ef948b1 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -298,7 +298,7 @@ private function getMetadata(string $key): array return []; } - return unserialize($entries); + return unserialize($entries) ?: []; } /** From 8da1969afc5a379e127d5053a693368ffb210034 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 9 Jul 2021 12:48:54 +0200 Subject: [PATCH 040/100] do not mock event classes --- .../Processor/ConsoleCommandProcessorTest.php | 6 +- .../AddRequestFormatsListenerTest.php | 13 +---- .../EventListener/SaveSessionListenerTest.php | 12 ++-- .../EventListener/SessionListenerTest.php | 4 +- .../AbstractPreAuthenticatedListenerTest.php | 44 ++------------- .../BasicAuthenticationListenerTest.php | 56 ++++--------------- .../Tests/Firewall/ChannelListenerTest.php | 55 +++++------------- .../Tests/Firewall/ContextListenerTest.php | 22 +------- .../Tests/Firewall/LogoutListenerTest.php | 46 ++++++--------- .../Tests/Firewall/RememberMeListenerTest.php | 6 -- .../SimplePreAuthenticationListenerTest.php | 8 +-- ...PasswordFormAuthenticationListenerTest.php | 9 +-- 12 files changed, 65 insertions(+), 216 deletions(-) diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/ConsoleCommandProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/ConsoleCommandProcessorTest.php index 6ee30da38a993..424f9ce10d597 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/ConsoleCommandProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/ConsoleCommandProcessorTest.php @@ -16,6 +16,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; class ConsoleCommandProcessorTest extends TestCase { @@ -66,10 +67,7 @@ private function getConsoleEvent(): ConsoleEvent $input->method('getOptions')->willReturn(self::TEST_OPTIONS); $command = $this->createMock(Command::class); $command->method('getName')->willReturn(self::TEST_NAME); - $consoleEvent = $this->createMock(ConsoleEvent::class); - $consoleEvent->method('getCommand')->willReturn($command); - $consoleEvent->method('getInput')->willReturn($input); - return $consoleEvent; + return new ConsoleEvent($command, $input, $this->createMock(OutputInterface::class)); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php index fab9a8a38f607..9b3c1a2e58bea 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -54,7 +55,7 @@ public function testRegisteredEvent() public function testSetAdditionalFormats() { $request = $this->createMock(Request::class); - $event = $this->getRequestEventMock($request); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $request->expects($this->once()) ->method('setFormat') @@ -62,14 +63,4 @@ public function testSetAdditionalFormats() $this->listener->onKernelRequest($event); } - - protected function getRequestEventMock(Request $request) - { - $event = $this->createMock(RequestEvent::class); - $event->expects($this->any()) - ->method('getRequest') - ->willReturn($request); - - return $event; - } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SaveSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SaveSessionListenerTest.php index f79b73c5fe47a..bbb76771e02c6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SaveSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SaveSessionListenerTest.php @@ -26,13 +26,17 @@ class SaveSessionListenerTest extends TestCase { public function testOnlyTriggeredOnMasterRequest() { + $session = $this->createMock(SessionInterface::class); + $session->expects($this->never())->method('save'); + $session->expects($this->any())->method('isStarted')->willReturn(true); + + $request = new Request(); + $request->setSession($session); + $listener = new SaveSessionListener(); - $event = $this->createMock(ResponseEvent::class); - $event->expects($this->once())->method('isMasterRequest')->willReturn(false); - $event->expects($this->never())->method('getRequest'); // sub request - $listener->onKernelResponse($event); + $listener->onKernelResponse(new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::SUB_REQUEST, new Response())); } public function testSessionSaved() diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php index e0dba81683ee9..d6ff42f926247 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php @@ -58,9 +58,7 @@ public function testSessionIsSet() $request = new Request(); $listener = new SessionListener($container); - $event = $this->createMock(RequestEvent::class); - $event->expects($this->exactly(2))->method('isMasterRequest')->willReturn(true); - $event->expects($this->once())->method('getRequest')->willReturn($request); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener->onKernelRequest($event); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php index e841273f78253..41d8f003602ff 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -62,14 +63,7 @@ public function testHandleWithValidValues() ->method('getPreAuthenticatedData') ->willReturn($userCredentials); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testHandleWhenAuthenticationFails() @@ -109,14 +103,7 @@ public function testHandleWhenAuthenticationFails() ->method('getPreAuthenticatedData') ->willReturn($userCredentials); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testHandleWhenAuthenticationFailsWithDifferentToken() @@ -158,12 +145,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() ->method('getPreAuthenticatedData') ->willReturn($userCredentials); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener($event); } @@ -200,14 +182,7 @@ public function testHandleWithASimilarAuthenticatedToken() ->method('getPreAuthenticatedData') ->willReturn($userCredentials); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testHandleWithAnInvalidSimilarToken() @@ -250,13 +225,6 @@ public function testHandleWithAnInvalidSimilarToken() ->method('getPreAuthenticatedData') ->willReturn($userCredentials); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php index 2993b4956f4b1..8216d277e7326 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager; use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface; @@ -64,14 +65,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() $this->createMock(AuthenticationEntryPointInterface::class) ); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testHandleWhenAuthenticationFails() @@ -109,19 +103,11 @@ public function testHandleWhenAuthenticationFails() $authenticationEntryPoint ); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - $event - ->expects($this->once()) - ->method('setResponse') - ->with($this->equalTo($response)) - ; + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener($event); + + $this->assertSame($response, $event->getResponse()); } public function testHandleWithNoUsernameServerParameter() @@ -141,14 +127,7 @@ public function testHandleWithNoUsernameServerParameter() $this->createMock(AuthenticationEntryPointInterface::class) ); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testHandleWithASimilarAuthenticatedToken() @@ -177,14 +156,7 @@ public function testHandleWithASimilarAuthenticatedToken() $this->createMock(AuthenticationEntryPointInterface::class) ); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testItRequiresProviderKey() @@ -236,18 +208,10 @@ public function testHandleWithADifferentAuthenticatedToken() $authenticationEntryPoint ); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - $event - ->expects($this->once()) - ->method('setResponse') - ->with($this->equalTo($response)) - ; + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener($event); + + $this->assertSame($response, $event->getResponse()); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php index 42dd734fca5d1..5fab54c13227d 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Http\AccessMapInterface; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; use Symfony\Component\Security\Http\Firewall\ChannelListener; @@ -44,19 +45,12 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() ->method('start') ; - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - $event - ->expects($this->never()) - ->method('setResponse') - ; + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener = new ChannelListener($accessMap, $entryPoint); $listener($event); + + $this->assertNull($event->getResponse()); } public function testHandleWithSecuredRequestAndHttpsChannel() @@ -82,19 +76,12 @@ public function testHandleWithSecuredRequestAndHttpsChannel() ->method('start') ; - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - $event - ->expects($this->never()) - ->method('setResponse') - ; + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener = new ChannelListener($accessMap, $entryPoint); $listener($event); + + $this->assertNull($event->getResponse()); } public function testHandleWithNotSecuredRequestAndHttpsChannel() @@ -124,20 +111,12 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() ->willReturn($response) ; - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - $event - ->expects($this->once()) - ->method('setResponse') - ->with($this->equalTo($response)) - ; + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener = new ChannelListener($accessMap, $entryPoint); $listener($event); + + $this->assertSame($response, $event->getResponse()); } public function testHandleWithSecuredRequestAndHttpChannel() @@ -167,19 +146,11 @@ public function testHandleWithSecuredRequestAndHttpChannel() ->willReturn($response) ; - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - $event - ->expects($this->once()) - ->method('setResponse') - ->with($this->equalTo($response)) - ; + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener = new ChannelListener($accessMap, $entryPoint); $listener($event); + + $this->assertSame($response, $event->getResponse()); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index f83f8d68038d8..7c60132bc055d 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -146,13 +146,9 @@ public function testOnKernelResponseWithoutSessionNorToken() public function testInvalidTokenInSession($token) { $tokenStorage = $this->createMock(TokenStorageInterface::class); - $event = $this->createMock(RequestEvent::class); $request = $this->createMock(Request::class); $session = $this->createMock(SessionInterface::class); - $event->expects($this->any()) - ->method('getRequest') - ->willReturn($request); $request->expects($this->any()) ->method('hasPreviousSession') ->willReturn(true); @@ -168,7 +164,7 @@ public function testInvalidTokenInSession($token) ->with(null); $listener = new ContextListener($tokenStorage, [], 'key123'); - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function provideInvalidToken() @@ -186,22 +182,13 @@ public function testHandleAddsKernelResponseListener() { $tokenStorage = $this->createMock(TokenStorageInterface::class); $dispatcher = $this->createMock(EventDispatcherInterface::class); - $event = $this->createMock(RequestEvent::class); - $listener = new ContextListener($tokenStorage, [], 'key123', null, $dispatcher); - $event->expects($this->any()) - ->method('isMasterRequest') - ->willReturn(true); - $event->expects($this->any()) - ->method('getRequest') - ->willReturn($this->createMock(Request::class)); - $dispatcher->expects($this->once()) ->method('addListener') ->with(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); } public function testOnKernelResponseListenerRemovesItself() @@ -234,14 +221,11 @@ public function testHandleRemovesTokenIfNoPreviousSessionWasFound() $request = $this->createMock(Request::class); $request->expects($this->any())->method('hasPreviousSession')->willReturn(false); - $event = $this->createMock(RequestEvent::class); - $event->expects($this->any())->method('getRequest')->willReturn($request); - $tokenStorage = $this->createMock(TokenStorageInterface::class); $tokenStorage->expects($this->once())->method('setToken')->with(null); $listener = new ContextListener($tokenStorage, [], 'key123'); - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testIfTokenIsDeauthenticated() diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php index f5c6107051ef0..397639fd940f7 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\LogoutException; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; @@ -30,10 +31,8 @@ public function testHandleUnmatchedPath() { [$listener, , $httpUtils, $options] = $this->getListener(); - [$event, $request] = $this->getGetResponseEvent(); - - $event->expects($this->never()) - ->method('setResponse'); + $request = new Request(); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $httpUtils->expects($this->once()) ->method('checkRequestPath') @@ -41,6 +40,8 @@ public function testHandleUnmatchedPath() ->willReturn(false); $listener($event); + + $this->assertNull($event->getResponse()); } public function testHandleMatchedPathWithSuccessHandlerAndCsrfValidation() @@ -50,7 +51,8 @@ public function testHandleMatchedPathWithSuccessHandlerAndCsrfValidation() [$listener, $tokenStorage, $httpUtils, $options] = $this->getListener($successHandler, $tokenManager); - [$event, $request] = $this->getGetResponseEvent(); + $request = new Request(); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $request->query->set('_csrf_token', 'token'); @@ -81,13 +83,11 @@ public function testHandleMatchedPathWithSuccessHandlerAndCsrfValidation() ->method('setToken') ->with(null); - $event->expects($this->once()) - ->method('setResponse') - ->with($response); - $listener->addHandler($handler); $listener($event); + + $this->assertSame($response, $event->getResponse()); } public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation() @@ -96,7 +96,8 @@ public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation() [$listener, $tokenStorage, $httpUtils, $options] = $this->getListener($successHandler); - [$event, $request] = $this->getGetResponseEvent(); + $request = new Request(); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $httpUtils->expects($this->once()) ->method('checkRequestPath') @@ -121,13 +122,11 @@ public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation() ->method('setToken') ->with(null); - $event->expects($this->once()) - ->method('setResponse') - ->with($response); - $listener->addHandler($handler); $listener($event); + + $this->assertSame($response, $event->getResponse()); } public function testSuccessHandlerReturnsNonResponse() @@ -137,7 +136,8 @@ public function testSuccessHandlerReturnsNonResponse() [$listener, , $httpUtils, $options] = $this->getListener($successHandler); - [$event, $request] = $this->getGetResponseEvent(); + $request = new Request(); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $httpUtils->expects($this->once()) ->method('checkRequestPath') @@ -159,8 +159,7 @@ public function testCsrfValidationFails() [$listener, , $httpUtils, $options] = $this->getListener(null, $tokenManager); - [$event, $request] = $this->getGetResponseEvent(); - + $request = new Request(); $request->query->set('_csrf_token', 'token'); $httpUtils->expects($this->once()) @@ -172,7 +171,7 @@ public function testCsrfValidationFails() ->method('isTokenValid') ->willReturn(false); - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } private function getTokenManager() @@ -185,17 +184,6 @@ private function getTokenStorage() return $this->createMock(TokenStorageInterface::class); } - private function getGetResponseEvent() - { - $event = $this->createMock(RequestEvent::class); - - $event->expects($this->any()) - ->method('getRequest') - ->willReturn($request = new Request()); - - return [$event, $request]; - } - private function getHandler() { return $this->createMock(LogoutHandlerInterface::class); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index ac6186b55aa78..c6da58ce1f16a 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -16,7 +16,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\Event\RequestEvent; -use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -363,11 +362,6 @@ protected function getGetResponseEvent(Request $request = null): RequestEvent return $event; } - protected function getResponseEvent(): ResponseEvent - { - return $this->createMock(ResponseEvent::class); - } - protected function getListener($withDispatcher = false, $catchExceptions = true, $withSessionStrategy = false) { $listener = new RememberMeListener( diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index 868d81103063e..78853dac878c4 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -16,6 +16,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; @@ -110,12 +111,7 @@ protected function setUp(): void $this->request = new Request([], [], [], [], [], []); - $this->event = $this->createMock(RequestEvent::class); - $this->event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($this->request) - ; + $this->event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->request, HttpKernelInterface::MASTER_REQUEST); $this->logger = $this->createMock(LoggerInterface::class); $this->tokenStorage = $this->createMock(TokenStorageInterface::class); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index c1299fd1fe9a3..312014cd1a6f5 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -78,14 +78,7 @@ public function testHandleWhenUsernameLength($username, $ok) ['require_previous_session' => false] ); - $event = $this->createMock(RequestEvent::class); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } /** From 968809c2f166b39c944d1b9b84cefa1fd9168e22 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 9 Jul 2021 16:39:14 +0200 Subject: [PATCH 041/100] do not mock the Request class --- .../WebDebugToolbarListenerTest.php | 65 ++++++------------- .../DisallowRobotsIndexingListenerTest.php | 2 +- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index 01d586346ad30..60c430f9b006f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -13,10 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener; -use Symfony\Component\HttpFoundation\HeaderBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Kernel; @@ -61,11 +59,11 @@ public function getInjectToolbarTests() /** * @dataProvider provideRedirects */ - public function testHtmlRedirectionIsIntercepted($statusCode, $hasSession) + public function testHtmlRedirectionIsIntercepted($statusCode) { $response = new Response('Some content', $statusCode); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true); $listener->onKernelResponse($event); @@ -78,7 +76,7 @@ public function testNonHtmlRedirectionIsNotIntercepted() { $response = new Response('Some content', '301'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json', true), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true); $listener->onKernelResponse($event); @@ -92,7 +90,7 @@ public function testToolbarIsInjected() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -108,7 +106,7 @@ public function testToolbarIsNotInjectedOnNonHtmlContentType() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $response->headers->set('Content-Type', 'text/xml'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -124,7 +122,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $response->headers->set('Content-Disposition', 'attachment; filename=test.html'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html'), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -136,11 +134,11 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment() * @depends testToolbarIsInjected * @dataProvider provideRedirects */ - public function testToolbarIsNotInjectedOnRedirection($statusCode, $hasSession) + public function testToolbarIsNotInjectedOnRedirection($statusCode) { $response = new Response('', $statusCode); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -151,10 +149,8 @@ public function testToolbarIsNotInjectedOnRedirection($statusCode, $hasSession) public function provideRedirects() { return [ - [301, true], - [302, true], - [301, false], - [302, false], + [301], + [302], ]; } @@ -165,7 +161,7 @@ public function testToolbarIsNotInjectedWhenThereIsNoNoXDebugTokenResponseHeader { $response = new Response(''); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -181,7 +177,7 @@ public function testToolbarIsNotInjectedWhenOnSubRequest() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::SUB_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::SUB_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -197,7 +193,7 @@ public function testToolbarIsNotInjectedOnIncompleteHtmlResponses() $response = new Response('
Some content
'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -213,7 +209,10 @@ public function testToolbarIsNotInjectedOnXmlHttpRequests() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(true), HttpKernelInterface::MASTER_REQUEST, $response); + $request = new Request(); + $request->headers->set('X-Requested-With', 'XMLHttpRequest'); + + $event = new ResponseEvent($this->createMock(Kernel::class), $request, HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -229,7 +228,7 @@ public function testToolbarIsNotInjectedOnNonHtmlRequests() $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json'), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -250,7 +249,7 @@ public function testXDebugUrlHeader() ->willReturn('http://mydomain.com/_profiler/xxxxxxxx') ; - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -271,7 +270,7 @@ public function testThrowingUrlGenerator() ->willThrowException(new \Exception('foo')) ; - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -292,7 +291,7 @@ public function testThrowingErrorCleanup() ->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline")) ; - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -300,28 +299,6 @@ public function testThrowingErrorCleanup() $this->assertEquals('Exception: This multiline tabbed text should come out on a single plain line', $response->headers->get('X-Debug-Error')); } - protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true) - { - $request = $this->getMockBuilder(Request::class)->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock(); - $request->expects($this->any()) - ->method('isXmlHttpRequest') - ->willReturn($isXmlHttpRequest); - $request->expects($this->any()) - ->method('getRequestFormat') - ->willReturn($requestFormat); - - $request->headers = new HeaderBag(); - - if ($hasSession) { - $session = $this->createMock(Session::class); - $request->expects($this->any()) - ->method('getSession') - ->willReturn($session); - } - - return $request; - } - protected function getTwigMock($render = 'WDT') { $templating = $this->createMock(Environment::class); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php index 6534ebf4e2122..4a05d65188be6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php @@ -29,7 +29,7 @@ public function testInvoke(?string $expected, array $responseArgs) $response = new Response(...$responseArgs); $listener = new DisallowRobotsIndexingListener(); - $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $this->createMock(Request::class), KernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), new Request(), KernelInterface::MASTER_REQUEST, $response); $listener->onResponse($event); From e49441d5c2cd4a3d4a86c56d0effd763870c97bf Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 7 Jul 2021 11:10:12 +0200 Subject: [PATCH 042/100] [Form] fix some type annotations --- src/Symfony/Component/Form/Button.php | 4 +- src/Symfony/Component/Form/ButtonBuilder.php | 78 ------------------- .../Factory/PropertyAccessDecorator.php | 38 +++++---- .../Validator/Constraints/FormValidator.php | 12 ++- src/Symfony/Component/Form/SubmitButton.php | 4 +- .../Form/Util/OptionsResolverWrapper.php | 4 + .../Validator/Constraints/GroupSequence.php | 4 +- 7 files changed, 38 insertions(+), 106 deletions(-) diff --git a/src/Symfony/Component/Form/Button.php b/src/Symfony/Component/Form/Button.php index aa981a0125b3d..2fc724fbd0dd5 100644 --- a/src/Symfony/Component/Form/Button.php +++ b/src/Symfony/Component/Form/Button.php @@ -371,8 +371,8 @@ public function handleRequest($request = null) /** * Submits data to the button. * - * @param string|null $submittedData Not used - * @param bool $clearMissing Not used + * @param array|string|null $submittedData Not used + * @param bool $clearMissing Not used * * @return $this * diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index eab4996a43c64..4d16632bbe40d 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -101,10 +101,6 @@ public function create($name, $type = null, array $options = []) /** * Unsupported method. * - * This method should not be invoked. - * - * @param string $name - * * @throws BadMethodCallException */ public function get($name) @@ -115,10 +111,6 @@ public function get($name) /** * Unsupported method. * - * This method should not be invoked. - * - * @param string $name - * * @throws BadMethodCallException */ public function remove($name) @@ -129,8 +121,6 @@ public function remove($name) /** * Unsupported method. * - * @param string $name - * * @return bool Always returns false */ public function has($name) @@ -161,12 +151,6 @@ public function getForm() /** * Unsupported method. * - * This method should not be invoked. - * - * @param string $eventName - * @param callable $listener - * @param int $priority - * * @throws BadMethodCallException */ public function addEventListener($eventName, $listener, $priority = 0) @@ -177,8 +161,6 @@ public function addEventListener($eventName, $listener, $priority = 0) /** * Unsupported method. * - * This method should not be invoked. - * * @throws BadMethodCallException */ public function addEventSubscriber(EventSubscriberInterface $subscriber) @@ -189,10 +171,6 @@ public function addEventSubscriber(EventSubscriberInterface $subscriber) /** * Unsupported method. * - * This method should not be invoked. - * - * @param bool $forcePrepend - * * @throws BadMethodCallException */ public function addViewTransformer(DataTransformerInterface $viewTransformer, $forcePrepend = false) @@ -203,8 +181,6 @@ public function addViewTransformer(DataTransformerInterface $viewTransformer, $f /** * Unsupported method. * - * This method should not be invoked. - * * @throws BadMethodCallException */ public function resetViewTransformers() @@ -215,10 +191,6 @@ public function resetViewTransformers() /** * Unsupported method. * - * This method should not be invoked. - * - * @param bool $forceAppend - * * @throws BadMethodCallException */ public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false) @@ -229,8 +201,6 @@ public function addModelTransformer(DataTransformerInterface $modelTransformer, /** * Unsupported method. * - * This method should not be invoked. - * * @throws BadMethodCallException */ public function resetModelTransformers() @@ -261,8 +231,6 @@ public function setAttributes(array $attributes) /** * Unsupported method. * - * This method should not be invoked. - * * @throws BadMethodCallException */ public function setDataMapper(DataMapperInterface $dataMapper = null) @@ -287,10 +255,6 @@ public function setDisabled($disabled) /** * Unsupported method. * - * This method should not be invoked. - * - * @param mixed $emptyData - * * @throws BadMethodCallException */ public function setEmptyData($emptyData) @@ -301,10 +265,6 @@ public function setEmptyData($emptyData) /** * Unsupported method. * - * This method should not be invoked. - * - * @param bool $errorBubbling - * * @throws BadMethodCallException */ public function setErrorBubbling($errorBubbling) @@ -315,10 +275,6 @@ public function setErrorBubbling($errorBubbling) /** * Unsupported method. * - * This method should not be invoked. - * - * @param bool $required - * * @throws BadMethodCallException */ public function setRequired($required) @@ -329,10 +285,6 @@ public function setRequired($required) /** * Unsupported method. * - * This method should not be invoked. - * - * @param null $propertyPath - * * @throws BadMethodCallException */ public function setPropertyPath($propertyPath) @@ -343,10 +295,6 @@ public function setPropertyPath($propertyPath) /** * Unsupported method. * - * This method should not be invoked. - * - * @param bool $mapped - * * @throws BadMethodCallException */ public function setMapped($mapped) @@ -357,10 +305,6 @@ public function setMapped($mapped) /** * Unsupported method. * - * This method should not be invoked. - * - * @param bool $byReference - * * @throws BadMethodCallException */ public function setByReference($byReference) @@ -371,10 +315,6 @@ public function setByReference($byReference) /** * Unsupported method. * - * This method should not be invoked. - * - * @param bool $compound - * * @throws BadMethodCallException */ public function setCompound($compound) @@ -397,10 +337,6 @@ public function setType(ResolvedFormTypeInterface $type) /** * Unsupported method. * - * This method should not be invoked. - * - * @param mixed $data - * * @throws BadMethodCallException */ public function setData($data) @@ -411,10 +347,6 @@ public function setData($data) /** * Unsupported method. * - * This method should not be invoked. - * - * @param bool $locked - * * @throws BadMethodCallException */ public function setDataLocked($locked) @@ -425,8 +357,6 @@ public function setDataLocked($locked) /** * Unsupported method. * - * This method should not be invoked. - * * @throws BadMethodCallException */ public function setFormFactory(FormFactoryInterface $formFactory) @@ -437,8 +367,6 @@ public function setFormFactory(FormFactoryInterface $formFactory) /** * Unsupported method. * - * @param string $action - * * @throws BadMethodCallException */ public function setAction($action) @@ -449,8 +377,6 @@ public function setAction($action) /** * Unsupported method. * - * @param string $method - * * @throws BadMethodCallException */ public function setMethod($method) @@ -471,8 +397,6 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler) /** * Unsupported method. * - * @param bool $initialize - * * @return $this * * @throws BadMethodCallException @@ -489,8 +413,6 @@ public function setAutoInitialize($initialize) /** * Unsupported method. * - * @param bool $inheritData - * * @throws BadMethodCallException */ public function setInheritData($inheritData) diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php index 4ce1d849a010a..d31e57799cd9e 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php @@ -18,6 +18,7 @@ use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\PropertyAccess\PropertyPath; +use Symfony\Component\PropertyAccess\PropertyPathInterface; /** * Adds property path support to a choice list factory. @@ -59,11 +60,9 @@ public function getDecoratedFactory() /** * {@inheritdoc} * - * @param iterable $choices The choices - * @param callable|string|PropertyPath|null $value The callable or path for - * generating the choice values + * @param mixed $value * - * @return ChoiceListInterface The choice list + * @return ChoiceListInterface */ public function createListFromChoices($choices, $value = null) { @@ -71,7 +70,7 @@ public function createListFromChoices($choices, $value = null) $value = new PropertyPath($value); } - if ($value instanceof PropertyPath) { + if ($value instanceof PropertyPathInterface) { $accessor = $this->propertyAccessor; $value = function ($choice) use ($accessor, $value) { // The callable may be invoked with a non-object/array value @@ -88,10 +87,9 @@ public function createListFromChoices($choices, $value = null) /** * {@inheritdoc} * - * @param callable|string|PropertyPath|null $value The callable or path for - * generating the choice values + * @param mixed $value * - * @return ChoiceListInterface The choice list + * @return ChoiceListInterface */ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null) { @@ -99,7 +97,7 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul $value = new PropertyPath($value); } - if ($value instanceof PropertyPath) { + if ($value instanceof PropertyPathInterface) { $accessor = $this->propertyAccessor; $value = function ($choice) use ($accessor, $value) { // The callable may be invoked with a non-object/array value @@ -116,13 +114,13 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul /** * {@inheritdoc} * - * @param array|callable|string|PropertyPath|null $preferredChoices The preferred choices - * @param callable|string|PropertyPath|null $label The callable or path generating the choice labels - * @param callable|string|PropertyPath|null $index The callable or path generating the view indices - * @param callable|string|PropertyPath|null $groupBy The callable or path generating the group names - * @param array|callable|string|PropertyPath|null $attr The callable or path generating the HTML attributes + * @param mixed $preferredChoices + * @param mixed $label + * @param mixed $index + * @param mixed $groupBy + * @param mixed $attr * - * @return ChoiceListView The choice list view + * @return ChoiceListView */ public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null) { @@ -132,7 +130,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = new PropertyPath($label); } - if ($label instanceof PropertyPath) { + if ($label instanceof PropertyPathInterface) { $label = function ($choice) use ($accessor, $label) { return $accessor->getValue($choice, $label); }; @@ -142,7 +140,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $preferredChoices = new PropertyPath($preferredChoices); } - if ($preferredChoices instanceof PropertyPath) { + if ($preferredChoices instanceof PropertyPathInterface) { $preferredChoices = function ($choice) use ($accessor, $preferredChoices) { try { return $accessor->getValue($choice, $preferredChoices); @@ -157,7 +155,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $index = new PropertyPath($index); } - if ($index instanceof PropertyPath) { + if ($index instanceof PropertyPathInterface) { $index = function ($choice) use ($accessor, $index) { return $accessor->getValue($choice, $index); }; @@ -167,7 +165,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $groupBy = new PropertyPath($groupBy); } - if ($groupBy instanceof PropertyPath) { + if ($groupBy instanceof PropertyPathInterface) { $groupBy = function ($choice) use ($accessor, $groupBy) { try { return $accessor->getValue($choice, $groupBy); @@ -182,7 +180,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $attr = new PropertyPath($attr); } - if ($attr instanceof PropertyPath) { + if ($attr instanceof PropertyPathInterface) { $attr = function ($choice) use ($accessor, $attr) { return $accessor->getValue($choice, $attr); }; diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index 66f198c669913..b0deef7f04e50 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -260,8 +260,16 @@ private static function resolveValidationGroups($groups, FormInterface $form) private static function getConstraintsInGroups($constraints, $group) { - return array_filter($constraints, static function (Constraint $constraint) use ($group) { - return \in_array($group, $constraint->groups, true); + $groups = (array) $group; + + return array_filter($constraints, static function (Constraint $constraint) use ($groups) { + foreach ($groups as $group) { + if (\in_array($group, $constraint->groups, true)) { + return true; + } + } + + return false; }); } } diff --git a/src/Symfony/Component/Form/SubmitButton.php b/src/Symfony/Component/Form/SubmitButton.php index a838542f975d8..08e1bf4c5c7ec 100644 --- a/src/Symfony/Component/Form/SubmitButton.php +++ b/src/Symfony/Component/Form/SubmitButton.php @@ -34,8 +34,8 @@ public function isClicked() /** * Submits data to the button. * - * @param string|null $submittedData The data - * @param bool $clearMissing Not used + * @param array|string|null $submittedData The data + * @param bool $clearMissing Not used * * @return $this * diff --git a/src/Symfony/Component/Form/Util/OptionsResolverWrapper.php b/src/Symfony/Component/Form/Util/OptionsResolverWrapper.php index fbf19ab638ae8..c8c4a870b17ec 100644 --- a/src/Symfony/Component/Form/Util/OptionsResolverWrapper.php +++ b/src/Symfony/Component/Form/Util/OptionsResolverWrapper.php @@ -67,6 +67,8 @@ public function addAllowedValues($option, $allowedValues): self } /** + * @param string|array $allowedTypes + * * @return $this */ public function setAllowedTypes($option, $allowedTypes): self @@ -81,6 +83,8 @@ public function setAllowedTypes($option, $allowedTypes): self } /** + * @param string|array $allowedTypes + * * @return $this */ public function addAllowedTypes($option, $allowedTypes): self diff --git a/src/Symfony/Component/Validator/Constraints/GroupSequence.php b/src/Symfony/Component/Validator/Constraints/GroupSequence.php index 569d2a0648381..30d8765e390f3 100644 --- a/src/Symfony/Component/Validator/Constraints/GroupSequence.php +++ b/src/Symfony/Component/Validator/Constraints/GroupSequence.php @@ -56,7 +56,7 @@ class GroupSequence /** * The groups in the sequence. * - * @var string[]|string[][]|GroupSequence[] + * @var array */ public $groups; @@ -79,7 +79,7 @@ class GroupSequence /** * Creates a new group sequence. * - * @param string[] $groups The groups in the sequence + * @param array $groups The groups in the sequence */ public function __construct(array $groups) { From f09bd17ba198c1eefbf0fddcf161ed4c981018e6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 10 Jul 2021 10:24:26 +0200 Subject: [PATCH 043/100] clean up remaining event mocks --- .../Tests/Templating/TimedPhpEngineTest.php | 26 +++------- .../GuardAuthenticationListenerTest.php | 10 +--- .../Tests/Firewall/RememberMeListenerTest.php | 50 ++++--------------- .../Security/Http/Tests/FirewallTest.php | 17 ++----- .../Stopwatch/Tests/StopwatchTest.php | 7 +-- 5 files changed, 21 insertions(+), 89 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php index 72e3fb0f78920..4951b46c45137 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php @@ -16,7 +16,6 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\Stopwatch\StopwatchEvent; use Symfony\Component\Templating\Loader\Loader; use Symfony\Component\Templating\Storage\StringStorage; use Symfony\Component\Templating\TemplateNameParserInterface; @@ -34,18 +33,15 @@ public function testThatRenderLogsTime() $globalVariables = $this->getGlobalVariables(); $loader = $this->getLoader($this->getStorage()); - $stopwatch = $this->getStopwatch(); - $stopwatchEvent = $this->getStopwatchEvent(); - - $stopwatch->expects($this->once()) - ->method('start') - ->with('template.php (index.php)', 'template') - ->willReturn($stopwatchEvent); - - $stopwatchEvent->expects($this->once())->method('stop'); + $stopwatch = new Stopwatch(); $engine = new TimedPhpEngine($templateNameParser, $container, $loader, $stopwatch, $globalVariables); $engine->render('index.php'); + + $sections = $stopwatch->getSections(); + + $this->assertCount(1, $sections); + $this->assertCount(1, reset($sections)->getEvents()); } private function getTemplateNameParser(): TemplateNameParserInterface @@ -83,14 +79,4 @@ private function getLoader($storage): Loader return $loader; } - - private function getStopwatchEvent(): StopwatchEvent - { - return $this->createMock(StopwatchEvent::class); - } - - private function getStopwatch(): Stopwatch - { - return $this->createMock(Stopwatch::class); - } } diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index b4dc224544d76..1ef0e20b46d3d 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\BadCredentialsException; @@ -322,14 +323,7 @@ protected function setUp(): void $this->guardAuthenticatorHandler = $this->createMock(GuardAuthenticatorHandler::class); $this->request = new Request([], [], [], [], [], []); - $this->event = $this->getMockBuilder(RequestEvent::class) - ->disableOriginalConstructor() - ->setMethods(['getRequest']) - ->getMock(); - $this->event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($this->request); + $this->event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->request, HttpKernelInterface::MASTER_REQUEST); $this->logger = $this->createMock(LoggerInterface::class); $this->rememberMeServices = $this->createMock(RememberMeServicesInterface::class); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index c6da58ce1f16a..81cf3ab353bf7 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -45,7 +45,7 @@ public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage() ->method('setToken') ; - $this->assertNull($listener($this->getGetResponseEvent())); + $this->assertNull($listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST))); } public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet() @@ -64,9 +64,7 @@ public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet() ->willReturn(null) ; - $event = $this->getGetResponseEvent(); - - $this->assertNull($listener($event)); + $this->assertNull($listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST))); } public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenticationManagerImplementation() @@ -99,9 +97,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti ->willThrowException($exception) ; - $event = $this->getGetResponseEvent($request); - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation() @@ -134,9 +130,7 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti ->willThrowException($exception) ; - $event = $this->getGetResponseEvent(); - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); } public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggersLoginFail() @@ -166,9 +160,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers ->method('authenticate') ; - $event = $this->getGetResponseEvent(); - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); } public function testOnCoreSecurity() @@ -200,9 +192,7 @@ public function testOnCoreSecurity() ->willReturn($token) ; - $event = $this->getGetResponseEvent(); - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); } public function testSessionStrategy() @@ -244,15 +234,13 @@ public function testSessionStrategy() $request = new Request(); $request->setSession($session); - $event = $this->getGetResponseEvent($request); - $sessionStrategy ->expects($this->once()) ->method('onAuthentication') ->willReturn(null) ; - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testSessionIsMigratedByDefault() @@ -298,9 +286,7 @@ public function testSessionIsMigratedByDefault() $request = new Request(); $request->setSession($session); - $event = $this->getGetResponseEvent($request); - - $listener($event); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); } public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherIsPresent() @@ -332,8 +318,6 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI ->willReturn($token) ; - $event = $this->getGetResponseEvent(); - $dispatcher ->expects($this->once()) ->method('dispatch') @@ -343,23 +327,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI ) ; - $listener($event); - } - - protected function getGetResponseEvent(Request $request = null): RequestEvent - { - $request = $request ?? new Request(); - - $event = $this->getMockBuilder(RequestEvent::class) - ->setConstructorArgs([$this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST]) - ->getMock(); - $event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($request) - ; - - return $event; + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); } protected function getListener($withDispatcher = false, $catchExceptions = true, $withSessionStrategy = false) diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php index 9f14c6de2eb80..1db12f4551cd4 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Http\Firewall; @@ -68,20 +69,8 @@ public function testOnKernelRequestStopsWhenThereIsAResponse() ->willReturn([[$first, $second], null, null]) ; - $event = $this->getMockBuilder(RequestEvent::class) - ->setMethods(['hasResponse']) - ->setConstructorArgs([ - $this->createMock(HttpKernelInterface::class), - $this->createMock(Request::class), - HttpKernelInterface::MASTER_REQUEST, - ]) - ->getMock() - ; - $event - ->expects($this->once()) - ->method('hasResponse') - ->willReturn(true) - ; + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST); + $event->setResponse(new Response()); $firewall = new Firewall($map, $this->createMock(EventDispatcherInterface::class)); $firewall->onKernelRequest($event); diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index 75d3bb5d5b0f0..d0bc1b0a7cd1f 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -71,12 +71,7 @@ public function testIsNotStartedEvent() $events = new \ReflectionProperty(Section::class, 'events'); $events->setAccessible(true); - $stopwatchMockEvent = $this->getMockBuilder(StopwatchEvent::class) - ->setConstructorArgs([microtime(true) * 1000]) - ->getMock() - ; - - $events->setValue(end($section), ['foo' => $stopwatchMockEvent]); + $events->setValue(end($section), ['foo' => new StopwatchEvent(microtime(true) * 1000)]); $this->assertFalse($stopwatch->isStarted('foo')); } From ceee81e33d71f60bdc34ec223e6f7c73e4f130f0 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 10 Jul 2021 14:16:00 +0200 Subject: [PATCH 044/100] do not render the same label id attribute twice --- .../views/Form/bootstrap_4_layout.html.twig | 2 +- .../Extension/AbstractBootstrap4LayoutTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig index 7db2a0dadd3e3..00ca8694c704a 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig @@ -122,7 +122,7 @@ <{{ element|default('div') }} class="custom-file"> {%- set type = type|default('file') -%} {{- block('form_widget_simple') -}} - {%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim }) -%} + {%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim })|filter((value, key) => key != 'id') -%}