Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
68e4440
Remove variable writes that are never read
ondrejmirtes Sep 10, 2026
6cae955
Remove unused private-method parameters
ondrejmirtes Sep 10, 2026
fd4a172
Remove assignments of values the variables already have
ondrejmirtes Sep 10, 2026
471b8fd
Use the assigned variables in E2E fixtures
ondrejmirtes Sep 10, 2026
69e0a94
Use the assigned variables in levels test fixtures
ondrejmirtes Sep 10, 2026
9359d69
Normalize paths in NodeScopeResolver::setAnalysedFiles()
ondrejmirtes Sep 10, 2026
b1c223b
Detect unused variables and parameters with immutable handler results
ondrejmirtes Sep 10, 2026
6a8637a
Bump expected turbo version
ondrejmirtes Sep 10, 2026
b1ba6f8
Cover variable reads in nullsafe call arguments
ondrejmirtes Sep 10, 2026
435856a
Add regression tests for #12789, #13472 and #14258
ondrejmirtes Sep 10, 2026
c1bc35d
Add regression test for #12012
ondrejmirtes Sep 10, 2026
fb7a088
Add regression test for #11483
ondrejmirtes Sep 10, 2026
5645d3d
Add regression test for #10202
ondrejmirtes Sep 10, 2026
69b9979
Cover PHP-version-dependent unused catch variables
ondrejmirtes Sep 10, 2026
bcb75f5
Do not report writes to a variable returned by reference
ondrejmirtes Sep 10, 2026
bbed891
Cover unused writes in statically dead branches
ondrejmirtes Sep 10, 2026
3723cc1
Treat comment-only bodies as no-op stubs in the unused-parameter rules
ondrejmirtes Sep 10, 2026
842976e
Cover array-shift loop inference and statically unreachable assignments
ondrejmirtes Sep 10, 2026
8a3b098
Treat func_get_arg() like func_get_args() when observing parameters
ondrejmirtes Sep 10, 2026
8c268f0
Cover variable liveness across evaluation order and control flow
ondrejmirtes Sep 10, 2026
7fdb62a
Cover variable liveness when foreach scope pollution is disabled
ondrejmirtes Sep 10, 2026
163f9a8
Cover variable usage through globals, static initializers and nested …
ondrejmirtes Sep 10, 2026
610b854
Respect short-circuiting of nullsafe dynamic member names
ondrejmirtes Sep 10, 2026
695d68f
Reuse concrete return types across inference contexts
ondrejmirtes Sep 10, 2026
bf91dae
Keep variables read by fallback Throwable catches live
ondrejmirtes Sep 10, 2026
a33871d
Track types written through variable variables
ondrejmirtes Sep 10, 2026
3f12a51
Preserve array writes made while evaluating an offset assignment
ondrejmirtes Sep 10, 2026
e5e374f
Retain variable mentions in skipped catch bodies
ondrejmirtes Sep 10, 2026
b84e05c
Observe writes through arrow function reference parameters
ondrejmirtes Sep 10, 2026
7d2352b
Include implicit throw points when analysing broad catches
ondrejmirtes Sep 10, 2026
d9ad990
Put the arrow reference fixture PHP version constraint on its first line
ondrejmirtes Sep 10, 2026
a83b91f
Mark reflection parameter checks and type stringification as non-thro…
ondrejmirtes Sep 10, 2026
5195842
Preserve reflection parameter query return types on PHP 7.4
ondrejmirtes Sep 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use the assigned variables in levels test fixtures
  • Loading branch information
