Skip to content

Commit eb64102

Browse files
committed
Implement Stringable interface on Enum
1 parent d56c200 commit eb64102

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
"autoload": {
1515
"psr-4": {
1616
"MyCLabs\\Enum\\": "src/"
17-
}
17+
},
18+
"classmap": [
19+
"stubs/Stringable.php"
20+
]
1821
},
1922
"autoload-dev": {
2023
"psr-4": {

src/Enum.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @psalm-immutable
2020
* @psalm-consistent-constructor
2121
*/
22-
abstract class Enum implements \JsonSerializable
22+
abstract class Enum implements \JsonSerializable, \Stringable
2323
{
2424
/**
2525
* Enum value

stubs/Stringable.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
if (\PHP_VERSION_ID < 80000 && !interface_exists('Stringable')) {
4+
interface Stringable
5+
{
6+
/**
7+
* @return string
8+
*/
9+
public function __toString();
10+
}
11+
}

0 commit comments

Comments
 (0)