Re: [RFC] Reclassifying engine warnings
| From: | Todd Ruth | Date: | Wed, 28 Aug 2019 21:21:58 +0000 |
| Subject: | Re: [RFC] Reclassifying engine warnings | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106776@lists.php.net to get a copy of this message | ||
> If we want PHP to be as easy as possible then $nullref->bar(), $foo->someUndefined(),
> new UndefinedClass etc shouldn’t be exceptions either - they can just be notices.
That's very different. Note that this code doesn't even generate a notice:
$x = null;
var_dump($x+1);
I'm joining the thread to point out another way to avoid the notice in hopes that
this way doesn't get deprecated or somesuch:
$temp =& $never_defined; // No notice :)
$temp++; // Happily becomes 1 if $never_defined wasn't defined
unset($temp); // so we don't unintentionally make more changes with $temp later
Our code predates "??" and we use the above boilerplate in many, many places, but
it isn't boilerplate enough to easily search and replace.
- Todd
> On Aug 28, 2019, at 4:01 PM, Stanislav Malyshev <smalyshev@gmail.com> wrote:
>
> Hi!
>
>> Javascript has treated undefined variables as a catchable exceptions since
>> (I think?) forever.
>
> Which seems to be why I open a random Javascript file in our codebase
> and see this:
>
> var wikibase = wikibase || {};
> wikibase.queryService = wikibase.queryService || {};
> wikibase.queryService.ui = wikibase.queryService.ui || {};
> wikibase.queryService.ui.toolbar = wikibase.queryService.toolbar || {};
>
> wikibase.queryService.ui.toolbar.Actionbar = ...
>
> (not my code but I've seen it a lot)
> IMHO, this is language getting in a way and people writing boilerplate
> to avoid "service" that is not actually needed.
>
>> much work. This means its developers often don't improve much either, which
>
> I don't think PHP should be a language that "builds character" by
> forcing people to do more work than it's necessary for them, in order
> for them to "improve". I think it should be as easy as possible, and if
> somebody wants to learn how the bits move, one can always pick up a good
> book or go to a Coursera course, etc.
>
> --
> Stas Malyshev
> smalyshev@gmail.com
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php