Skip to content

Commit 7b250db

Browse files
committed
Parameter #3 of function sprintf is expected to be string by placeholder #2 ("%s"), string|false given.
1 parent 113a97a commit 7b250db

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Rules/Cast/InvalidCastRule.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PHPStan\Rules\Rule;
1010
use PHPStan\Rules\RuleErrorBuilder;
1111
use PHPStan\Rules\RuleLevelHelper;
12+
use PHPStan\ShouldNotHappenException;
1213
use PHPStan\Type\ErrorType;
1314
use PHPStan\Type\Type;
1415
use PHPStan\Type\VerbosityLevel;
@@ -82,6 +83,10 @@ static function (Type $type) use ($castTypeCallback): bool {
8283
if ($castType instanceof ErrorType) {
8384
$classReflection = $this->reflectionProvider->getClass(get_class($node));
8485
$shortName = $classReflection->getNativeReflection()->getShortName();
86+
if ($shortName === '') {
87+
throw new ShouldNotHappenException();
88+
}
89+
8590
$shortName = strtolower($shortName);
8691
if ($shortName === 'double') {
8792
$shortName = 'float';

0 commit comments

Comments
 (0)