Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7b0f16

Browse files
committed
[DependencyInjection] Preload classes with union types correctly.
1 parent9bfd3ee commita7b0f16

File tree

10 files changed

+186
-1
lines changed

10 files changed

+186
-1
lines changed

‎.github/patch-types.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
casefalse !==strpos($file,'/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php'):
3434
casefalse !==strpos($file,'/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/uniontype_classes.php'):
3535
casefalse !==strpos($file,'/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
36+
casefalse !==strpos($file,'/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/'):
3637
casefalse !==strpos($file,'/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
3738
casefalse !==strpos($file,'/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
3839
casefalse !==strpos($file,'/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):

‎src/Symfony/Component/DependencyInjection/Dumper/Preloader.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static function doPreload(string $class, array &$preloaded): void
9494

9595
privatestaticfunctionpreloadType(?\ReflectionType$t,array &$preloaded):void
9696
{
97-
if (!$t ||$t->isBuiltin()) {
97+
if (!$t) {
9898
return;
9999
}
100100

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\DependencyInjection\Tests\Dumper;
13+
14+
usePHPUnit\Framework\TestCase;
15+
useSymfony\Component\DependencyInjection\Dumper\Preloader;
16+
17+
class PreloaderTestextends TestCase
18+
{
19+
/**
20+
* @requires PHP 7.4
21+
*/
22+
publicfunctiontestPreload()
23+
{
24+
$r =new \ReflectionMethod(Preloader::class,'doPreload');
25+
$r->setAccessible(true);
26+
27+
$preloaded = [];
28+
29+
$r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy', &$preloaded]);
30+
31+
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy',false));
32+
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\A',false));
33+
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\B',false));
34+
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\C',false));
35+
}
36+
37+
/**
38+
* @requires PHP 8
39+
*/
40+
publicfunctiontestPreloadUnion()
41+
{
42+
$r =new \ReflectionMethod(Preloader::class,'doPreload');
43+
$r->setAccessible(true);
44+
45+
$preloaded = [];
46+
47+
$r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy', &$preloaded]);
48+
49+
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy',false));
50+
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\D',false));
51+
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\E',false));
52+
}
53+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\DependencyInjection\Tests\Fixtures\Preload;
13+
14+
finalclass A
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\DependencyInjection\Tests\Fixtures\Preload;
13+
14+
finalclass B
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\DependencyInjection\Tests\Fixtures\Preload;
13+
14+
finalclass C
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\DependencyInjection\Tests\Fixtures\Preload;
13+
14+
finalclass D
15+
{
16+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\DependencyInjection\Tests\Fixtures\Preload;
13+
14+
finalclass Dummy
15+
{
16+
publicA$a;
17+
18+
publicfunctiondoSomething(B$b): ?C
19+
{
20+
returnnull;
21+
}
22+
23+
publicfunctionnoTypes($foo)
24+
{
25+
}
26+
27+
publicfunctionbuiltinTypes(int$foo): ?string
28+
{
29+
}
30+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\DependencyInjection\Tests\Fixtures\Preload;
13+
14+
finalclass E
15+
{
16+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\DependencyInjection\Tests\Fixtures\Preload;
13+
14+
finalclass UnionDummy
15+
{
16+
publicD|E$de;
17+
18+
publicfunctionbuiltinTypes(int|float$foo):string|\Stringable|null
19+
{
20+
}
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp