Skip to content

Commit

Permalink
support non-generic class-string
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Sep 4, 2022
1 parent c067543 commit 44cd775
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Type/Accessory/AccessoryLiteralStringType.php
Expand Up @@ -4,13 +4,13 @@

use PHPStan\TrinaryLogic;
use PHPStan\Type\BooleanType;
use PHPStan\Type\ClassStringType;
use PHPStan\Type\CompoundType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\ErrorType;
use PHPStan\Type\FloatType;
use PHPStan\Type\GeneralizePrecision;
use PHPStan\Type\Generic\GenericClassStringType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\MixedType;
Expand Down Expand Up @@ -51,7 +51,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic
return TrinaryLogic::createNo();
}

if ($type instanceof GenericClassStringType) {
if ($type instanceof ClassStringType) {
return TrinaryLogic::createYes();
}

Expand Down
32 changes: 32 additions & 0 deletions test.php
@@ -0,0 +1,32 @@
<?php

namespace Bug7823;

/**
* @param literal-string $s
*/
function sayHello(string $s): void
{
}

class A
{
}

/**
* @param T $t
*
* @template T of A
*/
function x($t): void
{
sayHello($t::class);
}

/**
* @param class-string $t
*/
function y($t): void
{
sayHello($t);
}
8 changes: 8 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-7823.php
Expand Up @@ -22,3 +22,11 @@ function x($t): void
{
sayHello($t::class);
}

/**
* @param class-string $t
*/
function y($t): void
{
sayHello($t);
}

0 comments on commit 44cd775

Please sign in to comment.