diff --git a/.github/patch-types.php b/.github/patch-types.php index 5c68a66c89c79..46c6980dab4a2 100644 --- a/.github/patch-types.php +++ b/.github/patch-types.php @@ -33,6 +33,7 @@ case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/uniontype_classes.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'): + case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'): case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'): diff --git a/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php b/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php index fb39645022edf..1e0b6919fd1fe 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php @@ -94,7 +94,7 @@ private static function doPreload(string $class, array &$preloaded): void private static function preloadType(?\ReflectionType $t, array &$preloaded): void { - if (!$t || $t->isBuiltin()) { + if (!$t) { return; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PreloaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PreloaderTest.php new file mode 100644 index 0000000000000..a9b3242031537 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PreloaderTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Dumper; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\DependencyInjection\Dumper\Preloader; + +class PreloaderTest extends TestCase +{ + /** + * @requires PHP 7.4 + */ + public function testPreload() + { + $r = new \ReflectionMethod(Preloader::class, 'doPreload'); + $r->setAccessible(true); + + $preloaded = []; + + $r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy', &$preloaded]); + + self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy', false)); + self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\A', false)); + self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\B', false)); + self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\C', false)); + } + + /** + * @requires PHP 8 + */ + public function testPreloadUnion() + { + $r = new \ReflectionMethod(Preloader::class, 'doPreload'); + $r->setAccessible(true); + + $preloaded = []; + + $r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy', &$preloaded]); + + self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy', false)); + self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\D', false)); + self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\E', false)); + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/A.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/A.php new file mode 100644 index 0000000000000..2802a577e85b1 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/A.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload; + +final class A +{ +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/B.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/B.php new file mode 100644 index 0000000000000..66dda101ce436 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/B.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload; + +final class B +{ +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/C.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/C.php new file mode 100644 index 0000000000000..331e9fed19c95 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/C.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload; + +final class C +{ +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/D.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/D.php new file mode 100644 index 0000000000000..52e10e918149b --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/D.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload; + +final class D +{ +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/Dummy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/Dummy.php new file mode 100644 index 0000000000000..35d61be5a573c --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/Dummy.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload; + +final class Dummy +{ + public A $a; + + public function doSomething(B $b): ?C + { + return null; + } + + public function noTypes($foo) + { + } + + public function builtinTypes(int $foo): ?string + { + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/E.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/E.php new file mode 100644 index 0000000000000..b4ec3b2734c57 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/E.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload; + +final class E +{ +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/UnionDummy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/UnionDummy.php new file mode 100644 index 0000000000000..24b709b0a2d69 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/UnionDummy.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload; + +final class UnionDummy +{ + public D|E $de; + + public function builtinTypes(int|float $foo): string|\Stringable|null + { + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy