File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -300,7 +300,7 @@ public function map($json, $object)
300300 && is_a ($ type , 'Traversable ' , true )
301301 ) {
302302 $ array = $ this ->createInstance ($ type , false , $ jvalue );
303- } else if (enum_exists ($ type )) {
303+ } else if (PHP_VERSION_ID >= 80100 && enum_exists ($ type )) {
304304 $ evalue = $ type ::tryFrom ($ jvalue );
305305 if ($ evalue === null ) {
306306 throw new JsonMapper_Exception (
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ public function testEnumMapping()
3838 */
3939 public function testBackedEnumPropertyIsMappedFromString (): void
4040 {
41+ if (PHP_VERSION_ID < 80100 ) {
42+ $ this ->markTestSkipped ('Enumerators are not supported for PHP versions below 8.1 ' );
43+ }
44+
4145 $ json = (object ) [
4246 'stringBackedEnum ' => 'foo ' ,
4347 'intBackedEnum ' => 2 ,
@@ -60,6 +64,10 @@ public function testBackedEnumPropertyIsMappedFromString(): void
6064 */
6165 public function testBackedEnumPropertyWithInvalidStringThrowsJsonMapperException (): void
6266 {
67+ if (PHP_VERSION_ID < 80100 ) {
68+ $ this ->markTestSkipped ('Enumerators are not supported for PHP versions below 8.1 ' );
69+ }
70+
6371 $ json = (object ) [
6472 'stringBackedEnum ' => 'not-a-valid-enum-value ' ,
6573 'intBackedEnum ' => 'not-a-valid-enum-value ' ,
You can’t perform that action at this time.
0 commit comments