unsafe usage of new static()

Created on 19 March 2025, 25 days ago

Problem/Motivation

phpstan reports,

Unsafe usage of new static().
πŸ’‘ See:
https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static

for AutologoutController, AutologoutBlockForm, AutologoutSettingsForm, and AutologoutWarningBlock. Additionally, for ConfigAutologoutRoles, it says

\Drupal calls should be avoided in classes, use dependency injection instead

Steps to reproduce

phpstan analyse autologout

Proposed resolution

Use the pattern $instance = parent::create() instead of re-implementing __construct() on child classes. In AutologoutWarningBlock, mark __construct() as final. In ConfigAutologoutRoles, implement create() to inject the dependency.

Remaining tasks

make an 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