diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md index 0620564f3b..2fed4defb0 100644 --- a/UPGRADE-4.4.md +++ b/UPGRADE-4.4.md @@ -85,3 +85,9 @@ TwigBridge * Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the `DebugCommand::__construct()` method, swap the variables position. + +Validator +--------- + + * Deprecated passing an `ExpressionLanguage` instance as the second argument of `ExpressionValidator::__construct()`. + Pass it as the first argument instead. diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index f51b1253a3..2e4c401689 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -475,6 +475,7 @@ TwigBridge Validator -------- + * An `ExpressionLanguage` instance or null must be passed as the first argument of `ExpressionValidator::__construct()` * The `checkMX` and `checkHost` options of the `Email` constraint were removed * The `Email::__construct()` 'strict' property has been removed. Use 'mode'=>"strict" instead. * Calling `EmailValidator::__construct()` method with a boolean parameter has been removed, use `EmailValidator("strict")` instead. diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php index da9e11c985..1a14169f22 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -47,9 +47,12 @@ $getEnvVar = function ($name, $default = false) { return $default; }; -if (PHP_VERSION_ID >= 70100) { +if (PHP_VERSION_ID >= 70200) { + // PHPUnit 8 requires PHP 7.2+ + $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.2'); +} elseif (PHP_VERSION_ID >= 70100) { // PHPUnit 7 requires PHP 7.1+ - $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.4'); + $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5'); } elseif (PHP_VERSION_ID >= 70000) { // PHPUnit 6 requires PHP 7.0+ $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5'); diff --git a/src/Symfony/Component/Cache/Exception/CacheException+psr16.php b/src/Symfony/Component/Cache/Exception/CacheException+psr16.php new file mode 100644 index 0000000000..e87b2db8fe --- /dev/null +++ b/src/Symfony/Component/Cache/Exception/CacheException+psr16.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Exception; + +use Psr\Cache\CacheException as Psr6CacheInterface; +use Psr\SimpleCache\CacheException as SimpleCacheInterface; + +class CacheException extends \Exception implements Psr6CacheInterface, SimpleCacheInterface +{ +} diff --git a/src/Symfony/Component/Cache/Exception/CacheException-psr16.php b/src/Symfony/Component/Cache/Exception/CacheException-psr16.php new file mode 100644 index 0000000000..1dca75f16d --- /dev/null +++ b/src/Symfony/Component/Cache/Exception/CacheException-psr16.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Exception; + +use Psr\Cache\CacheException as Psr6CacheInterface; + +class CacheException extends \Exception implements Psr6CacheInterface +{ +} diff --git a/src/Symfony/Component/Cache/Exception/CacheException.php b/src/Symfony/Component/Cache/Exception/CacheException.php index d2e975b2bc..c052a12c84 100644 --- a/src/Symfony/Component/Cache/Exception/CacheException.php +++ b/src/Symfony/Component/Cache/Exception/CacheException.php @@ -11,15 +11,10 @@ namespace Symfony\Component\Cache\Exception; -use Psr\Cache\CacheException as Psr6CacheInterface; use Psr\SimpleCache\CacheException as SimpleCacheInterface; if (interface_exists(SimpleCacheInterface::class)) { - class CacheException extends \Exception implements Psr6CacheInterface, SimpleCacheInterface - { - } + require __DIR__.\DIRECTORY_SEPARATOR.'CacheException+psr16.php'; } else { - class CacheException extends \Exception implements Psr6CacheInterface - { - } + require __DIR__.\DIRECTORY_SEPARATOR.'CacheException-psr16.php'; } diff --git a/src/Symfony/Component/Cache/Exception/InvalidArgumentException+psr16.php b/src/Symfony/Component/Cache/Exception/InvalidArgumentException+psr16.php new file mode 100644 index 0000000000..828bf3ed77 --- /dev/null +++ b/src/Symfony/Component/Cache/Exception/InvalidArgumentException+psr16.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Exception; + +use Psr\Cache\InvalidArgumentException as Psr6CacheInterface; +use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInterface; + +class InvalidArgumentException extends \InvalidArgumentException implements Psr6CacheInterface, SimpleCacheInterface +{ +} diff --git a/src/Symfony/Component/Cache/Exception/InvalidArgumentException-psr16.php b/src/Symfony/Component/Cache/Exception/InvalidArgumentException-psr16.php new file mode 100644 index 0000000000..5a80c94dab --- /dev/null +++ b/src/Symfony/Component/Cache/Exception/InvalidArgumentException-psr16.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Exception; + +use Psr\Cache\InvalidArgumentException as Psr6CacheInterface; + +class InvalidArgumentException extends \InvalidArgumentException implements Psr6CacheInterface +{ +} diff --git a/src/Symfony/Component/Cache/Exception/InvalidArgumentException.php b/src/Symfony/Component/Cache/Exception/InvalidArgumentException.php index 7f9584a264..2c891d7365 100644 --- a/src/Symfony/Component/Cache/Exception/InvalidArgumentException.php +++ b/src/Symfony/Component/Cache/Exception/InvalidArgumentException.php @@ -11,15 +11,10 @@ namespace Symfony\Component\Cache\Exception; -use Psr\Cache\InvalidArgumentException as Psr6CacheInterface; use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInterface; if (interface_exists(SimpleCacheInterface::class)) { - class InvalidArgumentException extends \InvalidArgumentException implements Psr6CacheInterface, SimpleCacheInterface - { - } + require __DIR__.\DIRECTORY_SEPARATOR.'InvalidArgumentException+psr16.php'; } else { - class InvalidArgumentException extends \InvalidArgumentException implements Psr6CacheInterface - { - } + require __DIR__.\DIRECTORY_SEPARATOR.'InvalidArgumentException-psr16.php'; } diff --git a/src/Symfony/Component/Cache/Exception/LogicException+psr16.php b/src/Symfony/Component/Cache/Exception/LogicException+psr16.php new file mode 100644 index 0000000000..d299673eb2 --- /dev/null +++ b/src/Symfony/Component/Cache/Exception/LogicException+psr16.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Exception; + +use Psr\Cache\CacheException as Psr6CacheInterface; +use Psr\SimpleCache\CacheException as SimpleCacheInterface; + +class LogicException extends \LogicException implements Psr6CacheInterface, SimpleCacheInterface +{ +} diff --git a/src/Symfony/Component/Cache/Exception/LogicException-psr16.php b/src/Symfony/Component/Cache/Exception/LogicException-psr16.php new file mode 100644 index 0000000000..fc330ffaf9 --- /dev/null +++ b/src/Symfony/Component/Cache/Exception/LogicException-psr16.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Exception; + +use Psr\Cache\CacheException as Psr6CacheInterface; + +class LogicException extends \LogicException implements Psr6CacheInterface +{ +} diff --git a/src/Symfony/Component/Cache/Exception/LogicException.php b/src/Symfony/Component/Cache/Exception/LogicException.php index 9ffa7ed695..2a69ebe655 100644 --- a/src/Symfony/Component/Cache/Exception/LogicException.php +++ b/src/Symfony/Component/Cache/Exception/LogicException.php @@ -11,15 +11,10 @@ namespace Symfony\Component\Cache\Exception; -use Psr\Cache\CacheException as Psr6CacheInterface; -use Psr\SimpleCache\CacheException as SimpleCacheInterface; +use Psr\SimpleCache\LogicException as SimpleCacheInterface; if (interface_exists(SimpleCacheInterface::class)) { - class LogicException extends \LogicException implements Psr6CacheInterface, SimpleCacheInterface - { - } + require __DIR__.\DIRECTORY_SEPARATOR.'LogicException-psr16.php'; } else { - class LogicException extends \LogicException implements Psr6CacheInterface - { - } + require __DIR__.\DIRECTORY_SEPARATOR.'LogicException-psr16.php'; } diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index dca5687a20..e40d97b2fb 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -523,4 +523,26 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition { return $this->children; } + + /** + * Finds a node defined by the given $nodePath. + * + * @param string $nodePath The path of the node to find. e.g "doctrine.orm.mappings" + */ + public function find(string $nodePath): NodeDefinition + { + $firstPathSegment = (false === $pathSeparatorPos = strpos($nodePath, $this->pathSeparator)) + ? $nodePath + : substr($nodePath, 0, $pathSeparatorPos); + + if (null === $node = ($this->children[$firstPathSegment] ?? null)) { + throw new \RuntimeException(sprintf('Node with name "%s" does not exist in the current node "%s".', $firstPathSegment, $this->name)); + } + + if (false === $pathSeparatorPos) { + return $node; + } + + return $node->find(substr($nodePath, $pathSeparatorPos + \strlen($this->pathSeparator))); + } } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php index 0aa2a08ab4..0c414a9b9d 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -13,6 +13,8 @@ namespace Symfony\Component\Config\Tests\Definition\Builder; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; +use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition; +use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition; use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException; use Symfony\Component\Config\Definition\Processor; @@ -357,6 +359,85 @@ class ArrayNodeDefinitionTest extends TestCase $node->getNode()->finalize([]); } + public function testFindShouldThrowExceptionIfNodeDoesNotExistInRootNode() + { + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Node with name "child" does not exist in the current node "root".'); + + $rootNode = new ArrayNodeDefinition('root'); + $rootNode + ->children() + ->arrayNode('social_media_channels')->end() + ->end() + ; + + $rootNode->find('child'); + } + + public function testFindShouldHandleComplexConfigurationProperly() + { + $rootNode = new ArrayNodeDefinition('root'); + $rootNode + ->children() + ->arrayNode('social_media_channels') + ->children() + ->booleanNode('enable')->end() + ->arrayNode('twitter')->end() + ->arrayNode('facebook')->end() + ->arrayNode('instagram') + ->children() + ->booleanNode('enable')->end() + ->arrayNode('accounts')->end() + ->end() + ->end() + ->end() + ->append( + $mailerNode = (new ArrayNodeDefinition('mailer')) + ->children() + ->booleanNode('enable')->end() + ->arrayNode('transports')->end() + ->end() + ) + ->end() + ; + + $this->assertNode('social_media_channels', ArrayNodeDefinition::class, $rootNode->find('social_media_channels')); + $this->assertNode('enable', BooleanNodeDefinition::class, $rootNode->find('social_media_channels.enable')); + $this->assertNode('twitter', ArrayNodeDefinition::class, $rootNode->find('social_media_channels.twitter')); + $this->assertNode('facebook', ArrayNodeDefinition::class, $rootNode->find('social_media_channels.facebook')); + $this->assertNode('instagram', ArrayNodeDefinition::class, $rootNode->find('social_media_channels.instagram')); + $this->assertNode('enable', BooleanNodeDefinition::class, $rootNode->find('social_media_channels.instagram.enable')); + $this->assertNode('accounts', ArrayNodeDefinition::class, $rootNode->find('social_media_channels.instagram.accounts')); + + $this->assertNode('enable', BooleanNodeDefinition::class, $mailerNode->find('enable')); + $this->assertNode('transports', ArrayNodeDefinition::class, $mailerNode->find('transports')); + } + + public function testFindShouldWorkProperlyForNonDefaultPathSeparator() + { + $rootNode = new ArrayNodeDefinition('root'); + $rootNode + ->setPathSeparator('.|') + ->children() + ->arrayNode('mailer.configuration') + ->children() + ->booleanNode('enable')->end() + ->arrayNode('transports')->end() + ->end() + ->end() + ; + + $this->assertNode('mailer.configuration', ArrayNodeDefinition::class, $rootNode->find('mailer.configuration')); + $this->assertNode('enable', BooleanNodeDefinition::class, $rootNode->find('mailer.configuration.|enable')); + $this->assertNode('transports', ArrayNodeDefinition::class, $rootNode->find('mailer.configuration.|transports')); + } + + protected function assertNode(string $expectedName, string $expectedType, NodeDefinition $actualNode): void + { + $this->assertInstanceOf($expectedType, $actualNode); + $this->assertSame($expectedName, $this->getField($actualNode, 'name')); + } + protected function getField($object, $field) { $reflection = new \ReflectionProperty($object, $field); diff --git a/src/Symfony/Component/DomCrawler/CHANGELOG.md b/src/Symfony/Component/DomCrawler/CHANGELOG.md index 4a0f2702f7..09cc0a55eb 100644 --- a/src/Symfony/Component/DomCrawler/CHANGELOG.md +++ b/src/Symfony/Component/DomCrawler/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG * Added argument `$selector` to ``Crawler::children()` * Added argument `$default` to ``Crawler::text()` and `html()` +4.4.0 +----- + +* Added `Form::getName()` method. + 4.3.0 ----- diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 8bdd364347..13d3bc70a8 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -250,6 +250,16 @@ class Form extends Link implements \ArrayAccess return $this->node->getAttribute('method') ? strtoupper($this->node->getAttribute('method')) : 'GET'; } + /** + * Gets the form name. + * + * If no name is defined on the form, an empty string is returned. + */ + public function getName(): string + { + return $this->node->getAttribute('name'); + } + /** * Returns true if the named field exists. * diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 2c0ee22c1f..f5827f0643 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -327,6 +327,18 @@ class FormTest extends TestCase $this->assertEquals('POST', $form->getMethod(), '->getMethod() returns the method attribute value of the form'); } + public function testGetName() + { + $form = $this->createForm('
'); + $this->assertSame('foo', $form->getName()); + } + + public function testGetNameOnFormWithoutName() + { + $form = $this->createForm(''); + $this->assertSame('', $form->getName()); + } + public function testGetSetValue() { $form = $this->createForm(''); diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index cc8f4604e9..324d212792 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -16,6 +16,7 @@ CHANGELOG 4.4.0 ----- + * deprecated passing an `ExpressionLanguage` instance as the second argument of `ExpressionValidator::__construct()`. Pass it as the first argument instead. * added the `compared_value_path` parameter in violations when using any comparison constraint with the `propertyPath` option. * added support for checking an array of types in `TypeValidator` diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php index b5476910e1..ff572fce17 100644 --- a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -24,8 +24,20 @@ class ExpressionValidator extends ConstraintValidator { private $expressionLanguage; - public function __construct($propertyAccessor = null, ExpressionLanguage $expressionLanguage = null) + public function __construct(/*ExpressionLanguage */$expressionLanguage = null) { + if (\func_num_args() > 1) { + @trigger_error(sprintf('The "%s" instance should be passed as "%s" first argument instead of second argument since 4.4.', ExpressionLanguage::class, __METHOD__), E_USER_DEPRECATED); + + $expressionLanguage = func_get_arg(1); + + if (null !== $expressionLanguage && !$expressionLanguage instanceof ExpressionLanguage) { + throw new \TypeError(sprintf('Argument 2 passed to %s() must be an instance of %s or null, %s given. Since 4.4, passing it as the second argument is deprecated and will trigger a deprecation. Pass it as the first argument instead.', __METHOD__, ExpressionLanguage::class, \is_object($expressionLanguage) ? \get_class($expressionLanguage) : \gettype($expressionLanguage))); + } + } elseif (null !== $expressionLanguage && !$expressionLanguage instanceof ExpressionLanguage) { + @trigger_error(sprintf('The "%s" first argument must be an instance of "%s" or null since 4.4. "%s" given', __METHOD__, ExpressionLanguage::class, \is_object($expressionLanguage) ? \get_class($expressionLanguage) : \gettype($expressionLanguage)), E_USER_DEPRECATED); + } + $this->expressionLanguage = $expressionLanguage; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 7e1b460a80..e1507fa8e9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\Validator\Constraints\Expression; use Symfony\Component\Validator\Constraints\ExpressionValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; @@ -253,6 +254,34 @@ class ExpressionValidatorTest extends ConstraintValidatorTestCase 'expression' => 'false', ]); + $expressionLanguage = $this->getMockBuilder(ExpressionLanguage::class)->getMock(); + + $used = false; + + $expressionLanguage->method('evaluate') + ->willReturnCallback(function () use (&$used) { + $used = true; + + return true; + }); + + $validator = new ExpressionValidator($expressionLanguage); + $validator->initialize($this->createContext()); + $validator->validate(null, $constraint); + + $this->assertTrue($used, 'Failed asserting that custom ExpressionLanguage instance is used.'); + } + + /** + * @group legacy + * @expectedDeprecation The "Symfony\Component\ExpressionLanguage\ExpressionLanguage" instance should be passed as "Symfony\Component\Validator\Constraints\ExpressionValidator::__construct" first argument instead of second argument since 4.4. + */ + public function testLegacyExpressionLanguageUsage() + { + $constraint = new Expression([ + 'expression' => 'false', + ]); + $expressionLanguage = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ExpressionLanguage')->getMock(); $used = false; @@ -271,6 +300,15 @@ class ExpressionValidatorTest extends ConstraintValidatorTestCase $this->assertTrue($used, 'Failed asserting that custom ExpressionLanguage instance is used.'); } + /** + * @group legacy + * @expectedDeprecation The "Symfony\Component\Validator\Constraints\ExpressionValidator::__construct" first argument must be an instance of "Symfony\Component\ExpressionLanguage\ExpressionLanguage" or null since 4.4. "string" given + */ + public function testConstructorInvalidType() + { + new ExpressionValidator('foo'); + } + public function testPassingCustomValues() { $constraint = new Expression([ diff --git a/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php b/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php index 78acb90b66..aa10465861 100644 --- a/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php @@ -48,4 +48,16 @@ class SymfonyCaster return $a; } + + public static function castHttpClientResponse($response, array $a, Stub $stub, $isNested) + { + $stub->cut += \count($a); + $a = []; + + foreach ($response->getInfo() + ['debug' => $response->getInfo('debug')] as $k => $v) { + $a[Caster::PREFIX_VIRTUAL.$k] = $v; + } + + return $a; + } } diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index aacab2c885..ea2b45ffa1 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -78,8 +78,8 @@ abstract class AbstractCloner implements ClonerInterface 'Symfony\Component\DependencyInjection\ContainerInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], 'Symfony\Component\HttpClient\CurlHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], 'Symfony\Component\HttpClient\NativeHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], - 'Symfony\Component\HttpClient\Response\CurlResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], - 'Symfony\Component\HttpClient\Response\NativeResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], + 'Symfony\Component\HttpClient\Response\CurlResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], + 'Symfony\Component\HttpClient\Response\NativeResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], 'Symfony\Component\HttpFoundation\Request' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castRequest'], 'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castThrowingCasterException'], 'Symfony\Component\VarDumper\Caster\TraceStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castTraceStub'], diff --git a/src/Symfony/Contracts/EventDispatcher/Event+psr14.php b/src/Symfony/Contracts/EventDispatcher/Event+psr14.php new file mode 100644 index 0000000000..26ca47377a --- /dev/null +++ b/src/Symfony/Contracts/EventDispatcher/Event+psr14.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Contracts\EventDispatcher; + +use Psr\EventDispatcher\StoppableEventInterface; + +/** + * Event is the base class for classes containing event data. + * + * This class contains no event data. It is used by events that do not pass + * state information to an event handler when an event is raised. + * + * You can call the method stopPropagation() to abort the execution of + * further listeners in your event listener. + * + * @author Guilherme Blanco
+ */
+class Event implements StoppableEventInterface
+{
+ private $propagationStopped = false;
+
+ /**
+ * Returns whether further event listeners should be triggered.
+ */
+ public function isPropagationStopped(): bool
+ {
+ return $this->propagationStopped;
+ }
+
+ /**
+ * Stops the propagation of the event to further event listeners.
+ *
+ * If multiple event listeners are connected to the same event, no
+ * further event listener will be triggered once any trigger calls
+ * stopPropagation().
+ */
+ public function stopPropagation(): void
+ {
+ $this->propagationStopped = true;
+ }
+}
diff --git a/src/Symfony/Contracts/EventDispatcher/Event-psr14.php b/src/Symfony/Contracts/EventDispatcher/Event-psr14.php
new file mode 100644
index 0000000000..7636c8bf17
--- /dev/null
+++ b/src/Symfony/Contracts/EventDispatcher/Event-psr14.php
@@ -0,0 +1,52 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\EventDispatcher;
+
+/**
+ * Event is the base class for classes containing event data.
+ *
+ * This class contains no event data. It is used by events that do not pass
+ * state information to an event handler when an event is raised.
+ *
+ * You can call the method stopPropagation() to abort the execution of
+ * further listeners in your event listener.
+ *
+ * @author Guilherme Blanco
+ */
+class Event
+{
+ private $propagationStopped = false;
+
+ /**
+ * Returns whether further event listeners should be triggered.
+ */
+ public function isPropagationStopped(): bool
+ {
+ return $this->propagationStopped;
+ }
+
+ /**
+ * Stops the propagation of the event to further event listeners.
+ *
+ * If multiple event listeners are connected to the same event, no
+ * further event listener will be triggered once any trigger calls
+ * stopPropagation().
+ */
+ public function stopPropagation(): void
+ {
+ $this->propagationStopped = true;
+ }
+}
diff --git a/src/Symfony/Contracts/EventDispatcher/Event.php b/src/Symfony/Contracts/EventDispatcher/Event.php
index 84f60f3ed0..3574fd44e9 100644
--- a/src/Symfony/Contracts/EventDispatcher/Event.php
+++ b/src/Symfony/Contracts/EventDispatcher/Event.php
@@ -14,83 +14,7 @@ namespace Symfony\Contracts\EventDispatcher;
use Psr\EventDispatcher\StoppableEventInterface;
if (interface_exists(StoppableEventInterface::class)) {
- /**
- * Event is the base class for classes containing event data.
- *
- * This class contains no event data. It is used by events that do not pass
- * state information to an event handler when an event is raised.
- *
- * You can call the method stopPropagation() to abort the execution of
- * further listeners in your event listener.
- *
- * @author Guilherme Blanco
- */
- class Event implements StoppableEventInterface
- {
- private $propagationStopped = false;
-
- /**
- * Returns whether further event listeners should be triggered.
- */
- public function isPropagationStopped(): bool
- {
- return $this->propagationStopped;
- }
-
- /**
- * Stops the propagation of the event to further event listeners.
- *
- * If multiple event listeners are connected to the same event, no
- * further event listener will be triggered once any trigger calls
- * stopPropagation().
- */
- public function stopPropagation(): void
- {
- $this->propagationStopped = true;
- }
- }
+ require __DIR__.\DIRECTORY_SEPARATOR.'Event+psr14.php';
} else {
- /**
- * Event is the base class for classes containing event data.
- *
- * This class contains no event data. It is used by events that do not pass
- * state information to an event handler when an event is raised.
- *
- * You can call the method stopPropagation() to abort the execution of
- * further listeners in your event listener.
- *
- * @author Guilherme Blanco
- */
- class Event
- {
- private $propagationStopped = false;
-
- /**
- * Returns whether further event listeners should be triggered.
- */
- public function isPropagationStopped(): bool
- {
- return $this->propagationStopped;
- }
-
- /**
- * Stops the propagation of the event to further event listeners.
- *
- * If multiple event listeners are connected to the same event, no
- * further event listener will be triggered once any trigger calls
- * stopPropagation().
- */
- public function stopPropagation(): void
- {
- $this->propagationStopped = true;
- }
- }
+ require __DIR__.\DIRECTORY_SEPARATOR.'Event-psr14.php';
}
diff --git a/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface+psr14.php b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface+psr14.php
new file mode 100644
index 0000000000..fcfa91c700
--- /dev/null
+++ b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface+psr14.php
@@ -0,0 +1,35 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\EventDispatcher;
+
+use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;
+
+/**
+ * Allows providing hooks on domain-specific lifecycles by dispatching events.
+ */
+interface EventDispatcherInterface extends PsrEventDispatcherInterface
+{
+ /**
+ * Dispatches an event to all registered listeners.
+ *
+ * For BC with Symfony 4, the $eventName argument is not declared explicitly on the
+ * signature of the method. Implementations that are not bound by this BC constraint
+ * MUST declare it explicitly, as allowed by PHP.
+ *
+ * @param object $event The event to pass to the event handlers/listeners
+ * @param string|null $eventName The name of the event to dispatch. If not supplied,
+ * the class of $event should be used instead.
+ *
+ * @return object The passed $event MUST be returned
+ */
+ public function dispatch($event/*, string $eventName = null*/);
+}
diff --git a/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface-psr14.php b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface-psr14.php
new file mode 100644
index 0000000000..a630339bdc
--- /dev/null
+++ b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface-psr14.php
@@ -0,0 +1,33 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\EventDispatcher;
+
+/**
+ * Allows providing hooks on domain-specific lifecycles by dispatching events.
+ */
+interface EventDispatcherInterface
+{
+ /**
+ * Dispatches an event to all registered listeners.
+ *
+ * For BC with Symfony 4, the $eventName argument is not declared explicitly on the
+ * signature of the method. Implementations that are not bound by this BC constraint
+ * MUST declare it explicitly, as allowed by PHP.
+ *
+ * @param object $event The event to pass to the event handlers/listeners
+ * @param string|null $eventName The name of the event to dispatch. If not supplied,
+ * the class of $event should be used instead.
+ *
+ * @return object The passed $event MUST be returned
+ */
+ public function dispatch($event/*, string $eventName = null*/);
+}
diff --git a/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php
index 2d470af920..ef8be54b5a 100644
--- a/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php
+++ b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php
@@ -14,45 +14,7 @@ namespace Symfony\Contracts\EventDispatcher;
use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;
if (interface_exists(PsrEventDispatcherInterface::class)) {
- /**
- * Allows providing hooks on domain-specific lifecycles by dispatching events.
- */
- interface EventDispatcherInterface extends PsrEventDispatcherInterface
- {
- /**
- * Dispatches an event to all registered listeners.
- *
- * For BC with Symfony 4, the $eventName argument is not declared explicitly on the
- * signature of the method. Implementations that are not bound by this BC constraint
- * MUST declare it explicitly, as allowed by PHP.
- *
- * @param object $event The event to pass to the event handlers/listeners
- * @param string|null $eventName The name of the event to dispatch. If not supplied,
- * the class of $event should be used instead.
- *
- * @return object The passed $event MUST be returned
- */
- public function dispatch($event/*, string $eventName = null*/);
- }
+ require __DIR__.\DIRECTORY_SEPARATOR.'EventDispatcherInterface+psr14.php';
} else {
- /**
- * Allows providing hooks on domain-specific lifecycles by dispatching events.
- */
- interface EventDispatcherInterface
- {
- /**
- * Dispatches an event to all registered listeners.
- *
- * For BC with Symfony 4, the $eventName argument is not declared explicitly on the
- * signature of the method. Implementations that are not bound by this BC constraint
- * MUST declare it explicitly, as allowed by PHP.
- *
- * @param object $event The event to pass to the event handlers/listeners
- * @param string|null $eventName The name of the event to dispatch. If not supplied,
- * the class of $event should be used instead.
- *
- * @return object The passed $event MUST be returned
- */
- public function dispatch($event/*, string $eventName = null*/);
- }
+ require __DIR__.\DIRECTORY_SEPARATOR.'EventDispatcherInterface-psr14.php';
}