You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -72,6 +73,25 @@ public function processNode(Node $node, Scope $scope): array
72
73
if (!$iteminstanceofNode\Expr\ArrayItem) {
73
74
continue;
74
75
}
76
+
// '#lazy_builder' has two items, callback and args. Others are direct callbacks.
77
+
// Lazy builder in Renderer: $elements['#lazy_builder'][0], $elements['#lazy_builder'][1]
78
+
if ($keyChecked === '#lazy_builder') {
79
+
if (!$item->valueinstanceofNode\Expr\Array_) {
80
+
$errors[] = RuleErrorBuilder::message(
81
+
sprintf("%s callback %s at key '%s' is not callable.", $keyChecked, $scope->getType($item->value)->describe(VerbosityLevel::value()), $pos)
82
+
)->line($item->value->getLine())->build();
83
+
continue;
84
+
}
85
+
86
+
if (count($item->value->items) !== 2) {
87
+
$errors[] = RuleErrorBuilder::message(
88
+
sprintf("%s callback %s at key '%s' is not valid. First value must be a callback and second value its arguments.", $keyChecked, $scope->getType($item->value)->describe(VerbosityLevel::value()), $pos)
89
+
)->line($item->value->getLine())->build();
90
+
continue;
91
+
}
92
+
// Replace $item with our nested callback.
93
+
$item = $item->value->items[0];
94
+
}
75
95
$errorLine = $item->value->getLine();
76
96
$type = $this->getType($item->value, $scope);
77
97
@@ -141,11 +161,10 @@ public function processNode(Node $node, Scope $scope): array
141
161
$errors[] = RuleErrorBuilder::message(
142
162
sprintf("%s value '%s' at key '%s' is invalid.", $keyChecked, $type->describe(VerbosityLevel::value()), $pos)
143
163
)->line($errorLine)->tip($tip)->build();
144
-
}else {
164
+
}else {
145
165
$errors[] = RuleErrorBuilder::message(
146
166
sprintf("%s value '%s' at key '%s' is invalid.", $keyChecked, $type->describe(VerbosityLevel::value()), $pos)
147
-
)->line($errorLine)->tip('Open an issue https://github.com/mglaman/phpstan-drupal/issues/new with this error.')
0 commit comments