Replies: 1 comment 2 replies
-
|
Here's a PoC you won't like: https://phpstan.org/r/b3fa4f91-9308-492e-b4e5-b33e45242f3f The problem you're facing is that there's no Basically you would have to reimplement https://github.com/phpstan/phpstan-src/blob/2.1.x/src/Type/KeyOfType.php and https://github.com/phpstan/phpstan-src/blob/2.1.x/src/Type/OffsetAccessType.php for properties, which is possible with https://phpstan.org/developing-extensions/custom-phpdoc-types. But personally I think that having an object that allows both |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Following from #13877 (comment) I would like to have a type
Row<object{one:string, two:string}>which can be accessed both as$row['one']and$row->one.https://phpstan.org/r/4c509663-a706-43c1-b24b-9979fac96f20
Is it possible to somehow infer the type of an array access by using it's key to retutn the type of a generic array shape?
Beta Was this translation helpful? Give feedback.
All reactions