PHP RFC: Make compact function reports undefined passed variables
- Version: 1.0
- Date: 2018-05-24
- Author: Gabriel Caruso (firstname.lastname@example.org)
- Status: Implemented (PHP 7.3)
- First Published at: https://wiki.php.net/rfc/compact
Recently, during a Coding Standards discussion, someone came up with the idea of forbidden the compact() function. One of the arguments was that this function does not report undefined variables passed to it. After checking its implementation and documentation, nothing was founded justifying the reason of why this has been this way since ever.
This RFC proposes the addition of a notice in the compact() function when a not defined variable had been passed to it.
$foo = 'bar'; $baz = compact('foz'); // Notice: compact(): Undefined variable: foz
Backward Incompatible Changes
Undefined variables passed to compact() will now be reported as a notice.
Proposed PHP Version
The next PHP 7.x, current version 7.3.
This RFC has only impact in the compact() function.
Proposed Voting Choices
Since this RFC contains a Backward Incompatible Change, 2/3 majority is required.
Voting starts on 2018-06-06 and ends on 2018-06-18 23:00 UTC.
Proposal and Patch
The patch (including tests) for this proposal is available in GitHub Pull Request #3240.