From d7766c31bf2321308dcd1f794348c447d4fed474 Mon Sep 17 00:00:00 2001 From: Jurriaan Roelofs Date: Tue, 14 Apr 2026 15:48:45 +0200 Subject: [PATCH] fix: use FetchAs::Associative enum for fetchAll() in RlAnalyzer Drupal 11 changed the Connection statement fetch-mode argument from the legacy int-based PDO::FETCH_* constants to the Drupal\Core\Database\Statement\FetchAs enum. Passing \PDO::FETCH_ASSOC still works at runtime (PDO defines it as an int), but PHPStan via mglaman/phpstan-drupal flags it as an argument.type error because the type declaration on Connection::fetchAll() is now FetchAs|null: Parameter #1 $mode of method Drupal\Core\Database\StatementInterface::fetchAll() expects Drupal\Core\Database\Statement\FetchAs|null, int given. Two call sites in src/Service/RlAnalyzer.php (lines 407 and 428) were the only remaining drupal-check failures on 1.x. Swap both for FetchAs::Associative and add the corresponding use statement. Verified: - drupal-check (PHPStan) is clean: [OK] No errors (was: Found 2 errors) - drupal-lint (PHPCS) is clean - e2e: 88/88 assertions pass across all 6 test files --- src/Service/RlAnalyzer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Service/RlAnalyzer.php b/src/Service/RlAnalyzer.php index da59c0e..b325f45 100644 --- a/src/Service/RlAnalyzer.php +++ b/src/Service/RlAnalyzer.php @@ -5,6 +5,7 @@ namespace Drupal\rl\Service; use Drupal\Core\Database\Connection; +use Drupal\Core\Database\Statement\FetchAs; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\rl\Exception\ExperimentNotFoundException; @@ -404,7 +405,7 @@ protected function getArmsData(string $experimentId): array { ->fields('a') ->condition('experiment_id', $experimentId) ->execute() - ->fetchAll(\PDO::FETCH_ASSOC); + ->fetchAll(FetchAs::Associative); } /** @@ -425,7 +426,7 @@ protected function getArmSnapshots(string $experimentId, string $armId): array { ->condition('arm_id', $armId) ->orderBy('created', 'ASC') ->execute() - ->fetchAll(\PDO::FETCH_ASSOC); + ->fetchAll(FetchAs::Associative); return array_map(function ($row) { return [