OK. As I said I don't have strong opinion about this.
So fell free to remove the warning.

Thanks. Dmitry.

On 07/11/2011 12:18 PM, Stas Malyshev wrote:
Hi!

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

is_a("NonExistingClass", "MyClass");

I think you've missed my point. The point was people use this to check
if first argument is an instance of a certain class or something else -
and "something else" may not be a class name at all, just random string
that they'll use later.

I think this warning may make sense. :)

I disagree, if you look at how people are using is_a on Google's
codesearch, you'll see that many use it in the same manner as
instanceof. In this case, the warning is useless since the first
argument is not meant to be class name, so it's no use to warn that it
is not - it does not add any information and does not expose any bug.
Here's an example of PEAR code:

function isError($data, $code = null)
{
if (!is_a($data, 'PEAR_Error')) {
return false;
}

if (is_null($code)) {
return true;
} elseif (is_string($code)) {
return $data->getMessage() == $code;
}

return $data->getCode() == $code;
}
}

I'm sure there is more code like that out there. And in such code,
producing a warning has no other result but make people to add useless
checks that have no other purpose but avoid warnings and annoy them.


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

Reply via email to