-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ReflectionEnum runtime stubs (PHP 8.0+)
- Loading branch information
1 parent
5a90731
commit e3a0e0d
Showing
8 changed files
with
127 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
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,14 @@ | ||
<?php | ||
|
||
if (\PHP_VERSION_ID < 80100) { | ||
if (interface_exists('BackedEnum', false)) { | ||
return; | ||
} | ||
|
||
interface BackedEnum extends UnitEnum | ||
{ | ||
public static function from(int|string $value): static; | ||
|
||
public static function tryFrom(int|string $value): ?static; | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
if (\PHP_VERSION_ID < 80100) { | ||
if (class_exists('ReflectionEnum', false)) { | ||
return; | ||
} | ||
|
||
class ReflectionEnum extends ReflectionClass | ||
{ | ||
public function __construct(object|string $objectOrClass) {} | ||
|
||
public function hasCase(string $name): bool | ||
{ | ||
} | ||
|
||
public function getCases(): array | ||
{ | ||
} | ||
|
||
public function getCase(string $name): ReflectionEnumUnitCase | ||
{ | ||
} | ||
|
||
public function isBacked(): bool | ||
{ | ||
} | ||
|
||
public function getBackingType(): ?ReflectionType | ||
{ | ||
} | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
|
||
if (\PHP_VERSION_ID < 80100) { | ||
if (class_exists('ReflectionEnumBackedCase', false)) { | ||
return; | ||
} | ||
|
||
class ReflectionEnumBackedCase extends ReflectionEnumUnitCase | ||
{ | ||
public function getBackingValue(): int|string | ||
{ | ||
} | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
if (\PHP_VERSION_ID < 80100) { | ||
if (class_exists('ReflectionEnumUnitCase', false)) { | ||
return; | ||
} | ||
|
||
class ReflectionEnumUnitCase extends ReflectionClassConstant | ||
{ | ||
public function __construct(object|string $class, string $constant) | ||
{ | ||
} | ||
|
||
public function getValue(): UnitEnum | ||
{ | ||
} | ||
|
||
/** | ||
* @return ReflectionEnum | ||
*/ | ||
public function getEnum(): ReflectionEnum | ||
{ | ||
} | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
|
||
if (\PHP_VERSION_ID < 80100) { | ||
if (interface_exists('UnitEnum', false)) { | ||
return; | ||
} | ||
|
||
interface UnitEnum | ||
{ | ||
/** | ||
* @return static[] | ||
*/ | ||
public static function cases(): array; | ||
} | ||
} |