From 60c2916b172481d10b3f82045804fd4d44b86676 Mon Sep 17 00:00:00 2001 From: catch Date: Fri, 10 Mar 2023 14:29:37 +0000 Subject: [PATCH] Issue #3335110 by Spokje, mondrake: Fix PHPStan L1 errors "#foo callback class 'Bar\Baz')' at key 'X' does not implement Drupal\Core\Security\TrustedCallbackInterface." --- core/phpstan-baseline.neon | 10 ---------- .../Drupal/Tests/Core/Render/RendererCallbackTest.php | 6 ++++++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 741fa2d7ac9..38538dd6a36 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -3175,21 +3175,11 @@ parameters: count: 1 path: tests/Drupal/Tests/Core/Plugin/TestPluginManager.php - - - message: "#^\\#access_callback callback class '\\$this\\(Drupal\\\\Tests\\\\Core\\\\Render\\\\RendererCallbackTest\\)' at key '0' does not implement Drupal\\\\Core\\\\Security\\\\TrustedCallbackInterface\\.$#" - count: 1 - path: tests/Drupal/Tests/Core/Render/RendererCallbackTest.php - - message: "#^\\#lazy_builder callback '\\\\\\\\Drupal\\\\\\\\Tests\\\\\\\\Core…' at key '0' is not trusted\\.$#" count: 1 path: tests/Drupal/Tests/Core/Render/RendererCallbackTest.php - - - message: "#^\\#post_render callback class 'static\\(Drupal\\\\Tests\\\\Core\\\\Render\\\\RendererCallbackTest\\)' at key '0' does not implement Drupal\\\\Core\\\\Security\\\\TrustedCallbackInterface\\.$#" - count: 1 - path: tests/Drupal/Tests/Core/Render/RendererCallbackTest.php - - message: "#^\\#pre_render callback '\\\\\\\\Drupal\\\\\\\\Tests\\\\\\\\Core…' at key '0' is not trusted\\.$#" count: 1 diff --git a/core/tests/Drupal/Tests/Core/Render/RendererCallbackTest.php b/core/tests/Drupal/Tests/Core/Render/RendererCallbackTest.php index a2e78e2e407..eabbb7f1c52 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererCallbackTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererCallbackTest.php @@ -46,10 +46,16 @@ class RendererCallbackTest extends RendererTestBase { 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was \Drupal\Tests\Core\Render\callback. See https://www.drupal.org/node/2966725', ], 'Static object method post render' => [ + // We specifically test an invalid callback here. We need to let PHPStan + // ignore it. + // @phpstan-ignore-next-line ['#post_render' => ['\Drupal\Tests\Core\Render\RendererCallbackTest::renderCallback'], '#type' => 'container'], 'Render #post_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was \Drupal\Tests\Core\Render\RendererCallbackTest::renderCallback. See https://www.drupal.org/node/2966725', ], 'Object method access callback' => [ + // We specifically test an invalid callback here. We need to let PHPStan + // ignore it. + // @phpstan-ignore-next-line ['#access_callback' => [$this, 'renderCallback'], '#type' => 'container'], 'Render #access_callback callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was Drupal\Tests\Core\Render\RendererCallbackTest::renderCallback. See https://www.drupal.org/node/2966725', ],