hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Broken empty() and isset()

Open nowak-ninja opened this issue 13 years ago • 3 comments

$string = 'abc';

var_dump(isset($string['test'])); // true var_dump(!empty($string['test'])); //true

var_dump($string['test']); // a

nowak-ninja avatar Jul 08 '13 11:07 nowak-ninja

HipHop's behavior is consistent with Zend 5.3 but the behavior has changed in 5.4:

seanc@[redacted]:~$ hhvm test.php bool(true) bool(true) string(1) "a"

seanc@[redacted]:~$ zend53 test.php bool(true) bool(true) string(1) "a"

seanc@[redacted]:~$ zend54 test.php bool(false) bool(false)

Warning: Illegal string offset 'test' in /home/seanc/test.php on line 8 string(1) "a"

Feel free to submit a patch if you're interested in getting this fixed sooner.

scannell avatar Jul 08 '13 12:07 scannell

As an update, @paroski is working on this.

scannell avatar Jul 31 '13 16:07 scannell

HHVM matches PHP5.5 and PHP5.6 for the sample code, aside from not raising a warning (which we plan to add some time in the coming months). Closing this issue out since we're compatible, if you see any other issues with isset() and empty() feel free to open a new github issue.

paroski avatar May 30 '14 00:05 paroski