Repository navigation
Conversation
xificurk
force-pushed
the
tester-assert-narrowing
branch
from
November 1, 2026 12:44
920d020 to
62c3e14
Compare
- unpacked arguments and first-class callables are declined
(Assert::null(...$args) narrowed $args to never)
- named arguments PHPStan couldn't resolve to positions (an invalid call)
are declined (Assert::null(description: $d) narrowed $d to null)
- type('') no longer crashes on an empty class name
- type() ignores a leading backslash in a class name
Co-Authored-By: Claude Code
…pe() accepts unions and list - nan() narrows to float, count() to array|Countable with count() === $n, hasKey()/hasNotKey() via array_key_exists() - type() with a union of constant strings narrows to the union of the types, 'list' narrows to list Co-Authored-By: Claude Code
xificurk
force-pushed
the
tester-assert-narrowing
branch
from
November 7, 2026 08:55
62c3e14 to
78f014e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Porting the missing support for type-narrowing of
Tester\Assertmethods from https://github.com/nepada/phpstan-nette-testerAssert::null(...$args)used to narrow$argstonever)Assert::type('', $x)no longer crashes the analysis with "Name cannot be empty"Assert::null(description: $d)used to narrow$dtonull)Assert::type('\stdClass', $x))Assert::nan($x)→floatAssert::count($n, $x)→array|Countablewithcount($x) === $n(e.g.non-empty-arrayfor$n > 0)Assert::hasKey($k, $x)/Assert::hasNotKey($k, $x)→ viaarray_key_exists(), e.g.array{foo?: int}→array{foo: int}Assert::type($type, $x)with a union of constant strings ('int'|'string'→int|string)Assert::type('list', $x)→list(wasarray)