# RFC: Make compact function reports undefined passed variables

- Status: Implemented (PHP 7.3)
- Authors: Gabriel Caruso (carusogabriel34@gmail.com)
- Date: 2018-05-24
- Version: 1.0
- Original: https://wiki.php.net/rfc/compact
- Page: https://externals.io/rfc/compact
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

## Votes

### Make compact function reports undefined passed variables (closed)

Yes: 32 · No: 5

Voters: ab (Yes), ashnazg (Yes), bwoebi (No), cmb (Yes), colinodell (Yes), danack (Yes), daverandom (Yes), emir (Yes), galvao (Yes), guilhermeblanco (Yes), heiglandreas (Yes), hywan (Yes), jhdxr (Yes), jwage (Yes), kalle (Yes), kguest (Yes), kinncj (No), lcobucci (Yes), levim (Yes), lex (Yes), marcio (Yes), mariano (Yes), narf (Yes), nikic (Yes), ocramius (Yes), peehaa (No), pmmaga (Yes), pollita (Yes), ralphschindler (Yes), ramsey (Yes), salathe (No), sammyk (Yes), stas (No), svpernova09 (Yes), trowski (Yes), yunosh (Yes), zeev (Yes)

## Discussions on the mailing list

- [\[RFC\]\[Discussion\] Make compact function reports undefined passed variables](https://externals.io/message/102012.md) — started on 2018-04-02, 7 messages
- [\[RFC\] Make compact function reports undefined passed variables](https://externals.io/message/102126.md) — started on 2018-05-25, 4 messages
- [\[VOTE\] Make compact function reports undefined passed variables](https://externals.io/message/102192.md) — started on 2018-06-06, 12 messages

---

## 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.

```php
$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](https://github.com/php/php-src/pull/3240).

## References

<https://externals.io/message/102012>
