rfc:engine_warnings

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:engine_warnings [2019/09/10 13:37] nikicrfc:engine_warnings [2020/08/03 12:41] (current) nikic
Line 2: Line 2:
   * Date: 2019-08-27   * Date: 2019-08-27
   * Author: Nikita Popov <nikic@php.net>   * Author: Nikita Popov <nikic@php.net>
-  * Status: Under Discussion+  * Status: Implemented
   * Target Version: PHP 8.0   * Target Version: PHP 8.0
  
Line 27: Line 27:
 The table shows both the current error level, as well as the proposed level. A rationale for the proposed change (or non-change) is provided below each group of errors. The table shows both the current error level, as well as the proposed level. A rationale for the proposed change (or non-change) is provided below each group of errors.
  
-The "undefined variable" and "division by zero" error conditions are discussed separately below, because they are more controversial.+The "undefined variable", "undefined array index" and "division by zero" error conditions are discussed separately below, because they are more controversial.
  
 ^ Message ^ Current Level ^ Proposed Level ^ ^ Message ^ Current Level ^ Proposed Level ^
Line 63: Line 63:
 | Array to string conversion | Notice | Warning | | Array to string conversion | Notice | Warning |
 | **Rationale:** This is generally a bug (and the "Array" string you get is meaningless), but in many cases also not a particularly severe one. Since [[rfc:tostring_exceptions|string conversion exceptions]] are supported now, we could also promote this to an Error exception, and I'm generally open to that. ||| | **Rationale:** This is generally a bug (and the "Array" string you get is meaningless), but in many cases also not a particularly severe one. Since [[rfc:tostring_exceptions|string conversion exceptions]] are supported now, we could also promote this to an Error exception, and I'm generally open to that. |||
-| Undefined offset: %d | Notice | Warning | 
-| Undefined index: %s | Notice | Warning | 
-| **Rationale:** In modern code this would be considered a bug, but I'm sure there is lots of legacy code that prefers to ignore undefined index diagnostics rather than using explicit isset checks. As such, this is promoted to a warning, but should probably not become an exception. This is symmetric with the undefined property case. ||| 
 | Resource ID#%d used as offset, casting to integer (%d) | Notice | Warning | | Resource ID#%d used as offset, casting to integer (%d) | Notice | Warning |
 | **Rationale:** This is in principle a meaningful operation, but exotic enough that intent should be indicated with an explicit integer cast. ||| | **Rationale:** This is in principle a meaningful operation, but exotic enough that intent should be indicated with an explicit integer cast. |||
Line 93: Line 90:
  
 For this reason, a separate vote will decide whether we should throw an Error exception, generate a warning or keep the current notice. For this reason, a separate vote will decide whether we should throw an Error exception, generate a warning or keep the current notice.
 +
 +==== Undefined array index ====
 +
 +Similarly to undefined variables or an undefined object properties, reading an undefined array index/key would generally be considered a programming error in modern PHP code. However, while variables and object properties are predominantly statically known (i.e., when variable variables and dynamic object properties are not used), the same is not true to array keys, which tend to be dynamic.
 +
 +Some languages, such as JavaScript, do not consider accesses to undefined array keys to be an error condition at all, and allow such an operation to be performed silently. While it is not predominant in the PHP world, some people subscribe to such a coding style also for PHP code, and as such would prefer undefined array key access to remain an easily suppressible notice. 
 +
 +A separate vote will decide whether to elevate undefined array offset/index conditions to a warning, or leave them as notices.
  
 ==== Division by zero ==== ==== Division by zero ====
Line 116: Line 121:
 ===== Vote ===== ===== Vote =====
  
-The bulk of the RFC will be held as a single vote, while the more controversial cases use a separate vote. All the votes are completely independent and as such each requires a 2/3 majority.+All the following votes are **independent**. Each requires a 2/3 majority and may pass/fail independent of other votes. Voting closes 2019-09-26. 
 + 
 +As the "undefined variable" vote is a 3-way vote, acceptance is determined as follows: "Error exception" is accepted if it has 2/3 majority. Otherwise, "Warning" is accepted if the first two options together have 2/3 majority. Otherwise, "Keep Notice" applies.
  
-  * Accept error condition reclassification shown in table? Yes/No. Requires 2/3 majority. +<doodle title="Change undefined variable severity to?" auth="nikic" voteType="single" closed="true"> 
-  * Change undefined variable severity to? Error exception Warning Keep Notice. "Error exceptionis accepted if it has 2/3 majority. Otherwise, "Warningis accepted if the first two options together have 2/3 majority. Otherwise, "Keep Notice" applies+   Error exception 
-  * Throw DivisionByZeroError for division by zero? Yes/NoRequires 2/3 majority.+   Warning 
 +   Keep Notice 
 +</doodle> 
 +. 
 +<doodle title="Change undefined array index severity to?auth="nikicvoteType="single" closed="true"> 
 +   * Warning 
 +   Keep Notice 
 +</doodle> 
 +
 +<doodle title="Change division by zero severity to?" auth="nikic" voteType="single" closed="true"> 
 +   * DivisionByZeroError exception 
 +   * Keep Warning 
 +</doodle> 
 +. 
 +<doodle title="Accept remaining classifications shown in the table above?" auth="nikic" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
 ===== Changelog ===== ===== Changelog =====
  
 +  * 2019-09-12: Split out undefined index/offset into a separate section.
   * 2019-09-10: Keep current classification for reference errors.   * 2019-09-10: Keep current classification for reference errors.
   * 2019-08-28: Split off the "undefined variable" case into a separate vote, as it was a major point of contention on-list.   * 2019-08-28: Split off the "undefined variable" case into a separate vote, as it was a major point of contention on-list.
rfc/engine_warnings.1568122642.txt.gz · Last modified: 2019/09/10 13:37 by nikic