@@ -60,6 +60,7 @@ public function processNode(Node $node, Scope $scope): array
60
60
61
61
$ errors = [];
62
62
63
+ // @todo Move into its own rule.
63
64
if ($ keyChecked === '#lazy_builder ' ) {
64
65
if (!$ value instanceof Node \Expr \Array_) {
65
66
return [
@@ -73,10 +74,13 @@ public function processNode(Node $node, Scope $scope): array
73
74
if ($ value ->items [0 ] === null ) {
74
75
return [];
75
76
}
77
+ // @todo take $value->items[1] and validate parameters against the callback.
76
78
$ errors [] = $ this ->doProcessNode ($ value ->items [0 ]->value , $ scope , $ keyChecked , 0 );
77
79
} elseif ($ keyChecked === '#access_callback ' ) {
80
+ // @todo move into its own rule.
78
81
$ errors [] = $ this ->doProcessNode ($ value , $ scope , $ keyChecked , 0 );
79
82
} else {
83
+ // @todo keep here.
80
84
if (!$ value instanceof Node \Expr \Array_) {
81
85
return [
82
86
RuleErrorBuilder::message (sprintf ('The "%s" render array value expects an array of callbacks. ' , $ keyChecked ))
@@ -114,7 +118,7 @@ private function doProcessNode(Node\Expr $node, Scope $scope, string $keyChecked
114
118
}
115
119
// We can determine if the callback is callable through the type system. However, we cannot determine
116
120
// if it is just a function or a static class call (MyClass::staticFunc).
117
- if ($ this ->reflectionProvider ->hasFunction (new \ PhpParser \ Node \Name ($ type ->getValue ()), null )) {
121
+ if ($ this ->reflectionProvider ->hasFunction (new Node \Name ($ type ->getValue ()), null )) {
118
122
return RuleErrorBuilder::message (
119
123
sprintf ("%s callback %s at key '%s' is not trusted. " , $ keyChecked , $ type ->describe (VerbosityLevel::value ()), $ pos )
120
124
)->line ($ errorLine )
@@ -185,6 +189,7 @@ private function doProcessNode(Node\Expr $node, Scope $scope, string $keyChecked
185
189
return null ;
186
190
}
187
191
192
+ // @todo move to a helper, as Drupal uses `service:method` references a lot.
188
193
private function getType (Node \Expr $ node , Scope $ scope ): Type
189
194
{
190
195
$ type = $ scope ->getType ($ node );
0 commit comments