From 133325af32a622723bb2992386736ea083789ca5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 8 Jun 2019 16:53:56 +0200 Subject: [PATCH] Remove deprecated code paths that trigger a runtime notice --- src/Symfony/Bridge/Doctrine/CHANGELOG.md | 1 + .../PropertyInfo/DoctrineExtractor.php | 15 +- .../PropertyInfo/DoctrineExtractorTest.php | 79 +- src/Symfony/Bridge/PhpUnit/CHANGELOG.md | 5 + .../PhpUnit/DeprecationErrorHandler.php | 12 - src/Symfony/Bridge/Twig/CHANGELOG.md | 1 + .../Extension/HttpFoundationExtension.php | 29 +- .../Twig/Extension/TranslationExtension.php | 7 +- .../Extension/HttpFoundationExtensionTest.php | 14 +- .../Bundle/FrameworkBundle/CHANGELOG.md | 1 + .../Controller/ControllerResolver.php | 2 +- .../Resources/config/console.xml | 1 - .../Routing/DelegatingLoader.php | 2 +- .../DependencyInjection/MainConfiguration.php | 16 - .../Security/FirewallContext.php | 16 +- .../SecurityUserValueResolver.php | 62 -- .../CompleteConfigurationTest.php | 14 - .../Tests/Security/FirewallContextTest.php | 9 - .../Tests/SecurityUserValueResolverTest.php | 104 --- .../Bundle/TwigBundle/TemplateIterator.php | 2 +- .../Component/BrowserKit/AbstractBrowser.php | 4 +- src/Symfony/Component/Config/CHANGELOG.md | 1 + .../Definition/Builder/NodeDefinition.php | 8 +- .../Component/Config/Definition/Processor.php | 4 +- .../Exception/FileLoaderLoadException.php | 111 --- .../Config/Exception/LoaderLoadException.php | 90 +- .../Resource/ClassExistenceResource.php | 4 +- .../Config/Resource/ComposerResource.php | 4 +- .../Config/Resource/DirectoryResource.php | 4 +- .../Config/Resource/FileExistenceResource.php | 4 +- .../Config/Resource/FileResource.php | 4 +- .../Config/Resource/GlobResource.php | 4 +- .../Resource/ReflectionClassResource.php | 7 +- .../SelfCheckingResourceInterface.php | 2 +- src/Symfony/Component/Debug/CHANGELOG.md | 5 + .../Debug/Exception/FlattenException.php | 10 - .../DependencyInjection/CHANGELOG.md | 9 +- .../Config/ContainerParametersResource.php | 2 +- .../DependencyInjection/Definition.php | 2 +- .../DependencyInjection/Dumper/PhpDumper.php | 2 +- .../php/container_alias_deprecation.php | 2 +- ...er_class_constructor_without_arguments.php | 2 +- ...s_with_mandatory_constructor_arguments.php | 2 +- ...ss_with_optional_constructor_arguments.php | 2 +- ...om_container_class_without_constructor.php | 2 +- .../Tests/Fixtures/php/services1-1.php | 2 +- .../Tests/Fixtures/php/services1.php | 2 +- .../Tests/Fixtures/php/services10.php | 2 +- .../Tests/Fixtures/php/services12.php | 2 +- .../Tests/Fixtures/php/services13.php | 2 +- .../Tests/Fixtures/php/services19.php | 2 +- .../Tests/Fixtures/php/services24.php | 2 +- .../Tests/Fixtures/php/services26.php | 2 +- .../Tests/Fixtures/php/services33.php | 2 +- .../Tests/Fixtures/php/services8.php | 2 +- .../Tests/Fixtures/php/services9_as_files.txt | 2 +- .../Tests/Fixtures/php/services9_compiled.php | 2 +- .../Tests/Fixtures/php/services_adawson.php | 2 +- .../php/services_almost_circular_private.php | 2 +- .../php/services_almost_circular_public.php | 2 +- .../Fixtures/php/services_array_params.php | 2 +- .../Fixtures/php/services_base64_env.php | 2 +- .../Tests/Fixtures/php/services_csv_env.php | 2 +- .../php/services_dedup_lazy_proxy.php | 2 +- .../Fixtures/php/services_deep_graph.php | 2 +- .../Fixtures/php/services_default_env.php | 2 +- .../Tests/Fixtures/php/services_env_in_id.php | 2 +- .../php/services_errored_definition.php | 2 +- .../Fixtures/php/services_inline_requires.php | 2 +- .../Fixtures/php/services_inline_self_ref.php | 2 +- .../Tests/Fixtures/php/services_json_env.php | 2 +- .../Tests/Fixtures/php/services_locator.php | 2 +- .../Fixtures/php/services_non_shared_lazy.php | 2 +- .../php/services_non_shared_lazy_as_files.txt | 4 +- .../Fixtures/php/services_private_frozen.php | 2 +- .../php/services_private_in_expression.php | 2 +- .../php/services_query_string_env.php | 2 +- .../Tests/Fixtures/php/services_rot13_env.php | 2 +- .../php/services_service_locator_argument.php | 2 +- .../Fixtures/php/services_subscriber.php | 2 +- .../Tests/Fixtures/php/services_tsantos.php | 2 +- .../php/services_uninitialized_ref.php | 2 +- .../php/services_unsupported_characters.php | 2 +- .../Tests/Fixtures/php/services_url_env.php | 2 +- .../Tests/Fixtures/php/services_wither.php | 2 +- src/Symfony/Component/DomCrawler/CHANGELOG.md | 6 + src/Symfony/Component/DomCrawler/Crawler.php | 15 +- .../DomCrawler/Tests/AbstractCrawlerTest.php | 58 +- src/Symfony/Component/Dotenv/CHANGELOG.md | 5 + src/Symfony/Component/Dotenv/Dotenv.php | 9 +- .../Component/Dotenv/Tests/DotenvTest.php | 9 - .../Debug/TraceableEventDispatcher.php | 6 +- src/Symfony/Component/Filesystem/CHANGELOG.md | 5 + .../Component/Filesystem/Filesystem.php | 4 +- .../Filesystem/Tests/FilesystemTest.php | 41 - src/Symfony/Component/Finder/CHANGELOG.md | 5 + src/Symfony/Component/Finder/Finder.php | 7 +- .../Component/Finder/Tests/FinderTest.php | 12 +- .../DataCollector/FormDataCollector.php | 2 +- .../Extension/Core/Type/ChoiceTypeTest.php | 15 - .../Component/HttpFoundation/CHANGELOG.md | 9 + .../Component/HttpFoundation/Cookie.php | 6 +- .../File/MimeType/ExtensionGuesser.php | 100 --- .../MimeType/ExtensionGuesserInterface.php | 31 - .../MimeType/FileBinaryMimeTypeGuesser.php | 104 --- .../File/MimeType/FileinfoMimeTypeGuesser.php | 74 -- .../MimeType/MimeTypeExtensionGuesser.php | 826 ------------------ .../File/MimeType/MimeTypeGuesser.php | 136 --- .../MimeType/MimeTypeGuesserInterface.php | 38 - .../HttpFoundation/File/UploadedFile.php | 26 +- .../Component/HttpFoundation/Request.php | 7 +- .../Component/HttpFoundation/Response.php | 5 - .../Tests/File/MimeType/MimeTypeTest.php | 89 -- .../Tests/File/UploadedFileTest.php | 34 - .../HttpFoundation/Tests/RequestTest.php | 9 - src/Symfony/Component/HttpKernel/CHANGELOG.md | 2 + .../DataCollector/DataCollector.php | 44 +- .../DataCollector/DumpDataCollector.php | 2 +- .../HttpKernel/Debug/FileLinkFormatter.php | 4 +- .../Profiler/FileProfilerStorage.php | 2 +- .../Profiler/ProfilerStorageInterface.php | 17 +- src/Symfony/Component/Lock/LockInterface.php | 2 +- src/Symfony/Component/Messenger/CHANGELOG.md | 1 + .../Command/ConsumeMessagesCommand.php | 22 +- .../Command/ConsumeMessagesCommandTest.php | 73 -- .../Transport/Sender/SendersLocatorTest.php | 25 - .../Transport/Sender/SendersLocator.php | 12 +- .../Component/OptionsResolver/CHANGELOG.md | 5 + .../OptionsResolver/OptionsResolver.php | 4 +- src/Symfony/Component/Process/CHANGELOG.md | 7 + src/Symfony/Component/Process/PhpProcess.php | 12 - src/Symfony/Component/Process/Process.php | 24 +- .../Routing/Loader/AnnotationClassLoader.php | 4 +- .../Routing/Loader/YamlFileLoader.php | 2 +- .../Loader/AnnotationClassLoaderTest.php | 7 +- .../Tests/Loader/YamlFileLoaderTest.php | 4 +- src/Symfony/Component/Security/CHANGELOG.md | 3 + .../Authorization/Voter/ExpressionVoter.php | 10 - .../Component/Security/Core/Security.php | 3 +- .../Security/Core/Tests/SecurityTest.php | 24 +- .../Http/Firewall/RememberMeListener.php | 2 +- .../Session/SessionAuthenticationStrategy.php | 2 +- .../TranslationDataCollector.php | 2 +- .../Component/Translation/Translator.php | 2 +- src/Symfony/Component/Workflow/CHANGELOG.md | 5 + .../MarkingStore/MarkingStoreInterface.php | 9 +- 146 files changed, 324 insertions(+), 2471 deletions(-) delete mode 100644 src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php delete mode 100644 src/Symfony/Component/Config/Exception/FileLoaderLoadException.php delete mode 100644 src/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php delete mode 100644 src/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php delete mode 100644 src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php delete mode 100644 src/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php delete mode 100644 src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php delete mode 100644 src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php delete mode 100644 src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php delete mode 100644 src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php diff --git a/src/Symfony/Bridge/Doctrine/CHANGELOG.md b/src/Symfony/Bridge/Doctrine/CHANGELOG.md index 983a7d939c10c..e7d6e2d20cc7f 100644 --- a/src/Symfony/Bridge/Doctrine/CHANGELOG.md +++ b/src/Symfony/Bridge/Doctrine/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * passing an `IdReader` to the `DoctrineChoiceLoader` when the query cannot be optimized with single id field, throws an exception; pass `null` instead * not explicitly passing an instance of `IdReader` to `DoctrineChoiceLoader` when it can optimize single id field, will not apply any optimization + * `DoctrineExtractor` now requires an `EntityManagerInterface` on instantiation 4.4.0 ----- diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index f14c38b36252a..89bb9afaf9681 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\PropertyInfo; -use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory; use Doctrine\Common\Persistence\Mapping\MappingException; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\EntityManagerInterface; @@ -33,19 +32,9 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE private $entityManager; private $classMetadataFactory; - /** - * @param EntityManagerInterface $entityManager - */ - public function __construct($entityManager) + public function __construct(EntityManagerInterface $entityManager) { - if ($entityManager instanceof EntityManagerInterface) { - $this->entityManager = $entityManager; - } elseif ($entityManager instanceof ClassMetadataFactory) { - @trigger_error(sprintf('Injecting an instance of "%s" in "%s" is deprecated since Symfony 4.2, inject an instance of "%s" instead.', ClassMetadataFactory::class, __CLASS__, EntityManagerInterface::class), E_USER_DEPRECATED); - $this->classMetadataFactory = $entityManager; - } else { - throw new \TypeError(sprintf('$entityManager must be an instance of "%s", "%s" given.', EntityManagerInterface::class, \is_object($entityManager) ? \get_class($entityManager) : \gettype($entityManager))); - } + $this->entityManager = $entityManager; } /** diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index dd5200117cfea..2a65ee9b0fc14 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -24,7 +24,7 @@ */ class DoctrineExtractorTest extends TestCase { - private function createExtractor(bool $legacy = false) + private function createExtractor() { $config = Setup::createAnnotationMetadataConfiguration([__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'], true); $entityManager = EntityManager::create(['driver' => 'pdo_sqlite'], $config); @@ -34,20 +34,10 @@ private function createExtractor(bool $legacy = false) $entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('custom_foo', 'foo'); } - return new DoctrineExtractor($legacy ? $entityManager->getMetadataFactory() : $entityManager); + return new DoctrineExtractor($entityManager); } public function testGetProperties() - { - $this->doTestGetProperties(false); - } - - public function testLegacyGetProperties() - { - $this->doTestGetProperties(true); - } - - private function doTestGetProperties(bool $legacy) { $this->assertEquals( [ @@ -69,21 +59,11 @@ private function doTestGetProperties(bool $legacy) 'indexedBar', 'indexedFoo', ], - $this->createExtractor($legacy)->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy') + $this->createExtractor()->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy') ); } public function testTestGetPropertiesWithEmbedded() - { - $this->doTestGetPropertiesWithEmbedded(false); - } - - public function testLegacyTestGetPropertiesWithEmbedded() - { - $this->doTestGetPropertiesWithEmbedded(true); - } - - private function doTestGetPropertiesWithEmbedded(bool $legacy) { if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); @@ -94,7 +74,7 @@ private function doTestGetPropertiesWithEmbedded(bool $legacy) 'id', 'embedded', ], - $this->createExtractor($legacy)->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded') + $this->createExtractor()->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded') ); } @@ -103,33 +83,10 @@ private function doTestGetPropertiesWithEmbedded(bool $legacy) */ public function testExtract($property, array $type = null) { - $this->doTestExtract(false, $property, $type); - } - - /** - * @dataProvider typesProvider - */ - public function testLegacyExtract($property, array $type = null) - { - $this->doTestExtract(true, $property, $type); - } - - private function doTestExtract(bool $legacy, $property, array $type = null) - { - $this->assertEquals($type, $this->createExtractor($legacy)->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, [])); + $this->assertEquals($type, $this->createExtractor()->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, [])); } public function testExtractWithEmbedded() - { - $this->doTestExtractWithEmbedded(false); - } - - public function testLegacyExtractWithEmbedded() - { - $this->doTestExtractWithEmbedded(true); - } - - private function doTestExtractWithEmbedded(bool $legacy) { if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); @@ -141,7 +98,7 @@ private function doTestExtractWithEmbedded(bool $legacy) 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineEmbeddable' )]; - $actualTypes = $this->createExtractor($legacy)->getTypes( + $actualTypes = $this->createExtractor()->getTypes( 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded', 'embedded', [] @@ -197,32 +154,12 @@ public function typesProvider() public function testGetPropertiesCatchException() { - $this->doTestGetPropertiesCatchException(false); - } - - public function testLegacyGetPropertiesCatchException() - { - $this->doTestGetPropertiesCatchException(true); - } - - private function doTestGetPropertiesCatchException(bool $legacy) - { - $this->assertNull($this->createExtractor($legacy)->getProperties('Not\Exist')); + $this->assertNull($this->createExtractor()->getProperties('Not\Exist')); } public function testGetTypesCatchException() { - return $this->doTestGetTypesCatchException(false); - } - - public function testLegacyGetTypesCatchException() - { - return $this->doTestGetTypesCatchException(true); - } - - private function doTestGetTypesCatchException(bool $legacy) - { - $this->assertNull($this->createExtractor($legacy)->getTypes('Not\Exist', 'baz')); + $this->assertNull($this->createExtractor()->getTypes('Not\Exist', 'baz')); } public function testGeneratedValueNotWritable() diff --git a/src/Symfony/Bridge/PhpUnit/CHANGELOG.md b/src/Symfony/Bridge/PhpUnit/CHANGELOG.md index 8cd3c372f2298..2fa3eedee8291 100644 --- a/src/Symfony/Bridge/PhpUnit/CHANGELOG.md +++ b/src/Symfony/Bridge/PhpUnit/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * removed `weak_vendor` mode, use `max[self]=0` instead + 4.3.0 ----- diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 55089e0be11f6..d9a570c837e86 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -21,11 +21,6 @@ */ class DeprecationErrorHandler { - /** - * @deprecated since Symfony 4.3, use max[self]=0 instead - */ - const MODE_WEAK_VENDORS = 'weak_vendors'; - const MODE_DISABLED = 'disabled'; const MODE_WEAK = 'max[total]=999999&verbose=0'; const MODE_STRICT = 'max[total]=0'; @@ -227,13 +222,6 @@ private function getConfiguration() if ('weak' === $mode) { return $this->configuration = Configuration::inWeakMode(); } - if (self::MODE_WEAK_VENDORS === $mode) { - ++$this->deprecations['remaining directCount']; - $msg = sprintf('Setting SYMFONY_DEPRECATIONS_HELPER to "%s" is deprecated in favor of "max[self]=0"', $mode); - $ref = &$this->deprecations['remaining direct'][$msg]['count']; - ++$ref; - $mode = 'max[self]=0'; - } if (isset($mode[0]) && '/' === $mode[0]) { return $this->configuration = Configuration::fromRegex($mode); } diff --git a/src/Symfony/Bridge/Twig/CHANGELOG.md b/src/Symfony/Bridge/Twig/CHANGELOG.md index 65246534c5249..4d380ba0c356d 100644 --- a/src/Symfony/Bridge/Twig/CHANGELOG.md +++ b/src/Symfony/Bridge/Twig/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * removed `TwigEngine` class, use `\Twig\Environment` instead. * removed `transChoice` filter and token + * `HttpFoundationExtension` requires a `UrlHelper` on instantiation 4.4.0 ----- diff --git a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php index a72339e1243e1..8e9fad837d910 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php @@ -12,9 +12,7 @@ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\UrlHelper; -use Symfony\Component\Routing\RequestContext; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -27,32 +25,9 @@ class HttpFoundationExtension extends AbstractExtension { private $urlHelper; - /** - * @param UrlHelper $urlHelper - */ - public function __construct($urlHelper) + public function __construct(UrlHelper $urlHelper) { - if ($urlHelper instanceof UrlHelper) { - $this->urlHelper = $urlHelper; - - return; - } - - if (!$urlHelper instanceof RequestStack) { - throw new \TypeError(sprintf('The first argument must be an instance of "%s" or an instance of "%s".', UrlHelper::class, RequestStack::class)); - } - - @trigger_error(sprintf('Passing a "%s" instance as the first argument to the "%s" constructor is deprecated since Symfony 4.3, pass a "%s" instance instead.', RequestStack::class, __CLASS__, UrlHelper::class), E_USER_DEPRECATED); - - $requestContext = null; - if (2 === \func_num_args()) { - $requestContext = \func_get_arg(1); - if (null !== $requestContext && !$requestContext instanceof RequestContext) { - throw new \TypeError(sprintf('The second argument must be an instance of "%s".', RequestContext::class)); - } - } - - $this->urlHelper = new UrlHelper($urlHelper, $requestContext); + $this->urlHelper = $urlHelper; } /** diff --git a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php index 163d5d56355c0..7bf3bdb24e8fe 100644 --- a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php @@ -27,7 +27,7 @@ * * @author Fabien Potencier * - * @final since Symfony 4.2 + * @final */ class TranslationExtension extends AbstractExtension { @@ -40,10 +40,7 @@ public function __construct(TranslatorInterface $translator = null, NodeVisitorI $this->translationNodeVisitor = $translationNodeVisitor; } - /** - * @return TranslatorInterface|null - */ - public function getTranslator() + public function getTranslator(): ?TranslatorInterface { if (null === $this->translator) { if (!interface_exists(TranslatorInterface::class)) { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php index 396f433bfda63..46031808589f9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -15,11 +15,9 @@ use Symfony\Bridge\Twig\Extension\HttpFoundationExtension; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\UrlHelper; use Symfony\Component\Routing\RequestContext; -/** - * @group legacy - */ class HttpFoundationExtensionTest extends TestCase { /** @@ -29,7 +27,7 @@ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) { $stack = new RequestStack(); $stack->push(Request::create($pathinfo)); - $extension = new HttpFoundationExtension($stack); + $extension = new HttpFoundationExtension(new UrlHelper($stack)); $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); } @@ -67,7 +65,7 @@ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host } $requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path); - $extension = new HttpFoundationExtension(new RequestStack(), $requestContext); + $extension = new HttpFoundationExtension(new UrlHelper(new RequestStack(), $requestContext)); $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); } @@ -81,7 +79,7 @@ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); } - $extension = new HttpFoundationExtension(new RequestStack()); + $extension = new HttpFoundationExtension(new UrlHelper(new RequestStack())); $this->assertEquals($path, $extension->generateAbsoluteUrl($path)); } @@ -107,7 +105,7 @@ public function testGenerateAbsoluteUrlWithScriptFileName() $stack = new RequestStack(); $stack->push($request); - $extension = new HttpFoundationExtension($stack); + $extension = new HttpFoundationExtension(new UrlHelper($stack)); $this->assertEquals( 'http://localhost/app/web/bundles/framework/css/structure.css', @@ -126,7 +124,7 @@ public function testGenerateRelativePath($expected, $path, $pathinfo) $stack = new RequestStack(); $stack->push(Request::create($pathinfo)); - $extension = new HttpFoundationExtension($stack); + $extension = new HttpFoundationExtension(new UrlHelper($stack)); $this->assertEquals($expected, $extension->generateRelativePath($path)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index cbd1861f63ddf..aa51ddf48b3e4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -16,6 +16,7 @@ CHANGELOG * Removed the `cache.app.simple` service and its corresponding PSR-16 autowiring alias * Removed cache-related compiler passes and `RequestDataCollector` * Removed the `translator.selector` and `session.save_listener` services + * Removed `SecurityUserValueResolver`, use `UserValueResolver` instead 4.4.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php index 9fc480759671e..a3d04de760b2f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php @@ -17,7 +17,7 @@ /** * @author Fabien Potencier * - * @final since Symfony 4.4 + * @final */ class ControllerResolver extends ContainerControllerResolver { diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml index ebd7d6ce46a6d..a8cb9765d491a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml @@ -93,7 +93,6 @@ - diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php index 4e11f1459c429..08690fa3dd078 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php @@ -23,7 +23,7 @@ * * @author Fabien Potencier * - * @final since Symfony 4.4 + * @final */ class DelegatingLoader extends BaseDelegatingLoader { diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index c1b2e6be34c65..228db30a7356a 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -225,22 +225,6 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto ->ifTrue(function ($v) { return \is_array($v) && \is_int(key($v)); }) ->then(function ($v) { return array_map(function ($v) { return ['name' => $v]; }, $v); }) ->end() - ->beforeNormalization() - ->ifArray()->then(function ($v) { - foreach ($v as $originalName => $cookieConfig) { - if (false !== strpos($originalName, '-')) { - $normalizedName = str_replace('-', '_', $originalName); - @trigger_error(sprintf('Normalization of cookie names is deprecated since Symfony 4.3. Starting from Symfony 5.0, the "%s" cookie configured in "logout.delete_cookies" will delete the "%s" cookie instead of the "%s" cookie.', $originalName, $originalName, $normalizedName), E_USER_DEPRECATED); - - // normalize cookie names manually for BC reasons. Remove it in Symfony 5.0. - $v[$normalizedName] = $cookieConfig; - unset($v[$originalName]); - } - } - - return $v; - }) - ->end() ->useAttributeAsKey('name') ->prototype('array') ->children() diff --git a/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php b/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php index d811faac4bf06..00754e4363cfc 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php @@ -27,22 +27,12 @@ class FirewallContext private $logoutListener; private $config; - /** - * @param LogoutListener|null $logoutListener - */ - public function __construct(iterable $listeners, ExceptionListener $exceptionListener = null, $logoutListener = null, FirewallConfig $config = null) + public function __construct(iterable $listeners, ExceptionListener $exceptionListener = null, LogoutListener $logoutListener = null, FirewallConfig $config = null) { $this->listeners = $listeners; $this->exceptionListener = $exceptionListener; - if ($logoutListener instanceof FirewallConfig) { - $this->config = $logoutListener; - @trigger_error(sprintf('Passing an instance of %s as the 3rd argument to "%s()" is deprecated since Symfony 4.2. Pass a %s instance instead.', FirewallConfig::class, __METHOD__, LogoutListener::class), E_USER_DEPRECATED); - } elseif (null === $logoutListener || $logoutListener instanceof LogoutListener) { - $this->logoutListener = $logoutListener; - $this->config = $config; - } else { - throw new \TypeError(sprintf('Argument 3 passed to %s() must be instance of %s or null, %s given.', __METHOD__, LogoutListener::class, \is_object($logoutListener) ? \get_class($logoutListener) : \gettype($logoutListener))); - } + $this->logoutListener = $logoutListener; + $this->config = $config; } public function getConfig() diff --git a/src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php b/src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php deleted file mode 100644 index 476e24ee4e456..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/SecurityUserValueResolver.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Security\Http\Controller\UserValueResolver; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.1, use "%s" instead.', SecurityUserValueResolver::class, UserValueResolver::class), E_USER_DEPRECATED); - -/** - * Supports the argument type of {@see UserInterface}. - * - * @author Iltar van der Berg - * - * @deprecated since Symfony 4.1, use {@link UserValueResolver} instead - */ -final class SecurityUserValueResolver implements ArgumentValueResolverInterface -{ - private $tokenStorage; - - public function __construct(TokenStorageInterface $tokenStorage) - { - $this->tokenStorage = $tokenStorage; - } - - public function supports(Request $request, ArgumentMetadata $argument) - { - // only security user implementations are supported - if (UserInterface::class !== $argument->getType()) { - return false; - } - - $token = $this->tokenStorage->getToken(); - if (!$token instanceof TokenInterface) { - return false; - } - - $user = $token->getUser(); - - // in case it's not an object we cannot do anything with it; E.g. "anon." - return $user instanceof UserInterface; - } - - public function resolve(Request $request, ArgumentMetadata $argument) - { - yield $this->tokenStorage->getToken()->getUser(); - } -} diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index bbeee1dcaf63c..2d0af768174e4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -469,20 +469,6 @@ public function testFirewallListenerWithProvider() $this->addToAssertionCount(1); } - /** - * @group legacy - * @expectedDeprecation Normalization of cookie names is deprecated since Symfony 4.3. Starting from Symfony 5.0, the "cookie1-name" cookie configured in "logout.delete_cookies" will delete the "cookie1-name" cookie instead of the "cookie1_name" cookie. - * @expectedDeprecation Normalization of cookie names is deprecated since Symfony 4.3. Starting from Symfony 5.0, the "cookie3-long_name" cookie configured in "logout.delete_cookies" will delete the "cookie3-long_name" cookie instead of the "cookie3_long_name" cookie. - */ - public function testLogoutDeleteCookieNamesNormalization() - { - $container = $this->getContainer('logout_delete_cookies'); - $cookiesToDelete = $container->getDefinition('security.logout.handler.cookie_clearing.main')->getArgument(0); - $expectedCookieNames = ['cookie2_name', 'cookie1_name', 'cookie3_long_name']; - - $this->assertSame($expectedCookieNames, array_keys($cookiesToDelete)); - } - protected function getContainer($file) { $file .= '.'.$this->getFileExtension(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php index 15f8764416099..c76783b7e08ad 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallContextTest.php @@ -34,15 +34,6 @@ public function testGetters() $this->assertEquals($config, $context->getConfig()); } - /** - * @group legacy - * @expectedDeprecation Passing an instance of Symfony\Bundle\SecurityBundle\Security\FirewallConfig as the 3rd argument to "Symfony\Bundle\SecurityBundle\Security\FirewallContext::__construct()" is deprecated since Symfony 4.2. Pass a Symfony\Component\Security\Http\Firewall\LogoutListener instance instead. - */ - public function testFirewallConfigAs3rdConstructorArgument() - { - new FirewallContext([], $this->getExceptionListenerMock(), new FirewallConfig('main', 'user_checker', 'request_matcher')); - } - private function getExceptionListenerMock() { return $this diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php deleted file mode 100644 index d015165739324..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\SecurityBundle\SecurityUserValueResolver; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\User\UserInterface; - -/** - * @group legacy - */ -class SecurityUserValueResolverTest extends TestCase -{ - public function testResolveNoToken() - { - $tokenStorage = new TokenStorage(); - $resolver = new SecurityUserValueResolver($tokenStorage); - $metadata = new ArgumentMetadata('foo', UserInterface::class, false, false, null); - - $this->assertFalse($resolver->supports(Request::create('/'), $metadata)); - } - - public function testResolveNoUser() - { - $mock = $this->getMockBuilder(UserInterface::class)->getMock(); - $token = $this->getMockBuilder(TokenInterface::class)->getMock(); - $tokenStorage = new TokenStorage(); - $tokenStorage->setToken($token); - - $resolver = new SecurityUserValueResolver($tokenStorage); - $metadata = new ArgumentMetadata('foo', \get_class($mock), false, false, null); - - $this->assertFalse($resolver->supports(Request::create('/'), $metadata)); - } - - public function testResolveWrongType() - { - $tokenStorage = new TokenStorage(); - $resolver = new SecurityUserValueResolver($tokenStorage); - $metadata = new ArgumentMetadata('foo', null, false, false, null); - - $this->assertFalse($resolver->supports(Request::create('/'), $metadata)); - } - - public function testResolve() - { - $user = $this->getMockBuilder(UserInterface::class)->getMock(); - $token = $this->getMockBuilder(TokenInterface::class)->getMock(); - $token->expects($this->any())->method('getUser')->willReturn($user); - $tokenStorage = new TokenStorage(); - $tokenStorage->setToken($token); - - $resolver = new SecurityUserValueResolver($tokenStorage); - $metadata = new ArgumentMetadata('foo', UserInterface::class, false, false, null); - - $this->assertTrue($resolver->supports(Request::create('/'), $metadata)); - $this->assertSame([$user], iterator_to_array($resolver->resolve(Request::create('/'), $metadata))); - } - - public function testIntegration() - { - $user = $this->getMockBuilder(UserInterface::class)->getMock(); - $token = $this->getMockBuilder(TokenInterface::class)->getMock(); - $token->expects($this->any())->method('getUser')->willReturn($user); - $tokenStorage = new TokenStorage(); - $tokenStorage->setToken($token); - - $argumentResolver = new ArgumentResolver(null, [new SecurityUserValueResolver($tokenStorage)]); - $this->assertSame([$user], $argumentResolver->getArguments(Request::create('/'), function (UserInterface $user) {})); - } - - public function testIntegrationNoUser() - { - $token = $this->getMockBuilder(TokenInterface::class)->getMock(); - $tokenStorage = new TokenStorage(); - $tokenStorage->setToken($token); - - $argumentResolver = new ArgumentResolver(null, [new SecurityUserValueResolver($tokenStorage), new DefaultValueResolver()]); - $this->assertSame([null], $argumentResolver->getArguments(Request::create('/'), function (UserInterface $user = null) {})); - } -} - -abstract class DummyUser implements UserInterface -{ -} - -abstract class DummySubUser extends DummyUser -{ -} diff --git a/src/Symfony/Bundle/TwigBundle/TemplateIterator.php b/src/Symfony/Bundle/TwigBundle/TemplateIterator.php index 2c2365737b0f5..26eefec94319a 100644 --- a/src/Symfony/Bundle/TwigBundle/TemplateIterator.php +++ b/src/Symfony/Bundle/TwigBundle/TemplateIterator.php @@ -19,7 +19,7 @@ * * @author Fabien Potencier * - * @internal since Symfony 4.4 + * @internal */ class TemplateIterator implements \IteratorAggregate { diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/Component/BrowserKit/AbstractBrowser.php index 57ba716d5cbbe..ae85eff25abb5 100644 --- a/src/Symfony/Component/BrowserKit/AbstractBrowser.php +++ b/src/Symfony/Component/BrowserKit/AbstractBrowser.php @@ -450,9 +450,9 @@ protected function doRequestInProcess($request) unlink($deprecationsFile); foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) { if ($deprecation[0]) { - @trigger_error($deprecation[1], E_USER_DEPRECATED); + @trigger_error($deprecation[1], E_USER_DEPRECATED); //??XXX } else { - @trigger_error($deprecation[1], E_USER_DEPRECATED); + @trigger_error($deprecation[1], E_USER_DEPRECATED); //??XXX } } } diff --git a/src/Symfony/Component/Config/CHANGELOG.md b/src/Symfony/Component/Config/CHANGELOG.md index 4bd58d541b4cc..49be47ac8be46 100644 --- a/src/Symfony/Component/Config/CHANGELOG.md +++ b/src/Symfony/Component/Config/CHANGELOG.md @@ -7,6 +7,7 @@ CHANGELOG * Dropped support for constructing a `TreeBuilder` without passing root node information. * Removed the `root()` method in `TreeBuilder`, pass the root node information to the constructor instead * Added method `getChildNodeDefinitions()` to ParentNodeDefinitionInterface + * Removed `FileLoaderLoadException`, use `LoaderLoadException` instead 4.3.0 ----- diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index a771a43cd2a50..c51b0b4a67cad 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -359,12 +359,8 @@ abstract protected function createNode(); public function setPathSeparator(string $separator) { if ($this instanceof ParentNodeDefinitionInterface) { - if (method_exists($this, 'getChildNodeDefinitions')) { - foreach ($this->getChildNodeDefinitions() as $child) { - $child->setPathSeparator($separator); - } - } else { - @trigger_error('Passing a ParentNodeDefinitionInterface without getChildNodeDefinitions() is deprecated since Symfony 4.1.', E_USER_DEPRECATED); + foreach ($this->getChildNodeDefinitions() as $child) { + $child->setPathSeparator($separator); } } diff --git a/src/Symfony/Component/Config/Definition/Processor.php b/src/Symfony/Component/Config/Definition/Processor.php index b6a3434113b9d..a8c43620b9d1f 100644 --- a/src/Symfony/Component/Config/Definition/Processor.php +++ b/src/Symfony/Component/Config/Definition/Processor.php @@ -16,7 +16,7 @@ * * @author Johannes M. Schmitt * - * @final since version 4.1 + * @final */ class Processor { @@ -75,7 +75,7 @@ public function processConfiguration(ConfigurationInterface $configuration, arra * * @return array */ - public static function normalizeConfig($config, $key, $plural = null) + public static function normalizeConfig(array $config, string $key, string $plural = null) { if (null === $plural) { $plural = $key.'s'; diff --git a/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php b/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php deleted file mode 100644 index 16beec5930c82..0000000000000 --- a/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Config\Exception; - -/** - * Exception class for when a resource cannot be loaded or imported. - * - * @author Ryan Weaver - * - * @deprecated since Symfony 4.2, use LoaderLoadException instead. - */ -class FileLoaderLoadException extends \Exception -{ - /** - * @param string $resource The resource that could not be imported - * @param string $sourceResource The original resource importing the new resource - * @param int $code The error code - * @param \Throwable $previous A previous exception - * @param string $type The type of resource - */ - public function __construct(string $resource, string $sourceResource = null, int $code = null, \Throwable $previous = null, string $type = null) - { - $message = ''; - if ($previous) { - // Include the previous exception, to help the user see what might be the underlying cause - - // Trim the trailing period of the previous message. We only want 1 period remove so no rtrim... - if ('.' === substr($previous->getMessage(), -1)) { - $trimmedMessage = substr($previous->getMessage(), 0, -1); - $message .= sprintf('%s', $trimmedMessage).' in '; - } else { - $message .= sprintf('%s', $previous->getMessage()).' in '; - } - $message .= $resource.' '; - - // show tweaked trace to complete the human readable sentence - if (null === $sourceResource) { - $message .= sprintf('(which is loaded in resource "%s")', $resource); - } else { - $message .= sprintf('(which is being imported from "%s")', $sourceResource); - } - $message .= '.'; - - // if there's no previous message, present it the default way - } elseif (null === $sourceResource) { - $message .= sprintf('Cannot load resource "%s".', $resource); - } else { - $message .= sprintf('Cannot import resource "%s" from "%s".', $resource, $sourceResource); - } - - // Is the resource located inside a bundle? - if ('@' === $resource[0]) { - $parts = explode(\DIRECTORY_SEPARATOR, $resource); - $bundle = substr($parts[0], 1); - $message .= sprintf(' Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle); - $message .= sprintf(' If the bundle is registered, make sure the bundle path "%s" is not empty.', $resource); - } elseif (null !== $type) { - // maybe there is no loader for this specific type - if ('annotation' === $type) { - $message .= ' Make sure annotations are installed and enabled.'; - } else { - $message .= sprintf(' Make sure there is a loader supporting the "%s" type.', $type); - } - } - - parent::__construct($message, $code, $previous); - } - - protected function varToString($var) - { - if (\is_object($var)) { - return sprintf('Object(%s)', \get_class($var)); - } - - if (\is_array($var)) { - $a = []; - foreach ($var as $k => $v) { - $a[] = sprintf('%s => %s', $k, $this->varToString($v)); - } - - return sprintf('Array(%s)', implode(', ', $a)); - } - - if (\is_resource($var)) { - return sprintf('Resource(%s)', get_resource_type($var)); - } - - if (null === $var) { - return 'null'; - } - - if (false === $var) { - return 'false'; - } - - if (true === $var) { - return 'true'; - } - - return (string) $var; - } -} diff --git a/src/Symfony/Component/Config/Exception/LoaderLoadException.php b/src/Symfony/Component/Config/Exception/LoaderLoadException.php index 41a959d38df8f..dcec3201bdb20 100644 --- a/src/Symfony/Component/Config/Exception/LoaderLoadException.php +++ b/src/Symfony/Component/Config/Exception/LoaderLoadException.php @@ -16,6 +16,94 @@ * * @author Ryan Weaver */ -class LoaderLoadException extends FileLoaderLoadException +class LoaderLoadException extends \Exception { + /** + * @param string $resource The resource that could not be imported + * @param string $sourceResource The original resource importing the new resource + * @param int $code The error code + * @param \Throwable $previous A previous exception + * @param string $type The type of resource + */ + public function __construct(string $resource, string $sourceResource = null, int $code = null, \Throwable $previous = null, string $type = null) + { + $message = ''; + if ($previous) { + // Include the previous exception, to help the user see what might be the underlying cause + + // Trim the trailing period of the previous message. We only want 1 period remove so no rtrim... + if ('.' === substr($previous->getMessage(), -1)) { + $trimmedMessage = substr($previous->getMessage(), 0, -1); + $message .= sprintf('%s', $trimmedMessage).' in '; + } else { + $message .= sprintf('%s', $previous->getMessage()).' in '; + } + $message .= $resource.' '; + + // show tweaked trace to complete the human readable sentence + if (null === $sourceResource) { + $message .= sprintf('(which is loaded in resource "%s")', $resource); + } else { + $message .= sprintf('(which is being imported from "%s")', $sourceResource); + } + $message .= '.'; + + // if there's no previous message, present it the default way + } elseif (null === $sourceResource) { + $message .= sprintf('Cannot load resource "%s".', $resource); + } else { + $message .= sprintf('Cannot import resource "%s" from "%s".', $resource, $sourceResource); + } + + // Is the resource located inside a bundle? + if ('@' === $resource[0]) { + $parts = explode(\DIRECTORY_SEPARATOR, $resource); + $bundle = substr($parts[0], 1); + $message .= sprintf(' Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle); + $message .= sprintf(' If the bundle is registered, make sure the bundle path "%s" is not empty.', $resource); + } elseif (null !== $type) { + // maybe there is no loader for this specific type + if ('annotation' === $type) { + $message .= ' Make sure annotations are installed and enabled.'; + } else { + $message .= sprintf(' Make sure there is a loader supporting the "%s" type.', $type); + } + } + + parent::__construct($message, $code, $previous); + } + + protected function varToString($var) + { + if (\is_object($var)) { + return sprintf('Object(%s)', \get_class($var)); + } + + if (\is_array($var)) { + $a = []; + foreach ($var as $k => $v) { + $a[] = sprintf('%s => %s', $k, $this->varToString($v)); + } + + return sprintf('Array(%s)', implode(', ', $a)); + } + + if (\is_resource($var)) { + return sprintf('Resource(%s)', get_resource_type($var)); + } + + if (null === $var) { + return 'null'; + } + + if (false === $var) { + return 'false'; + } + + if (true === $var) { + return 'true'; + } + + return (string) $var; + } } diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index 51154cfd6a41f..b033dd1fac040 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -19,7 +19,7 @@ * * @author Fabien Potencier * - * @final since Symfony 4.3 + * @final */ class ClassExistenceResource implements SelfCheckingResourceInterface { @@ -61,7 +61,7 @@ public function getResource() * * @throws \ReflectionException when a parent class/interface/trait is not found */ - public function isFresh($timestamp) + public function isFresh(int $timestamp) { $loaded = class_exists($this->resource, false) || interface_exists($this->resource, false) || trait_exists($this->resource, false); diff --git a/src/Symfony/Component/Config/Resource/ComposerResource.php b/src/Symfony/Component/Config/Resource/ComposerResource.php index db6b04c812c57..7e7642e35f4da 100644 --- a/src/Symfony/Component/Config/Resource/ComposerResource.php +++ b/src/Symfony/Component/Config/Resource/ComposerResource.php @@ -16,7 +16,7 @@ * * @author Nicolas Grekas * - * @final since Symfony 4.3 + * @final */ class ComposerResource implements SelfCheckingResourceInterface { @@ -46,7 +46,7 @@ public function __toString() /** * {@inheritdoc} */ - public function isFresh($timestamp) + public function isFresh(int $timestamp) { self::refresh(); diff --git a/src/Symfony/Component/Config/Resource/DirectoryResource.php b/src/Symfony/Component/Config/Resource/DirectoryResource.php index 3d703db7f6ebe..bd3240e9b2cdc 100644 --- a/src/Symfony/Component/Config/Resource/DirectoryResource.php +++ b/src/Symfony/Component/Config/Resource/DirectoryResource.php @@ -16,7 +16,7 @@ * * @author Fabien Potencier * - * @final since Symfony 4.3 + * @final */ class DirectoryResource implements SelfCheckingResourceInterface { @@ -68,7 +68,7 @@ public function getPattern() /** * {@inheritdoc} */ - public function isFresh($timestamp) + public function isFresh(int $timestamp) { if (!is_dir($this->resource)) { return false; diff --git a/src/Symfony/Component/Config/Resource/FileExistenceResource.php b/src/Symfony/Component/Config/Resource/FileExistenceResource.php index 57234161588c7..886fb403f1827 100644 --- a/src/Symfony/Component/Config/Resource/FileExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/FileExistenceResource.php @@ -19,7 +19,7 @@ * * @author Charles-Henri Bruyand * - * @final since Symfony 4.3 + * @final */ class FileExistenceResource implements SelfCheckingResourceInterface { @@ -55,7 +55,7 @@ public function getResource() /** * {@inheritdoc} */ - public function isFresh($timestamp) + public function isFresh(int $timestamp) { return file_exists($this->resource) === $this->exists; } diff --git a/src/Symfony/Component/Config/Resource/FileResource.php b/src/Symfony/Component/Config/Resource/FileResource.php index 95fe8a0bf802c..6d00b2baf69ed 100644 --- a/src/Symfony/Component/Config/Resource/FileResource.php +++ b/src/Symfony/Component/Config/Resource/FileResource.php @@ -18,7 +18,7 @@ * * @author Fabien Potencier * - * @final since Symfony 4.3 + * @final */ class FileResource implements SelfCheckingResourceInterface { @@ -60,7 +60,7 @@ public function getResource() /** * {@inheritdoc} */ - public function isFresh($timestamp) + public function isFresh(int $timestamp) { return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp; } diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index fce8f6e2062a0..c9e0b34734a28 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -21,7 +21,7 @@ * * @author Nicolas Grekas * - * @final since Symfony 4.3 + * @final */ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface { @@ -68,7 +68,7 @@ public function __toString() /** * {@inheritdoc} */ - public function isFresh($timestamp) + public function isFresh(int $timestamp) { $hash = $this->computeHash(); diff --git a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php index 1c582183d2ca4..14bbf7c226752 100644 --- a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php +++ b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php @@ -18,7 +18,7 @@ /** * @author Nicolas Grekas * - * @final since Symfony 4.3 + * @final */ class ReflectionClassResource implements SelfCheckingResourceInterface { @@ -35,7 +35,10 @@ public function __construct(\ReflectionClass $classReflector, array $excludedVen $this->excludedVendors = $excludedVendors; } - public function isFresh($timestamp) + /** + * {@inheritdoc} + */ + public function isFresh(int $timestamp) { if (null === $this->hash) { $this->hash = $this->computeHash(); diff --git a/src/Symfony/Component/Config/Resource/SelfCheckingResourceInterface.php b/src/Symfony/Component/Config/Resource/SelfCheckingResourceInterface.php index b3260f2be3e58..c08d96973ec95 100644 --- a/src/Symfony/Component/Config/Resource/SelfCheckingResourceInterface.php +++ b/src/Symfony/Component/Config/Resource/SelfCheckingResourceInterface.php @@ -26,5 +26,5 @@ interface SelfCheckingResourceInterface extends ResourceInterface * * @return bool True if the resource has not been updated, false otherwise */ - public function isFresh($timestamp); + public function isFresh(int $timestamp); } diff --git a/src/Symfony/Component/Debug/CHANGELOG.md b/src/Symfony/Component/Debug/CHANGELOG.md index 367e834f01e7e..85026b25acf6e 100644 --- a/src/Symfony/Component/Debug/CHANGELOG.md +++ b/src/Symfony/Component/Debug/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + +* removed `FlattenException::setTraceFromException()` in favor of `setTraceFromThrowable()` + 4.3.0 ----- diff --git a/src/Symfony/Component/Debug/Exception/FlattenException.php b/src/Symfony/Component/Debug/Exception/FlattenException.php index 304df0405c267..972496cf10341 100644 --- a/src/Symfony/Component/Debug/Exception/FlattenException.php +++ b/src/Symfony/Component/Debug/Exception/FlattenException.php @@ -228,16 +228,6 @@ public function getTrace() return $this->trace; } - /** - * @deprecated since 4.1, use {@see setTraceFromThrowable()} instead. - */ - public function setTraceFromException(\Exception $exception) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use "setTraceFromThrowable()" instead.', __METHOD__), E_USER_DEPRECATED); - - $this->setTraceFromThrowable($exception); - } - public function setTraceFromThrowable(\Throwable $throwable) { $this->traceAsString = $throwable->getTraceAsString(); diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index 9f5543b49e79e..2c70c0dc63fdc 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -4,8 +4,13 @@ CHANGELOG 5.0.0 ----- -* removed support for auto-discovered extension configuration class which does not implement `ConfigurationInterface` -* removed support for non-string default env() parameters + * removed support for auto-discovered extension configuration class which does not implement `ConfigurationInterface` + * removed support for non-string default env() parameters + * moved `ServiceSubscriberInterface` to the `Symfony\Contracts\Service` namespace + * removed `RepeatedPass` and `RepeatablePassInterface` + * removed support for short factory/configurator syntax from `YamlFileLoader` + * removed `ResettableContainerInterface`, use `ResetInterface` instead + * added argument `$returnsClone` to `Definition::addMethodCall()` 4.4.0 ----- diff --git a/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php b/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php index e9a4fffe2ad1c..605ab0415194d 100644 --- a/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php +++ b/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php @@ -18,7 +18,7 @@ * * @author Maxime Steinhausser * - * @final since Symfony 4.3 + * @final */ class ContainerParametersResource implements ResourceInterface { diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 2700f88c47a31..182ca1ef483ab 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -349,7 +349,7 @@ public function setMethodCalls(array $calls = []) * * @throws InvalidArgumentException on empty $method param */ - public function addMethodCall($method, array $arguments = []/*, bool $returnsClone = false*/) + public function addMethodCall($method, array $arguments = [], bool $returnsClone = false) { if (empty($method)) { throw new InvalidArgumentException('Method name cannot be empty.'); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 2228bdc00f598..d643402edfb22 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -977,7 +977,7 @@ private function startClass(string $class, string $baseClass, string $baseClassW * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class $class extends $baseClass { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php index 695c49c917b27..37f8ace6379f4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Aliases_Deprecation extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php index fdc9510ffe769..fd8690b228099 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php @@ -14,7 +14,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithoutArgumentsContainer { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php index e9e0ce940ccce..794b5136f0d49 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php @@ -14,7 +14,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithMandatoryArgumentsContainer { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php index 84714daaf1faa..a491d698bb583 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php @@ -14,7 +14,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithOptionalArgumentsContainer { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php index 5fecfcff4f171..62bd4866e5a58 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php @@ -14,7 +14,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\NoConstructorContainer { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php index 09e5585c11ec9..6f73bcf63e5f0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -14,7 +14,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index 25b363060bac4..81a57fad1ae66 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index 101e8b57e83b0..e83b88ac82de6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index f37923c4b1c55..b1cc6ae03264e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index ff3aef254d492..b9713fa8b7933 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index 7f8c93c5c646a..4151590d383be 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php index 96dee5eb92d25..e3954a93b8fa1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index 5d7c85b70dfc3..38622e77d96c6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php index 398c4406b1684..c0e1cbc195599 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index d8894ced9782f..f7b357a3d3485 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt index e20a0fcd3b812..d8152cac9b0c0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt @@ -367,7 +367,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 3c6cea1a43c29..716c4cc1e7141 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php index 4fde7e6d5d237..3d91f5e22a0bf 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php index e76fa907e2042..f8375dd4d4794 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php index 7af6de85c1146..a731fe2b4f31e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php index 4d7b13f620963..ff1b42608c2c8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php index b25d3853d2269..2aa9d06c910f7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php index c5266d2c4dfbe..bdc71de0b9f1f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_CsvParameters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy_proxy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy_proxy.php index 8e7a204d4c22b..4fd389ff67c89 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy_proxy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy_proxy.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php index 3f8f49bd3d854..ff9e6bd6eec18 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Deep_Graph extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php index 17fda12fc3a19..3e939b3a29e2c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_DefaultParameters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php index 84fb1599bf166..3c7934ad88a66 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php index 23a15486f39ce..a33a9301a28d5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Errored_Definition extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php index cca9d46cd02f2..1f417b3896846 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php index ea76b0d15780b..7b2b4ef6b9802 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Inline_Self_Ref extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php index 5b90e5b4160aa..3bf21240936d4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_JsonParameters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php index 5c6d4af8a5478..1396684374528 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php index 212f12dd24d97..1862c8f2e5818 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt index 0bd0fa41635c4..50b534e6489a3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt @@ -39,7 +39,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { @@ -107,4 +107,4 @@ return new \Container%s\ProjectServiceContainer([ 'container.build_time' => %d, ], __DIR__.\DIRECTORY_SEPARATOR.'Container%s'); -) \ No newline at end of file +) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php index f815c0811dce4..1a6096be16c28 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php index 761d476103865..841c0604fe077 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php index e69a22b12931d..7e50980728e31 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_QueryStringParameters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php index 25f43a3f80323..be92854b0cb9d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php index 94b5931ed3acb..723cd8bc628d4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Service_Locator_Argument extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php index 00f444e0afd75..fa0b4069a5159 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php index 3aa6ae94a8200..645d64c5891a0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class ProjectServiceContainer extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php index 47e4b8f63432d..9a532b3b4e3e2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php index 754d615df6dfc..e58f89cbda301 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_Unsupported_Characters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php index bd0d9105d7cc3..3eb78e5d8b5b1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Test_UrlParameters extends Container { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php index c8a0d035886e4..4e1d9cf921bdc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php @@ -12,7 +12,7 @@ * This class has been auto-generated * by the Symfony Dependency Injection Component. * - * @final since Symfony 3.3 + * @final */ class Symfony_DI_PhpDumper_Service_Wither extends Container { diff --git a/src/Symfony/Component/DomCrawler/CHANGELOG.md b/src/Symfony/Component/DomCrawler/CHANGELOG.md index 6c3cd979b6525..4a0f2702f7130 100644 --- a/src/Symfony/Component/DomCrawler/CHANGELOG.md +++ b/src/Symfony/Component/DomCrawler/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +5.0.0 +----- + +* Added argument `$selector` to ``Crawler::children()` +* Added argument `$default` to ``Crawler::text()` and `html()` + 4.3.0 ----- diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 70a4b607dcdca..24a5843225430 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -494,13 +494,8 @@ public function parents() * @throws \InvalidArgumentException When current node is empty * @throws \RuntimeException If the CssSelector Component is not available and $selector is provided */ - public function children(/* string $selector = null */) + public function children(string $selector = null) { - if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { - @trigger_error(sprintf('The "%s()" method will have a new "string $selector = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); - } - $selector = 0 < \func_num_args() ? func_get_arg(0) : null; - if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); } @@ -562,11 +557,11 @@ public function nodeName() * * @throws \InvalidArgumentException When current node is empty */ - public function text(/* $default = null */) + public function text($default = null) { if (!$this->nodes) { if (0 < \func_num_args()) { - return \func_get_arg(0); + return $default; } throw new \InvalidArgumentException('The current node list is empty.'); @@ -584,11 +579,11 @@ public function text(/* $default = null */) * * @throws \InvalidArgumentException When current node is empty */ - public function html(/* $default = null */) + public function html($default = null) { if (!$this->nodes) { if (0 < \func_num_args()) { - return \func_get_arg(0); + return $default; } throw new \InvalidArgumentException('The current node list is empty.'); diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php index 49e4e1e294c65..8254294345d03 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php @@ -1100,62 +1100,6 @@ public function testEvaluateThrowsAnExceptionIfDocumentIsEmpty() $this->createCrawler()->evaluate('//form/input[1]'); } - /** - * @group legacy - * @expectedDeprecation The "Symfony\Component\DomCrawler\Crawler::children()" method will have a new "string $selector = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2. - */ - public function testInheritedClassCallChildrenWithoutArgument() - { - $dom = new \DOMDocument(); - $dom->loadHTML($this->getDoctype().' - - - Foo - Fabien\'s Foo - Fabien"s Foo - \' Fabien"s Foo - - Bar -    Fabien\'s Bar   - Fabien"s Bar - \' Fabien"s Bar - - GetLink - - Klausi|Claudiu - -
- - - -