Table of Contents

PHP RFC: Make compact function reports undefined passed variables

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.

Make compact function reports undefined passed variables
Real name Yes No
ab (ab)  
ashnazg (ashnazg)  
bwoebi (bwoebi)  
cmb (cmb)  
colinodell (colinodell)  
danack (danack)  
daverandom (daverandom)  
emir (emir)  
galvao (galvao)  
guilhermeblanco (guilhermeblanco)  
heiglandreas (heiglandreas)  
hywan (hywan)  
jhdxr (jhdxr)  
jwage (jwage)  
kalle (kalle)  
kguest (kguest)  
kinncj (kinncj)  
lcobucci (lcobucci)  
levim (levim)  
lex (lex)  
marcio (marcio)  
mariano (mariano)  
narf (narf)  
nikic (nikic)  
ocramius (ocramius)  
peehaa (peehaa)  
pmmaga (pmmaga)  
pollita (pollita)  
ralphschindler (ralphschindler)  
ramsey (ramsey)  
salathe (salathe)  
sammyk (sammyk)  
stas (stas)  
svpernova09 (svpernova09)  
trowski (trowski)  
yunosh (yunosh)  
zeev (zeev)  
Final result: 32 5
This poll has been 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