|
34 | 34 | * which is a url-encoded array with the follow parameters:
|
35 | 35 | * - "force": any value enables deprecation notices - can be any of:
|
36 | 36 | * - "phpdoc" to patch only docblock annotations
|
37 |
| - * - "object" to turn union types to the "object" type when possible (not recommended) |
38 |
| - * - "1" to add all possible return types including magic methods |
39 |
| - * - "0" to add possible return types excluding magic methods |
| 37 | + * - "2" to add all possible return types |
| 38 | + * - "1" to add return types but only to tests/final/internal/private methods |
40 | 39 | * - "php": the target version of PHP - e.g. "7.1" doesn't generate "object" types
|
41 | 40 | * - "deprecations": "1" to trigger a deprecation notice when a child class misses a
|
42 | 41 | * return type while the parent declares an "@return" annotation
|
@@ -73,6 +72,7 @@ class DebugClassLoader
|
73 | 72 | 'mixed' => 'mixed',
|
74 | 73 | 'static' => 'static',
|
75 | 74 | '$this' => 'static',
|
| 75 | + 'list' => 'array', |
76 | 76 | ];
|
77 | 77 |
|
78 | 78 | private const BUILTIN_RETURN_TYPES = [
|
@@ -127,7 +127,7 @@ public function __construct(callable $classLoader)
|
127 | 127 | $this->patchTypes += [
|
128 | 128 | 'force' => null,
|
129 | 129 | 'php' => \PHP_MAJOR_VERSION.'.'.\PHP_MINOR_VERSION,
|
130 |
| - 'deprecations' => false, |
| 130 | + 'deprecations' => \PHP_VERSION_ID >= 70300, |
131 | 131 | ];
|
132 | 132 |
|
133 | 133 | if ('phpdoc' === $this->patchTypes['force']) {
|
@@ -534,7 +534,8 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
|
534 | 534 | $this->patchTypes['force'] = $forcePatchTypes ?: 'docblock';
|
535 | 535 | }
|
536 | 536 |
|
537 |
| - $canAddReturnType = false !== stripos($method->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR) |
| 537 | + $canAddReturnType = 2 === (int) $forcePatchTypes |
| 538 | + || false !== stripos($method->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR) |
538 | 539 | || $refl->isFinal()
|
539 | 540 | || $method->isFinal()
|
540 | 541 | || $method->isPrivate()
|
|
0 commit comments