Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public function specifyTypes(
$returnType->withAccessCheck(),
TypeSpecifierContext::createTruthy(),
$scope
);
)->setAlwaysOverwriteTypes();
}
}
26 changes: 26 additions & 0 deletions tests/src/Rules/Bug825Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace mglaman\PHPStanDrupal\Tests\Rules;

use mglaman\PHPStanDrupal\Tests\DrupalRuleTestCase;
use PHPStan\Rules\Comparison\ImpossibleCheckTypeMethodCallRule;
use PHPStan\Rules\Rule;

final class Bug825Test extends DrupalRuleTestCase
{
protected function getRule(): Rule
{
/** @phpstan-ignore phpstanApi.constructor, phpstanApi.classConstant */
return self::getContainer()->getByType(ImpossibleCheckTypeMethodCallRule::class);
}

public function test(): void
{
$this->analyse(
[__DIR__ . '/data/bug-825.php'],
[]
);
}
}
34 changes: 34 additions & 0 deletions tests/src/Rules/data/bug-825.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Bug825;

// Fluent: accessCheck() immediately after entityQuery().
function accessCheckImmediatelyAfterEntityQuery(): void {
\Drupal::entityQuery('node')
->accessCheck()
->execute();
}

// Fluent: accessCheck() immediately after entityQuery(), then condition.
function accessCheckBeforeCondition(): void {
\Drupal::entityQuery('node')
->accessCheck()
->condition('type', 'article')
->execute();
}

// Fluent: condition before accessCheck().
function conditionBeforeAccessCheck(): void {
\Drupal::entityQuery('node')
->condition('type', 'article')
->accessCheck()
->execute();
}

// Non-fluent: separate statements.
function separateStatements(): void {
$query = \Drupal::entityQuery('node');
$query->condition('type', 'article');
$query->accessCheck();
$query->execute();
}
Loading