PHPStan reporting "Unsafe use of new static()"

Created on 11 November 2023, 8 months ago
Updated 4 January 2024, 6 months ago

Problem/Motivation

The issue ✨ Twould be terrific if this module provided a Twig filter Fixed is failing in the GitLab CI due to a PHPStan error:

  Line   src/Plugin/Field/FieldFormatter/SmartTrimFormatter.php                        
 ------ ------------------------------------------------------------------------------ 
  88     Unsafe usage of new static().                                                 
         💡 See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  

As the file reporting the error has not changed in this issue, I think the fix for it should be a separate issue.

Steps to reproduce

On issue ✨ Twould be terrific if this module provided a Twig filter Fixed , open the source for the change branch, navigate to pipelines, and rerun the CI.

Proposed resolution

Add a "phpstan.neon" file containing the following:

parameters:
  level: 1

  ignoreErrors:
    # new static() is a best practice in Drupal, so we cannot fix that.
    - "#^Unsafe usage of new static#"

This change was suggested by abramm.

📌 Task
Status

Closed: duplicate

Version

2.1

Component

Code

Created by

🇮🇪Ireland lostcarpark

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

Comments & Activities

Production build 0.69.0 2024