marc-mabe / php-enum

Simple and fast implementation of enumerations with native PHP
BSD 3-Clause "New" or "Revised" License
464 stars 36 forks source link

Implement Stringable interface on Enum #156

Closed jdecool closed 2 years ago

jdecool commented 2 years ago

Enum class has a __toString, so it would be great to implements the new Stringable interface.

As the interface is not available for php < 8, I've had the symfony/polyfill-php-80.

I've removed psalm totallyTyped attribute as it's now deprecated.

codecov-commenter commented 2 years ago

Codecov Report

Merging #156 (3ddddff) into master (2eb0a50) will not change coverage. The diff coverage is n/a.

@@            Coverage Diff            @@
##             master     #156   +/-   ##
=========================================
  Coverage     99.81%   99.81%           
  Complexity      227      227           
=========================================
  Files             4        4           
  Lines           555      555           
=========================================
  Hits            554      554           
  Misses            1        1           
Impacted Files Coverage Δ
src/Enum.php 100.00% <ø> (ø)

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

marc-mabe commented 2 years ago

@jdecool thank you for this PR and improvement. I think it's a good idea to make this interface explicit and available for all versions. Although I don't really like to add a dependency for this simple case. A stub with class map loading from composer same as https://github.com/symfony/polyfill/blob/main/src/Php80/Resources/stubs/Stringable.php should be enough.

jdecool commented 2 years ago

👍

LGTM. I’m going to update this PR

jdecool commented 2 years ago

@marc-mabe The PR has just been updated

marc-mabe commented 2 years ago

I have moved the classmap setting from autoload-dev to autoload. It's released as 4.7.0 Thanks :+1: