Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix incorrect type inference for @phpstan-assert-if-true on $this with union types #4246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yt-catpaw wants to merge 5 commits into phpstan:2.1.x
base: 2.1.x
Choose a base branch
Loading
from yt-catpaw:bugfix/13358-assert-if-true-this
Open
Changes from 1 commit
Commits
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
fix(reflection): merge assertions in UnionTypeMethodReflection::getAs...
...serts()
  • Loading branch information
potet committed Aug 17, 2025
commit 1f1e9163d263e03d61322ca791d6e18ee7ca4366

Some comments aren't visible on the classic Files Changed page.

8 changes: 7 additions & 1 deletion src/Reflection/Type/UnionTypeMethodReflection.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ public function getDocComment(): ?string

public function getAsserts(): Assertions
{
return Assertions::createEmpty();
$mergedAssertions = Assertions::createEmpty();

foreach ($this->methods as $method) {
$mergedAssertions = $mergedAssertions->intersectWith($method->getAsserts());
}

return $mergedAssertions;
}

public function acceptsNamedArguments(): TrinaryLogic
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /