Re: [RFC] Reclassifying engine warnings

From: Date: Thu, 12 Sep 2019 23:29:29 +0000
Subject: Re: [RFC] Reclassifying engine warnings
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-107034@lists.php.net to get a copy of this message
l want to point out that way in which notices and warnings are triggered when concerning operators, is also inconsistent. Sometimes a check is done by the function of the operator (or a deeper function). Other times the operator will simply cast the operand and the casting produces a notice, warning or error. As an example; The concatenation operator will implicitly cast anything to a string. Explicitly casting it has no effect [ ] . 'abc'; // Notice: Array to string conversion (string)[ ] . 'abc'; // Notice: Array to string conversion But arithmetic operators will do a check. Explicitly casting will remove any warning or error [ ] * 10; // Fatal error: Unsupported operand types (int)[ ] * 10; // 0 "22 bikes" * 10; // Notice: A non well formed numeric value encountered (int)"22 bikes" * 10; // 220 To some extent, the inconsistent error levels come from a different approach. Even more, there is a big difference between types that can are cast silently to a non-sensical value and types where any type of warning or error is given, for seemingly no apparent reason. Changing the warning levels without addressing this issue doesn't make a whole lot of sense. - Arnold In the past I suggested operators like ??++ ??+= for this purpose. But the [? $key] is even better, because it makes it explicit which array keys we expect to already exist and which we don't. $var[$k0][? $k1][? $k2]++; This is great but the second "?" is redundant isn't it? Tekst uit oorspronkelijke berichten weergeven

« previous php.internals (#107034) next »