Skip to content

Commit a950fd5

Browse files
authored
Merge pull request #453 from mglaman/filterprocessresult-stub
Add generic callable check for RenderCallbackRule
2 parents ad47ecc + 5f9fb7b commit a950fd5

File tree

8 files changed

+60
-0
lines changed

8 files changed

+60
-0
lines changed

src/Rules/Drupal/RenderCallbackRule.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ private function doProcessNode(Node\Expr $node, Scope $scope, string $keyChecked
192192
sprintf("%s callback %s at key '%s' is not callable.", $keyChecked, $type->describe(VerbosityLevel::value()), $pos)
193193
)->line($errorLine)->build();
194194
}
195+
} elseif ($type->isCallable()->yes()) {
196+
// If the value has been marked as callable or callable-string, we cannot resolve the callable, trust it.
197+
return null;
195198
} else {
196199
return RuleErrorBuilder::message(
197200
sprintf("%s value '%s' at key '%s' is invalid.", $keyChecked, $type->describe(VerbosityLevel::value()), $pos)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Drupal\Core\Cache;
4+
5+
interface CacheableDependencyInterface {
6+
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Drupal\Core\Cache;
4+
5+
class CacheableMetadata implements RefinableCacheableDependencyInterface {
6+
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Drupal\Core\Cache;
4+
5+
interface RefinableCacheableDependencyInterface extends CacheableDependencyInterface {
6+
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Drupal\Core\Render;
4+
5+
interface AttachmentsInterface {
6+
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Drupal\Core\Render;
4+
5+
use Drupal\Core\Cache\CacheableMetadata;
6+
7+
class BubbleableMetadata extends CacheableMetadata implements AttachmentsInterface {
8+
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Drupal\filter;
4+
5+
use Drupal\Core\Render\BubbleableMetadata;
6+
7+
class FilterProcessResult extends BubbleableMetadata {
8+
9+
/**
10+
* @param callable-string $callback
11+
* @param array<int|string, mixed> $args
12+
*/
13+
public function createPlaceholder($callback, array $args): string {
14+
15+
}
16+
}

tests/src/Rules/RenderCallbackRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public function fileData(): \Generator
111111
]
112112
]
113113
];
114+
yield [
115+
__DIR__ . '/../../fixtures/drupal/core/modules/filter/src/FilterProcessResult.php',
116+
[]
117+
];
114118
}
115119

116120

0 commit comments

Comments
 (0)