Hi internals,

Something I've seen play out a couple of times: Newbies try to use
something like "integer" or "resource" as a type, and then get a confusing
error message along the lines of "must be an instance of resource, resource
given".

I would like to throw a compiler warning in this case, that looks as one of
the following:

> Warning: "integer" will be interpreted as a class type. Did you mean
"int"? Use qualified name or "use" to suppress this warning

> Warning: "resource" is not a supported builtin type and will be
interpreted as a class type. Use qualified name or "use" to suppress this
warning

This warning only triggers if the type is lowercase (integer but not
Integer), is unqualified (integer but not \integer) and is not imported
(there is no "use integer"). This provides multiple ways to avoid the
warning for code that does legitimately want to use lowercase "integer" as
a class type.

Implementation: https://github.com/php/php-src/pull/4815

Thoughts?

Nikita

Reply via email to