Re: Callable type
| From: | Stas Malyshev | Date: | Sun, 10 Jul 2011 19:57:41 +0000 |
| Subject: | Re: Callable type | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-53806@lists.php.net to get a copy of this message | ||
Hi!
On 7/10/11 12:02 PM, Johannes Schlüter wrote:
Well, it's like array type - you know it's an array but you can't know if it contains certain element that you expect, for example. As I'm not a big fan of strict typing in PHP anyway, I can't really defend this thing, but this is nothing new - other type restrictions don't guarantee you the code would work properly either, they only guarantee the type.I can call it in some way. It won't ensure that the signature is compatible with what I expect.
Indeed, E_RECOVERABLE is more or less useless - they are only marginally better than E_ERROR since error handler could be invoked on it. I do not know why people think E_RECOVERABLE makes anything better. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227function foo(callable $cb) { $cb(); } foo("strpos"); // This one in fact is illegal but won't beprevented But maybe this doesn't matter as type hints purely serve documentation (as E_RECOVERABLE are useless unless we make them Exceptions ...) while