Skip to content

Commit

Permalink
Implement Stringable interface on Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
jdecool committed Apr 21, 2022
1 parent d56c200 commit eb64102
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"autoload": {
"psr-4": {
"MyCLabs\\Enum\\": "src/"
}
},
"classmap": [
"stubs/Stringable.php"
]
},
"autoload-dev": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @psalm-immutable
* @psalm-consistent-constructor
*/
abstract class Enum implements \JsonSerializable
abstract class Enum implements \JsonSerializable, \Stringable
{
/**
* Enum value
Expand Down
11 changes: 11 additions & 0 deletions stubs/Stringable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

if (\PHP_VERSION_ID < 80000 && !interface_exists('Stringable')) {
interface Stringable
{
/**
* @return string
*/
public function __toString();
}
}

0 comments on commit eb64102

Please sign in to comment.