- Issue created by @mondrake
- 🇺🇸United States smustgrave
What's the pro of using @phpstan-type? Seems tough to read
- 🇮🇹Italy mondrake 🇮🇹
This is not PHPStan level 0... it's PHPStan level 10. If you test locally the patch on the single core/lib/Drupal/Core/Database/Database.php file with PHPStan, and set the level to 10, it will pass.
I know it's a little bit futuristic but here I am exploring.
Wrt #4, on higher levels than what we have now PHPStan checks validity of the array keys being used in code against the array shape. Without @phpstan-type defined on the class level as an 'alias' of the array shape, we'd have to enter the full array shape every time it is used (16 times in this class). Readability would get definitely worse as well as the risk of errors (if you start using a new array key, you'd have to change all the instances).
There's interest in using
@phpstan-type
, see https://git.drupalcode.org/project/drupal/-/merge_requests/10809#note_51..., but probably not yet enough focus, see https://www.drupal.org/project/drupal/issues/3497431#comment-16102077 📌 Deprecate TestDiscovery test file scanning, use PHPUnit API instead Active and https://www.drupal.org/project/drupal/issues/3082239#comment-15153451 📌 Forbid limited length primary and unique keys, allow only in indexes Needs work (later comments)BTW, such long array shapes probably hint at the opportunity to use value objects instead. I opened ✨ Introduce a ConnectionParameters object to store database connection parameters Active .