-
Notifications
You must be signed in to change notification settings - Fork 461
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
1 parent
9a598b2
commit 05b85ba
Showing
7 changed files
with
101 additions
and
57 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/Reflection/Php/EnumUnresolvedPropertyPrototypeReflection.php
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,36 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Reflection\Php; | ||
|
||
use PHPStan\Reflection\PropertyReflection; | ||
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection; | ||
use PHPStan\Type\Type; | ||
|
||
class EnumUnresolvedPropertyPrototypeReflection implements UnresolvedPropertyPrototypeReflection | ||
{ | ||
|
||
public function __construct(private EnumPropertyReflection $property) | ||
{ | ||
} | ||
|
||
public function doNotResolveTemplateTypeMapToBounds(): UnresolvedPropertyPrototypeReflection | ||
{ | ||
return $this; | ||
} | ||
|
||
public function getNakedProperty(): PropertyReflection | ||
{ | ||
return $this->property; | ||
} | ||
|
||
public function getTransformedProperty(): PropertyReflection | ||
{ | ||
return $this->property; | ||
} | ||
|
||
public function withFechedOnType(Type $type): UnresolvedPropertyPrototypeReflection | ||
{ | ||
return $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
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,31 @@ | ||
<?php // lint >= 8.1 | ||
|
||
namespace Bug9000; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
enum A:string { | ||
case A = "A"; | ||
case B = "B"; | ||
case C = "C"; | ||
} | ||
|
||
const A_ARRAY = [ | ||
'A' => A::A, | ||
'B' => A::B, | ||
]; | ||
|
||
/** | ||
* @param string $key | ||
* @return value-of<A_ARRAY> | ||
*/ | ||
function testA(string $key): A | ||
{ | ||
return A_ARRAY[$key]; | ||
} | ||
|
||
function (): void { | ||
$test = testA('A'); | ||
assertType('Bug9000\A::A|Bug9000\A::B', $test); | ||
assertType("'A'|'B'", $test->value); | ||
}; |