On Thu, Feb 12, 2015 at 8:53 AM, Rowan Collins <rowan.coll...@gmail.com>
wrote:

> François Laupretre wrote on 12/02/2015 14:56:
>
>> Sorry to get off-topic but could we raise the 'undefined variable' error
>> to E_WARNING, at least ? E_NOTICE seems very low for such an error.
>>
>
> I think the division between E_NOTICE and E_WARNING is a bit arbitrary
> sometimes, but without a good definition of the difference, I think it's
> unhelpful to introduce "inflation" by raising severities. Don't forget that
> while an undefined variable is sometimes an error, it's sometimes just poor
> coding style, and the user is consciously relying on the implicit null
> (e.g. $count++, or $hash[$key] = $value, or even echo $hash[$key]).
>
> Perhaps what's needed is a survey of current messages, and an RFC to
> reclassify them based on some consistent definitions?
>
> Regards,
> --
> Rowan Collins
> [IMSoP]
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I would also like to see undefined variables escalated to E_WARNING.  Even
though it is often bad coding style, it's also frequently just an oversight
on the part of the developer; an oversight that can lead to unexpected
results.  Since it's very common for environments to display E_WARNING but
not E_NOTICE, some devs-- particularly those who are less experienced in
PHP-- can end up wasting a lot of time trying to chase down the behavior
because they're not seeing any errors.

Besides, making it only an E_NOTICE, we're encouraging people to develop
bad habits that can and do lead to all kinds of problems down the line.  I
know many devs who erroneously believe that declaring variables is actually
discouraged in PHP.  When I point out that not declaring a variable will
throw a notice, they always seem surprised; something along the lines of,
"Oh yeah I never see those."

Given the problems that can arise from this, I think that's reasonable
justification enough to make this an E_WARNING instead of E_NOTICE.

--Kris

Reply via email to