Download src/php/php-src/ext/date/tests/DateTimeImmutable_createFromInterface_exceptions.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 942 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/date/tests/DateTimeImmutable_createFromInterface_exceptions.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/date/tests/DateTimeImmutable_createFromInterface_exceptions.phpt
-
curl -L -o DateTimeImmutable_createFromInterface_exceptions.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/date/tests/DateTimeImmutable_createFromInterface_exceptions.phpt
942 Bytes
| --TEST-- | |
| DateTimeImmutable::createFromInterface exception | |
| --INI-- | |
| date.timezone=Europe/London | |
| --FILE-- | |
| class MyDateTime extends DateTime | |
| { | |
| function __construct() | |
| { | |
| } | |
| } | |
| class MyDateTimeImmutable extends DateTimeImmutable | |
| { | |
| function __construct() | |
| { | |
| } | |
| } | |
| $i = new MyDateTime(); | |
| try { | |
| $m = DateTimeImmutable::createFromInterface( $i ); | |
| } catch (\DateObjectError $e) { | |
| echo $e::class, ': ', $e->getMessage(), "\n"; | |
| } | |
| $i = new MyDateTimeImmutable(); | |
| try { | |
| $m = DateTimeImmutable::createFromInterface( $i ); | |
| } catch (\DateObjectError $e) { | |
| echo $e::class, ': ', $e->getMessage(), "\n"; | |
| } | |
| --EXPECTF-- | |
| DateObjectError: Object of type MyDateTime (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor | |
| DateObjectError: Object of type MyDateTimeImmutable (inheriting DateTimeImmutable) has not been correctly initialized by calling parent::__construct() in its constructor | |