PHPStan fails on “previous major” (Drupal 10) pipeline: Drupal\Core\Entity\Attribute\*EntityType classes not found

Created on 16 August 2025, 2 months ago

Problem/Motivation

The GitLab CI composer (previous major) job (Drupal 10) started failing PHPStan due to missing classes when analyzing the new attribute-based entity definitions:
These attributes exist in Drupal 11 but not in Drupal 10. At runtime on D10 the attributes are ignored, but PHPStan flags them as missing.

https://git.drupalcode.org/project/og/-/jobs/6226789

Note: Using configuration file /builds/project/og/web/modules/custom/og/phpstan.neon.
 ------ --------------------------------------------------------------------- 
  Line   src/Entity/OgMembership.php                                          
 ------ --------------------------------------------------------------------- 
  104    Attribute class Drupal\Core\Entity\Attribute\ContentEntityType does  
         not exist.                                                           
 ------ --------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------- 
  Line   src/Entity/OgMembershipType.php                                     
 ------ -------------------------------------------------------------------- 
  61     Attribute class Drupal\Core\Entity\Attribute\ConfigEntityType does  
         not exist.                                                          
 ------ -------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------- 
  Line   src/Entity/OgRole.php                                               
 ------ -------------------------------------------------------------------- 
  72     Attribute class Drupal\Core\Entity\Attribute\ConfigEntityType does  
         not exist.                                                          
 ------ -------------------------------------------------------------------- 

 [ERROR] Found 3 errors  

Proposed resolution

Investigate whether these are false positives. Depending on findings:

  1. Adjust the version of Drupal that the job is running against, or
  2. Mute the errors in PHPStan configuration for the D10 job.
📌 Task
Status

Active

Version

2.0

Component

og.module

Created by

🇨🇦Canada joelpittet Vancouver

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