Skip to content

Commit b848b0a

Browse files
committed
wip
1 parent 588a925 commit b848b0a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Rules/Classes/ClassConstantRule.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ public function processNode(Node $node, Scope $scope): array
6666
}
6767

6868
if ($this->checkNonStringableDynamicAccess) {
69-
$accepts = $this->ruleLevelHelper->accepts(new StringType(), $nameType, true);
7069
$typeResult = $this->ruleLevelHelper->findTypeToCheck(
7170
$scope,
7271
$node->name,
7372
'',
7473
static fn (Type $type) => $type->toString()->isString()->yes()
74+
&& ! $type->toString()->isNumericString()->yes(),
7575
);
7676

77-
if (! $typeResult->getType()->isString()->yes() ||
78-
$typeResult->getType()->toString()->isNumericString()->yes()
79-
) {
80-
$errors[] = RuleErrorBuilder::message(sprintf('Cannot fetch class constant with a non-stringable type %s.', $nameType->describe(VerbosityLevel::typeOnly())))
77+
$type = $typeResult->getType();
78+
79+
if ($type instanceof ErrorType) {
80+
$errors[] = RuleErrorBuilder::message(sprintf('Cannot fetch class constant with a non-stringable type %s.', $nameType->describe(VerbosityLevel::precise())))
8181
->identifier('classConstant.fetchInvalidExpression')
8282
->build();
8383
}

0 commit comments

Comments
 (0)