Unsafe usage of new static()

Created on 18 March 2025, 23 days ago

Problem/Motivation

phpstan reports,

------ -----------------------------------------------------------------------------------
Line src/Plugin/views/filter/AdministrativeArea.php
------ -----------------------------------------------------------------------------------
87 Unsafe usage of new static().
πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
134 \Drupal calls should be avoided in classes, use dependency injection instead
559 \Drupal calls should be avoided in classes, use dependency injection instead
------ -----------------------------------------------------------------------------------

The first warning appears on a number of other plugins as well.

Steps to reproduce

phpstan analyse address

Proposed resolution

Mark the construct() functions of these plugins as final, since any inheriting class should use create(). In the AdministrativeArea class, inject the moduleHandler and languageManager dependencies.

Remaining tasks

make an MR

πŸ“Œ Task
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States BenStallings

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024