Skip to content

Commit 5ba5884

Browse files
authored
Merge pull request #97 from sasezaki/literal-string
MessageStaticStringRule should be allow `literal-string` as static message
2 parents 98e484a + 30a3c5a commit 5ba5884

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Rules/MessageStaticStringRule.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ public function processNode(Node $node, Scope $scope): array
7171
}
7272

7373
$message = $args[$messageArgumentNo];
74-
$value = $scope->getType($message->value);
75-
$strings = $value->getConstantStrings();
74+
$type = $scope->getType($message->value);
7675

77-
if (count($strings) === 0) {
76+
if ($type->isLiteralString()->maybe()) {
7877
return [
7978
RuleErrorBuilder::message(
8079
sprintf(self::ERROR_MESSAGE_NOT_STATIC, $methodName)

test/Rules/data/messageMustBeStatic.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,11 @@ function main(Psr\Log\LoggerInterface $logger, string $m, string $literals, stri
3434
// Allow literal-string intersection
3535
$logger->info($literals);
3636
}
37+
38+
/**
39+
* @param literal-string $literal
40+
*/
41+
function logging(Psr\Log\LoggerInterface $logger, string $literal): void
42+
{
43+
$logger->info($literal);
44+
}

0 commit comments

Comments
 (0)