Skip to content

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Aug 6, 2025

Static analysis is failing because TypeTraverserInstanceofVisitor doesn't support SimultaneousTypeTraverser (not sure it should).

The only current test failing is

16: Function ReturnListNullables\doFoo() should return array<string>|null but returns list<string|null>.

but I feel like we could reproduce more errors because...

UnionType/Intersection types doesn't work well with the SimultaneousTypeTraverser because

  • when it's called with A&B&C and A we're not traversing because second type is not an Intersection
  • when it's called with A&B&C and A&C we're not traversing because types count are different

The main issue would be, when traversing A&B&C and A&C, to match types in order to

  • traverse (A, A)
  • traverse (B, Never)
  • traverse (C, C)

@ondrejmirtes
Copy link
Member

The output from issue-bot is yummy here! https://github.com/phpstan/phpstan-src/actions/runs/16773630245

Please add regression tests for those.

I feel like we could improve IntersectionType::traverseSimultaneously() for all the common pseudotypes like non-empty-string, list etc. represented with IntersectionType.

I feel that even when there's non-empty-string on left side and string on the right side and vice versa, the callback should still be invoked for them.

This needs extensive tests of course.

@ondrejmirtes
Copy link
Member

Linking phpstan/phpstan#9096

@VincentLanglet
Copy link
Contributor Author

The output from issue-bot is yummy here! phpstan/phpstan-src/actions/runs/16773630245

Please add regression tests for those.

Sure, but shouldn't we fix the actual tests first ?

I feel like we could improve IntersectionType::traverseSimultaneously() for all the common pseudotypes like non-empty-string, list etc. represented with IntersectionType.

I feel that even when there's non-empty-string on left side and string on the right side and vice versa, the callback should still be invoked for them.

Yeah, but I dunno how to improve the implementation of the existing traverseSimultaneously, it's not easy :/

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