Re: Backward Compatibility RFC - was Re: [PHP-DEV] Re: is_a() - again - a better fix

From: Date: Sun, 25 Sep 2011 06:08:17 +0000
Subject: Re: Backward Compatibility RFC - was Re: [PHP-DEV] Re: is_a() - again - a better fix
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.internals 
Request: Send a blank email to internals+get-55626@lists.php.net to get a copy of this message
Sorry, never even noticed instanceof got fixed (in 5.1) with undefined classes. Since it did not work when introduced, i just assumed it would stay that way....... Anyway, It's a pretty good justification for phased "Announced" long term depreciation plan in 5.4 is_a() usage called without a third argument shows depreciated warning pointing to a message that you should use instanceof (as it has worked ok since 5.1) Then changing the behavior in 5.5 / 1yr+ and changing the default to true is a BC plan. Only downside is that users of is_a() for class string/autoload testing have to put true at the end, and eventually can remove it after a few years. Regards Alan On Sunday, September 25, 2011 11:53 AM, Stas Malyshev wrote:
Hi! On 9/24/11 7:00 PM, Alan Knowles wrote:
Obviously I'd be keen to see this fix applied to 5.4 as the standard use case for is_a() is mixed return testing as '$x instanceof "somestring"' does not work.
There is no reason to do $x instanceof "somestring" as you can do just $x instanceof Class. And for 99% of cases I've seen the second argument of is_a was constant - which means this code was plain wrong, there's no reason to use is_a in such case. In case you do have to use is_a - namely, when you have variable arguments - it would be rather strange if first argument wouldn't support string as class name, but the second one would, and moreover, is_subclass_of also would.


« previous php.internals (#55626) next »