Unsafe usage of new static()

Created on 22 May 2025, 17 days ago

Problem/Motivation

phpstan reports, among other things:

------ -----------------------------------------------------------------------------------
Line src/Controller/SwitchController.php
------ -----------------------------------------------------------------------------------
54 Unsafe usage of new static().
πŸͺͺ new.static
πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
------ -----------------------------------------------------------------------------------

------ -----------------------------------------------------------------------------------
Line src/Form/MasqueradeForm.php
------ -----------------------------------------------------------------------------------
47 Unsafe usage of new static().
πŸͺͺ new.static
πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
------ -----------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/MasqueradeCallbacks.php
------ ------------------------------------------------------------------------------
87 \Drupal calls should be avoided in classes, use dependency injection instead
πŸͺͺ globalDrupalDependencyInjection.useDependencyInjection
------ ------------------------------------------------------------------------------

------ -----------------------------------------------------------------------------------
Line src/Plugin/Block/MasqueradeBlock.php
------ -----------------------------------------------------------------------------------
43 Unsafe usage of new static().
πŸͺͺ new.static
πŸ’‘ See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
------ -----------------------------------------------------------------------------------

Steps to reproduce

phpstan analyse -l0 masquerade

Proposed resolution

Use the $instance = parent::create() pattern.

Remaining tasks

make a MR.

πŸ“Œ Task
Status

Active

Version

2.0

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