4242 ['testArrayOptional ' , 'array ' , false , false ],
4343 ['testArrayNullable ' , 'array ' , true , true ],
4444
45- ['testMixed ' , 'mixed ' , true , true ],
45+ ['testMixed ' , 'mixed ' , true , true , ' 8.0 ' ],
4646
4747 ['testCallable ' , 'callable ' , false , true ],
4848 ['testCallableOptional ' , 'callable ' , false , false ],
5858
5959 ['testNull ' , 'null ' , true , true , '8.2 ' ],
6060
61- ['testClassEntry ' , 'class_name ' , false , true ],
62- ['testClassEntryOptional ' , 'class_name ' , false , false ],
63- ['testClassEntryNullable ' , 'class_name ' , true , true ],
61+ ['testClassEntry ' , 'class_name ' , false , true , ' 7.4 ' ],
62+ ['testClassEntryOptional ' , 'class_name ' , false , false , ' 7.4 ' ],
63+ ['testClassEntryNullable ' , 'class_name ' , true , true , ' 7.4 ' ],
6464];
6565
6666// typehints
105105 ['returnCallableNullable ' , 'callable ' , true ],
106106 ['returnIterable ' , 'iterable ' , false ],
107107 ['returnIterableNullable ' , 'iterable ' , true ],
108- ['returnMixed ' , 'mixed ' , true ],
108+ ['returnMixed ' , 'mixed ' , true , ' 7.4 ' ],
109109 ['returnNever ' , 'never ' , false , '8.1 ' ],
110110 ['returnVoid ' , 'void ' , false ],
111- ['returnClassEntry ' , 'class_name ' , false ],
112- ['returnClassEntryNullable ' , 'class_name ' , true ],
111+ ['returnClassEntry ' , 'class_name ' , false , ' 7.4 ' ],
112+ ['returnClassEntryNullable ' , 'class_name ' , true , ' 7.4 ' ],
113113];
114114echo PHP_EOL . 'Testing return typehints ' . PHP_EOL ;
115115$ cls = new \IntegrationTest \TypeHints \ReturnTypeHintTest ();
@@ -147,23 +147,27 @@ public function setValue($value): void {
147147assert_eq ($ foo , $ handler ->handle ($ foo ));
148148
149149$ argumentDefaultValueProvider = [
150- // <method>, <expected default value>
151- ['stringDefault ' , 'foobarbaz ' , 'string ' ],
152- ['stringConstantDefault ' , PHP_VERSION , 'string ' ],
153- ['boolDefaultTrue ' , true , 'boolean ' ],
154- ['boolDefaultFalse ' , false , 'boolean ' ],
155- ['intDefault ' , 42 , 'integer ' ],
156- ['floatDefault ' , 3.14159 , 'double ' ],
157- ['arrayDefault ' , ['a ' => 'b ' ], 'array ' ],
158- ['iterableDefault ' , [0 => 1 ], 'array ' ],
159- ['mixedDefault ' , 999 , 'integer ' ],
150+ // <method>, <expected default value>, <(optional) min php version>
151+ ['stringDefault ' , 'foobarbaz ' , 'string ' , ' 7.4 ' ],
152+ ['stringConstantDefault ' , PHP_VERSION , 'string ' , ' 7.4 ' ],
153+ ['boolDefaultTrue ' , true , 'boolean ' , ' 7.4 ' ],
154+ ['boolDefaultFalse ' , false , 'boolean ' , ' 7.4 ' ],
155+ ['intDefault ' , 42 , 'integer ' , ' 7.4 ' ],
156+ ['floatDefault ' , 3.14159 , 'double ' , ' 7.4 ' ],
157+ ['arrayDefault ' , ['a ' => 'b ' ], 'array ' , ' 7.4 ' ],
158+ ['iterableDefault ' , [0 => 1 ], 'array ' , ' 7.4 ' ],
159+ ['mixedDefault ' , 999 , 'integer ' , ' 7.4 ' ],
160160];
161161
162162echo PHP_EOL . 'Testing argument default values ' . PHP_EOL ;
163163$ cls = new IntegrationTest \TypeHints \ArgumentDefaultValueTest ();
164164$ reflection = new ReflectionClass ($ cls );
165165foreach ($ argumentDefaultValueProvider as $ input ) {
166166 echo (sprintf ("%s.. " , $ input [0 ]));
167+ if (array_key_exists (3 , $ input ) && !php_at_least ($ input [3 ])) {
168+ echo sprintf ("SKIPPED requires at least PHP %s " , $ input [3 ]) . PHP_EOL ;
169+ continue ;
170+ }
167171 $ reflectionMethod = $ reflection ->getMethod ($ input [0 ]);
168172 $ params = $ reflectionMethod ->getParameters ();
169173 $ param = $ params [0 ];
@@ -183,14 +187,16 @@ public function setValue($value): void {
183187 ['m ' , 'mixed ' , 1.23 ],
184188
185189];
186- echo PHP_EOL . 'Testing function typehints ' . PHP_EOL ;
187- $ reflection = new ReflectionFunction ('integration_function_typehints ' );
188- $ params = $ reflection ->getParameters ();
189- foreach ($ expectedArgs as $ i => $ input ) {
190- echo (sprintf ("argument %d.. " , $ i ));
191- assert_eq ($ input [0 ], $ params [$ i ]->getName (), sprintf ('argument %d has correct name ' , $ i ));
192- assert_eq ($ input [1 ], $ params [$ i ]->getType ()->getName (), sprintf ('argument %d has correct type ' , $ i ));
193- assert_eq ($ input [2 ], $ params [$ i ]->getDefaultValue (), sprintf ('argument %d has correct default value ' , $ i ));
194- echo "PASS " . PHP_EOL ;
195- }
196- assert_eq ('void ' , $ reflection ->getReturnType ()->getName (), 'integration_function_typehints return type is void ' );
190+ if (PHP_VERSION_ID >= 70400 ) {
191+ echo PHP_EOL . 'Testing function typehints ' . PHP_EOL ;
192+ $ reflection = new ReflectionFunction ('integration_function_typehints ' );
193+ $ params = $ reflection ->getParameters ();
194+ foreach ($ expectedArgs as $ i => $ input ) {
195+ echo (sprintf ("argument %d.. " , $ i ));
196+ assert_eq ($ input [0 ], $ params [$ i ]->getName (), sprintf ('argument %d has correct name ' , $ i ));
197+ assert_eq ($ input [1 ], $ params [$ i ]->getType ()->getName (), sprintf ('argument %d has correct type ' , $ i ));
198+ assert_eq ($ input [2 ], $ params [$ i ]->getDefaultValue (), sprintf ('argument %d has correct default value ' , $ i ));
199+ echo "PASS " . PHP_EOL ;
200+ }
201+ assert_eq ('void ' , $ reflection ->getReturnType ()->getName (), 'integration_function_typehints return type is void ' );
202+ }
0 commit comments