Skip to content

Conversation

VincentLanglet
Copy link
Contributor

While thinking about phpstan/phpstan#12390 I just decovered the weird behavior
https://phpstan.org/r/0850c2cb-3c81-4451-b2f6-b570d1d41a30

I expect mixed~object~stdclass & object to be stdClass.

if ($foo) {
$date = new \stdClass();
}
assertType('mixed~object~stdClass', $date);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what this means. There should be parentheses to disambiguate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already the current behavior https://phpstan.org/r/0850c2cb-3c81-4451-b2f6-b570d1d41a30

I'll see what I can do

trait SubstractableTypeTrait
{

public function describeSubtractedType(?Type $subtractedType, VerbosityLevel $level): string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno if it's worth to add this method to the interface (I didn't) but since the logic was used 5 times I thought it could been useful to have a specific method (for later updates ?)

@ondrejmirtes ondrejmirtes merged commit 275f816 into phpstan:2.1.x Sep 7, 2025
449 of 456 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants