Annotation of embedaddon/php/Zend/tests/bug63462.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test script to verify that magic methods should be called only once when accessing an unset property.
! 3: --CREDITS--
! 4: Marco Pivetta <ocramius@gmail.com>
! 5: --FILE--
! 6: <?php
! 7: class Test {
! 8: public $publicProperty;
! 9: protected $protectedProperty;
! 10: private $privateProperty;
! 11:
! 12: public function __construct() {
! 13: unset(
! 14: $this->publicProperty,
! 15: $this->protectedProperty,
! 16: $this->privateProperty
! 17: );
! 18: }
! 19:
! 20: function __get($name) {
! 21: echo '__get ' . $name . "\n";
! 22: return $this->$name;
! 23: }
! 24:
! 25: function __set($name, $value) {
! 26: echo '__set ' . $name . "\n";
! 27: $this->$name = $value;
! 28: }
! 29:
! 30: function __isset($name) {
! 31: echo '__isset ' . $name . "\n";
! 32: return isset($this->$name);
! 33: }
! 34: }
! 35:
! 36: $test = new Test();
! 37:
! 38: $test->nonExisting;
! 39: $test->publicProperty;
! 40: $test->protectedProperty;
! 41: $test->privateProperty;
! 42: isset($test->nonExisting);
! 43: isset($test->publicProperty);
! 44: isset($test->protectedProperty);
! 45: isset($test->privateProperty);
! 46: $test->nonExisting = 'value';
! 47: $test->publicProperty = 'value';
! 48: $test->protectedProperty = 'value';
! 49: $test->privateProperty = 'value';
! 50:
! 51: ?>
! 52:
! 53: --EXPECTF--
! 54: __get nonExisting
! 55:
! 56: Notice: Undefined property: Test::$nonExisting in %s on line %d
! 57: __get publicProperty
! 58:
! 59: Notice: Undefined property: Test::$publicProperty in %s on line %d
! 60: __get protectedProperty
! 61:
! 62: Notice: Undefined property: Test::$protectedProperty in %s on line %d
! 63: __get privateProperty
! 64:
! 65: Notice: Undefined property: Test::$privateProperty in %s on line %d
! 66: __isset nonExisting
! 67: __isset publicProperty
! 68: __isset protectedProperty
! 69: __isset privateProperty
! 70: __set nonExisting
! 71: __set publicProperty
! 72: __set protectedProperty
! 73: __set privateProperty
! 74:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>