3v4l.org

run code in 500+ PHP versions simultaneously
<?php // declare(strict_types=1); trait changed_tryFrom { public static function changed_tryFrom(mixed $value): self|null { if ($value instanceof self) { // nothing to do, already a valid "self". return $value; } elseif (null === $value) { // A backed enum of type int or type string can never contain the null value. // Prevent warning "Passing null to parameter #1 ($value) of type string|int is deprecated". return null; } try { return self::from($value); } catch (\Throwable $ex) { return null; } } } enum SuitAsInt: int { use \changed_tryFrom; case Clubs = 1; case Diamonds = 2; case Hearts = 3; case Spades = 4; } enum SuitAsString: string { use \changed_tryFrom; case Clubs = '1'; case Diamonds = '2'; case Hearts = '3'; case Spades = '4'; } $testcases = [ new \DateTimeImmutable(), null, 4, 4.0, '4', \SuitAsInt::Spades, \SuitAsString::Spades, ]; foreach ($testcases as $testcase) { echo '----------------------------------------'."\n"; echo '--------------[ TESTCASE ]--------------'."\n"; echo '----------------------------------------'."\n"; var_dump($testcase); echo "\n"; echo '------- [ INT backed enum ] -------'."\n"; echo '--- SuitAsInt::tryFrom()'."\n"; try { $value = \SuitAsInt::tryFrom($testcase); if (null !== $value) { echo 'Value is '.$value->name.' with value '.$value->value.'.'."\n"; } else { echo 'Value is NULL.'."\n"; } } catch (\Throwable $exception) { echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo '--- SuitAsInt::changed_tryFrom() [CHANGED]'."\n"; try { $value = \SuitAsInt::changed_tryFrom($testcase); if (null !== $value) { echo 'Value is '.$value->name.' with value '.$value->value.'.'."\n"; } else { echo 'Value is NULL.'."\n"; } } catch (\Throwable $exception) { echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo "\n"; echo '------- [ STRING backed enum ] -------'."\n"; echo '--- SuitAsString::tryFrom()'."\n"; try { $value = \SuitAsString::tryFrom($testcase); if (null !== $value) { echo 'Value is '.$value->name.' with value '.$value->value.'.'."\n"; } else { echo 'Value is NULL.'."\n"; } } catch (\Throwable $exception) { echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo '--- SuitAsString::changed_tryFrom() [CHANGED]'."\n"; try { $value = \SuitAsString::changed_tryFrom($testcase); if (null !== $value) { echo 'Value is '.$value->name.' with value '.$value->value.'.'."\n"; } else { echo 'Value is NULL.'."\n"; } } catch (\Throwable $exception) { echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo "\n"; echo "\n"; }
Output for 8.5.9
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.008651" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.5.11
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.007810" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.5.10
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.008356" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.4.26
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.005059" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.4.25
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.010723" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.3.18
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.004308" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.3.5
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.007834" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.2.34
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.009121" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.3.35
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.008848" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.
Output for 8.4.9
---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2026-08-31 18:28:48.009927" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, DateTimeImmutable given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, DateTimeImmutable given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- NULL ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Deprecated: SuitAsInt::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 67 Value is NULL. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Deprecated: SuitAsString::tryFrom(): Passing null to parameter #1 ($value) of type string|int is deprecated in /in/sNm6E on line 94 Value is NULL. --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- int(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- float(4) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- string(1) "4" ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() Value is Spades with value 4. --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() Value is Spades with value 4. --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsInt::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsInt given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is Spades with value 4. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsInt given --- SuitAsString::changed_tryFrom() [CHANGED] Value is NULL. ---------------------------------------- --------------[ TESTCASE ]-------------- ---------------------------------------- enum(SuitAsString::Spades) ------- [ INT backed enum ] ------- --- SuitAsInt::tryFrom() TypeError: SuitAsInt::tryFrom(): Argument #1 ($value) must be of type int, SuitAsString given --- SuitAsInt::changed_tryFrom() [CHANGED] Value is NULL. ------- [ STRING backed enum ] ------- --- SuitAsString::tryFrom() TypeError: SuitAsString::tryFrom(): Argument #1 ($value) must be of type string|int, SuitAsString given --- SuitAsString::changed_tryFrom() [CHANGED] Value is Spades with value 4.

preferences:
41.84 ms | 1212 KiB | 15 Q