How best to handle "Unsafe usage of 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.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • drupal
  • DreamBathrooms
  • PowerRangers
  • hgfsjryuu7
  • magazineikmin
  • InstantRegret
  • rosin
  • everett
  • Youngstown
  • slotface
  • vwfavf
  • thenastyranch
  • mdbf
  • kavyap
  • Durango
  • anitta
  • tacticalgear
  • cubers
  • cisconetworking
  • khanakhh
  • osvaldo12
  • GTA5RPClips
  • ngwrru68w68
  • tester
  • normalnudes
  • ethstaker
  • modclub
  • Leos
  • provamag3
  • All magazines