Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to method Drupal\Core\Entity\Query\QueryInterface::accessCheck() will always evaluate to true (PHPStan 2) #825

Open
WalkingDexter opened this issue Feb 11, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@WalkingDexter
Copy link

Bug report

After upgrading to PHPStan 2, errors related to the accessCheck() method occurred. A similar problem was previously solved in #508.

Versions used:

  • phpstan/phpstan 2.1.4
  • mglaman/phpstan-drupal 2.0.1

Code snippet that reproduces the problem

// Error: method.alreadyNarrowedType
\Drupal::entityQuery('node')
  ->accessCheck()
  ->execute();

// Error: method.alreadyNarrowedType
\Drupal::entityQuery('node')
  ->accessCheck()
  ->condition('type', 'article')
  ->execute();

// No error.
\Drupal::entityQuery('node')
  ->condition('type', 'article')
  ->accessCheck()
  ->execute();

// Error: method.alreadyNarrowedType
$query = \Drupal::entityQuery('node');
$query->condition('type', 'article');
$query->accessCheck();
$query->execute();

Public example from GitLab CI: https://git.drupalcode.org/project/simple_sitemap/-/jobs/4303395

@WalkingDexter WalkingDexter added the bug Something isn't working label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant