com php-src: add test for bug: Zend/tests/bug71359.phpt

From: Date: Sat, 26 Mar 2016 11:15:08 +0000
Subject: com php-src: add test for bug: Zend/tests/bug71359.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-91488@lists.php.net to get a copy of this message
Commit: 1a75cd29a200989aeed04f695df5b2b563cfd54e Author: Joe Watkins <krakjoe@php.net> Sat, 26 Mar 2016 11:08:19 +0000 Parents: 373da7aa6f5e7bf57d434fd449f97770fb479d3e Branches: PHP-7.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1a75cd29a200989aeed04f695df5b2b563cfd54e Log: add test for bug Changed paths: A Zend/tests/bug71359.phpt Diff: diff --git a/Zend/tests/bug71359.phpt b/Zend/tests/bug71359.phpt new file mode 100644 index 0000000..b239549 --- /dev/null +++ b/Zend/tests/bug71359.phpt @@ -0,0 +1,61 @@ +--TEST-- +Bug #71359: Null coalescing operator and magic +--FILE-- +<?php +class AA { + private $data = []; + public function __isset($name) { + echo "__isset($name)\n"; + return array_key_exists($name, $this->data); + } + public function &__get($name) { + echo "__get($name)\n"; + if (!array_key_exists($name, $this->data)) { + throw new Exception('Unknown offset'); + } + return $this->data[$name]; + } + public function __set($name, $value) { + echo "__set($name)\n"; + $this->data[$name] = $value; + } + public function __unset($name) { + echo "__unset($name)\n"; + unset($this->data[$name]); + } +} + +$aa = new AA; +var_dump(isset($aa->zero->one->two)); +var_dump(isset($aa->zero->foo)); +var_dump($aa->zero ?? 42); +var_dump($aa->zero->one->two ?? 42); +$aa->zero = new AA; +$aa->zero->one = new AA; +var_dump(isset($aa->zero->one->two)); +var_dump($aa->zero->one->two ?? 42); +?> +--EXPECT-- +__isset(zero) +bool(false) +__isset(zero) +bool(false) +__isset(zero) +int(42) +__isset(zero) +int(42) +__set(zero) +__get(zero) +__set(one) +__isset(zero) +__get(zero) +__isset(one) +__get(one) +__isset(two) +bool(false) +__isset(zero) +__get(zero) +__isset(one) +__get(one) +__isset(two) +int(42)

« previous php.cvs (#91488) next »