-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize enum value to ClassConstFetch
Fixes #930
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
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
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,19 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PhpParser; | ||
|
||
use PhpParser\Node\Expr; | ||
use PhpParser\Node\Name\FullyQualified; | ||
|
||
class BuilderHelpersPHP81Test extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testNormalizeValueEnum() { | ||
if (\PHP_VERSION_ID <= 80100) { | ||
$this->markTestSkipped('Enums are supported since PHP 8.1'); | ||
} | ||
|
||
include __DIR__ . '/../code/Suit.php'; | ||
|
||
$this->assertEquals(new Expr\ClassConstFetch(new FullyQualified(\Suit::class), 'Hearts'), BuilderHelpers::normalizeValue(\Suit::Hearts)); | ||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
enum Suit | ||
{ | ||
case Hearts; | ||
case Diamonds; | ||
case Clubs; | ||
case Spades; | ||
} |