mirror of
https://github.com/php/php-src.git
synced 2024-11-25 02:44:58 +08:00
MFB Enforce protocol of magic methods/classes
This commit is contained in:
parent
5f0433db83
commit
1e6c12c919
15
tests/classes/__call_002.phpt
Executable file
15
tests/classes/__call_002.phpt
Executable 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
|
14
tests/classes/__set__get_002.phpt
Executable file
14
tests/classes/__set__get_002.phpt
Executable 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
|
14
tests/classes/__set__get_003.phpt
Executable file
14
tests/classes/__set__get_003.phpt
Executable 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
|
24
tests/classes/destructor_visibility_001.phpt
Executable file
24
tests/classes/destructor_visibility_001.phpt
Executable 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
|
24
tests/classes/destructor_visibility_002.phpt
Executable file
24
tests/classes/destructor_visibility_002.phpt
Executable 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
|
28
tests/classes/destructor_visibility_003.phpt
Executable file
28
tests/classes/destructor_visibility_003.phpt
Executable 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===
|
Loading…
Reference in New Issue
Block a user