rfc:undefined_variable_error_promotion
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:undefined_variable_error_promotion [2022/02/22 11:10] – marandall | rfc:undefined_variable_error_promotion [2022/03/28 17:52] (current) – marandall | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2022-02-17 | * Date: 2022-02-17 | ||
* Author: Mark Randall marandall@php.net | * Author: Mark Randall marandall@php.net | ||
- | * Status: | + | * Status: |
* Target: PHP 9.0 | * Target: PHP 9.0 | ||
* First Published at: https:// | * First Published at: https:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Undefined variables are those that have not yet been initialised with a value prior to being read. Accessing | + | Undefined variables are those that have not yet been initialised with a value prior to being read. Accessing an undefined variable currently emits an E_WARNING " |
- | Although a custom error handler can already be used to raise an Error exception, this requires additional userland code to configure, when instead we should be aiming to provide a safer experience by default. The need to support calling a custom error handler does itself also introduce additional complexity into the engine, leading | + | Although a custom error handler can already be used to raise an Error exception, this requires additional userland code to configure, when instead we should be aiming to provide a safer experience by default. The need to support calling a custom error handler does itself also introduce additional complexity into the engine, leading |
+ | |||
+ | **RFC History / Previous Votes** | ||
+ | |||
+ | This change was last discussed during the Engine Warnings RFC (https:// | ||
===== Proposal ===== | ===== Proposal ===== | ||
This RFC proposes that accessing an undefined variable is rendered illegal behaviour in the next major version of PHP, and will result in an Error exception being thrown if it occurs. | This RFC proposes that accessing an undefined variable is rendered illegal behaviour in the next major version of PHP, and will result in an Error exception being thrown if it occurs. | ||
+ | |||
+ | For the purposes of this RFC, accessing a variable means to use the variable in such a way that the engine attempts to read its value for use in an expression, without accounting for possibly being unset. These can be identified by the warning " | ||
+ | |||
+ | isset / empty / null coalesce DO account for undefined values and such are not covered by this RFC. | ||
Undefined variable access can come about in one of 3 main ways: | Undefined variable access can come about in one of 3 main ways: | ||
Line 118: | Line 126: | ||
Although the target version is mandated by our traditional breaking changes policy, it is also the intent of this RFC to give multiple years of notice that this change will be coming, affording the greatest opportunity for developers to modify their code in anticipation of this change. | Although the target version is mandated by our traditional breaking changes policy, it is also the intent of this RFC to give multiple years of notice that this change will be coming, affording the greatest opportunity for developers to modify their code in anticipation of this change. | ||
- | A minor change | + | A minor change |
+ | |||
+ | |||
+ | ===== Unaffected Functionality ===== | ||
+ | If the code does not currently emit a " | ||
+ | |||
+ | ===== Vote ===== | ||
+ | Vote opened 2022-03-14, vote closes 2022-03-28 | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | Meta vote for reasoning of voting against: | ||
- | ===== Proposed Voting Choices ===== | + | <doodle title="Main reason for voting against if you did?" auth=" |
- | Yes / No to promote to Error. | + | * Using undefined variables is a legitimate coding style |
+ | * Backwards compatibility breaks | ||
+ | * Would be in favour, but not in 9.0 | ||
+ | * Something else | ||
+ | </doodle> | ||
===== References ===== | ===== References ===== |
rfc/undefined_variable_error_promotion.1645528259.txt.gz · Last modified: 2022/02/22 11:10 by marandall