Take the State of PHP 2026 Survey →

Make compact function reports undefined passed variables View as Markdown

Implemented (PHP 7.3)
Authors
Gabriel Caruso (carusogabriel34@gmail.com)
Date
2018-05-24
Version
1.0
Source
wiki.php.net/rfc/compact

Vote

Make compact function reports undefined passed variables closed
Yes
32
No
5
37 voters
ab Yes 2018-06-08 07:57
ashnazg Yes 2018-06-06 14:15
bwoebi No 2018-06-06 13:59
cmb Yes 2018-06-06 15:04
colinodell Yes 2018-06-09 13:07
danack Yes 2018-06-09 10:13
daverandom Yes 2018-06-06 13:43
emir Yes 2018-06-07 16:24
galvao Yes 2018-06-08 00:51
guilhermeblanco Yes 2018-06-15 20:35
heiglandreas Yes 2018-06-18 15:16
hywan Yes 2018-06-06 14:11
jhdxr Yes 2018-06-08 15:38
jwage Yes 2018-06-06 14:07
kalle Yes 2018-06-13 11:40
kguest Yes 2018-06-06 20:13
kinncj No 2018-06-06 22:11
lcobucci Yes 2018-06-07 06:47
levim Yes 2018-06-18 16:32
lex Yes 2018-06-14 15:48
marcio Yes 2018-06-06 13:15
mariano Yes 2018-06-06 13:57
narf Yes 2018-06-10 02:05
nikic Yes 2018-06-06 13:36
ocramius Yes 2018-06-06 14:21
peehaa No 2018-06-06 13:18
pmmaga Yes 2018-06-09 17:32
pollita Yes 2018-06-06 16:54
ralphschindler Yes 2018-06-06 18:25
ramsey Yes 2018-06-07 04:37
salathe No 2018-06-18 18:31
sammyk Yes 2018-06-06 13:40
stas No 2018-06-10 19:43
svpernova09 Yes 2018-06-11 12:42
trowski Yes 2018-06-08 15:51
yunosh Yes 2018-06-07 08:19
zeev Yes 2018-06-06 14:25

Discussions on the mailing list

[RFC] Make compact function reports undefined passed variables
by Gabriel Caruso · 4 messages
[VOTE] Make compact function reports undefined passed variables
by Gabriel Caruso · 12 messages

RFC text

Copied from wiki.php.net, last synchronized Oct 13, 2026 11:51 UTC

Introduction

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.

Proposal

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.

RFC Impact

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.

Vote: Make compact function reports undefined passed variables — Yes: 32 · No: 5 (closed)

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.

References

https://externals.io/message/102012