Re: Re: svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/Zend/tests/bug53727.phpt branches/PHP_5_3/Zend/tests/is_a.phpt
branches/PHP_5_3/Zend/zend_builtin_functions.c branches/PHP_5_3/ext/standard/tests/class_object/is_a_
| From: | Hannes Magnusson | Date: | Mon, 11 Jul 2011 08:17:27 +0000 |
| Subject: | Re: Re: svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/Zend/tests/bug53727.phpt branches/PHP_5_3/Zend/tests/is_a.phpt branches/PHP_5_3/Zend/zend_builtin_functions.c branches/PHP_5_3/ext/standard/tests/class_object/is_a_ |
||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-53834@lists.php.net to get a copy of this message | ||
On Mon, Jul 11, 2011 at 09:25, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
> Hi!
>
> On 7/11/11 12:18 AM, Dmitry Stogov wrote:
>>
>> Hi Ralph,
>>
>> I don't have strong opinion about your suggestion.
>>
>> In some cases this warning might help to find a typo, in others it may
>> be useless, but anyway, I think that usage of undefined class name is a
>> quite rare situation. I would prefer to keep it as is.
>
> It's not as rare, if people use is_a the same way as instanceof. Example
> I've seen recently - suppose you've got a method that receives either
> instance of an object or it's ID, something like this:
>
> function process($obj)
> {
> if(!is_a($obj, "MyClass") {
> $obj = new MyClass($obj);
> }
> // process $obj
> }
>
> Here you've got a new warning. Of course, you could do just $obj instanceof
> MyClass, but it's a very subtle distinction which many people miss. So the
> thing here is not that $obj has unknown class name - it's not even a class
> name at all.
Isn't this exactly why is_a() was un-deprecated in the firstplace?
Getting warnings from is_a() would be very weird.
-Hannes