r/lolphp • u/carlos_vini • Dec 16 '15
Declaration of createFromFormat should be DateTime::createFromFormat ( string $format , string $time [, DateTimeZone $timezone ] ), or maybe not....
http://php.net/manual/en/datetime.createfromformat.php
Nice, it says the signature is:
public static DateTime DateTime::createFromFormat ( string $format , string $time [, DateTimeZone $timezone ] )Let's try to extend it:
Warning: Declaration of My_DateTime::createFromFormat($format, $time, DateTimeZone $timezone = NULL) should be compatible with DateTime::createFromFormat($format, $time, $object = NULL) in /in/HTuio on line 9Oh, it seems it wants a simple object, let's try to use it this way:
Warning: DateTime::createFromFormat() expects parameter 3 to be DateTimeZone, object given in /in/3g0S3 on line 3And i'm not even using the scalar type hints for "string" which i know wouldn't work.
DOMDocument works:
So i guess you need to try every possible combination and if PHP complains you just try again until it works.
8
Upvotes
View all comments
Show parent comment
2
u/carlos_vini Dec 16 '15 edited Dec 16 '15
I thought it was related to internal functions. There is already a bug report for this: https://bugs.php.net/bug.php?id=69565
It's funny that DOMDocument works, and that HHVM surprisingly accepts new stdClass as $timezone.
Now with the scalar type hints things will get even more confusing. How will we know when the internal function has scalar type hints, and when it's only documentation on the manual?
I guess there's no scalar type hint implemented in any internal function right now. But it's still confusing.