Problem/Motivation
There are calls to add array shape data to the documentation for each Drupal core method. This would help Drupal to pass PHPStan tests when it's run at a high level.
Proposed resolution
Because this would be a lot of work for something that at the moment is optional, it would be preferable to obtain that information in an automated way.
I suggest adding code that would wrap every method of every class. If that method has an array argument, the code would attempt to determine the shape of the array. Then, it would record that to the database or external files. Likewise with the return values. With enough data, it would be fairly certain that the shapes are correct.
This modified version of Drupal wouldn't be used on live sites. Developers would volunteer to run it on dev sites and the like. Then, they'd upload the results to a central server.
There would be minimal privacy concerns. While the additional code would see the values in the arrays, it would only record things like array<string,string>. It would not record the contents. And, only Drupal core would be modified, not contrib or custom modules.
If 100 developers upload that SomeClass::someMethod takes array<string,string>, then it would be fairly certain that's accurate. If someone uploads a different value for that method, that would be looked into manually.
Remaining tasks
There are various ways to implement this: using AOP, an IDE, reflection, or just text processing. The upload process could be handled on this site with a new node type. Only if enough uploads are created would code be written to process the uploads.
Comments
Comment #2
tolstoydotcom