Skip to content
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

Don't collapse Traversable with php-src native traversable objects #2676

Closed
wants to merge 1 commit into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Oct 12, 2023

@staabm staabm changed the base branch from 1.11.x to 1.10.x October 12, 2023 14:30
@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

use Traversable;
use function PHPStan\Testing\assertType;

class HelloWorld
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -138,6 +140,17 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
return $type->isSubTypeOf($this);
}

// don't collapse Traversable with classes which also implement Traversable to support phpstan-dba
// in inferring Traversable shapes onto php-src builtin classes
if ($this->getClassName() === Traversable::class) {
Copy link
Member

Choose a reason for hiding this comment

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

You can't special-case this about Traversable, this needs to work generally.

@ondrejmirtes
Copy link
Member

I tried a fix and it's hard: phpstan/phpstan#10008 (comment)

@staabm staabm deleted the travers branch October 24, 2023 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants