How best to handle "Unsafe usage of new static()" PHPStan errors

Open link in next tab

How best to handle "Unsafe usage of new static()" PHPStan errors

https://www.drupaleasy.com/blogs/ultimike/2023/12/how-best-handle-unsafe-usage-new-static-phpstan-errors

As a Drupal module developer, if you're as big of a fan of PHPStan as I am, then you'll no doubt have run across the Unsafe usage of new static() error that PHPStan throws when analyzing code at level 0. In this article I will describe what causes this error and provide four possible solutions, weighing the pros and cons of each.

How best to handle "Unsafe usage of new static()" PHPStan errors