rfc:engine_warnings
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:engine_warnings [2019/09/10 13:27] – nikic | rfc:engine_warnings [2020/08/03 12:41] (current) – nikic | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Date: 2019-08-27 | * Date: 2019-08-27 | ||
* Author: Nikita Popov < | * Author: Nikita Popov < | ||
- | * Status: | + | * Status: |
* 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 " | + | The " |
^ 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: | | **Rationale: | ||
- | | Undefined offset: %d | Notice | Warning | | ||
- | | Undefined index: %s | Notice | Warning | | ||
- | | **Rationale: | ||
| 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: | | **Rationale: | ||
Line 90: | Line 87: | ||
Ideally, undefined variables should be compile errors, but as the dynamic nature of PHP precludes a reliable compile-time analysis, this RFC proposes to generate an Error exception instead. | Ideally, undefined variables should be compile errors, but as the dynamic nature of PHP precludes a reliable compile-time analysis, this RFC proposes to generate an Error exception instead. | ||
- | However, throwing an exception may complicate the upgrading of legacy code that currently suppresses the generation of notices wholesale, as the issue can no longer be ignored. For this reason, a separate vote will decide whether we should throw an Error exception, generate a warning or keep the current notice. | + | However, throwing an exception may complicate the upgrading of legacy code that currently suppresses the generation of notices wholesale, as the issue can no longer be ignored. |
+ | |||
+ | 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/ | ||
==== Division by zero ==== | ==== Division by zero ==== | ||
Line 114: | 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 | + | All the following |
+ | |||
+ | As the " | ||
- | * Accept error condition reclassification shown in table? Yes/No. Requires 2/3 majority. | + | <doodle title=" |
- | * Change undefined variable severity to? Error exception | + | |
- | * Throw DivisionByZeroError for division by zero? Yes/No. Requires 2/3 majority. | + | |
+ | | ||
+ | </ | ||
+ | . | ||
+ | <doodle title="Change undefined array index severity to?" | ||
+ | * Warning | ||
+ | | ||
+ | </ | ||
+ | . | ||
+ | <doodle title=" | ||
+ | * DivisionByZeroError exception | ||
+ | * Keep Warning | ||
+ | </doodle> | ||
+ | . | ||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </doodle> | ||
===== Changelog ===== | ===== Changelog ===== | ||
+ | * 2019-09-12: Split out undefined index/ | ||
* 2019-09-10: Keep current classification for reference errors. | * 2019-09-10: Keep current classification for reference errors. | ||
* 2019-08-28: Split off the " | * 2019-08-28: Split off the " |
rfc/engine_warnings.txt · Last modified: 2020/08/03 12:41 by nikic