MFB Enforce protocol of magic methods/classes

This commit is contained in:
Marcus Boerger 2004-08-02 08:29:59 +00:00
parent 5f0433db83
commit 1e6c12c919
6 changed files with 119 additions and 0 deletions

15
tests/classes/__call_002.phpt Executable file
View File

@ -0,0 +1,15 @@
--TEST--
ZE2 __call() signature check
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php
class Test {
function __call() {
}
}
?>
--EXPECTF--
Fatal error: Method Test::__call() must take exactly 2 arguments in %s__call_002.php on line %d

View File

@ -0,0 +1,14 @@
--TEST--
ZE2 __get() signature check
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php
class Test {
function __get($x,$y) {
}
}
?>
--EXPECTF--
Fatal error: Method Test::__get() must take exactly 1 argument in %s__set__get_002.php on line %d

View File

@ -0,0 +1,14 @@
--TEST--
ZE2 __set() signature check
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php
class Test {
function __set() {
}
}
?>
--EXPECTF--
Fatal error: Method Test::__set() must take exactly 2 arguments in %s__set__get_003.php on line %d

View File

@ -0,0 +1,24 @@
--TEST--
ZE2 Ensuring destructor visibility
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php
class Base {
private function __destruct() {
echo __METHOD__ . "\n";
}
}
class Derived extends Base {
}
$obj = new Derived;
unset($obj);
?>
===DONE===
--EXPECTF--
Fatal error: Call to private Derived::__destruct() from context '' in %sdestructor_visibility_001.php on line %d

View File

@ -0,0 +1,24 @@
--TEST--
ZE2 Ensuring destructor visibility
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php
class Base {
private function __destruct() {
echo __METHOD__ . "\n";
}
}
class Derived extends Base {
}
$obj = new Derived;
?>
===DONE===
--EXPECTF--
===DONE===
Warning: Call to private Derived::__destruct() from context '' during shutdown ignored in Unknown on line %d

View File

@ -0,0 +1,28 @@
--TEST--
ZE2 Ensuring destructor visibility
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php
class Base {
private function __destruct() {
echo __METHOD__ . "\n";
}
}
class Derived extends Base {
public function __destruct() {
echo __METHOD__ . "\n";
}
}
$obj = new Derived;
unset($obj); // Derived::__destruct is being called not Base::__destruct
?>
===DONE===
--EXPECTF--
Derived::__destruct
===DONE===