Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityQueryHasAccessCheckRule.php

function EntityQueryHasAccessCheckRule::processNode

File

vendor/mglaman/phpstan-drupal/src/Rules/Drupal/EntityQuery/EntityQueryHasAccessCheckRule.php, line 25

Class

EntityQueryHasAccessCheckRule
@implements Rule<Node\Expr\MethodCall>

Namespace

mglaman\PHPStanDrupal\Rules\Drupal\EntityQuery

Code

public function processNode(Node $node, Scope $scope) : array {
    $name = $node->name;
    if (!$name instanceof Node\Identifier) {
        return [];
    }
    if ($name->toString() !== 'execute') {
        return [];
    }
    $type = $scope->getType($node);
    if (!$type instanceof EntityQueryExecuteWithoutAccessCheckCountType && !$type instanceof EntityQueryExecuteWithoutAccessCheckType) {
        return [];
    }
    $parent = $scope->getType($node->var);
    if ($parent instanceof ConfigEntityQueryType) {
        return [];
    }
    return [
        RuleErrorBuilder::message('Relying on entity queries to check access by default is deprecated in drupal:9.2.0 and an error will be thrown from drupal:10.0.0. Call \\Drupal\\Core\\Entity\\Query\\QueryInterface::accessCheck() with TRUE or FALSE to specify whether access should be checked.')->tip('See https://www.drupal.org/node/3201242')
            ->build(),
    ];
}
RSS feed
Powered by Drupal