Issue #3335110 by Spokje, mondrake: Fix PHPStan L1 errors "#foo callback class 'Bar\Baz')' at key 'X' does not implement Drupal\Core\Security\TrustedCallbackInterface."

merge-requests/3622/merge
catch 2023-03-10 14:29:37 +00:00
parent 341af8bf30
commit 60c2916b17
2 changed files with 6 additions and 10 deletions

View File

@ -3175,21 +3175,11 @@ parameters:
count: 1 count: 1
path: tests/Drupal/Tests/Core/Plugin/TestPluginManager.php 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\\.$#" message: "#^\\#lazy_builder callback '\\\\\\\\Drupal\\\\\\\\Tests\\\\\\\\Core…' at key '0' is not trusted\\.$#"
count: 1 count: 1
path: tests/Drupal/Tests/Core/Render/RendererCallbackTest.php 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\\.$#" message: "#^\\#pre_render callback '\\\\\\\\Drupal\\\\\\\\Tests\\\\\\\\Core…' at key '0' is not trusted\\.$#"
count: 1 count: 1

View File

@ -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', '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' => [ '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'], ['#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', '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' => [ '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'], ['#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', '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',
], ],