|
21 | 21 | assert_eq($value, 'foobar'); |
22 | 22 |
|
23 | 23 | $argumentTypehintProvider = [ |
24 | | - // <method>, <expected typehint>, <is nullable>, <is required> |
| 24 | + // <method>, <expected typehint>, <is nullable>, <is required>, <(optional)min php version> |
25 | 25 | ['testString', 'string', false, true], |
26 | 26 | ['testStringOptional', 'string', false, false], |
27 | 27 | ['testStringNullable', 'string', true, true], |
|
56 | 56 | ['testIterableOptional', 'iterable', false, false], |
57 | 57 | ['testIterableNullable', 'iterable', true, true], |
58 | 58 |
|
59 | | - ['testNull', 'null', true, true], |
| 59 | + ['testNull', 'null', true, true, '8.2'], |
60 | 60 |
|
61 | 61 | ['testClassEntry', 'class_name', false, true], |
62 | 62 | ['testClassEntryOptional', 'class_name', false, false], |
|
69 | 69 | $reflection = new ReflectionClass($cls); |
70 | 70 | foreach ($argumentTypehintProvider as $input) { |
71 | 71 | echo(sprintf("%s..", $input[0])); |
| 72 | + if (array_key_exists(4, $input) && !php_at_least($input[4])) { |
| 73 | + echo sprintf("SKIPPED requires at least PHP %s", $input[4]) . PHP_EOL; |
| 74 | + continue; |
| 75 | + } |
72 | 76 | $reflectionMethod = $reflection->getMethod($input[0]); |
73 | 77 | $params = $reflectionMethod->getParameters(); |
74 | 78 |
|
|
83 | 87 |
|
84 | 88 | // return typehints |
85 | 89 | $returnTypehintProvider = [ |
86 | | - // <method>, <expected typehint>, <is nullable> |
87 | | - ['returnNull', 'null', true], |
| 90 | + // <method>, <expected typehint>, <is nullable>, <(optional)min php version> |
| 91 | + ['returnNull', 'null', true, '8.2'], |
88 | 92 | ['returnBool', 'bool', false], |
89 | 93 | ['returnBoolNullable', 'bool', true], |
90 | 94 | ['returnInt', 'int', false], |
|
102 | 106 | ['returnIterable', 'iterable', false], |
103 | 107 | ['returnIterableNullable', 'iterable', true], |
104 | 108 | ['returnMixed', 'mixed', true], |
105 | | - ['returnNever', 'never', false], |
| 109 | + ['returnNever', 'never', false, '8.1'], |
106 | 110 | ['returnVoid', 'void', false], |
107 | 111 | ['returnClassEntry', 'class_name', false], |
108 | 112 | ['returnClassEntryNullable', 'class_name', true], |
|
112 | 116 | $reflection = new ReflectionClass($cls); |
113 | 117 | foreach ($returnTypehintProvider as $input) { |
114 | 118 | echo(sprintf("%s..", $input[0])); |
| 119 | + if (array_key_exists(3, $input) && !php_at_least($input[3])) { |
| 120 | + echo sprintf("SKIPPED requires at least PHP %s", $input[3]) . PHP_EOL; |
| 121 | + continue; |
| 122 | + } |
115 | 123 | $reflectionMethod = $reflection->getMethod($input[0]); |
116 | 124 | $return = $reflectionMethod->getReturnType(); |
117 | | - assert_eq($input[1], $return->getName(), sprintf('%s has typehint type', $input[0])); |
118 | | - assert_eq($input[2], $return->allowsNull(), sprintf('%s allows null', $input[0])); |
| 125 | + if ($input[1] !== 'never') { |
| 126 | + assert_eq($input[1], $return->getName(), sprintf('%s has typehint type', $input[0])); |
| 127 | + assert_eq($input[2], $return->allowsNull(), sprintf('%s allows null', $input[0])); |
| 128 | + } |
119 | 129 | echo 'PASS' . PHP_EOL; |
120 | 130 | } |
121 | 131 |
|
|
0 commit comments