Problem/Motivation
Now that autowiring is supported in Drupal core, there is less reason to ignore the "unsafe usage of new static()" messages that phpstan and Upgrade Status module report when scanning the module.
Steps to reproduce
Use phpstan outside the context of Drupal's phpstan.neon file (which suppresses the message), or use Upgrade Status in Drupal 11 to scan the module.
Proposed resolution
When a parent class uses AutowireTrait, use that and remove the create() method. When a parent class uses create(), use the $instance = parent::create() pattern instead of "new static".
Remaining tasks
Make an MR and test it.
Issue fork custom_field-3590742
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments