Skip to content

Commit a49db03

Browse files
committed
Replace deprecated PHPStan\Type\Constant\ConstantArrayType::findTypeAndMethodName() call
1 parent 480245d commit a49db03

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Rules/Drupal/RenderCallbackRule.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,17 @@ private function doProcessNode(Node\Expr $node, Scope $scope, string $keyChecked
162162
sprintf("%s callback %s at key '%s' is not callable.", $keyChecked, $type->describe(VerbosityLevel::value()), $pos)
163163
)->line($errorLine)->build();
164164
}
165-
$typeAndMethodName = $type->findTypeAndMethodName();
166-
if ($typeAndMethodName === null) {
165+
$typeAndMethodNames = $type->findTypeAndMethodNames();
166+
if ($typeAndMethodNames === []) {
167167
throw new \PHPStan\ShouldNotHappenException();
168168
}
169169

170-
if (!$trustedCallbackType->isSuperTypeOf($typeAndMethodName->getType())->yes()) {
171-
return RuleErrorBuilder::message(
172-
sprintf("%s callback class '%s' at key '%s' does not implement Drupal\Core\Security\TrustedCallbackInterface.", $keyChecked, $typeAndMethodName->getType()->describe(VerbosityLevel::value()), $pos)
173-
)->line($errorLine)->tip('Change record: https://www.drupal.org/node/2966725.')->build();
170+
foreach ($typeAndMethodNames as $typeAndMethodName) {
171+
if (!$trustedCallbackType->isSuperTypeOf($typeAndMethodName->getType())->yes()) {
172+
return RuleErrorBuilder::message(
173+
sprintf("%s callback class '%s' at key '%s' does not implement Drupal\Core\Security\TrustedCallbackInterface.", $keyChecked, $typeAndMethodName->getType()->describe(VerbosityLevel::value()), $pos)
174+
)->line($errorLine)->tip('Change record: https://www.drupal.org/node/2966725.')->build();
175+
}
174176
}
175177
} elseif ($type instanceof ClosureType) {
176178
if ($scope->isInClass()) {

0 commit comments

Comments
 (0)