File tree Expand file tree Collapse file tree
rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector/FixtureIntersection
rules/TypeDeclaration/NodeAnalyzer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \FixtureIntersection ;
6+
7+ final class CoverIntersection
8+ {
9+ public function run (array $ values ): void
10+ {
11+ $ items = [];
12+
13+ foreach ($ values as $ value ) {
14+ $ items [] = 10 ;
15+ }
16+
17+ $ this ->nextItems ($ items );
18+ }
19+
20+ private function nextItems ($ items ): void
21+ {
22+ }
23+ }
24+
25+ ?>
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \Fixture ;
5+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \FixtureIntersection ;
66
77final class CoverIntersection
88{
99 public function run (array $ values ): void
1010 {
11- /** @var int[] $items */
1211 $ items = [];
1312
1413 foreach ($ values as $ value ) {
@@ -29,13 +28,12 @@ final class CoverIntersection
2928
3029declare (strict_types=1 );
3130
32- namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \Fixture ;
31+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \FixtureIntersection ;
3332
3433final class CoverIntersection
3534{
3635 public function run (array $ values ): void
3736 {
38- /** @var int[] $items */
3937 $ items = [];
4038
4139 foreach ($ values as $ value ) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \FixtureIntersection ;
6+
7+ final class CoverIntersectionWithDocblock
8+ {
9+ public function run (array $ values ): void
10+ {
11+ /** @var int[] $items */
12+ $ items = [];
13+
14+ foreach ($ values as $ value ) {
15+ $ items [] = 10 ;
16+ }
17+
18+ $ this ->nextItems ($ items );
19+ }
20+
21+ private function nextItems ($ items ): void
22+ {
23+ }
24+ }
25+
26+ ?>
27+ -----
28+ <?php
29+
30+ declare (strict_types=1 );
31+
32+ namespace Rector \Tests \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector \FixtureIntersection ;
33+
34+ final class CoverIntersectionWithDocblock
35+ {
36+ public function run (array $ values ): void
37+ {
38+ /** @var int[] $items */
39+ $ items = [];
40+
41+ foreach ($ values as $ value ) {
42+ $ items [] = 10 ;
43+ }
44+
45+ $ this ->nextItems ($ items );
46+ }
47+
48+ private function nextItems (array $ items ): void
49+ {
50+ }
51+ }
52+
53+ ?>
Original file line number Diff line number Diff line change 1212use PhpParser \Node \Identifier ;
1313use PhpParser \Node \VariadicPlaceholder ;
1414use PHPStan \Reflection \ReflectionProvider ;
15+ use PHPStan \Type \Accessory \AccessoryArrayListType ;
1516use PHPStan \Type \ArrayType ;
1617use PHPStan \Type \Constant \ConstantArrayType ;
18+ use PHPStan \Type \IntersectionType ;
1719use PHPStan \Type \MixedType ;
1820use PHPStan \Type \NeverType ;
1921use PHPStan \Type \ObjectType ;
2022use PHPStan \Type \ThisType ;
2123use PHPStan \Type \Type ;
24+ use PHPStan \Type \TypeCombinator ;
25+ use PHPStan \Type \TypeUtils ;
2226use PHPStan \Type \UnionType ;
2327use Rector \NodeTypeResolver \NodeTypeResolver ;
2428use Rector \NodeTypeResolver \PHPStan \Type \TypeFactory ;
@@ -90,6 +94,15 @@ private function resolveStrictArgValueType(Arg $arg): Type
9094 {
9195 $ argValueType = $ this ->nodeTypeResolver ->getNativeType ($ arg ->value );
9296
97+ if ($ argValueType instanceof IntersectionType) {
98+ dump ($ argValueType );
99+
100+ $ argValueType = TypeCombinator::remove ($ argValueType , new AccessoryArrayListType ());
101+
102+ dump ($ argValueType );
103+ die;
104+ }
105+
93106 return $ this ->normalizeType ($ argValueType );
94107 }
95108
You can’t perform that action at this time.
0 commit comments