Skip to content

Adding bug 63462 test #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions tests/classes/bug63462.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
--TEST--
Test script to verify that magic methods should be called only once when accessing an unset property.
--CREDITS--
Marco Pivetta <ocramius@gmail.com>
--XFAIL--
Bug 63462 is not yet fixed
--FILE--
<?php
class Test {
public $publicProperty;
protected $protectedProperty;
private $privateProperty;

public function __construct() {
unset(
$this->publicProperty,
$this->protectedProperty,
$this->privateProperty
);
}

function __get($name) {
echo '__get ' . $name . "\n";
return $this->$name;
}

function __set($name, $value) {
echo '__set ' . $name . "\n";
$this->$name = $value;
}

function __isset($name) {
echo '__isset ' . $name . "\n";
return isset($this->$name);
}
}

$test = new Test();

$test->nonExisting;
$test->publicProperty;
$test->protectedProperty;
$test->privateProperty;
isset($test->nonExisting);
isset($test->publicProperty);
isset($test->protectedProperty);
isset($test->privateProperty);
$test->nonExisting = 'value';
$test->publicProperty = 'value';
$test->protectedProperty = 'value';
$test->privateProperty = 'value';

?>

--EXPECTF--
__get nonExisting
Notice: Undefined index: nonExisting in %__set__get_006.php on line %d
__get publicProperty
Notice: Undefined index: publicProperty in %__set__get_006.php on line %d
__get protectedProperty
Notice: Undefined index: protectedProperty in %__set__get_006.php on line %d
__get privateProperty
Notice: Undefined index: privateProperty in %__set__get_006.php on line %d
__isset nonExisting
__isset publicProperty
__isset protectedProperty
__isset privateProperty
__set nonExisting
__set publicProperty
__set protectedProperty
__set privateProperty