@@ -61,15 +61,35 @@ public function __construct(bool $b, callable $c, int $i, string $s) {}
6161 public function __construct(Foo $x = null, ?Bar $y = null, float $z = 3.14) {}
6262 } ' ,
6363 ];
64+ }
65+
66+ /**
67+ * @param array<string> $expected
68+ *
69+ * @dataProvider provideGettingConstructorParameterNames80Cases
70+ *
71+ * @requires PHP ^8.0
72+ */
73+ public function testGettingConstructorParameterNames80 (array $ expected , string $ code ): void
74+ {
75+ $ tokens = Tokens::fromCode ($ code );
76+ $ analysis = new ConstructorAnalysis ($ tokens , 11 );
6477
65- if (\PHP_VERSION_ID >= 80000 ) {
66- yield 'some already promoted ' => [
67- ['$a ' , '$b ' , '$q ' , '$s ' , '$t ' ],
68- '<?php class Foo {
78+ self ::assertSame (11 , $ analysis ->getConstructorIndex ());
79+ self ::assertSame ($ expected , $ analysis ->getConstructorParameterNames ());
80+ }
81+
82+ /**
83+ * @return iterable<array{array<string>, string}>
84+ */
85+ public static function provideGettingConstructorParameterNames80Cases (): iterable
86+ {
87+ yield 'some already promoted ' => [
88+ ['$a ' , '$b ' , '$q ' , '$s ' , '$t ' ],
89+ '<?php class Foo {
6990 public function __construct(public array $a, bool $b, protected ?Bar\Baz\Qux $q, string $s, private OtherType $t) {}
7091 } ' ,
71- ];
72- }
92+ ];
7393 }
7494
7595 /**
@@ -118,15 +138,35 @@ public function __construct(array $a, bool $b, callable $c1, CALLABLE $c1, int $
118138 public function __construct(int $x, int $y, int ...$z) {}
119139 } ' ,
120140 ];
141+ }
121142
122- if (\PHP_VERSION_ID >= 80000 ) {
123- yield 'some already promoted ' => [
124- [22 => '$b ' , 39 => '$s ' ],
125- '<?php class Foo {
143+ /**
144+ * @param array<int, string> $expected
145+ *
146+ * @dataProvider provideGettingConstructorPromotableParameters80Cases
147+ *
148+ * @requires PHP ^8.0
149+ */
150+ public function testGettingConstructorPromotableParameters80 (array $ expected , string $ code ): void
151+ {
152+ $ tokens = Tokens::fromCode ($ code );
153+ $ analysis = new ConstructorAnalysis ($ tokens , 11 );
154+
155+ self ::assertSame (11 , $ analysis ->getConstructorIndex ());
156+ self ::assertSame ($ expected , $ analysis ->getConstructorPromotableParameters ());
157+ }
158+
159+ /**
160+ * @return iterable<array{array<int, string>, string}>
161+ */
162+ public static function provideGettingConstructorPromotableParameters80Cases (): iterable
163+ {
164+ yield 'some already promoted ' => [
165+ [22 => '$b ' , 39 => '$s ' ],
166+ '<?php class Foo {
126167 public function __construct(public array $a, bool $b, protected ?Bar\Baz\Qux $q, string $s, private OtherType $t) {}
127168 } ' ,
128- ];
129- }
169+ ];
130170 }
131171
132172 /**
0 commit comments