Download src/php/php-src/Zend/tests/enum/backed-mismatch.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 843 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/enum/backed-mismatch.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/enum/backed-mismatch.phpt
-
curl -L -o backed-mismatch.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/enum/backed-mismatch.phpt
843 Bytes
| --TEST-- | |
| Mismatched enum backing type | |
| --FILE-- | |
| enum Foo: int { | |
| case Bar = 'bar'; | |
| } | |
| try { | |
| var_dump(Foo::Bar); | |
| } catch (Error $e) { | |
| echo get_class($e), ': ', $e->getMessage(), "\n"; | |
| } | |
| try { | |
| var_dump(Foo::Bar); | |
| } catch (Error $e) { | |
| echo get_class($e), ': ', $e->getMessage(), "\n"; | |
| } | |
| try { | |
| var_dump(Foo::from(42)); | |
| } catch (Error $e) { | |
| echo get_class($e), ': ', $e->getMessage(), "\n"; | |
| } | |
| try { | |
| var_dump(Foo::from('bar')); | |
| } catch (Error $e) { | |
| echo get_class($e), ': ', $e->getMessage(), "\n"; | |
| } | |
| --EXPECT-- | |
| TypeError: Enum case type string does not match enum backing type int | |
| TypeError: Enum case type string does not match enum backing type int | |
| TypeError: Enum case type string does not match enum backing type int | |
| TypeError: Foo::from(): Argument #1 ($value) must be of type int, string given | |