Problem/Motivation

Update to PHPSTan 2.2.14 and there are new errors. The workaround is that they are ignored in phpstan.neon.dist.

 ------ ------------------------------------------------------------------------------------------- 
  Line   core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php                         
 ------ ------------------------------------------------------------------------------------------- 
  68     A file could not be loaded from Drupal\Core\Extension\ModuleHandlerInterface::loadInclude  
         🪪  loadIncludes.fileNotLoadable                                                           
 ------ ------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------- 
  Line   core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php                               
 ------ ------------------------------------------------------------------------------------------- 
  52     A file could not be loaded from Drupal\Core\Extension\ModuleHandlerInterface::loadInclude  
         🪪  loadIncludes.fileNotLoadable                                                           
 ------ ------------------------------------------------------------------------------------------- 

Steps to reproduce

Proposed resolution

Remaining tasks

Fix the error ;-)
Remove the @todo in phpstan.neon.dist
Review

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3624168

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

quietone created an issue. See original summary.

catch’s picture

This was failing at random after we updated phpstan (before it got reverted) so it may be an upstream bug in phpstan.

For Drupal 13 this code will go so it's a temporary situation either way.

leandro713’s picture

The issue identifies the two PHPStan violations, but the proposed resolution is currently open.

Would the expected approach be to move the required setup logic from entity_test_install() into a reusable method in EntityTestHelper, and then call that method from both the install hook and the two affected tests?

Alternatively, is there a smaller or preferred solution for avoiding the dynamic loadInclude() calls?

Should this change be developed against main, or tested against the PHPStan 2.2.14 branch from #3621326 until that issue is committed?

mondrake made their first commit to this issue’s fork.

mondrake’s picture

I think the problem is somewhere in mglaman/phpstan-drupal, not in phpstan itself. At least, I can only see this error identifier only here https://github.com/mglaman/phpstan-drupal/blob/99d198489a50bf5a654187bf2...

mondrake’s picture

Title: Fix loadIncludes.fileNotLoadable phpstan violations » [upstream, likely] Fix loadIncludes.fileNotLoadable phpstan violations