php-to-string icon indicating copy to clipboard operation
php-to-string copied to clipboard

Add support for printing Enums when using PHP 8.1

Open gabrielanhaia opened this issue 4 years ago • 2 comments

Change Log

Added

    - Support for printing Enums when using PHP 8.1

Fixed

Changed

    Now it's possible to print Enums, however We will need a new version (probably) for backward compatibility.

Removed

Deprecated

Security


Description

  • It was implemented the possibility to print Enums when using PHP8.1+
  • I changed the minimum version of PHP to 8.1 in the composer.json file, probably We will need a 4.x version or something like that to keep the previous versions working.
  • If you take a look at my PR you will see that the return of \gettype in the case of an Enum is still an object for PHP. That is why I had to combine the \get_class and this new nice PHP function enum_exists

gabrielanhaia avatar Dec 01 '21 23:12 gabrielanhaia

@norberttech Proposition of an improvement now that PHP 8.1 is out there

gabrielanhaia avatar Dec 01 '21 23:12 gabrielanhaia

Do we really need to break BC to support enums? It might be better to probably just check if method enum_exists and then use it to check if given value is an enum and use it. Could you also add 8.1 to testsuite matrix in github action workflow files?

norberttech avatar Dec 02 '21 07:12 norberttech