diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php index 1b880e506476..1b6ca4d8939e 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php @@ -84,6 +84,6 @@ public function getEntitiesByIds($identifier, array $values) return $qb->andWhere($where) ->getQuery() ->setParameter($parameter, $values, $parameterType) - ->getResult(); + ->getResult() ?: []; } } diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index 9fa39a431ca4..a75b7b2cc46c 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -113,6 +113,8 @@ protected function doLeaveNode(Node $node, Environment $env) /** * {@inheritdoc} + * + * @return int */ public function getPriority() { diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php index 84d97df2fbee..3279c2cbccd0 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php @@ -103,6 +103,8 @@ protected function doLeaveNode(Node $node, Environment $env) /** * {@inheritdoc} + * + * @return int */ public function getPriority() { diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php index a921582dbabd..56427c762ffb 100644 --- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php +++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php @@ -106,9 +106,7 @@ protected function canBeExtracted($file) } /** - * @param string|array $directory - * - * @return array + * {@inheritdoc} */ protected function extractFromDirectory($directory) { diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 268643556dcb..5e302f0e3716 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2003,9 +2003,7 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co } /** - * Returns the base path for the XSD files. - * - * @return string The XSD base path + * {@inheritdoc} */ public function getXsdValidationBasePath() { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php index 678d573586f3..26d03ef9b99b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php @@ -36,6 +36,13 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load(__DIR__.\DIRECTORY_SEPARATOR.'config.yml'); } + public function setAnnotatedClassCache(array $annotatedClasses) + { + $annotatedClasses = array_diff($annotatedClasses, ['Symfony\Bundle\WebProfilerBundle\Controller\ExceptionController', 'Symfony\Bundle\TwigBundle\Controller\ExceptionController']); + + parent::setAnnotatedClassCache($annotatedClasses); + } + protected function build(ContainerBuilder $container) { $container->register('logger', NullLogger::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php index 7ee42cdd17a3..35c2e63b7e04 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php @@ -24,16 +24,16 @@ public function testProfilerIsDisabled($insulate) } $client->request('GET', '/profiler'); - $this->assertFalse($client->getProfile()); + $this->assertNull($client->getProfile()); // enable the profiler for the next request $client->enableProfiler(); - $this->assertFalse($client->getProfile()); + $this->assertNull($client->getProfile()); $client->request('GET', '/profiler'); $this->assertIsObject($client->getProfile()); $client->request('GET', '/profiler'); - $this->assertFalse($client->getProfile()); + $this->assertNull($client->getProfile()); } public function getConfigs() diff --git a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php index 0d122efe7fd8..29fa33b3f32a 100644 --- a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php +++ b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php @@ -259,7 +259,7 @@ public function getUser() /** * Gets the roles of the user. * - * @return array The roles + * @return array|Data */ public function getRoles() { @@ -269,7 +269,7 @@ public function getRoles() /** * Gets the inherited roles of the user. * - * @return array The inherited roles + * @return array|Data */ public function getInheritedRoles() { @@ -297,16 +297,25 @@ public function isAuthenticated() return $this->data['authenticated']; } + /** + * @return bool + */ public function isImpersonated() { return $this->data['impersonated']; } + /** + * @return string|null + */ public function getImpersonatorUser() { return $this->data['impersonator_user']; } + /** + * @return string|null + */ public function getImpersonationExitPath() { return $this->data['impersonation_exit_path']; @@ -315,7 +324,7 @@ public function getImpersonationExitPath() /** * Get the class name of the security token. * - * @return string The token + * @return string|Data|null The token */ public function getTokenClass() { @@ -325,7 +334,7 @@ public function getTokenClass() /** * Get the full security token class as Data object. * - * @return Data + * @return Data|null */ public function getToken() { @@ -335,7 +344,7 @@ public function getToken() /** * Get the logout URL. * - * @return string The logout URL + * @return string|null The logout URL */ public function getLogoutUrl() { @@ -345,7 +354,7 @@ public function getLogoutUrl() /** * Returns the FQCN of the security voters enabled in the application. * - * @return string[] + * @return string[]|Data */ public function getVoters() { @@ -365,7 +374,7 @@ public function getVoterStrategy() /** * Returns the log of the security decisions made by the access decision manager. * - * @return array + * @return array|Data */ public function getAccessDecisionLog() { @@ -375,13 +384,16 @@ public function getAccessDecisionLog() /** * Returns the configuration of the current firewall context. * - * @return array + * @return array|Data */ public function getFirewall() { return $this->data['firewall']; } + /** + * @return array|Data + */ public function getListeners() { return $this->data['listeners']; diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php index 3f7a51598352..5e07c6303f5a 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php @@ -130,9 +130,9 @@ abstract protected function getListenerId(); * @param ContainerBuilder $container * @param string $id * @param array $config - * @param string $defaultEntryPointId + * @param string|null $defaultEntryPointId * - * @return string the entry point id + * @return string|null the entry point id */ protected function createEntryPoint($container, $id, $config, $defaultEntryPointId) { diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SecurityFactoryInterface.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SecurityFactoryInterface.php index 027fe6586896..533e8d0cfce1 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SecurityFactoryInterface.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SecurityFactoryInterface.php @@ -24,10 +24,10 @@ interface SecurityFactoryInterface /** * Configures the container services required to use the authentication listener. * - * @param string $id The unique id of the firewall - * @param array $config The options array for the listener - * @param string $userProvider The service id of the user provider - * @param string $defaultEntryPoint + * @param string $id The unique id of the firewall + * @param array $config The options array for the listener + * @param string $userProvider The service id of the user provider + * @param string|null $defaultEntryPoint * * @return array containing three values: * - the provider id diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 5930e4619a4e..2a38636ac8d2 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -787,9 +787,7 @@ public function addUserProviderFactory(UserProviderFactoryInterface $factory) } /** - * Returns the base path for the XSD files. - * - * @return string The XSD base path + * {@inheritdoc} */ public function getXsdValidationBasePath() { diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index b15516d465c1..7f3233ad4325 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -207,9 +207,7 @@ private function normalizeBundleName(string $name) } /** - * Returns the base path for the XSD files. - * - * @return string The XSD base path + * {@inheritdoc} */ public function getXsdValidationBasePath() { diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php index 4994a5f2ecd0..05aa911354df 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php @@ -61,9 +61,7 @@ public function load(array $configs, ContainerBuilder $container) } /** - * Returns the base path for the XSD files. - * - * @return string The XSD base path + * {@inheritdoc} */ public function getXsdValidationBasePath() { diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 6ab9bd3b6be3..16d098322b40 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -151,9 +151,9 @@ public function setServerParameter($key, $value) * Gets single server parameter for specified key. * * @param string $key A key of the parameter to get - * @param string $default A default value when key is undefined + * @param mixed $default A default value when key is undefined * - * @return string A value of the parameter + * @return mixed A value of the parameter */ public function getServerParameter($key, $default = '') { diff --git a/src/Symfony/Component/BrowserKit/Request.php b/src/Symfony/Component/BrowserKit/Request.php index c1e7ba4ce8be..4dd0bc406f8c 100644 --- a/src/Symfony/Component/BrowserKit/Request.php +++ b/src/Symfony/Component/BrowserKit/Request.php @@ -107,7 +107,7 @@ public function getServer() /** * Gets the request raw body data. * - * @return string The request raw body data + * @return string|null The request raw body data */ public function getContent() { diff --git a/src/Symfony/Component/Cache/DoctrineProvider.php b/src/Symfony/Component/Cache/DoctrineProvider.php index ee3102617e22..d7e0bca927d6 100644 --- a/src/Symfony/Component/Cache/DoctrineProvider.php +++ b/src/Symfony/Component/Cache/DoctrineProvider.php @@ -99,7 +99,7 @@ protected function doDelete($id) */ protected function doFlush() { - $this->pool->clear(); + return $this->pool->clear(); } /** @@ -109,5 +109,6 @@ protected function doFlush() */ protected function doGetStats() { + return null; } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php index 99f8f85c5a5c..724aa9451cbc 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php @@ -40,6 +40,10 @@ public function testLongKeyVersioning() ->setConstructorArgs([str_repeat('-', 26)]) ->getMock(); + $cache + ->method('doFetch') + ->willReturn(['2:']); + $reflectionClass = new \ReflectionClass(AbstractAdapter::class); $reflectionMethod = $reflectionClass->getMethod('getId'); @@ -56,7 +60,7 @@ public function testLongKeyVersioning() $reflectionProperty->setValue($cache, true); // Versioning enabled - $this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); + $this->assertEquals('--------------------------:2:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)]))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)]))); diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index a063978ef14f..3b2ace70645f 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -38,17 +38,13 @@ public function setNormalizeKeys($normalizeKeys) } /** - * Normalizes keys between the different configuration formats. + * {@inheritdoc} * * Namely, you mostly have foo_bar in YAML while you have foo-bar in XML. * After running this method, all keys are normalized to foo_bar. * * If you have a mixed key like foo-bar_moo, it will not be altered. * The key will also not be altered if the target key already exists. - * - * @param mixed $value - * - * @return array The value with normalized keys */ protected function preNormalize($value) { diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index e0a12f1fe275..076d175807c7 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -97,21 +97,37 @@ public static function resetPlaceholders(): void self::$placeholders = []; } + /** + * @param string $key + */ public function setAttribute($key, $value) { $this->attributes[$key] = $value; } + /** + * @param string $key + * + * @return mixed + */ public function getAttribute($key, $default = null) { return isset($this->attributes[$key]) ? $this->attributes[$key] : $default; } + /** + * @param string $key + * + * @return bool + */ public function hasAttribute($key) { return isset($this->attributes[$key]); } + /** + * @return array + */ public function getAttributes() { return $this->attributes; @@ -122,6 +138,9 @@ public function setAttributes(array $attributes) $this->attributes = $attributes; } + /** + * @param string $key + */ public function removeAttribute($key) { unset($this->attributes[$key]); @@ -140,7 +159,7 @@ public function setInfo($info) /** * Returns info message. * - * @return string The info text + * @return string|null The info text */ public function getInfo() { @@ -160,7 +179,7 @@ public function setExample($example) /** * Retrieves the example configuration for this node. * - * @return string|array The example + * @return string|array|null The example */ public function getExample() { diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index dd6ccd94a358..72d8fa0072dc 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -78,7 +78,7 @@ public function setKeyAttribute($attribute, $remove = true) /** * Retrieves the name of the attribute which value should be used as key. * - * @return string The name of the attribute + * @return string|null The name of the attribute */ public function getKeyAttribute() { diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index c32bef9d94f8..6688d93e31a2 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -152,7 +152,7 @@ public static function loadFile($file, $schemaOrCallable = null) * @param \DOMElement $element A \DOMElement instance * @param bool $checkPrefix Check prefix in an element or an attribute name * - * @return array A PHP array + * @return mixed */ public static function convertDomElementToArray(\DOMElement $element, $checkPrefix = true) { diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 9adfc46e2d7b..cb498e925c7d 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -20,7 +20,6 @@ use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\Exception\CommandNotFoundException; use Symfony\Component\Console\Exception\ExceptionInterface; -use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Exception\NamespaceNotFoundException; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\DebugFormatterHelper; @@ -485,13 +484,8 @@ public function add(Command $command) return null; } - if (null === $command->getDefinition()) { - throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command))); - } - - if (!$command->getName()) { - throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($command))); - } + // Will throw if the command is not correctly initialized. + $command->getDefinition(); $this->commands[$command->getName()] = $command; @@ -976,7 +970,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI /** * Gets the name of the command based on input. * - * @return string The command name + * @return string|null */ protected function getCommandName(InputInterface $input) { diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 1420eda667fa..61dcf4f16c50 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -40,8 +40,8 @@ class Command private $aliases = []; private $definition; private $hidden = false; - private $help; - private $description; + private $help = ''; + private $description = ''; private $ignoreValidationErrors = false; private $applicationDefinitionMerged = false; private $applicationDefinitionMergedWithArgs = false; @@ -105,7 +105,7 @@ public function setHelperSet(HelperSet $helperSet) /** * Gets the helper set. * - * @return HelperSet A HelperSet instance + * @return HelperSet|null A HelperSet instance */ public function getHelperSet() { @@ -115,7 +115,7 @@ public function getHelperSet() /** * Gets the application instance for this command. * - * @return Application An Application instance + * @return Application|null An Application instance */ public function getApplication() { @@ -339,6 +339,10 @@ public function setDefinition($definition) */ public function getDefinition() { + if (null === $this->definition) { + throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($this))); + } + return $this->definition; } @@ -445,6 +449,10 @@ public function setProcessTitle($title) */ public function getName() { + if (!$this->name) { + throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this))); + } + return $this->name; } diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 6d02c4af0944..c28e0bf55b8e 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -260,7 +260,7 @@ public function setNormalizer(callable $normalizer) * * The normalizer can ba a callable (a string), a closure or a class implementing __invoke. * - * @return callable + * @return callable|null */ public function getNormalizer() { diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 356eb9a385d5..e873072ffe49 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -371,8 +371,6 @@ public static function underscore($id) /** * Creates a service by requiring its factory file. - * - * @return object The service created by the file */ protected function load($file) { diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index d41895858551..06636b299947 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -814,7 +814,7 @@ public function setConfigurator($configurator) /** * Gets the configurator to call after the service is fully initialized. * - * @return callable|null The PHP callable to call + * @return callable|array|null */ public function getConfigurator() { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php b/src/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php index e8c3e4898e20..8abc19250f70 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/DumperInterface.php @@ -21,7 +21,7 @@ interface DumperInterface /** * Dumps the service container. * - * @return string The representation of the service container + * @return string|array The representation of the service container */ public function dump(array $options = []); } diff --git a/src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php b/src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php index 18de31272f32..6a7a2cf02381 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php +++ b/src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php @@ -37,7 +37,7 @@ public function getNamespace(); /** * Returns the base path for the XSD files. * - * @return string The XSD base path + * @return string|false */ public function getXsdValidationBasePath(); diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index effff780bc22..50b90a81aaba 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -706,7 +706,7 @@ private function loadFromExtensions(\DOMDocument $xml) * * @param \DOMElement $element A \DOMElement instance * - * @return array A PHP array + * @return mixed */ public static function convertDomElementToArray(\DOMElement $element) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 988dbf88cca6..48887c3756d2 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -193,7 +193,7 @@ public function resolveValue($value, array $resolving = []) * @param string $value The string to resolve * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) * - * @return string The resolved string + * @return mixed The resolved string * * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist * @throws ParameterCircularReferenceException if a circular reference if detected diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php index 4dee6add0191..c9fb65ddeecd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php @@ -25,7 +25,7 @@ public function load(array $configs, ContainerBuilder $configuration) return $configuration; } - public function getXsdValidationBasePath(): string + public function getXsdValidationBasePath() { return false; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectWithXsdExtension.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectWithXsdExtension.php index f457abd2a379..f986cccec962 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectWithXsdExtension.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectWithXsdExtension.php @@ -2,7 +2,7 @@ class ProjectWithXsdExtension extends ProjectExtension { - public function getXsdValidationBasePath(): string + public function getXsdValidationBasePath() { return __DIR__.'/schema'; } diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 64546693524f..169b056e4a57 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -44,7 +44,7 @@ class Crawler implements \Countable, \IteratorAggregate private $document; /** - * @var \DOMElement[] + * @var \DOMNode[] */ private $nodes = []; @@ -61,9 +61,7 @@ class Crawler implements \Countable, \IteratorAggregate private $html5Parser; /** - * @param mixed $node A Node to use as the base for the crawling - * @param string $uri The current URI - * @param string $baseHref The base href value + * @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A Node to use as the base for the crawling */ public function __construct($node = null, string $uri = null, string $baseHref = null) { @@ -109,7 +107,7 @@ public function clear() * This method uses the appropriate specialized add*() method based * on the type of the argument. * - * @param \DOMNodeList|\DOMNode|array|string|null $node A node + * @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A node * * @throws \InvalidArgumentException when node is not the expected type */ @@ -1112,7 +1110,7 @@ private function relativize(string $xpath): string /** * @param int $position * - * @return \DOMElement|null + * @return \DOMNode|null */ public function getNode($position) { @@ -1128,7 +1126,7 @@ public function count() } /** - * @return \ArrayIterator|\DOMElement[] + * @return \ArrayIterator|\DOMNode[] */ public function getIterator() { @@ -1246,7 +1244,7 @@ private function findNamespacePrefixes(string $xpath): array /** * Creates a crawler for some subnodes. * - * @param \DOMElement|\DOMElement[]|\DOMNodeList|null $nodes + * @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $nodes * * @return static */ @@ -1262,7 +1260,7 @@ private function createSubCrawler($nodes) } /** - * @throws \RuntimeException If the CssSelector Component is not available + * @throws \LogicException If the CssSelector Component is not available */ private function createCssSelectorConverter(): CssSelectorConverter { diff --git a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php index 09b58f00ed43..cc1a4b93606a 100644 --- a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php +++ b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php @@ -51,7 +51,7 @@ public static function decorate(?ContractsEventDispatcherInterface $dispatcher): * * @param string|null $eventName * - * @return Event + * @return object */ public function dispatch($event/*, string $eventName = null*/) { diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 57aeed8f690b..64687bbb4bb7 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -27,7 +27,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface /** * @var bool */ - private $disabled; + private $disabled = false; /** * @var ResolvedFormTypeInterface diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php b/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php index b05dcc018dc3..ba2f8dfe0e57 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php @@ -26,6 +26,7 @@ class ButtonType extends BaseType implements ButtonTypeInterface */ public function getParent() { + return null; } /** diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php index a2bec3694998..14302617454d 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php @@ -204,6 +204,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { + return null; } /** diff --git a/src/Symfony/Component/Form/FormError.php b/src/Symfony/Component/Form/FormError.php index 63a40ca5ac46..10ff0961a600 100644 --- a/src/Symfony/Component/Form/FormError.php +++ b/src/Symfony/Component/Form/FormError.php @@ -130,7 +130,7 @@ public function setOrigin(FormInterface $origin) /** * Returns the form that caused this error. * - * @return FormInterface The form that caused this error + * @return FormInterface|null The form that caused this error */ public function getOrigin() { diff --git a/src/Symfony/Component/Form/FormInterface.php b/src/Symfony/Component/Form/FormInterface.php index 9be500818274..c16d7c54747a 100644 --- a/src/Symfony/Component/Form/FormInterface.php +++ b/src/Symfony/Component/Form/FormInterface.php @@ -31,7 +31,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable * @throws Exception\LogicException when trying to set a parent for a form with * an empty name */ - public function setParent(self $parent = null); + public function setParent(FormInterface $parent = null); /** * Returns the parent form. diff --git a/src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php b/src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php index 07dd9e0d5559..46bd8b7e576d 100644 --- a/src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php +++ b/src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php @@ -13,6 +13,7 @@ use Symfony\Component\Form\Extension\Validator\ValidatorExtension; use Symfony\Component\Form\Test\TypeTestCase; +use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -37,9 +38,9 @@ protected function getValidatorExtension() } $this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock(); - $metadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->setMethods(['addPropertyConstraint'])->getMock(); + $metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->setMethods(['addPropertyConstraint'])->getMock(); $this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata)); - $this->validator->expects($this->any())->method('validate')->will($this->returnValue([])); + $this->validator->expects($this->any())->method('validate')->will($this->returnValue(new ConstraintViolationList())); return new ValidatorExtension($this->validator); } diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index 714cc71dc894..61455a51330d 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php @@ -346,7 +346,7 @@ public function getPostMaxSizeFixtures() [1024, '1K', false], [null, '1K', false], [1024, '', false], - [1024, 0, false], + [1024, '0', false], ]; } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index dcddc0298d6f..39d54c536a51 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -13,7 +13,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator; +use Symfony\Component\Form\ChoiceList\View\ChoiceListView; /** * @author Bernhard Schussek @@ -38,7 +40,7 @@ protected function setUp(): void public function testCreateFromChoicesEmpty() { - $list = new \stdClass(); + $list = new ArrayChoiceList([]); $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') @@ -54,7 +56,7 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray() // The top-most traversable is converted to an array $choices1 = new \ArrayIterator(['A' => 'a']); $choices2 = ['A' => 'a']; - $list = new \stdClass(); + $list = new ArrayChoiceList([]); $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') @@ -69,8 +71,8 @@ public function testCreateFromChoicesGroupedChoices() { $choices1 = ['key' => ['A' => 'a']]; $choices2 = ['A' => 'a']; - $list1 = new \stdClass(); - $list2 = new \stdClass(); + $list1 = new ArrayChoiceList([]); + $list2 = new ArrayChoiceList([]); $this->decoratedFactory->expects($this->at(0)) ->method('createListFromChoices') @@ -92,7 +94,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2) { $choices1 = [$choice1]; $choices2 = [$choice2]; - $list = new \stdClass(); + $list = new ArrayChoiceList([]); $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') @@ -110,8 +112,8 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2) { $choices1 = [$choice1]; $choices2 = [$choice2]; - $list1 = new \stdClass(); - $list2 = new \stdClass(); + $list1 = new ArrayChoiceList([]); + $list2 = new ArrayChoiceList([]); $this->decoratedFactory->expects($this->at(0)) ->method('createListFromChoices') @@ -129,7 +131,7 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2) public function testCreateFromChoicesSameValueClosure() { $choices = [1]; - $list = new \stdClass(); + $list = new ArrayChoiceList([]); $closure = function () {}; $this->decoratedFactory->expects($this->once()) @@ -144,8 +146,8 @@ public function testCreateFromChoicesSameValueClosure() public function testCreateFromChoicesDifferentValueClosure() { $choices = [1]; - $list1 = new \stdClass(); - $list2 = new \stdClass(); + $list1 = new ArrayChoiceList([]); + $list2 = new ArrayChoiceList([]); $closure1 = function () {}; $closure2 = function () {}; @@ -165,7 +167,7 @@ public function testCreateFromChoicesDifferentValueClosure() public function testCreateFromLoaderSameLoader() { $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); - $list = new \stdClass(); + $list = new ArrayChoiceList([]); $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') @@ -180,8 +182,8 @@ public function testCreateFromLoaderDifferentLoader() { $loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); - $list1 = new \stdClass(); - $list2 = new \stdClass(); + $list1 = new ArrayChoiceList([]); + $list2 = new ArrayChoiceList([]); $this->decoratedFactory->expects($this->at(0)) ->method('createListFromLoader') @@ -199,7 +201,7 @@ public function testCreateFromLoaderDifferentLoader() public function testCreateFromLoaderSameValueClosure() { $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); - $list = new \stdClass(); + $list = new ArrayChoiceList([]); $closure = function () {}; $this->decoratedFactory->expects($this->once()) @@ -214,8 +216,8 @@ public function testCreateFromLoaderSameValueClosure() public function testCreateFromLoaderDifferentValueClosure() { $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); - $list1 = new \stdClass(); - $list2 = new \stdClass(); + $list1 = new ArrayChoiceList([]); + $list2 = new ArrayChoiceList([]); $closure1 = function () {}; $closure2 = function () {}; @@ -236,7 +238,7 @@ public function testCreateViewSamePreferredChoices() { $preferred = ['a']; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view = new \stdClass(); + $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -252,8 +254,8 @@ public function testCreateViewDifferentPreferredChoices() $preferred1 = ['a']; $preferred2 = ['b']; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view1 = new \stdClass(); - $view2 = new \stdClass(); + $view1 = new ChoiceListView(); + $view2 = new ChoiceListView(); $this->decoratedFactory->expects($this->at(0)) ->method('createView') @@ -272,7 +274,7 @@ public function testCreateViewSamePreferredChoicesClosure() { $preferred = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view = new \stdClass(); + $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -288,8 +290,8 @@ public function testCreateViewDifferentPreferredChoicesClosure() $preferred1 = function () {}; $preferred2 = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view1 = new \stdClass(); - $view2 = new \stdClass(); + $view1 = new ChoiceListView(); + $view2 = new ChoiceListView(); $this->decoratedFactory->expects($this->at(0)) ->method('createView') @@ -308,7 +310,7 @@ public function testCreateViewSameLabelClosure() { $labels = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view = new \stdClass(); + $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -324,8 +326,8 @@ public function testCreateViewDifferentLabelClosure() $labels1 = function () {}; $labels2 = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view1 = new \stdClass(); - $view2 = new \stdClass(); + $view1 = new ChoiceListView(); + $view2 = new ChoiceListView(); $this->decoratedFactory->expects($this->at(0)) ->method('createView') @@ -344,7 +346,7 @@ public function testCreateViewSameIndexClosure() { $index = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view = new \stdClass(); + $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -360,8 +362,8 @@ public function testCreateViewDifferentIndexClosure() $index1 = function () {}; $index2 = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view1 = new \stdClass(); - $view2 = new \stdClass(); + $view1 = new ChoiceListView(); + $view2 = new ChoiceListView(); $this->decoratedFactory->expects($this->at(0)) ->method('createView') @@ -380,7 +382,7 @@ public function testCreateViewSameGroupByClosure() { $groupBy = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view = new \stdClass(); + $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -396,8 +398,8 @@ public function testCreateViewDifferentGroupByClosure() $groupBy1 = function () {}; $groupBy2 = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view1 = new \stdClass(); - $view2 = new \stdClass(); + $view1 = new ChoiceListView(); + $view2 = new ChoiceListView(); $this->decoratedFactory->expects($this->at(0)) ->method('createView') @@ -416,7 +418,7 @@ public function testCreateViewSameAttributes() { $attr = ['class' => 'foobar']; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view = new \stdClass(); + $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -432,8 +434,8 @@ public function testCreateViewDifferentAttributes() $attr1 = ['class' => 'foobar1']; $attr2 = ['class' => 'foobar2']; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view1 = new \stdClass(); - $view2 = new \stdClass(); + $view1 = new ChoiceListView(); + $view2 = new ChoiceListView(); $this->decoratedFactory->expects($this->at(0)) ->method('createView') @@ -452,7 +454,7 @@ public function testCreateViewSameAttributesClosure() { $attr = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view = new \stdClass(); + $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -468,8 +470,8 @@ public function testCreateViewDifferentAttributesClosure() $attr1 = function () {}; $attr2 = function () {}; $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $view1 = new \stdClass(); - $view2 = new \stdClass(); + $view1 = new ChoiceListView(); + $view2 = new ChoiceListView(); $this->decoratedFactory->expects($this->at(0)) ->method('createView') diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 87b8c87fc58e..df3a6bb7051d 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -13,7 +13,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator; +use Symfony\Component\Form\ChoiceList\View\ChoiceListView; use Symfony\Component\PropertyAccess\PropertyPath; /** @@ -45,10 +47,10 @@ public function testCreateFromChoicesPropertyPath() ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($choices, $callback) { - return array_map($callback, $choices); + return new ArrayChoiceList(array_map($callback, $choices)); }); - $this->assertSame(['value'], $this->factory->createListFromChoices($choices, 'property')); + $this->assertSame(['value' => 'value'], $this->factory->createListFromChoices($choices, 'property')->getChoices()); } public function testCreateFromChoicesPropertyPathInstance() @@ -59,10 +61,10 @@ public function testCreateFromChoicesPropertyPathInstance() ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($choices, $callback) { - return array_map($callback, $choices); + return new ArrayChoiceList(array_map($callback, $choices)); }); - $this->assertSame(['value'], $this->factory->createListFromChoices($choices, new PropertyPath('property'))); + $this->assertSame(['value' => 'value'], $this->factory->createListFromChoices($choices, new PropertyPath('property'))->getChoices()); } public function testCreateFromLoaderPropertyPath() @@ -73,10 +75,10 @@ public function testCreateFromLoaderPropertyPath() ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($loader, $callback) { - return $callback((object) ['property' => 'value']); + return new ArrayChoiceList((array) $callback((object) ['property' => 'value'])); }); - $this->assertSame('value', $this->factory->createListFromLoader($loader, 'property')); + $this->assertSame(['value' => 'value'], $this->factory->createListFromLoader($loader, 'property')->getChoices()); } // https://github.com/symfony/symfony/issues/5494 @@ -88,10 +90,10 @@ public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable() ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($choices, $callback) { - return array_map($callback, $choices); + return new ArrayChoiceList(array_map($callback, $choices)); }); - $this->assertSame([null], $this->factory->createListFromChoices($choices, 'property')); + $this->assertSame([null], $this->factory->createListFromChoices($choices, 'property')->getChoices()); } // https://github.com/symfony/symfony/issues/5494 @@ -103,10 +105,10 @@ public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadabl ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($loader, $callback) { - return $callback(null); + return new ArrayChoiceList((array) $callback(null)); }); - $this->assertNull($this->factory->createListFromLoader($loader, 'property')); + $this->assertSame([], $this->factory->createListFromLoader($loader, 'property')->getChoices()); } public function testCreateFromLoaderPropertyPathInstance() @@ -117,10 +119,10 @@ public function testCreateFromLoaderPropertyPathInstance() ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($loader, $callback) { - return $callback((object) ['property' => 'value']); + return new ArrayChoiceList((array) $callback((object) ['property' => 'value'])); }); - $this->assertSame('value', $this->factory->createListFromLoader($loader, new PropertyPath('property'))); + $this->assertSame(['value' => 'value'], $this->factory->createListFromLoader($loader, new PropertyPath('property'))->getChoices()); } public function testCreateViewPreferredChoicesAsPropertyPath() @@ -131,13 +133,10 @@ public function testCreateViewPreferredChoicesAsPropertyPath() ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred) { - return $preferred((object) ['property' => true]); + return new ChoiceListView((array) $preferred((object) ['property' => true])); }); - $this->assertTrue($this->factory->createView( - $list, - 'property' - )); + $this->assertSame([true], $this->factory->createView($list, 'property')->choices); } public function testCreateViewPreferredChoicesAsPropertyPathInstance() @@ -148,13 +147,10 @@ public function testCreateViewPreferredChoicesAsPropertyPathInstance() ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred) { - return $preferred((object) ['property' => true]); + return new ChoiceListView((array) $preferred((object) ['property' => true])); }); - $this->assertTrue($this->factory->createView( - $list, - new PropertyPath('property') - )); + $this->assertSame([true], $this->factory->createView($list, 'property')->choices); } // https://github.com/symfony/symfony/issues/5494 @@ -166,13 +162,10 @@ public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred) { - return $preferred((object) ['category' => null]); + return new ChoiceListView((array) $preferred((object) ['category' => null])); }); - $this->assertFalse($this->factory->createView( - $list, - 'category.preferred' - )); + $this->assertSame([false], $this->factory->createView($list, 'category.preferred')->choices); } public function testCreateViewLabelsAsPropertyPath() @@ -183,14 +176,10 @@ public function testCreateViewLabelsAsPropertyPath() ->method('createView') ->with($list, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label) { - return $label((object) ['property' => 'label']); + return new ChoiceListView((array) $label((object) ['property' => 'label'])); }); - $this->assertSame('label', $this->factory->createView( - $list, - null, // preferred choices - 'property' - )); + $this->assertSame(['label'], $this->factory->createView($list, null, 'property')->choices); } public function testCreateViewLabelsAsPropertyPathInstance() @@ -201,14 +190,10 @@ public function testCreateViewLabelsAsPropertyPathInstance() ->method('createView') ->with($list, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label) { - return $label((object) ['property' => 'label']); + return new ChoiceListView((array) $label((object) ['property' => 'label'])); }); - $this->assertSame('label', $this->factory->createView( - $list, - null, // preferred choices - new PropertyPath('property') - )); + $this->assertSame(['label'], $this->factory->createView($list, null, new PropertyPath('property'))->choices); } public function testCreateViewIndicesAsPropertyPath() @@ -219,15 +204,10 @@ public function testCreateViewIndicesAsPropertyPath() ->method('createView') ->with($list, null, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label, $index) { - return $index((object) ['property' => 'index']); + return new ChoiceListView((array) $index((object) ['property' => 'index'])); }); - $this->assertSame('index', $this->factory->createView( - $list, - null, // preferred choices - null, // label - 'property' - )); + $this->assertSame(['index'], $this->factory->createView($list, null, null, 'property')->choices); } public function testCreateViewIndicesAsPropertyPathInstance() @@ -238,15 +218,10 @@ public function testCreateViewIndicesAsPropertyPathInstance() ->method('createView') ->with($list, null, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label, $index) { - return $index((object) ['property' => 'index']); + return new ChoiceListView((array) $index((object) ['property' => 'index'])); }); - $this->assertSame('index', $this->factory->createView( - $list, - null, // preferred choices - null, // label - new PropertyPath('property') - )); + $this->assertSame(['index'], $this->factory->createView($list, null, null, new PropertyPath('property'))->choices); } public function testCreateViewGroupsAsPropertyPath() @@ -257,16 +232,10 @@ public function testCreateViewGroupsAsPropertyPath() ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { - return $groupBy((object) ['property' => 'group']); + return new ChoiceListView((array) $groupBy((object) ['property' => 'group'])); }); - $this->assertSame('group', $this->factory->createView( - $list, - null, // preferred choices - null, // label - null, // index - 'property' - )); + $this->assertSame(['group'], $this->factory->createView($list, null, null, null, 'property')->choices); } public function testCreateViewGroupsAsPropertyPathInstance() @@ -277,16 +246,10 @@ public function testCreateViewGroupsAsPropertyPathInstance() ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { - return $groupBy((object) ['property' => 'group']); + return new ChoiceListView((array) $groupBy((object) ['property' => 'group'])); }); - $this->assertSame('group', $this->factory->createView( - $list, - null, // preferred choices - null, // label - null, // index - new PropertyPath('property') - )); + $this->assertSame(['group'], $this->factory->createView($list, null, null, null, new PropertyPath('property'))->choices); } // https://github.com/symfony/symfony/issues/5494 @@ -298,16 +261,10 @@ public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable() ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { - return $groupBy((object) ['group' => null]); + return new ChoiceListView((array) $groupBy((object) ['group' => null])); }); - $this->assertNull($this->factory->createView( - $list, - null, // preferred choices - null, // label - null, // index - 'group.name' - )); + $this->assertSame([], $this->factory->createView($list, null, null, null, 'group.name')->choices); } public function testCreateViewAttrAsPropertyPath() @@ -318,17 +275,10 @@ public function testCreateViewAttrAsPropertyPath() ->method('createView') ->with($list, null, null, null, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { - return $attr((object) ['property' => 'attr']); + return new ChoiceListView((array) $attr((object) ['property' => 'attr'])); }); - $this->assertSame('attr', $this->factory->createView( - $list, - null, // preferred choices - null, // label - null, // index - null, // groups - 'property' - )); + $this->assertSame(['attr'], $this->factory->createView($list, null, null, null, null, 'property')->choices); } public function testCreateViewAttrAsPropertyPathInstance() @@ -339,16 +289,9 @@ public function testCreateViewAttrAsPropertyPathInstance() ->method('createView') ->with($list, null, null, null, null, $this->isInstanceOf('\Closure')) ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { - return $attr((object) ['property' => 'attr']); + return new ChoiceListView((array) $attr((object) ['property' => 'attr'])); }); - $this->assertSame('attr', $this->factory->createView( - $list, - null, // preferred choices - null, // label - null, // index - null, // groups - new PropertyPath('property') - )); + $this->assertSame(['attr'], $this->factory->createView($list, null, null, null, null, new PropertyPath('property'))->choices); } } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php index 0e822d50ee43..50403931bebc 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php @@ -55,10 +55,10 @@ public function testGetChoiceLoadersLoadsLoadedListOnFirstCall() // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getChoices') - ->willReturn('RESULT'); + ->willReturn(['RESULT']); - $this->assertSame('RESULT', $this->list->getChoices()); - $this->assertSame('RESULT', $this->list->getChoices()); + $this->assertSame(['RESULT'], $this->list->getChoices()); + $this->assertSame(['RESULT'], $this->list->getChoices()); } public function testGetValuesLoadsLoadedListOnFirstCall() @@ -71,10 +71,10 @@ public function testGetValuesLoadsLoadedListOnFirstCall() // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getValues') - ->willReturn('RESULT'); + ->willReturn(['RESULT']); - $this->assertSame('RESULT', $this->list->getValues()); - $this->assertSame('RESULT', $this->list->getValues()); + $this->assertSame(['RESULT'], $this->list->getValues()); + $this->assertSame(['RESULT'], $this->list->getValues()); } public function testGetStructuredValuesLoadsLoadedListOnFirstCall() @@ -87,10 +87,10 @@ public function testGetStructuredValuesLoadsLoadedListOnFirstCall() // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getStructuredValues') - ->willReturn('RESULT'); + ->willReturn(['RESULT']); - $this->assertSame('RESULT', $this->list->getStructuredValues()); - $this->assertSame('RESULT', $this->list->getStructuredValues()); + $this->assertSame(['RESULT'], $this->list->getStructuredValues()); + $this->assertSame(['RESULT'], $this->list->getStructuredValues()); } public function testGetOriginalKeysLoadsLoadedListOnFirstCall() @@ -103,10 +103,10 @@ public function testGetOriginalKeysLoadsLoadedListOnFirstCall() // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getOriginalKeys') - ->willReturn('RESULT'); + ->willReturn(['RESULT']); - $this->assertSame('RESULT', $this->list->getOriginalKeys()); - $this->assertSame('RESULT', $this->list->getOriginalKeys()); + $this->assertSame(['RESULT'], $this->list->getOriginalKeys()); + $this->assertSame(['RESULT'], $this->list->getOriginalKeys()); } public function testGetChoicesForValuesForwardsCallIfListNotLoaded() @@ -114,10 +114,10 @@ public function testGetChoicesForValuesForwardsCallIfListNotLoaded() $this->loader->expects($this->exactly(2)) ->method('loadChoicesForValues') ->with(['a', 'b']) - ->willReturn('RESULT'); + ->willReturn(['RESULT']); - $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); - $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); + $this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b'])); + $this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b'])); } public function testGetChoicesForValuesUsesLoadedList() @@ -130,13 +130,13 @@ public function testGetChoicesForValuesUsesLoadedList() $this->loader->expects($this->exactly(2)) ->method('loadChoicesForValues') ->with(['a', 'b']) - ->willReturn('RESULT'); + ->willReturn(['RESULT']); // load choice list $this->list->getChoices(); - $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); - $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); + $this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b'])); + $this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b'])); } public function testGetValuesForChoicesUsesLoadedList() @@ -149,12 +149,12 @@ public function testGetValuesForChoicesUsesLoadedList() $this->loader->expects($this->exactly(2)) ->method('loadValuesForChoices') ->with(['a', 'b']) - ->willReturn('RESULT'); + ->willReturn(['RESULT']); // load choice list $this->list->getChoices(); - $this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b'])); - $this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b'])); + $this->assertSame(['RESULT'], $this->list->getValuesForChoices(['a', 'b'])); + $this->assertSame(['RESULT'], $this->list->getValuesForChoices(['a', 'b'])); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index e43adf1558ad..abde92b1559f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -145,7 +145,7 @@ public function testGenerateCsrfTokenUsesFormNameAsIntentionByDefault() $this->tokenManager->expects($this->once()) ->method('getToken') ->with('FORM_NAME') - ->willReturn('token'); + ->willReturn(new CsrfToken('TOKEN_ID', 'token')); $view = $this->factory ->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -163,7 +163,7 @@ public function testGenerateCsrfTokenUsesTypeClassAsIntentionIfEmptyFormName() $this->tokenManager->expects($this->once()) ->method('getToken') ->with('Symfony\Component\Form\Extension\Core\Type\FormType') - ->willReturn('token'); + ->willReturn(new CsrfToken('TOKEN_ID', 'token')); $view = $this->factory ->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php index 0c544c3ebc6c..7d76f79a45c6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php @@ -16,6 +16,7 @@ use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormView; @@ -57,7 +58,7 @@ public function testExtractConfiguration() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->willReturn(new \stdClass()); + ->willReturn(new HiddenType()); $form = $this->createBuilder('name') ->setType($type) @@ -66,7 +67,7 @@ public function testExtractConfiguration() $this->assertSame([ 'id' => 'name', 'name' => 'name', - 'type_class' => 'stdClass', + 'type_class' => HiddenType::class, 'synchronized' => true, 'passed_options' => [], 'resolved_options' => [], @@ -78,7 +79,7 @@ public function testExtractConfigurationSortsPassedOptions() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->willReturn(new \stdClass()); + ->willReturn(new HiddenType()); $options = [ 'b' => 'foo', @@ -96,7 +97,7 @@ public function testExtractConfigurationSortsPassedOptions() $this->assertSame([ 'id' => 'name', 'name' => 'name', - 'type_class' => 'stdClass', + 'type_class' => HiddenType::class, 'synchronized' => true, 'passed_options' => [ 'a' => 'bar', @@ -112,7 +113,7 @@ public function testExtractConfigurationSortsResolvedOptions() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->willReturn(new \stdClass()); + ->willReturn(new HiddenType()); $options = [ 'b' => 'foo', @@ -127,7 +128,7 @@ public function testExtractConfigurationSortsResolvedOptions() $this->assertSame([ 'id' => 'name', 'name' => 'name', - 'type_class' => 'stdClass', + 'type_class' => HiddenType::class, 'synchronized' => true, 'passed_options' => [], 'resolved_options' => [ @@ -143,7 +144,7 @@ public function testExtractConfigurationBuildsIdRecursively() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->willReturn(new \stdClass()); + ->willReturn(new HiddenType()); $grandParent = $this->createBuilder('grandParent') ->setCompound(true) @@ -163,7 +164,7 @@ public function testExtractConfigurationBuildsIdRecursively() $this->assertSame([ 'id' => 'grandParent_parent_name', 'name' => 'name', - 'type_class' => 'stdClass', + 'type_class' => HiddenType::class, 'synchronized' => true, 'passed_options' => [], 'resolved_options' => [], diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index c756c0d90f55..adc703d8d019 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\FormFactory; +use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormTypeGuesserChain; use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Guess\TypeGuess; @@ -193,11 +194,13 @@ public function testCreateUsesBlockPrefixIfTypeGivenAsString() ->method('buildForm') ->with($this->builder, $resolvedOptions); + $form = $this->createMock(FormInterface::class); + $this->builder->expects($this->once()) ->method('getForm') - ->willReturn('FORM'); + ->willReturn($form); - $this->assertSame('FORM', $this->factory->create('TYPE', null, $options)); + $this->assertSame($form, $this->factory->create('TYPE', null, $options)); } public function testCreateNamed() @@ -224,11 +227,13 @@ public function testCreateNamed() ->method('buildForm') ->with($this->builder, $resolvedOptions); + $form = $this->createMock(FormInterface::class); + $this->builder->expects($this->once()) ->method('getForm') - ->willReturn('FORM'); + ->willReturn($form); - $this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options)); + $this->assertSame($form, $this->factory->createNamed('name', 'type', null, $options)); } public function testCreateBuilderForPropertyWithoutTypeGuesser() @@ -242,11 +247,11 @@ public function testCreateBuilderForPropertyWithoutTypeGuesser() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, []) - ->willReturn('builderInstance'); + ->willReturn($this->builder); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); - $this->assertEquals('builderInstance', $this->builder); + $this->assertSame($this->builder, $this->builder); } public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() @@ -274,11 +279,11 @@ public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]]) - ->willReturn('builderInstance'); + ->willReturn($this->builder); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); - $this->assertEquals('builderInstance', $this->builder); + $this->assertSame($this->builder, $this->builder); } public function testCreateBuilderCreatesTextFormIfNoGuess() @@ -293,11 +298,11 @@ public function testCreateBuilderCreatesTextFormIfNoGuess() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->willReturn('builderInstance'); + ->willReturn($this->builder); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); - $this->assertEquals('builderInstance', $this->builder); + $this->assertSame($this->builder, $this->builder); } public function testOptionsCanBeOverridden() @@ -316,7 +321,7 @@ public function testOptionsCanBeOverridden() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]]) - ->willReturn('builderInstance'); + ->willReturn($this->builder); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -325,7 +330,7 @@ public function testOptionsCanBeOverridden() ['attr' => ['maxlength' => 11]] ); - $this->assertEquals('builderInstance', $this->builder); + $this->assertSame($this->builder, $this->builder); } public function testCreateBuilderUsesMaxLengthIfFound() @@ -351,14 +356,14 @@ public function testCreateBuilderUsesMaxLengthIfFound() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]]) - ->willReturn('builderInstance'); + ->willReturn($this->builder); $this->builder = $factory->createBuilderForProperty( 'Application\Author', 'firstName' ); - $this->assertEquals('builderInstance', $this->builder); + $this->assertSame($this->builder, $this->builder); } public function testCreateBuilderUsesMaxLengthAndPattern() @@ -384,7 +389,7 @@ public function testCreateBuilderUsesMaxLengthAndPattern() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']]) - ->willReturn('builderInstance'); + ->willReturn($this->builder); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -393,7 +398,7 @@ public function testCreateBuilderUsesMaxLengthAndPattern() ['attr' => ['class' => 'tinymce']] ); - $this->assertEquals('builderInstance', $this->builder); + $this->assertSame($this->builder, $this->builder); } public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() @@ -419,14 +424,14 @@ public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false]) - ->willReturn('builderInstance'); + ->willReturn($this->builder); $this->builder = $factory->createBuilderForProperty( 'Application\Author', 'firstName' ); - $this->assertEquals('builderInstance', $this->builder); + $this->assertSame($this->builder, $this->builder); } public function testCreateBuilderUsesPatternIfFound() @@ -452,14 +457,14 @@ public function testCreateBuilderUsesPatternIfFound() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']]) - ->willReturn('builderInstance'); + ->willReturn($this->builder); $this->builder = $factory->createBuilderForProperty( 'Application\Author', 'firstName' ); - $this->assertEquals('builderInstance', $this->builder); + $this->assertSame($this->builder, $this->builder); } private function getMockFactory(array $methods = []) diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 798d1fb858bd..d5e0832d1712 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Form; use Symfony\Component\Form\FormConfigInterface; use Symfony\Component\Form\FormTypeExtensionInterface; @@ -183,7 +184,7 @@ public function testCreateBuilderWithDataClassOption() public function testFailsCreateBuilderOnInvalidFormOptionsResolution() { $this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); - $this->expectExceptionMessage('An error has occurred resolving the options of the form "stdClass": The required option "foo" is missing.'); + $this->expectExceptionMessage('An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\HiddenType": The required option "foo" is missing.'); $optionsResolver = (new OptionsResolver()) ->setRequired('foo') ; @@ -198,7 +199,7 @@ public function testFailsCreateBuilderOnInvalidFormOptionsResolution() ; $this->resolvedType->expects($this->once()) ->method('getInnerType') - ->willReturn(new \stdClass()) + ->willReturn(new HiddenType()) ; $factory = $this->getMockFormFactory(); diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 4fd4aec1af29..f02075f63021 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -322,12 +322,12 @@ public function setContent($content) if (null !== $content) { throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.'); } + + return $this; } /** * {@inheritdoc} - * - * @return false */ public function getContent() { diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php index eec3ff446591..d79075c920b4 100644 --- a/src/Symfony/Component/HttpFoundation/FileBag.php +++ b/src/Symfony/Component/HttpFoundation/FileBag.php @@ -75,8 +75,8 @@ protected function convertFileInformation($file) return $file; } - $file = $this->fixPhpFilesArray($file); if (\is_array($file)) { + $file = $this->fixPhpFilesArray($file); $keys = array_keys($file); sort($keys); @@ -109,14 +109,12 @@ protected function convertFileInformation($file) * It's safe to pass an already converted array, in which case this method * just returns the original array unmodified. * + * @param array $data + * * @return array */ protected function fixPhpFilesArray($data) { - if (!\is_array($data)) { - return $data; - } - $keys = array_keys($data); sort($keys); diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index 3d12cb0f663f..d6ce96815f4f 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -118,7 +118,7 @@ public function get($key, $default = null) } } - return $headers[0] ?? $default; + return isset($headers[0]) ? (string) $headers[0] : $default; } /** diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index e74e57c07e25..866fea4fb5cf 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -499,6 +499,10 @@ public function __toString() try { $content = $this->getContent(); } catch (\LogicException $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + return trigger_error($e, E_USER_ERROR); } @@ -795,7 +799,7 @@ public function getClientIps() * ("Client-Ip" for instance), configure it via the $trustedHeaderSet * argument of the Request::setTrustedProxies() method instead. * - * @return string The client IP address + * @return string|null The client IP address * * @see getClientIps() * @see https://wikipedia.org/wiki/X-Forwarded-For diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 1c2b6e8d6e63..e6acafff55b1 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -409,7 +409,7 @@ public function setContent($content) /** * Gets the current response content. * - * @return string Content + * @return string|false */ public function getContent() { diff --git a/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php b/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php index 162c4b529584..2cf0743cf9d5 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php @@ -97,7 +97,7 @@ public function remove($name) * @param string $name Key name * @param bool $writeContext Write context, default false * - * @return array + * @return array|null */ protected function &resolveAttributePath($name, $writeContext = false) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php index 7a528e655a29..a399be5fd8ee 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php @@ -99,7 +99,7 @@ protected function doDestroy($sessionId) } /** - * @return int + * @return bool */ public function gc($maxlifetime) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php index ccf23de7eb29..c6b16d11c854 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php @@ -61,7 +61,7 @@ public function destroy($sessionId) } /** - * @return int + * @return bool */ public function gc($maxlifetime) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php index ba063960469c..0634e46dd53f 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php @@ -67,7 +67,7 @@ protected function doDestroy($sessionId) } /** - * @return int + * @return bool */ public function gc($maxlifetime) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index 0cd1296c0916..3c6b0d46120d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -288,7 +288,7 @@ public function read($sessionId) } /** - * @return int + * @return bool */ public function gc($maxlifetime) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php index 31a39a6973a4..3144ea597ea6 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php @@ -94,7 +94,7 @@ public function close() } /** - * @return int + * @return bool */ public function gc($maxlifetime) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php index 09c92483c757..0303729e7b38 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php @@ -31,7 +31,7 @@ abstract class AbstractProxy /** * Gets the session.save_handler name. * - * @return string + * @return string|null */ public function getSaveHandlerName() { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php index 8034b7a46b1e..de4f550badbc 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php @@ -76,7 +76,7 @@ public function destroy($sessionId) } /** - * @return int + * @return bool */ public function gc($maxlifetime) { diff --git a/src/Symfony/Component/HttpFoundation/StreamedResponse.php b/src/Symfony/Component/HttpFoundation/StreamedResponse.php index 06d7a47ad8bc..ef8095bbe22e 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -134,8 +134,6 @@ public function setContent($content) /** * {@inheritdoc} - * - * @return false */ public function getContent() { diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index b90144809c62..734f8e84545b 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -107,7 +107,7 @@ public function testRequests($requestRange, $offset, $length, $responseRange) $this->assertEquals(206, $response->getStatusCode()); $this->assertEquals($responseRange, $response->headers->get('Content-Range')); - $this->assertSame($length, $response->headers->get('Content-Length')); + $this->assertSame((string) $length, $response->headers->get('Content-Length')); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc index 7a064c7f3f06..a887f607e899 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc @@ -60,14 +60,14 @@ class TestSessionHandler extends AbstractSessionHandler $this->data = $data; } - public function open($path, $name) + public function open($path, $name): bool { echo __FUNCTION__, "\n"; return parent::open($path, $name); } - public function validateId($sessionId) + public function validateId($sessionId): bool { echo __FUNCTION__, "\n"; @@ -77,7 +77,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function read($sessionId) + public function read($sessionId): string { echo __FUNCTION__, "\n"; @@ -87,7 +87,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function updateTimestamp($sessionId, $data) + public function updateTimestamp($sessionId, $data): bool { echo __FUNCTION__, "\n"; @@ -97,7 +97,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function write($sessionId, $data) + public function write($sessionId, $data): bool { echo __FUNCTION__, "\n"; @@ -107,42 +107,42 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function destroy($sessionId) + public function destroy($sessionId): bool { echo __FUNCTION__, "\n"; return parent::destroy($sessionId); } - public function close() + public function close(): bool { echo __FUNCTION__, "\n"; return true; } - public function gc($maxLifetime) + public function gc($maxLifetime): bool { echo __FUNCTION__, "\n"; return true; } - protected function doRead($sessionId) + protected function doRead($sessionId): string { echo __FUNCTION__.': ', $this->data, "\n"; return $this->data; } - protected function doWrite($sessionId, $data) + protected function doWrite($sessionId, $data): bool { echo __FUNCTION__.': ', $data, "\n"; return true; } - protected function doDestroy($sessionId) + protected function doDestroy($sessionId): bool { echo __FUNCTION__, "\n"; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index 540d58a27054..1cf4aed06a25 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -144,7 +144,8 @@ public function testUpdateTimestamp() { $mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock(); $mock->expects($this->once()) - ->method('updateTimestamp'); + ->method('updateTimestamp') + ->willReturn(false); $proxy = new SessionHandlerProxy($mock); $proxy->updateTimestamp('id', 'data'); diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index 3cebfb3e8bea..7291c25da728 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -82,7 +82,11 @@ public function getController(Request $request) return $controller; } - $callable = $this->createController($controller); + try { + $callable = $this->createController($controller); + } catch (\InvalidArgumentException $e) { + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage())); + } if (!\is_callable($callable)) { throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($callable))); @@ -97,17 +101,25 @@ public function getController(Request $request) * @param string $controller A Controller string * * @return callable A PHP callable + * + * @throws \InvalidArgumentException When the controller cannot be created */ protected function createController($controller) { if (false === strpos($controller, '::')) { - return $this->instantiateController($controller); + $controller = $this->instantiateController($controller); + + if (!\is_callable($controller)) { + throw new \InvalidArgumentException($this->getControllerError($controller)); + } + + return $controller; } list($class, $method) = explode('::', $controller, 2); try { - return [$this->instantiateController($class), $method]; + $controller = [$this->instantiateController($class), $method]; } catch (\Error | \LogicException $e) { try { if ((new \ReflectionMethod($class, $method))->isStatic()) { @@ -119,6 +131,12 @@ protected function createController($controller) throw $e; } + + if (!\is_callable($controller)) { + throw new \InvalidArgumentException($this->getControllerError($controller)); + } + + return $controller; } /** diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php index 4ea8ea643feb..e73b848e6002 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php @@ -50,7 +50,7 @@ public function getName() * * The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+. * - * @return string + * @return string|null */ public function getType() { diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 287abe31bb7c..186ae134a8a2 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -132,7 +132,7 @@ public function getApplicationVersion() /** * Gets the token. * - * @return string The token + * @return string|null The token */ public function getToken() { diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php index bda8aeddcf66..09d6e4b47246 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php @@ -55,7 +55,7 @@ public function hasException() /** * Gets the exception. * - * @return \Exception The exception + * @return \Exception|FlattenException */ public function getException() { diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index e2059830a2b5..af7b1bc3dbc1 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -75,11 +75,6 @@ public function lateCollect() $this->currentRequest = null; } - /** - * Gets the logs. - * - * @return array An array of logs - */ public function getLogs() { return isset($this->data['logs']) ? $this->data['logs'] : []; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index d070e838685d..cb490c2bb37d 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -132,7 +132,7 @@ public function getInitTime() /** * Gets the request time. * - * @return int The time + * @return float */ public function getStartTime() { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php b/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php index 1d62f32e67fb..9b4541793f05 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php @@ -110,7 +110,7 @@ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) } } - return null; + return ''; } /** diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php b/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php index 707abca5eb7a..40aac64f2a13 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php @@ -95,6 +95,6 @@ public function process(Request $request, Response $response) // remove SSI/1.0 from the Surrogate-Control header $this->removeFromControl($response); - return null; + return $response; } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 55f8467faa06..d2ef8515b4a1 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -204,7 +204,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ /** * Gets a HTTP kernel from the container. * - * @return HttpKernel + * @return HttpKernelInterface */ protected function getHttpKernel() { @@ -390,7 +390,7 @@ public function setAnnotatedClassCache(array $annotatedClasses) */ public function getStartTime() { - return $this->debug ? $this->startTime : -INF; + return $this->debug && null !== $this->startTime ? $this->startTime : -INF; } /** diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/Component/HttpKernel/KernelInterface.php index 103dd9f86460..c97dde829271 100644 --- a/src/Symfony/Component/HttpKernel/KernelInterface.php +++ b/src/Symfony/Component/HttpKernel/KernelInterface.php @@ -131,7 +131,7 @@ public function getContainer(); /** * Gets the request start time (not available if debug is disabled). * - * @return int The request start timestamp + * @return float The request start timestamp */ public function getStartTime(); diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profile.php b/src/Symfony/Component/HttpKernel/Profiler/Profile.php index 9de221fc8f91..ac5b5044c1e7 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profile.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profile.php @@ -99,7 +99,7 @@ public function getParentToken() /** * Returns the IP. * - * @return string The IP + * @return string|null The IP */ public function getIp() { @@ -119,7 +119,7 @@ public function setIp($ip) /** * Returns the request method. * - * @return string The request method + * @return string|null The request method */ public function getMethod() { @@ -134,13 +134,16 @@ public function setMethod($method) /** * Returns the URL. * - * @return string The URL + * @return string|null The URL */ public function getUrl() { return $this->url; } + /** + * @param string $url + */ public function setUrl($url) { $this->url = $url; @@ -177,7 +180,7 @@ public function setStatusCode($statusCode) } /** - * @return int + * @return int|null */ public function getStatusCode() { diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php index f9d94b6f32ae..87a4996392c9 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -63,12 +63,12 @@ public function enable() /** * Loads the Profile for the given Response. * - * @return Profile|false A Profile instance + * @return Profile|null A Profile instance */ public function loadProfileFromResponse(Response $response) { if (!$token = $response->headers->get('X-Debug-Token')) { - return false; + return null; } return $this->loadProfile($token); @@ -79,7 +79,7 @@ public function loadProfileFromResponse(Response $response) * * @param string $token A token * - * @return Profile A Profile instance + * @return Profile|null A Profile instance */ public function loadProfile($token) { diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index be03734dc426..46dcee216267 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -28,6 +28,9 @@ public function testGetContainerExtension() ); } + /** + * @group legacy + */ public function testGetContainerExtensionWithInvalidClass() { $this->expectException('LogicException'); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 3010c5e02eb8..adfba5d4220e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -27,7 +27,7 @@ public function testCollectWithUnexpectedFormat() ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); - $logger->expects($this->once())->method('countErrors')->willReturn('foo'); + $logger->expects($this->once())->method('countErrors')->willReturn(123); $logger->expects($this->exactly(2))->method('getLogs')->willReturn([]); $c = new LoggerDataCollector($logger, __DIR__.'/'); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php index e044e5e1add5..9de9eb599ad6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -44,7 +44,7 @@ public function testCollect() $this->assertEquals(0, $c->getStartTime()); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); - $kernel->expects($this->once())->method('getStartTime')->willReturn(123456); + $kernel->expects($this->once())->method('getStartTime')->willReturn(123456.0); $c = new TimeDataCollector($kernel); $request = new Request(); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php index 37d471e81535..5a2faf4243df 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php @@ -160,7 +160,7 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() ; $file->expects($this->any()) ->method('getClientSize') - ->willReturn(INF) + ->willReturn(PHP_INT_MAX) ; $client->request('POST', '/', [], [$file]); diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 3d8253827963..a8319db6902f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -21,6 +21,7 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; +use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; @@ -470,8 +471,8 @@ public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWith { $this->expectException('LogicException'); $this->expectExceptionMessage('Trying to register two bundles with the same name "DuplicateName"'); - $fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName'); - $barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName'); + $fooBundle = $this->getBundle(__DIR__.'/Fixtures/FooBundle', null, 'FooBundle', 'DuplicateName'); + $barBundle = $this->getBundle(__DIR__.'/Fixtures/BarBundle', null, 'BarBundle', 'DuplicateName'); $kernel = $this->getKernel([], [$fooBundle, $barBundle]); $kernel->boot(); diff --git a/src/Symfony/Component/HttpKernel/Tests/Logger.php b/src/Symfony/Component/HttpKernel/Tests/Logger.php index d15e79a6c0f6..b6875793bc3e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Logger.php +++ b/src/Symfony/Component/HttpKernel/Tests/Logger.php @@ -22,7 +22,7 @@ public function __construct() $this->clear(); } - public function getLogs($level = false) + public function getLogs($level = false): array { return false === $level ? $this->logs : $this->logs[$level]; } diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 4ceabec809ab..6f42964bd707 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -415,7 +415,7 @@ public function localtime($value, &$position = 0) * contain -1 otherwise it will contain the position at which parsing * ended. If $parse_pos > strlen($value), the parse fails immediately. * - * @return int Parsed value as a timestamp + * @return int|false Parsed value as a timestamp * * @see https://php.net/intldateformatter.parse * diff --git a/src/Symfony/Component/Ldap/Security/LdapUserProvider.php b/src/Symfony/Component/Ldap/Security/LdapUserProvider.php index 4de49a05960c..7dfab0c839e2 100644 --- a/src/Symfony/Component/Ldap/Security/LdapUserProvider.php +++ b/src/Symfony/Component/Ldap/Security/LdapUserProvider.php @@ -144,7 +144,7 @@ public function supportsClass($class) /** * Loads a user from an LDAP entry. * - * @return LdapUser + * @return UserInterface */ protected function loadUser($username, Entry $entry) { diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index d0c2e084c5b2..27574eb8ddd6 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -69,7 +69,7 @@ class Process implements \IteratorAggregate private $status = self::STATUS_READY; private $incrementalOutputOffset = 0; private $incrementalErrorOutputOffset = 0; - private $tty; + private $tty = false; private $pty; private $useFileHandles = false; @@ -895,7 +895,7 @@ public function getStatus() * @param int|float $timeout The timeout in seconds * @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9) * - * @return int The exit-code of the process + * @return int|null The exit-code of the process or null if it's not running */ public function stop($timeout = 10, $signal = null) { diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php index b37c7dbe0366..fc74e0e17966 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php @@ -193,7 +193,7 @@ public function getLength() /** * Returns the current property path. * - * @return PropertyPathInterface The constructed property path + * @return PropertyPathInterface|null The constructed property path */ public function getPropertyPath() { diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathInterface.php b/src/Symfony/Component/PropertyAccess/PropertyPathInterface.php index ecaffac79a8d..56d70aa5294f 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathInterface.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathInterface.php @@ -40,7 +40,7 @@ public function getLength(); * * If this property path only contains one item, null is returned. * - * @return PropertyPath|null The parent path or null + * @return self|null The parent path or null */ public function getParent(); diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php index 6878db7cf3b9..acae86a06f48 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php @@ -31,6 +31,8 @@ public function getShortDescription($class, $property, array $context = []) { $this->assertIsString($class); $this->assertIsString($property); + + return null; } /** @@ -40,6 +42,8 @@ public function getLongDescription($class, $property, array $context = []) { $this->assertIsString($class); $this->assertIsString($property); + + return null; } /** @@ -49,6 +53,8 @@ public function getTypes($class, $property, array $context = []) { $this->assertIsString($class); $this->assertIsString($property); + + return null; } /** @@ -58,6 +64,8 @@ public function isReadable($class, $property, array $context = []) { $this->assertIsString($class); $this->assertIsString($property); + + return null; } /** @@ -67,6 +75,8 @@ public function isWritable($class, $property, array $context = []) { $this->assertIsString($class); $this->assertIsString($property); + + return null; } /** @@ -75,6 +85,8 @@ public function isWritable($class, $property, array $context = []) public function getProperties($class, array $context = []) { $this->assertIsString($class); + + return null; } /** diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index 47df4210c303..9d583315e255 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -271,9 +271,9 @@ public function matchRequest(Request $request) } /** - * Gets the UrlMatcher instance associated with this Router. + * Gets the UrlMatcher or RequestMatcher instance associated with this Router. * - * @return UrlMatcherInterface A UrlMatcherInterface instance + * @return UrlMatcherInterface|RequestMatcherInterface */ public function getMatcher() { diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php index 6c93facefe69..cec1fa422cb2 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php @@ -62,6 +62,9 @@ public function getBadResourceStrings() ]; } + /** + * @group legacy + */ public function testExceptionOnNoObjectReturned() { $this->expectException('LogicException'); diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php b/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php index 1b10bc219eb6..8a02802d9c98 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php @@ -39,7 +39,7 @@ public function getToken() */ public function setToken(TokenInterface $token = null) { - if (null !== $token && !method_exists($token, 'getRoleNames')) { + if (null !== $token && !method_exists($token, 'getRoleNames') && !$token instanceof \PHPUnit\Framework\MockObject\MockObject && !$token instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { @trigger_error(sprintf('Not implementing the "%s::getRoleNames()" method in "%s" is deprecated since Symfony 4.3.', TokenInterface::class, \get_class($token)), E_USER_DEPRECATED); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php index 0981b13c8f01..342db15095bd 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php @@ -22,6 +22,9 @@ class DaoAuthenticationProviderTest extends TestCase { + /** + * @group legacy + */ public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface() { $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php index 8ec92d5014da..5a42b3290f6d 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php @@ -62,6 +62,9 @@ public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue() $provider->authenticate($this->getSupportedToken()); } + /** + * @group legacy + */ public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface() { $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php index 5df07a22487b..f9e157c6978e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php @@ -233,7 +233,7 @@ public function testAccessDecisionManagerCalledByVoter() ->method('vote') ->willReturnCallback(function (TokenInterface $token, $subject, array $attributes) use ($sut, $voter3) { if (\in_array('attr2', $attributes) && $subject) { - $vote = $sut->decide($token, $attributes); + $vote = $sut->decide($token, $attributes) ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED; } else { $vote = VoterInterface::ACCESS_ABSTAIN; } diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php index 7b94f8077a22..f1a56fe1fcf5 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php @@ -12,11 +12,11 @@ namespace Symfony\Component\Security\Guard\Tests\Provider; use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\BadCredentialsException; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Guard\AuthenticatorInterface; use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider; +use Symfony\Component\Security\Guard\Token\GuardTokenInterface; use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken; use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken; @@ -69,7 +69,7 @@ public function testAuthenticate() ->with($enteredCredentials, $mockedUser) // authentication works! ->willReturn(true); - $authedToken = $this->getMockBuilder(TokenInterface::class)->getMock(); + $authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock(); $authenticatorB->expects($this->once()) ->method('createAuthenticatedToken') ->with($mockedUser, $providerKey) diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php index ce8c27ba7db3..b1e6e2718695 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php @@ -31,7 +31,7 @@ interface AuthenticationSuccessHandlerInterface * is called by authentication listeners inheriting from * AbstractAuthenticationListener. * - * @return Response never null + * @return Response */ public function onAuthenticationSuccess(Request $request, TokenInterface $token); } diff --git a/src/Symfony/Component/Security/Http/RememberMe/RememberMeServicesInterface.php b/src/Symfony/Component/Security/Http/RememberMe/RememberMeServicesInterface.php index fe8b0faee545..ae52591da0ad 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/RememberMeServicesInterface.php +++ b/src/Symfony/Component/Security/Http/RememberMe/RememberMeServicesInterface.php @@ -46,7 +46,7 @@ interface RememberMeServicesInterface * make sure to throw an AuthenticationException as this will consequentially * result in a call to loginFail() and therefore an invalidation of the cookie. * - * @return TokenInterface + * @return TokenInterface|null */ public function autoLogin(Request $request); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php index e7588e275a88..8fe7ce0c8662 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Security\Http\Tests\Authentication; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Security; @@ -62,7 +63,7 @@ public function testForward() public function testRedirect() { - $response = new Response(); + $response = new RedirectResponse('/login'); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/login') ->willReturn($response); diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php index 999ff728bf46..05c5930ec8d7 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Security\Http\Tests\EntryPoint; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint; @@ -21,7 +22,7 @@ class FormAuthenticationEntryPointTest extends TestCase public function testStart() { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $response = new Response(); + $response = new RedirectResponse('/the/login/path'); $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index ac1c5fbab86b..f02a52894df1 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -73,6 +73,9 @@ public function getAuthenticationExceptionProvider() ]; } + /** + * @group legacy + */ public function testExceptionWhenEntryPointReturnsBadValue() { $event = $this->createEvent(new AuthenticationException()); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php index f6d206c483ee..7cb438e3a783 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php @@ -123,6 +123,9 @@ public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation() $listener($event); } + /** + * @group legacy + */ public function testSuccessHandlerReturnsNonResponse() { $this->expectException('RuntimeException'); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index c83d7e878713..0676490fc037 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Security\Tests\Http\Firewall; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; @@ -40,6 +41,10 @@ public function testHandleWhenUsernameLength($username, $ok) ->method('checkRequestPath') ->willReturn(true) ; + $httpUtils + ->method('createRedirectResponse') + ->willReturn(new RedirectResponse('/hello')) + ; $failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); $failureHandler @@ -52,7 +57,7 @@ public function testHandleWhenUsernameLength($username, $ok) $authenticationManager ->expects($ok ? $this->once() : $this->never()) ->method('authenticate') - ->willReturn(new Response()) + ->willReturnArgument(0) ; $listener = new UsernamePasswordFormAuthenticationListener( @@ -61,7 +66,7 @@ public function testHandleWhenUsernameLength($username, $ok) $this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(), $httpUtils, 'TheProviderKey', - $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(), + new DefaultAuthenticationSuccessHandler($httpUtils), $failureHandler, ['require_previous_session' => false] ); diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php index 926f8cc4b23a..d0c638323680 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Security\Http\Tests\Logout; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler; class DefaultLogoutSuccessHandlerTest extends TestCase @@ -20,7 +20,7 @@ class DefaultLogoutSuccessHandlerTest extends TestCase public function testLogout() { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $response = new Response(); + $response = new RedirectResponse('/dashboard'); $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils->expects($this->once()) diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php index c476e65403c2..8dc2042f12c0 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php @@ -39,6 +39,9 @@ public function testAutoLoginReturnsNullWhenNoCookie() $this->assertNull($service->autoLogin(new Request())); } + /** + * @group legacy + */ public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface() { $this->expectException('RuntimeException'); diff --git a/src/Symfony/Component/Serializer/SerializerInterface.php b/src/Symfony/Component/Serializer/SerializerInterface.php index aca146c156a0..aa00f2222b84 100644 --- a/src/Symfony/Component/Serializer/SerializerInterface.php +++ b/src/Symfony/Component/Serializer/SerializerInterface.php @@ -36,7 +36,7 @@ public function serialize($data, $format, array $context = []); * @param string $type * @param string $format * - * @return object + * @return object|array */ public function deserialize($data, $type, $format, array $context = []); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index f6ad1a39558e..af8ea2850152 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -15,10 +15,12 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Exception\NotNormalizableValueException; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping; use Symfony\Component\Serializer\Mapping\ClassMetadata; +use Symfony\Component\Serializer\Mapping\ClassMetadataInterface; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; @@ -155,26 +157,28 @@ private function getDenormalizerForDummyCollection() public function testDenormalizeWithDiscriminatorMapUsesCorrectClassname() { $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); - $loaderMock = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); - $loaderMock->method('hasMetadataFor')->willReturnMap([ - [ - AbstractDummy::class, - true, - ], - ]); - $loaderMock->method('getMetadataFor')->willReturnMap([ - [ - AbstractDummy::class, - new ClassMetadata( - AbstractDummy::class, - new ClassDiscriminatorMapping('type', [ - 'first' => AbstractDummyFirstChild::class, - 'second' => AbstractDummySecondChild::class, - ]) - ), - ], - ]); + $loaderMock = new class() implements ClassMetadataFactoryInterface { + public function getMetadataFor($value): ClassMetadataInterface + { + if (AbstractDummy::class === $value) { + return new ClassMetadata( + AbstractDummy::class, + new ClassDiscriminatorMapping('type', [ + 'first' => AbstractDummyFirstChild::class, + 'second' => AbstractDummySecondChild::class, + ]) + ); + } + + throw new InvalidArgumentException; + } + + public function hasMetadataFor($value): bool + { + return $value === AbstractDummy::class; + } + }; $discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock); $normalizer = new AbstractObjectNormalizerDummy($factory, null, new PhpDocExtractor(), $discriminatorResolver); diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index aed4842ee061..0e79259844ee 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -16,9 +16,11 @@ use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping; use Symfony\Component\Serializer\Mapping\ClassMetadata; +use Symfony\Component\Serializer\Mapping\ClassMetadataInterface; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; @@ -381,26 +383,27 @@ public function testDeserializeAndSerializeAbstractObjectsWithTheClassMetadataDi $example = new AbstractDummyFirstChild('foo-value', 'bar-value'); $example->setQuux(new DummyFirstChildQuux('quux')); - $loaderMock = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); - $loaderMock->method('hasMetadataFor')->willReturnMap([ - [ - AbstractDummy::class, - true, - ], - ]); - - $loaderMock->method('getMetadataFor')->willReturnMap([ - [ - AbstractDummy::class, - new ClassMetadata( - AbstractDummy::class, - new ClassDiscriminatorMapping('type', [ - 'first' => AbstractDummyFirstChild::class, - 'second' => AbstractDummySecondChild::class, - ]) - ), - ], - ]); + $loaderMock = new class() implements ClassMetadataFactoryInterface { + public function getMetadataFor($value): ClassMetadataInterface + { + if (AbstractDummy::class === $value) { + return new ClassMetadata( + AbstractDummy::class, + new ClassDiscriminatorMapping('type', [ + 'first' => AbstractDummyFirstChild::class, + 'second' => AbstractDummySecondChild::class, + ]) + ); + } + + throw new InvalidArgumentException(); + } + + public function hasMetadataFor($value): bool + { + return $value === AbstractDummy::class; + } + }; $discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock); $serializer = new Serializer([new ObjectNormalizer(null, null, null, new PhpDocExtractor(), $discriminatorResolver)], ['json' => new JsonEncoder()]); diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 35dcb026bcc6..c08bc5bdb7fd 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -297,7 +297,7 @@ public function extend($template) * @param mixed $value A variable to escape * @param string $context The context name * - * @return string The escaped value + * @return mixed The escaped value */ public function escape($value, $context = 'html') { diff --git a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php index 15f751780a00..7fc931ca897a 100644 --- a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php +++ b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php @@ -60,7 +60,7 @@ public function reset() } /** - * @return array + * @return array|Data */ public function getMessages() { diff --git a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php index 8d722dad81df..c18b7b2e4fcd 100644 --- a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php @@ -21,13 +21,13 @@ abstract class AbstractFileExtractor { /** - * @param string|array $resource Files, a file or a directory + * @param string|iterable $resource Files, a file or a directory * - * @return array + * @return iterable */ protected function extractFiles($resource) { - if (\is_array($resource) || $resource instanceof \Traversable) { + if (\is_iterable($resource)) { $files = []; foreach ($resource as $file) { if ($this->canBeExtracted($file)) { @@ -74,7 +74,7 @@ abstract protected function canBeExtracted($file); /** * @param string|array $resource Files, a file or a directory * - * @return array files to be extracted + * @return iterable files to be extracted */ abstract protected function extractFromDirectory($resource); } diff --git a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php index 91c14ec384c9..265b8d76841f 100644 --- a/src/Symfony/Component/Translation/Extractor/PhpExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/PhpExtractor.php @@ -100,7 +100,7 @@ public function setPrefix($prefix) * * @param mixed $token * - * @return string + * @return string|null */ protected function normalizeToken($token) { @@ -264,9 +264,7 @@ protected function canBeExtracted($file) } /** - * @param string|array $directory - * - * @return array + * {@inheritdoc} */ protected function extractFromDirectory($directory) { diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index 584a055cdbb5..438d7d76421b 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -45,6 +45,10 @@ protected function loadResource($resource) throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e); } - return $messages; + if (null !== $messages && !\is_array($messages)) { + throw new InvalidResourceException(sprintf('Unable to load file "%s".', $resource)); + } + + return $messages ?: []; } } diff --git a/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php b/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php index 7b45c1460e9c..05ca27b3f476 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php @@ -280,7 +280,7 @@ public function getMetadata(); /** * Returns the validation group that is currently being validated. * - * @return string The current validation group + * @return string|null The current validation group */ public function getGroup(); diff --git a/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php b/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php index 053448e3c11c..1d4e4da36794 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php @@ -128,7 +128,7 @@ public function testMessageCanBeStringableObject() toString EOF; $this->assertSame($expected, (string) $violation); - $this->assertSame($message, $violation->getMessage()); + $this->assertSame((string) $message, $violation->getMessage()); } public function testMessageCannotBeArray() diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index 00acab3460fd..4079fd3c53e6 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -35,7 +35,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface protected $indentPad = ' '; protected $flags; - private $charset; + private $charset = ''; /** * @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput diff --git a/src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php b/src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php index 4040c0ff1475..713cd45ca8ac 100644 --- a/src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php +++ b/src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php @@ -7,6 +7,9 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; +use Symfony\Component\Security\Core\Role\RoleHierarchy; +use Symfony\Component\Validator\ConstraintViolation; +use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow\Event\GuardEvent; use Symfony\Component\Workflow\EventListener\ExpressionLanguage; @@ -41,7 +44,8 @@ protected function setUp(): void $this->authenticationChecker = $this->getMockBuilder(AuthorizationCheckerInterface::class)->getMock(); $trustResolver = $this->getMockBuilder(AuthenticationTrustResolverInterface::class)->getMock(); $this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock(); - $this->listener = new GuardListener($this->configuration, $expressionLanguage, $tokenStorage, $this->authenticationChecker, $trustResolver, null, $this->validator); + $roleHierarchy = new RoleHierarchy([]); + $this->listener = new GuardListener($this->configuration, $expressionLanguage, $tokenStorage, $this->authenticationChecker, $trustResolver, $roleHierarchy, $this->validator); } protected function tearDown(): void @@ -171,7 +175,7 @@ private function configureValidator($isUsed, $valid = true) $this->validator ->expects($this->once()) ->method('validate') - ->willReturn($valid ? [] : ['a violation']) + ->willReturn(new ConstraintViolationList($valid ? [] : [new ConstraintViolation('a violation', null, [], '', null, '')])) ; } } diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 58caa122ea5b..261d64f5bebb 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -12,7 +12,6 @@ use Symfony\Component\Workflow\Marking; use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface; use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore; -use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore; use Symfony\Component\Workflow\Transition; use Symfony\Component\Workflow\TransitionBlocker; use Symfony\Component\Workflow\Workflow; @@ -21,6 +20,9 @@ class WorkflowTest extends TestCase { use WorkflowBuilderTrait; + /** + * @group legacy + */ public function testGetMarkingWithInvalidStoreReturn() { $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); @@ -36,7 +38,7 @@ public function testGetMarkingWithEmptyDefinition() $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); $this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".'); $subject = new Subject(); - $workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore()); + $workflow = new Workflow(new Definition([], []), new MethodMarkingStore()); $workflow->getMarking($subject); } @@ -47,7 +49,7 @@ public function testGetMarkingWithImpossiblePlace() $this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".'); $subject = new Subject(); $subject->setMarking(['nope' => 1]); - $workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore()); + $workflow = new Workflow(new Definition([], []), new MethodMarkingStore()); $workflow->getMarking($subject); } @@ -56,7 +58,7 @@ public function testGetMarkingWithEmptyInitialMarking() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->getMarking($subject); @@ -70,7 +72,7 @@ public function testGetMarkingWithExistingMarking() $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); $subject->setMarking(['b' => 1, 'c' => 1]); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->getMarking($subject); @@ -83,7 +85,7 @@ public function testCanWithUnexistingTransition() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $this->assertFalse($workflow->can($subject, 'foobar')); } @@ -92,7 +94,7 @@ public function testCan() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $this->assertTrue($workflow->can($subject, 't1')); $this->assertFalse($workflow->can($subject, 't2')); @@ -123,7 +125,7 @@ public function testCanWithGuard() $eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) { $event->setBlocked(true); }); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $this->assertFalse($workflow->can($subject, 't1')); } @@ -136,7 +138,7 @@ public function testCanDoesNotTriggerGuardEventsForNotEnabledTransitions() $dispatchedEvents = []; $eventDispatcher = new EventDispatcher(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $workflow->apply($subject, 't1'); $workflow->apply($subject, 't2'); @@ -155,7 +157,7 @@ public function testCanDoesNotTriggerGuardEventsForNotEnabledTransitions() public function testCanWithSameNameTransition() { $definition = $this->createWorkflowWithSameNameTransition(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $subject = new Subject(); $this->assertTrue($workflow->can($subject, 'a_to_bc')); @@ -183,7 +185,7 @@ public function testBuildTransitionBlockerList() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $this->assertTrue($workflow->buildTransitionBlockerList($subject, 't1')->isEmpty()); $this->assertFalse($workflow->buildTransitionBlockerList($subject, 't2')->isEmpty()); @@ -208,7 +210,7 @@ public function testBuildTransitionBlockerListReturnsReasonsProvidedByMarking() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $transitionBlockerList = $workflow->buildTransitionBlockerList($subject, 't2'); $this->assertCount(1, $transitionBlockerList); @@ -222,7 +224,7 @@ public function testBuildTransitionBlockerListReturnsReasonsProvidedInGuards() $definition = $this->createSimpleWorkflowDefinition(); $subject = new Subject(); $dispatcher = new EventDispatcher(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher); + $workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher); $dispatcher->addListener('workflow.guard', function (GuardEvent $event) { $event->addTransitionBlocker(new TransitionBlocker('Transition blocker 1', 'blocker_1')); @@ -254,7 +256,7 @@ public function testApplyWithNotExisingTransition() $this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".'); $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $workflow->apply($subject, '404 Not Found'); } @@ -263,7 +265,7 @@ public function testApplyWithNotEnabledTransition() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); try { $workflow->apply($subject, 't2'); @@ -284,7 +286,7 @@ public function testApply() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->apply($subject, 't1'); @@ -298,7 +300,7 @@ public function testApplyWithSameNameTransition() { $subject = new Subject(); $definition = $this->createWorkflowWithSameNameTransition(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->apply($subject, 'a_to_bc'); @@ -336,7 +338,7 @@ public function testApplyWithSameNameTransition2() $transitions[] = new Transition('t', 'a', 'c'); $transitions[] = new Transition('t', 'b', 'd'); $definition = new Definition($places, $transitions); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->apply($subject, 't'); @@ -357,7 +359,7 @@ public function testApplyWithSameNameTransition3() $transitions[] = new Transition('t', 'b', 'c'); $transitions[] = new Transition('t', 'c', 'd'); $definition = new Definition($places, $transitions); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->apply($subject, 't'); // We want to make sure we do not end up in "d" @@ -370,7 +372,7 @@ public function testApplyWithEventDispatcher() $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); $eventDispatcher = new EventDispatcherMock(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $eventNameExpected = [ 'workflow.entered', @@ -417,7 +419,7 @@ public function testApplyDoesNotTriggerExtraGuardWithEventDispatcher() $subject = new Subject(); $eventDispatcher = new EventDispatcherMock(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $eventNameExpected = [ 'workflow.entered', @@ -470,7 +472,7 @@ public function testEventName() $subject = new Subject(); $dispatcher = new EventDispatcher(); $name = 'workflow_name'; - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, $name); + $workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, $name); $assertWorkflowName = function (Event $event) use ($name) { $this->assertEquals($name, $event->getWorkflowName()); @@ -501,7 +503,7 @@ public function testMarkingStateOnApplyWithEventDispatcher() $dispatcher = new EventDispatcher(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, 'test'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, 'test'); $assertInitialState = function (Event $event) { $this->assertEquals(new Marking(['a' => 1, 'b' => 1, 'c' => 1]), $event->getMarking()); @@ -535,7 +537,7 @@ public function testGetEnabledTransitions() $eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) { $event->setBlocked(true); }); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $this->assertEmpty($workflow->getEnabledTransitions($subject)); @@ -555,7 +557,7 @@ public function testGetEnabledTransitionsWithSameNameTransition() { $definition = $this->createWorkflowWithSameNameTransition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $transitions = $workflow->getEnabledTransitions($subject); $this->assertCount(1, $transitions);