For PHP static analysers, what's the best way to handle a method that takes a list of object-like-arrays, adds a known new key to each, and returns the list?

eg
https://psalm.dev/r/68a894d26d
https://phpstan.org/r/5edc07eb-466d-4456-b675-bfba9ee8ee54

Psalm - a static analysis tool for PHP

@m1ke I've run into this numerous times working in existing codebases that extensively used shaped arrays and unfortunately there's no good out-of-the-box answer. PHPStan won't include helpers like `Partial` and doesn't support `TInput&array{b: int}` syntax. The next best solution is creating a custom phpdoc type parser. https://github.com/phpstan/phpstan/discussions/9102

I've had limited success creating multiple phpstan types that copy-pastes base definitions instead of using generics.

Is there a syntax to merge multiple two array in the PHPdoc · phpstan phpstan · Discussion #9102

I was looking for something like https://phpstan.org/r/70a19ee1-f8f7-49e5-a0c5-638b27aee363 Does PHPStan have a syntax to handle a type declaration like this ? The idea would be to refactor differe...

GitHub