ondrejmirtes committed Sep 10, 2026
commit 69e0a94bde276a80cb32966252f6d631ebdee5c9
6 changes: 3 additions & 3 deletions tests/PHPStan/Generics/data/invalidReturn-7.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[
{
"message": "Function PHPStan\\Generics\\InvalidReturn\\invalidReturnA() should return T but returns int.",
"line": 11,
"line": 13,
"ignorable": true
},
{
"message": "Function PHPStan\\Generics\\InvalidReturn\\invalidReturnB() should return T of DateTimeInterface but returns DateTime.",
"line": 20,
"line": 24,
"ignorable": true
},
{
"message": "Function PHPStan\\Generics\\InvalidReturn\\invalidReturnC() should return T of DateTime but returns DateTime.",
"line": 29,
"line": 35,
"ignorable": true
}
]
6 changes: 6 additions & 0 deletions tests/PHPStan/Generics/data/invalidReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @return T
*/
function invalidReturnA($a) {
var_dump($a);

return 1;
}

Expand All @@ -17,6 +19,8 @@ function invalidReturnA($a) {
* @return T
*/
function invalidReturnB($a) {
var_dump($a);

return new \DateTime();
}

Expand All @@ -26,5 +30,7 @@ function invalidReturnB($a) {
* @return T
*/
function invalidReturnC($a) {
var_dump($a);

return new \DateTime();
}
4 changes: 2 additions & 2 deletions tests/PHPStan/Generics/data/variance-0.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[
{
"message": "Template type T of function PHPStan\\Generics\\Variance\\returnOut() is not referenced in a parameter.",
"line": 109,
"line": 111,
"ignorable": true
},
{
"message": "Template type T of function PHPStan\\Generics\\Variance\\returnInvariant() is not referenced in a parameter.",
"line": 117,
"line": 119,
"ignorable": true
}
]
12 changes: 6 additions & 6 deletions tests/PHPStan/Generics/data/variance-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,32 @@
},
{
"message": "Variance annotation is only allowed for type parameters of classes and interfaces, but occurs in template type T in in function PHPStan\\Generics\\Variance\\returnOut().",
"line": 109,
"line": 111,
"ignorable": true
},
{
"message": "Variance annotation is only allowed for type parameters of classes and interfaces, but occurs in template type T in in function PHPStan\\Generics\\Variance\\returnInvariant().",
"line": 117,
"line": 119,
"ignorable": true
},
{
"message": "Template type T is declared as covariant, but occurs in contravariant position in parameter v of method PHPStan\\Generics\\Variance\\CovariantOfOBject::set().",
"line": 124,
"line": 126,
"ignorable": true
},
{
"message": "Template type T is declared as covariant, but occurs in contravariant position in parameter t of method PHPStan\\Generics\\Variance\\ConstructorAndStatic::create().",
"line": 154,
"line": 156,
"ignorable": true
},
{
"message": "Template type T is declared as covariant, but occurs in contravariant position in parameter w of method PHPStan\\Generics\\Variance\\ConstructorAndStatic::create().",
"line": 154,
"line": 156,
"ignorable": true
},
{
"message": "Template type T is declared as covariant, but occurs in invariant position in parameter v of method PHPStan\\Generics\\Variance\\ConstructorAndStatic::create().",
"line": 154,
"line": 156,
"ignorable": true
}
]
2 changes: 1 addition & 1 deletion tests/PHPStan/Generics/data/variance-4.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"message": "Property PHPStan\\Generics\\Variance\\ConstructorAndStatic::$data is never read, only written.",
"line": 135,
"line": 137,
"ignorable": true
}
]
2 changes: 1 addition & 1 deletion tests/PHPStan/Generics/data/variance-5.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"message": "Parameter #1 $it of function PHPStan\\Generics\\Variance\\acceptInvariantIterOfDateTimeInterface expects PHPStan\\Generics\\Variance\\InvariantIter<DateTimeInterface>, PHPStan\\Generics\\Variance\\InvariantIter<DateTime> given.",
"line": 165,
"line": 167,
"ignorable": true
}
]
2 changes: 2 additions & 0 deletions tests/PHPStan/Generics/data/variance.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class Quuz extends Quux {
* @return T
*/
function x($a, $b, $c, $d, $e) {
var_dump($b, $c, $d, $e);

return $a;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Generics/data/varyingAcceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function testApply()
* @param callable(callable():T):T $closure
* @return T
*/
function bar(callable $closure) { throw new \Exception(); }
function bar(callable $closure) { var_dump($closure); throw new \Exception(); }

/** @param callable(callable():int):string $callable */
function testBar($callable): void {
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Levels/data/acceptTypes-10.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
},
{
"message": "Parameter #1 $closure of method Levels\\AcceptTypes\\ClosureAccepts::doBar() expects Closure(Levels\\AcceptTypes\\FooInterface, int): Levels\\AcceptTypes\\FooInterface, Closure(mixed): mixed given.",
"line": 325,
"line": 326,
"ignorable": true
},
{
"message": "Parameter #1 $callable of method Levels\\AcceptTypes\\ClosureAccepts::doBaz() expects callable(Levels\\AcceptTypes\\FooInterface, int): Levels\\AcceptTypes\\FooInterface, Closure(mixed): mixed given.",
"line": 326,
"line": 327,
"ignorable": true
}
]
8 changes: 4 additions & 4 deletions tests/PHPStan/Levels/data/acceptTypes-4.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[
{
"message": "Call to method Levels\\AcceptTypes\\Baz::requireArray() on a separate line has no effect.",
"line": 531,
"line": 532,
"ignorable": true
},
{
"message": "Call to method Levels\\AcceptTypes\\Baz::requireFoo() on a separate line has no effect.",
"line": 532,
"line": 533,
"ignorable": true
},
{
"message": "Call to method Levels\\AcceptTypes\\Baz::requireArray() on a separate line has no effect.",
"line": 542,
"line": 543,
"ignorable": true
},
{
"message": "Call to method Levels\\AcceptTypes\\Baz::requireFoo() on a separate line has no effect.",
"line": 543,
"line": 544,
"ignorable": true
}
]
58 changes: 29 additions & 29 deletions tests/PHPStan/Levels/data/acceptTypes-5.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,147 +66,147 @@
},
{
"message": "Parameter #1 $closure of method Levels\\AcceptTypes\\ClosureAccepts::doBar() expects Closure(Levels\\AcceptTypes\\FooInterface, int): Levels\\AcceptTypes\\FooInterface, Closure(Levels\\AcceptTypes\\FooInterface, mixed, mixed): Levels\\AcceptTypes\\FooImpl given.",
"line": 226,
"line": 227,
"ignorable": true
},
{
"message": "Parameter #1 $callable of method Levels\\AcceptTypes\\ClosureAccepts::doBaz() expects callable(Levels\\AcceptTypes\\FooInterface, int): Levels\\AcceptTypes\\FooInterface, Closure(Levels\\AcceptTypes\\FooInterface, mixed, mixed): Levels\\AcceptTypes\\FooImpl given.",
"line": 227,
"line": 228,
"ignorable": true
},
{
"message": "Parameter #1 $closure of method Levels\\AcceptTypes\\ClosureAccepts::doBar() expects Closure(Levels\\AcceptTypes\\FooInterface, int): Levels\\AcceptTypes\\FooInterface, Closure(Levels\\AcceptTypes\\FooImpl): Levels\\AcceptTypes\\FooImpl given.",
"line": 238,
"line": 239,
"ignorable": true
},
{
"message": "Parameter #1 $callable of method Levels\\AcceptTypes\\ClosureAccepts::doBaz() expects callable(Levels\\AcceptTypes\\FooInterface, int): Levels\\AcceptTypes\\FooInterface, Closure(Levels\\AcceptTypes\\FooImpl): Levels\\AcceptTypes\\FooImpl given.",
"line": 239,
"line": 240,
"ignorable": true
},
{
"message": "Parameter #1 $closure of method Levels\\AcceptTypes\\ClosureAccepts::doBar() expects Closure(Levels\\AcceptTypes\\FooInterface, int): Levels\\AcceptTypes\\FooInterface, Closure(Levels\\AcceptTypes\\FooInterface): Levels\\AcceptTypes\\ParentFooInterface given.",
"line": 250,
"line": 251,
"ignorable": true
},
{
"message": "Parameter #1 $callable of method Levels\\AcceptTypes\\ClosureAccepts::doBaz() expects callable(Levels\\AcceptTypes\\FooInterface, int): Levels\\AcceptTypes\\FooInterface, Closure(Levels\\AcceptTypes\\FooInterface): Levels\\AcceptTypes\\ParentFooInterface given.",
"line": 251,
"line": 252,
"ignorable": true
},
{
"message": "Parameter #1 $i of method Levels\\AcceptTypes\\Baz::doBar() expects int, float given.",
"line": 412,
"line": 413,
"ignorable": true
},
{
"message": "Parameter #1 $i of method Levels\\AcceptTypes\\Baz::doBar() expects int, float|string given.",
"line": 413,
"line": 414,
"ignorable": true
},
{
"message": "Parameter #1 $a of method Levels\\AcceptTypes\\Baz::doLorem() expects int|resource, float|string given.",
"line": 425,
"line": 426,
"ignorable": true
},
{
"message": "Parameter #1 $a of method Levels\\AcceptTypes\\Baz::doLorem() expects int|resource, float|string|null given.",
"line": 426,
"line": 427,
"ignorable": true
},
{
"message": "Parameter #1 $i of method Levels\\AcceptTypes\\Baz::doBar() expects int, null given.",
"line": 431,
"line": 432,
"ignorable": true
},
{
"message": "Parameter #1 $i of method Levels\\AcceptTypes\\Baz::doBarArray() expects array<int>, array<float> given.",
"line": 493,
"line": 494,
"ignorable": true
},
{
"message": "Parameter #1 $i of method Levels\\AcceptTypes\\Baz::doBarArray() expects array<int>, array<float|string> given.",
"line": 494,
"line": 495,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, array<callable(): mixed> given.",
"line": 577,
"line": 578,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, array<string> given.",
"line": 578,
"line": 579,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, array<int> given.",
"line": 579,
"line": 580,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, array{} given.",
"line": 580,
"line": 581,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, array{foo: 1} given.",
"line": 582,
"line": 583,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, array{foo: 'date', bar: 'date'} given.",
"line": 583,
"line": 584,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, array{foo: 'nonexistent'} given.",
"line": 584,
"line": 585,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, array{bar: 'date'} given.",
"line": 585,
"line": 586,
"ignorable": true
},
{
"message": "Parameter #1 $one of method Levels\\AcceptTypes\\ArrayShapes::doBar() expects array{foo: callable(): mixed}, non-empty-array<callable(): mixed> given.",
"line": 588,
"line": 589,
"ignorable": true
},
{
"message": "Parameter #1 $static of method Levels\\AcceptTypes\\RequireObjectWithoutClassType::requireStatic() expects static(Levels\\AcceptTypes\\RequireObjectWithoutClassType), object given.",
"line": 648,
"line": 649,
"ignorable": true
},
{
"message": "Parameter #1 $min (0) of function random_int expects lower number than parameter #2 $max (-1).",
"line": 671,
"line": 672,
"ignorable": true
},
{
"message": "Parameter #1 $min (int<11, max>) of function random_int expects lower number than parameter #2 $max (10).",
"line": 678,
"line": 679,
"ignorable": true
},
{
"message": "Parameter #1 $min (340) of function random_int expects lower number than parameter #2 $max (int<min, 339>).",
"line": 685,
"line": 686,
"ignorable": true
},
{
"message": "Parameter #1 $numericString of method Levels\\AcceptTypes\\NumericStrings::doBar() expects numeric-string, 'foo' given.",
"line": 707,
"line": 708,
"ignorable": true
},
{
"message": "Parameter #1 $nonEmpty of method Levels\\AcceptTypes\\AcceptNonEmpty::doBar() expects non-empty-array<mixed>, array{} given.",
"line": 733,
"line": 734,
"ignorable": true
},
{
"message": "Parameter #2 $array of function implode expects array, int given.",
"line": 763,
"line": 766,
"ignorable": true
}
]
Loading