Skip to content

Commit 96cbec6

Browse files
phpstan-botclaude
andcommitted
Remove comments and use @param mixed for PHP 7.4 compatibility
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5857b59 commit 96cbec6

3 files changed

Lines changed: 7 additions & 20 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,18 +3649,6 @@ private function createConditionalExpressions(
36493649
) {
36503650
continue;
36513651
}
3652-
// Skip non-Variable expressions absent from the other branch when
3653-
// the guard overlaps with the other branch's guard type.
3654-
// Non-Variable expressions (array dim fetches, property fetches)
3655-
// are always queryable, so absence from a branch means "not
3656-
// narrowed", not "doesn't exist". Creating a conditional
3657-
// expression would incorrectly narrow the type when the guard
3658-
// fires from the branch that never referenced the expression.
3659-
// Variables are exempt: their absence means genuinely "not
3660-
// defined", and conditional expressions for newly-defined
3661-
// variables are needed for variable certainty tracking (e.g.
3662-
// bug-14411-regression). Pre-defined variables (present in both
3663-
// branches) are handled by the check above.
36643652
if (
36653653
!array_key_exists($exprString, $theirExpressionTypes)
36663654
&& !$holder->getExpr() instanceof Variable

tests/PHPStan/Analyser/nsrt/bug-14469.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ function t(array $R, bool $var1, object $user): void {
1818
}
1919
}
2020

21-
/** Variable equivalent: pre-defined variable stays mixed inside if ($aa) */
22-
function variableEquivalent(mixed $input, bool $var1, object $user): void {
21+
/**
22+
* Variable equivalent: pre-defined variable stays mixed inside if ($aa)
23+
* @param mixed $input
24+
*/
25+
function variableEquivalent($input, bool $var1, object $user): void {
2326
$aa = null;
2427
$bb = $input;
2528

tests/PHPStan/Rules/Comparison/data/bug-14469.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,9 @@ function multipleElseif(array $R, bool $var1, bool $var2, object $user): void {
7373
}
7474

7575
/**
76-
* Variable equivalent: pre-defined variable used in elseif condition.
77-
* Same pattern as the array dim fetch case but $bb is a Variable defined
78-
* before the if/elseif, so it's present in both branches' expression types.
79-
* The existing guard-overlap check (lines that test array_key_exists($exprString,
80-
* $theirExpressionTypes)) handles this case correctly.
76+
* @param mixed $input
8177
*/
82-
function variableEquivalent(bool $var1, object $user, mixed $input): void {
78+
function variableEquivalent(bool $var1, object $user, $input): void {
8379
$aa = null;
8480
$bb = $input;
8581

0 commit comments

Comments
 (0)