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/08/28 19:40] – 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 | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | While newly introduced error conditions in the engine typically use '' | + | While newly introduced error conditions in the engine typically use '' |
===== Proposal ===== | ===== Proposal ===== | ||
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 76: | Line 73: | ||
| Cannot assign an empty string to a string offset | Warning | Error exception | | | Cannot assign an empty string to a string offset | Warning | Error exception | | ||
| **Rationale: | | **Rationale: | ||
- | | Only variables should be passed by reference | Notice | ??? | | + | | Only variables should be passed by reference | Notice | (Notice) |
- | | Only variable references should be returned by reference | Notice | ??? | | + | | Only variable references should be returned by reference | Notice | (Notice) |
- | | Only variable references should be yielded by reference | Notice | ??? | | + | | Only variable references should be yielded by reference | Notice | (Notice) |
- | | Only variables should be assigned by reference | Notice | ??? | | + | | Only variables should be assigned by reference | Notice | (Notice) |
- | | Attempting to set reference to non referenceable value | Notice | ??? | | + | | Attempting to set reference to non referenceable value | Notice | (Notice) |
- | | Cannot pass by-reference argument %d of %s%s%s() by unpacking a Traversable, | + | | Cannot pass by-reference argument %d of %s%s%s() by unpacking a Traversable, |
- | | **Rationale: | + | | **Rationale: |
==== Undefined variable ==== | ==== Undefined variable ==== | ||
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 106: | Line 113: | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | Conversion of noticed | + | Conversion of notices |
This may impact code that makes very liberal use of the error suppression operator '' | This may impact code that makes very liberal use of the error suppression operator '' | ||
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-08-28: Split off the " | * 2019-08-28: Split off the " |
rfc/engine_warnings.1567021201.txt.gz · Last modified: 2019/08/28 19:40 by nikic