psalm: False positive TypeDoesNotContainType introduced recently (4.15 maybe)

An example can be found with this PR: https://github.com/sonata-project/SonataAdminBundle/pull/7643

Code like

$class = \stdClass::class;
static::assertSame([$class => ['sonata.user.admin.group1']], $pool->getAdminClasses());

is reported

TypeDoesNotContainType: Cannot resolve types for $pool->getadminclasses() - array<class-string, array<array-key, string>> does not contain array{stdClass: array{"sonata.user.admin.group1"}}

But to me array<class-string, array<array-key, string>> contains array{stdClass: array{"sonata.user.admin.group1"}}.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 26 (7 by maintainers)

Most upvoted comments

Can be reproduced by https://psalm.dev/r/0482bc5bc7

Seems to be caused by https://github.com/vimeo/psalm/pull/7076

@klimick mind taking a look?

Ok, the class-string do make it to the TKeyedArray, I was not expecting it to be stored like that. I’m able to change the output, I’m now trying to check the parser

If the class-string is actually preserved in the TKeyedArray, then the fault must be in the comparison of the two types