Hi Stas,

On 07/11/2011 11:25 AM, Stas Malyshev 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.


That warning might be only emitted if the first operand is a name of non existing class.

is_a("NonExistingClass", "MyClass");

I think this warning may make sense. :)

Thanks. Dmitry.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to