Skip to content

Offset access type issue within function doing the accessing #7380

@Seldaek

Description

@Seldaek

Bug report

(continuation from https://github.com/phpstan/phpstan-src/pull/1318/files#r886790778)

Code snippet that reproduces the problem

It does error already with the code copied 1:1 from the test suite https://github.com/phpstan/phpstan-src/blob/a6a4df610fc3c03bcaef9aaad87fef6b1e4f3978/tests/PHPStan/Analyser/data/bug-7094.php

https://phpstan.org/r/a24d7d2c-1b2b-4927-a446-21b702eb2499 - I am not sure why this does not break the tests?

Adding &key-of makes $key more accurate, but $val is still borked https://phpstan.org/r/ffcd4faf-f56a-422b-883d-ac7e2a27e4a6 I guess the issue is it does not understand that for a given K, $val will be only T[K] and not value-of<T>.

Expected output

No error within the function

cc @rvanvelzen

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions