Skip to content

Commit 707ec77

Browse files
committed
[BE] @param-out changes
1 parent 5a2afed commit 707ec77

16 files changed

+14
-59
lines changed

changelog-2.0.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Major new features 🚀
77

88
* **Array `list` type** ([#1751](https://github.com/phpstan/phpstan-src/pull/1751)), #3311, #8185, #6243, thanks @rvanvelzen!
99
* Lists are arrays with sequential integer keys starting at 0
10+
* **Enhancements in Handling Parameters Passed by Reference**
11+
* [Learn more on phpstan.org](https://phpstan.org/blog/enhancements-in-handling-parameters-passed-by-reference)
12+
* [#2941](https://github.com/phpstan/phpstan-src/pull/2941), thanks @ljmaskey!
1013

1114
Bleeding edge (TODO move to other sections)
1215
=====================
@@ -71,9 +74,6 @@ Bleeding edge (TODO move to other sections)
7174
* Report unused results of `and` and `or` (https://github.com/phpstan/phpstan-src/commit/1d8fff637d70a9e9ed3f11dee5d61b9f796cbf1a)
7275
* Report unused result of ternary (https://github.com/phpstan/phpstan-src/commit/9664f7a9d2223c07e750f0dfc949c3accfa6b65e)
7376
* Report unused results of `&&` and `||` (https://github.com/phpstan/phpstan-src/commit/cf2c8bbd9ebd2ebe300dbd310e136ad603d7def3)
74-
* **Enhancements in Handling Parameters Passed by Reference**
75-
* [Learn more on phpstan.org](https://phpstan.org/blog/enhancements-in-handling-parameters-passed-by-reference)
76-
* [#2941](https://github.com/phpstan/phpstan-src/pull/2941), thanks @ljmaskey!
7777
* Add option `reportAnyTypeWideningInVarTag` ([#2840](https://github.com/phpstan/phpstan-src/pull/2840)), thanks @janedbal!
7878
* `array_values` rule (report when a `list` type is always passed in) ([#2917](https://github.com/phpstan/phpstan-src/pull/2917)), thanks @kamil-zacek!
7979
* Fix checking generic `mixed` type based on config ([#2885](https://github.com/phpstan/phpstan-src/pull/2885)), thanks @schlndh!
@@ -84,7 +84,6 @@ Bleeding edge (TODO move to other sections)
8484
* [#3022](https://github.com/phpstan/phpstan-src/pull/3022), thanks @staabm!
8585
* [#3023](https://github.com/phpstan/phpstan-src/pull/3023), thanks @staabm!
8686
* BetterNoopRule - take advantage of impure points (https://github.com/phpstan/phpstan-src/commit/a6470521b65d7424f552633c1f3827704c6262c3), #10389
87-
* Run missing type check on `@param-out` (https://github.com/phpstan/phpstan-src/commit/56b20024386d983927c64dfa895ff026bed2798c)
8887
* CallToConstructorStatementWithoutSideEffectsRule - report class with no constructor (https://github.com/phpstan/phpstan-src/commit/b116d25a6e4ba6c09f59af6569d9e6f6fd20aff4)
8988
* Check if required file exists ([#3294](https://github.com/phpstan/phpstan-src/pull/3294)), #3397, thanks @Bellangelo!
9089
* Check generics `@method` `@template` tags above traits (https://github.com/phpstan/phpstan-src/commit/aadbf62d3ae4517fc7a212b07130bedcef8d13ac)
@@ -139,6 +138,7 @@ Improvements 🔧
139138
* Infer explicit mixed when instantiating generic class with unknown template types (https://github.com/phpstan/phpstan-src/commit/089d4c6fb6eb709c44123548d33990113d174b86), #6398
140139
* Use explicit mixed for global array variables ([#1411](https://github.com/phpstan/phpstan-src/pull/1411)), thanks @herndlm!
141140
* Consider implicit throw points when the only explicit one is `Throw_` (https://github.com/phpstan/phpstan-src/commit/22eef6d5ab9a4afafb2305258fea273be6cc06e4)
141+
* Run missing type check on `@param-out` (https://github.com/phpstan/phpstan-src/commit/56b20024386d983927c64dfa895ff026bed2798c)
142142

143143
Bugfixes 🐛
144144
=====================

conf/bleedingEdge.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ parameters:
4141
callUserFunc: true
4242
finalByPhpDoc: true
4343
magicConstantOutOfContext: true
44-
paramOutType: true
4544
pure: true
4645
checkParameterCastableToStringFunctions: true
4746
uselessReturnValue: true

conf/config.level3.neon

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ conditionalTags:
88
phpstan.rules.rule: %featureToggles.readOnlyByPhpDoc%
99
PHPStan\Rules\Properties\ReadOnlyByPhpDocPropertyAssignRule:
1010
phpstan.rules.rule: %featureToggles.readOnlyByPhpDoc%
11-
PHPStan\Rules\Variables\ParameterOutAssignedTypeRule:
12-
phpstan.rules.rule: %featureToggles.paramOutType%
13-
PHPStan\Rules\Variables\ParameterOutExecutionEndTypeRule:
14-
phpstan.rules.rule: %featureToggles.paramOutType%
1511

1612
rules:
1713
- PHPStan\Rules\Arrays\ArrayDestructuringRule
@@ -30,6 +26,8 @@ rules:
3026
- PHPStan\Rules\Properties\ReadOnlyPropertyAssignRule
3127
- PHPStan\Rules\Properties\ReadOnlyPropertyAssignRefRule
3228
- PHPStan\Rules\Properties\TypesAssignedToPropertiesRule
29+
- PHPStan\Rules\Variables\ParameterOutAssignedTypeRule
30+
- PHPStan\Rules\Variables\ParameterOutExecutionEndTypeRule
3331
- PHPStan\Rules\Variables\VariableCloningRule
3432

3533
parameters:
@@ -95,9 +93,3 @@ services:
9593

9694
-
9795
class: PHPStan\Rules\Properties\ReadOnlyByPhpDocPropertyAssignRule
98-
99-
-
100-
class: PHPStan\Rules\Variables\ParameterOutAssignedTypeRule
101-
102-
-
103-
class: PHPStan\Rules\Variables\ParameterOutExecutionEndTypeRule

conf/config.level4.neon

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ rules:
1414
- PHPStan\Rules\TooWideTypehints\TooWideArrowFunctionReturnTypehintRule
1515
- PHPStan\Rules\TooWideTypehints\TooWideClosureReturnTypehintRule
1616
- PHPStan\Rules\TooWideTypehints\TooWideFunctionReturnTypehintRule
17+
- PHPStan\Rules\TooWideTypehints\TooWideFunctionParameterOutTypeRule
18+
- PHPStan\Rules\TooWideTypehints\TooWideMethodParameterOutTypeRule
1719

1820
conditionalTags:
1921
PHPStan\Rules\Comparison\ConstantLooseComparisonRule:
@@ -28,10 +30,6 @@ conditionalTags:
2830
phpstan.rules.rule: %featureToggles.logicalXor%
2931
PHPStan\Rules\DeadCode\BetterNoopRule:
3032
phpstan.rules.rule: %featureToggles.betterNoop%
31-
PHPStan\Rules\TooWideTypehints\TooWideFunctionParameterOutTypeRule:
32-
phpstan.rules.rule: %featureToggles.paramOutType%
33-
PHPStan\Rules\TooWideTypehints\TooWideMethodParameterOutTypeRule:
34-
phpstan.rules.rule: %featureToggles.paramOutType%
3533
PHPStan\Rules\DeadCode\CallToConstructorStatementWithoutImpurePointsRule:
3634
phpstan.rules.rule: %featureToggles.pure%
3735
PHPStan\Rules\DeadCode\PossiblyPureNewCollector:
@@ -322,11 +320,6 @@ services:
322320
tags:
323321
- phpstan.rules.rule
324322

325-
-
326-
class: PHPStan\Rules\TooWideTypehints\TooWideFunctionParameterOutTypeRule
327-
328-
-
329-
class: PHPStan\Rules\TooWideTypehints\TooWideMethodParameterOutTypeRule
330323

331324
-
332325
class: PHPStan\Rules\TooWideTypehints\TooWidePropertyTypeRule

conf/config.level6.neon

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ parameters:
99

1010
rules:
1111
- PHPStan\Rules\Constants\MissingClassConstantTypehintRule
12+
- PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule
1213
- PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule
14+
- PHPStan\Rules\Methods\MissingMethodParameterTypehintRule
1315
- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule
1416
- PHPStan\Rules\Properties\MissingPropertyTypehintRule
1517

@@ -18,19 +20,5 @@ conditionalTags:
1820
phpstan.rules.rule: %featureToggles.absentTypeChecks%
1921

2022
services:
21-
-
22-
class: PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule
23-
arguments:
24-
paramOut: %featureToggles.paramOutType%
25-
tags:
26-
- phpstan.rules.rule
27-
28-
-
29-
class: PHPStan\Rules\Methods\MissingMethodParameterTypehintRule
30-
arguments:
31-
paramOut: %featureToggles.paramOutType%
32-
tags:
33-
- phpstan.rules.rule
34-
3523
-
3624
class: PHPStan\Rules\Methods\MissingMethodSelfOutTypeRule

conf/config.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ parameters:
7777
callUserFunc: false
7878
finalByPhpDoc: false
7979
magicConstantOutOfContext: false
80-
paramOutType: false
8180
pure: false
8281
checkParameterCastableToStringFunctions: false
8382
uselessReturnValue: false
@@ -531,7 +530,6 @@ services:
531530
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
532531
detectDeadTypeInMultiCatch: %featureToggles.detectDeadTypeInMultiCatch%
533532
universalObjectCratesClasses: %universalObjectCratesClasses%
534-
paramOutType: %featureToggles.paramOutType%
535533
preciseMissingReturn: %featureToggles.preciseMissingReturn%
536534

537535
-

conf/parametersSchema.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ parametersSchema:
7171
callUserFunc: bool()
7272
finalByPhpDoc: bool()
7373
magicConstantOutOfContext: bool()
74-
paramOutType: bool()
7574
pure: bool()
7675
checkParameterCastableToStringFunctions: bool()
7776
uselessReturnValue: bool()

src/Analyser/NodeScopeResolver.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ public function __construct(
260260
private readonly bool $implicitThrows,
261261
private readonly bool $treatPhpDocTypesAsCertain,
262262
private readonly bool $detectDeadTypeInMultiCatch,
263-
private readonly bool $paramOutType,
264263
private readonly bool $preciseMissingReturn,
265264
)
266265
{
@@ -4748,13 +4747,11 @@ private function processArgs(
47484747
} elseif (
47494748
$calleeReflection instanceof MethodReflection
47504749
&& !$calleeReflection->getDeclaringClass()->isBuiltin()
4751-
&& $this->paramOutType
47524750
) {
47534751
$byRefType = $currentParameter->getType();
47544752
} elseif (
47554753
$calleeReflection instanceof FunctionReflection
47564754
&& !$calleeReflection->isBuiltin()
4757-
&& $this->paramOutType
47584755
) {
47594756
$byRefType = $currentParameter->getType();
47604757
}

src/PhpDoc/StubValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ private function getRuleRegistry(Container $container): RuleRegistry
228228
new InvalidThrowsPhpDocValueRule($fileTypeMapper),
229229

230230
// level 6
231-
new MissingFunctionParameterTypehintRule($missingTypehintCheck, $container->getParameter('featureToggles')['paramOutType']),
231+
new MissingFunctionParameterTypehintRule($missingTypehintCheck),
232232
new MissingFunctionReturnTypehintRule($missingTypehintCheck),
233-
new MissingMethodParameterTypehintRule($missingTypehintCheck, $container->getParameter('featureToggles')['paramOutType']),
233+
new MissingMethodParameterTypehintRule($missingTypehintCheck),
234234
new MissingMethodReturnTypehintRule($missingTypehintCheck),
235235
new MissingPropertyTypehintRule($missingTypehintCheck),
236236
];

src/Rules/Functions/MissingFunctionParameterTypehintRule.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ final class MissingFunctionParameterTypehintRule implements Rule
2525

2626
public function __construct(
2727
private MissingTypehintCheck $missingTypehintCheck,
28-
private bool $paramOut,
2928
)
3029
{
3130
}
@@ -51,9 +50,6 @@ public function processNode(Node $node, Scope $scope): array
5150
}
5251
}
5352

54-
if (!$this->paramOut) {
55-
continue;
56-
}
5753
if ($parameterReflection->getOutType() === null) {
5854
continue;
5955
}

0 commit comments

Comments
 (0)