-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Typhoon\Type; | ||
|
||
/** | ||
* @api | ||
* @psalm-immutable | ||
* @template-covariant TClass of class-string | ||
* @implements Type<TClass> | ||
*/ | ||
final class ClassStringLiteralType implements Type | ||
{ | ||
/** | ||
* @var TClass | ||
*/ | ||
public readonly string $class; | ||
|
||
/** | ||
* @internal | ||
* @psalm-internal Typhoon\Type | ||
* @param TClass $class | ||
*/ | ||
public function __construct( | ||
string $class, | ||
) { | ||
$this->class = $class; | ||
} | ||
|
||
public function accept(TypeVisitor $visitor): mixed | ||
{ | ||
return $visitor->visitClassStringLiteral($this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Typhoon\Type\ClassStringLiteralTest; | ||
|
||
use Typhoon\Type\ClassStringLiteralType; | ||
use function Typhoon\Type\extractType; | ||
|
||
/** @psalm-check-type-exact $_classLiteral = stdClass::class */ | ||
$_classLiteral = extractType(new ClassStringLiteralType(\stdClass::class)); |