> -----Original Message----- > From: Sebastian Krebs [mailto:krebs.seb@xxxxxxxxx] > Sent: Wednesday, March 05, 2014 10:24 AM > To: Robert Stoll > Cc: PHP General List > Subject: Re: Mixed return type - boolean and array/resource/closure or object > > 2014-03-05 9:52 GMT+01:00 Robert Stoll <php@xxxxxxxxxx>: > > > > > > > From: Sebastian Krebs [mailto:krebs.seb@xxxxxxxxx] > > Sent: Wednesday, March 05, 2014 3:18 AM > > To: Robert Stoll > > Cc: PHP General List > > Subject: Re: Mixed return type - boolean and array/resource/closure > > or object > > > > > Some array functions like "current", "array_pop" and so on (item of > > arbitrary type or null) can return everything. An > > example for "boolean or object" is 'date_create' [1]. Afaik there is no > > built-in function, that returns a closure, so > > the combination "boolean or closure" is not possible at all. > > > > Hm... date_create is an alias of DateTime::__construct and as far as I > > understood __construct returns usually an object > > and false only in the case where an exception has been thrown anyway. > > Right? > > > > It isn't directly an alias, because one is a method and the other one a > function ;) OK, thats too easy, but that makes the difference: In case of > an error DateTime::__construct() emits an Exception (OOP-like), whereas > date_create() proceeds, but return 'false' (functional-like). > > > > > > -- > github.com/KingCrunch I see, thanks. A little bit confusing that this information is located at DateTime::__construct() and not directly at date_create(). Nevertheless, the signature in the documentation implies that date_create() returns always DateTime. I already submitted a patch to change it to mixed :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php