diff options
Diffstat (limited to 'Zend/tests')
94 files changed, 2680 insertions, 181 deletions
diff --git a/Zend/tests/001.phpt b/Zend/tests/001.phpt new file mode 100644 index 000000000..78d982a7a --- /dev/null +++ b/Zend/tests/001.phpt @@ -0,0 +1,54 @@ +--TEST-- +func_num_args() tests +--FILE-- +<?php + +function test1() { + var_dump(func_num_args()); +} + +function test2($a) { + var_dump(func_num_args()); +} + +function test3($a, $b) { + var_dump(func_num_args()); +} + +test1(); +test2(1); +test2(); +test3(1,2); + +call_user_func("test1"); +call_user_func("test3", 1); +call_user_func("test3", 1, 2); + +class test { + static function test1($a) { + var_dump(func_num_args()); + } +} + +test::test1(1); +var_dump(func_num_args()); + +echo "Done\n"; +?> +--EXPECTF-- +int(0) +int(1) + +Warning: Missing argument 1 for test2(), called in %s on line %d +int(0) +int(2) +int(0) + +Warning: Missing argument 2 for test3() in %s on line %d +int(1) +int(2) +int(1) + +Warning: func_num_args(): Called from the global scope - no function context in %s on line %d +int(-1) +Done diff --git a/Zend/tests/002.phpt b/Zend/tests/002.phpt new file mode 100644 index 000000000..73c8d3ec4 --- /dev/null +++ b/Zend/tests/002.phpt @@ -0,0 +1,108 @@ +--TEST-- +func_get_arg() tests +--FILE-- +<?php + +function test1() { + var_dump(func_get_arg(-10)); + var_dump(func_get_arg(0)); + var_dump(func_get_arg(1)); +} + +function test2($a) { + var_dump(func_get_arg(0)); + var_dump(func_get_arg(1)); +} + +function test3($a, $b) { + var_dump(func_get_arg(0)); + var_dump(func_get_arg(1)); + var_dump(func_get_arg(2)); +} + +test1(); +test1(10); +test2(1); +test2(); +test3(1,2); + +call_user_func("test1"); +call_user_func("test3", 1); +call_user_func("test3", 1, 2); + +class test { + static function test1($a) { + var_dump(func_get_arg(0)); + var_dump(func_get_arg(1)); + } +} + +test::test1(1); +var_dump(func_get_arg(1)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d +bool(false) + +Warning: func_get_arg(): Argument 0 not passed to function in %s on line %d +bool(false) + +Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d +bool(false) + +Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d +bool(false) +int(10) + +Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d +bool(false) +int(1) + +Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d +bool(false) + +Warning: Missing argument 1 for test2(), called in %s on line %d and defined in %s on line %d + +Warning: func_get_arg(): Argument 0 not passed to function in %s on line %d +bool(false) + +Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d +bool(false) +int(1) +int(2) + +Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d +bool(false) + +Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d +bool(false) + +Warning: func_get_arg(): Argument 0 not passed to function in %s on line %d +bool(false) + +Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d +bool(false) + +Warning: Missing argument 2 for test3() in %s on line %d +int(1) + +Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d +bool(false) + +Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d +bool(false) +int(1) +int(2) + +Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d +bool(false) +int(1) + +Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d +bool(false) + +Warning: func_get_arg(): Called from the global scope - no function context in %s on line %d +bool(false) +Done diff --git a/Zend/tests/003.phpt b/Zend/tests/003.phpt new file mode 100644 index 000000000..81f70b8d8 --- /dev/null +++ b/Zend/tests/003.phpt @@ -0,0 +1,81 @@ +--TEST-- +func_get_args() tests +--FILE-- +<?php + +function test1() { + var_dump(func_get_args()); +} + +function test2($a) { + var_dump(func_get_args()); +} + +function test3($a, $b) { + var_dump(func_get_args()); +} + +test1(); +test1(10); +test2(1); +test2(); +test3(1,2); + +call_user_func("test1"); +call_user_func("test3", 1); +call_user_func("test3", 1, 2); + +class test { + static function test1($a) { + var_dump(func_get_args()); + } +} + +test::test1(1); +var_dump(func_get_args()); + +echo "Done\n"; +?> +--EXPECTF-- +array(0) { +} +array(1) { + [0]=> + int(10) +} +array(1) { + [0]=> + int(1) +} + +Warning: Missing argument 1 for test2(), called in %s on line %d and defined in %s on line %d +array(0) { +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(0) { +} + +Warning: Missing argument 2 for test3() in %s on line %d +array(1) { + [0]=> + int(1) +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(1) { + [0]=> + int(1) +} + +Warning: func_get_args(): Called from the global scope - no function context in %s on line %d +bool(false) +Done diff --git a/Zend/tests/004.phpt b/Zend/tests/004.phpt new file mode 100644 index 000000000..ff7863346 --- /dev/null +++ b/Zend/tests/004.phpt @@ -0,0 +1,25 @@ +--TEST-- +strncmp() tests +--FILE-- +<?php + +var_dump(strncmp("", "")); +var_dump(strncmp("", "", 100)); +var_dump(strncmp("aef", "dfsgbdf", -1)); +var_dump(strncmp("fghjkl", "qwer", 0)); +var_dump(strncmp("qwerty", "qwerty123", 6)); +var_dump(strncmp("qwerty", "qwerty123", 7)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for strncmp() in %s on line %d +NULL +int(0) + +Warning: Length must be greater than or equal to 0 in %s on line %d +bool(false) +int(0) +int(0) +int(-1) +Done diff --git a/Zend/tests/005.phpt b/Zend/tests/005.phpt new file mode 100644 index 000000000..15a510bfe --- /dev/null +++ b/Zend/tests/005.phpt @@ -0,0 +1,27 @@ +--TEST-- +strcasecmp() tests +--FILE-- +<?php + +var_dump(strcasecmp("")); +var_dump(strcasecmp("", "")); +var_dump(strcasecmp("aef", "dfsgbdf")); +var_dump(strcasecmp("qwe", "qwer")); +var_dump(strcasecmp("qwerty", "QweRty")); +var_dump(strcasecmp("qwErtY", "qwerty")); +var_dump(strcasecmp("q123", "Q123")); +var_dump(strcasecmp("01", "01")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for strcasecmp() in %s on line %d +NULL +int(0) +int(-3) +int(-1) +int(0) +int(0) +int(0) +int(0) +Done diff --git a/Zend/tests/006.phpt b/Zend/tests/006.phpt new file mode 100644 index 000000000..c600baa01 --- /dev/null +++ b/Zend/tests/006.phpt @@ -0,0 +1,31 @@ +--TEST-- +strncasecmp() tests +--FILE-- +<?php + +var_dump(strncasecmp("")); +var_dump(strncasecmp("", "", -1)); +var_dump(strncasecmp("aef", "dfsgbdf", 0)); +var_dump(strncasecmp("aef", "dfsgbdf", 10)); +var_dump(strncasecmp("qwe", "qwer", 3)); +var_dump(strncasecmp("qwerty", "QweRty", 6)); +var_dump(strncasecmp("qwErtY", "qwer", 7)); +var_dump(strncasecmp("q123", "Q123", 3)); +var_dump(strncasecmp("01", "01", 1000)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for strncasecmp() in %s on line %d +NULL + +Warning: Length must be greater than or equal to 0 in %s on line %d +bool(false) +int(0) +int(-3) +int(0) +int(0) +int(2) +int(0) +int(0) +Done diff --git a/Zend/tests/007.phpt b/Zend/tests/007.phpt new file mode 100644 index 000000000..e04e0bf9e --- /dev/null +++ b/Zend/tests/007.phpt @@ -0,0 +1,63 @@ +--TEST-- +each() tests +--FILE-- +<?php + +var_dump(each()); +$var = 1; +var_dump(each($var)); +$var = "string"; +var_dump(each($var)); +$var = array(1,2,3); +var_dump(each($var)); +$var = array("a"=>1,"b"=>2,"c"=>3); +var_dump(each($var)); + +$a = array(1); +$a [] =&$a[0]; + +var_dump(each($a)); + + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for each() in %s on line %d +NULL + +Warning: Variable passed to each() is not an array or object in %s on line %d +NULL + +Warning: Variable passed to each() is not an array or object in %s on line %d +NULL +array(4) { + [1]=> + int(1) + ["value"]=> + int(1) + [0]=> + int(0) + ["key"]=> + int(0) +} +array(4) { + [1]=> + int(1) + ["value"]=> + int(1) + [0]=> + string(1) "a" + ["key"]=> + string(1) "a" +} +array(4) { + [1]=> + int(1) + ["value"]=> + int(1) + [0]=> + int(0) + ["key"]=> + int(0) +} +Done diff --git a/Zend/tests/008.phpt b/Zend/tests/008.phpt new file mode 100644 index 000000000..5b229a070 --- /dev/null +++ b/Zend/tests/008.phpt @@ -0,0 +1,53 @@ +--TEST-- +define() tests +--FILE-- +<?php + +var_dump(define()); +var_dump(define("TRUE")); +var_dump(define("TRUE", 1)); +var_dump(define("TRUE", 1, array(1))); + +var_dump(define(array(1,2,3,4,5), 1)); +var_dump(define(" ", 1)); +var_dump(define("[[[", 2)); +var_dump(define("test const", 3)); +var_dump(define("test const", 3)); +var_dump(define("test", array(1))); +var_dump(define("test1", new stdclass)); + +var_dump(constant(" ")); +var_dump(constant("[[[")); +var_dump(constant("test const")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for define() in %s on line %d +NULL + +Warning: Wrong parameter count for define() in %s on line %d +NULL +bool(true) + +Notice: Constant true already defined in %s on line %d +bool(false) + +Notice: Array to string conversion in %s on line %d +bool(true) +bool(true) +bool(true) +bool(true) + +Notice: Constant test const already defined in %s on line %d +bool(false) + +Warning: Constants may only evaluate to scalar values in %s on line %d +bool(false) + +Warning: Constants may only evaluate to scalar values in %s on line %d +bool(false) +int(1) +int(2) +int(3) +Done diff --git a/Zend/tests/009.phpt b/Zend/tests/009.phpt new file mode 100644 index 000000000..87eeb2755 --- /dev/null +++ b/Zend/tests/009.phpt @@ -0,0 +1,46 @@ +--TEST-- +get_class() tests +--FILE-- +<?php + +class foo { + function bar () { + var_dump(get_class()); + } +} + +class foo2 extends foo { +} + +foo::bar(); +foo2::bar(); + +$f1 = new foo; +$f2 = new foo2; + +$f1->bar(); +$f2->bar(); + +var_dump(get_class()); +var_dump(get_class("qwerty")); + +var_dump(get_class($f1)); +var_dump(get_class($f2)); + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Non-static method foo::bar() should not be called statically in %s on line %d +string(3) "foo" + +Strict Standards: Non-static method foo::bar() should not be called statically in %s on line %d +string(3) "foo" +string(3) "foo" +string(3) "foo" + +Warning: get_class() called without object from outside a class in %s on line %d +bool(false) +bool(false) +string(3) "foo" +string(4) "foo2" +Done diff --git a/Zend/tests/010.phpt b/Zend/tests/010.phpt new file mode 100644 index 000000000..45e183291 --- /dev/null +++ b/Zend/tests/010.phpt @@ -0,0 +1,59 @@ +--TEST-- +get_parent_class() tests +--FILE-- +<?php + +interface i { + function test(); +} + +class foo implements i { + function test() { + var_dump(get_parent_class()); + } +} + +class bar extends foo { + function test_bar() { + var_dump(get_parent_class()); + } +} + +$bar = new bar; +$foo = new foo; + +$foo->test(); +$bar->test(); +$bar->test_bar(); + +var_dump(get_parent_class($bar)); +var_dump(get_parent_class($foo)); +var_dump(get_parent_class("bar")); +var_dump(get_parent_class("foo")); +var_dump(get_parent_class("i")); + +var_dump(get_parent_class("")); +var_dump(get_parent_class("[[[[")); +var_dump(get_parent_class(" ")); +var_dump(get_parent_class(new stdclass)); +var_dump(get_parent_class(array())); +var_dump(get_parent_class(1)); + +echo "Done\n"; +?> +--EXPECTF-- +bool(false) +bool(false) +string(3) "foo" +string(3) "foo" +bool(false) +string(3) "foo" +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +Done diff --git a/Zend/tests/011.phpt b/Zend/tests/011.phpt new file mode 100644 index 000000000..58ed8d74d --- /dev/null +++ b/Zend/tests/011.phpt @@ -0,0 +1,89 @@ +--TEST-- +property_exists() tests +--FILE-- +<?php + +class foo { + public $pp1 = 1; + private $pp2 = 2; + protected $pp3 = 3; + + function bar() { + var_dump(property_exists("foo","pp1")); + var_dump(property_exists("foo","pp2")); + var_dump(property_exists("foo","pp3")); + } +} + +class bar extends foo { + function test() { + var_dump(property_exists("foo","pp1")); + var_dump(property_exists("foo","pp2")); + var_dump(property_exists("foo","pp3")); + } +} + +var_dump(property_exists()); +var_dump(property_exists("")); +var_dump(property_exists("foo","pp1")); +var_dump(property_exists("foo","pp2")); +var_dump(property_exists("foo","pp3")); +var_dump(property_exists("foo","nonexistent")); +var_dump(property_exists("fo","nonexistent")); +var_dump(property_exists("foo","")); +var_dump(property_exists("","test")); +var_dump(property_exists("","")); + +$foo = new foo; + +var_dump(property_exists($foo,"pp1")); +var_dump(property_exists($foo,"pp2")); +var_dump(property_exists($foo,"pp3")); +var_dump(property_exists($foo,"nonexistent")); +var_dump(property_exists($foo,"")); +var_dump(property_exists(array(),"test")); +var_dump(property_exists(1,"test")); +var_dump(property_exists(true,"test")); + +$foo->bar(); + +$bar = new bar; +$bar->test(); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for property_exists() in %s on line %d +NULL + +Warning: Wrong parameter count for property_exists() in %s on line %d +NULL +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: First parameter must either be an object or the name of an existing class in %s on line %d +NULL + +Warning: First parameter must either be an object or the name of an existing class in %s on line %d +NULL + +Warning: First parameter must either be an object or the name of an existing class in %s on line %d +NULL +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +Done diff --git a/Zend/tests/012.phpt b/Zend/tests/012.phpt new file mode 100644 index 000000000..b192bc1e0 --- /dev/null +++ b/Zend/tests/012.phpt @@ -0,0 +1,34 @@ +--TEST-- +class_exists() tests +--FILE-- +<?php + +class foo { +} + +var_dump(class_exists()); +var_dump(class_exists("qwerty")); +var_dump(class_exists("")); +var_dump(class_exists(array())); +var_dump(class_exists("test", false)); +var_dump(class_exists("foo", false)); +var_dump(class_exists("foo")); +var_dump(class_exists("stdClass", false)); +var_dump(class_exists("stdClass")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: class_exists() expects at least 1 parameter, 0 given in %s on line %d +NULL +bool(false) +bool(false) + +Warning: class_exists() expects parameter 1 to be string, array given in %s on line %d +NULL +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +Done diff --git a/Zend/tests/013.phpt b/Zend/tests/013.phpt new file mode 100644 index 000000000..1fc4af77a --- /dev/null +++ b/Zend/tests/013.phpt @@ -0,0 +1,34 @@ +--TEST-- +interface_exists() tests +--FILE-- +<?php + +interface foo { +} + +var_dump(interface_exists()); +var_dump(interface_exists("qwerty")); +var_dump(interface_exists("")); +var_dump(interface_exists(array())); +var_dump(interface_exists("test", false)); +var_dump(interface_exists("foo", false)); +var_dump(interface_exists("foo")); +var_dump(interface_exists("stdClass", false)); +var_dump(interface_exists("stdClass")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: interface_exists() expects at least 1 parameter, 0 given in %s on line %d +NULL +bool(false) +bool(false) + +Warning: interface_exists() expects parameter 1 to be string, array given in %s on line %d +NULL +bool(false) +bool(true) +bool(true) +bool(false) +bool(false) +Done diff --git a/Zend/tests/014.inc b/Zend/tests/014.inc new file mode 100644 index 000000000..69c9bc079 --- /dev/null +++ b/Zend/tests/014.inc @@ -0,0 +1,3 @@ +<?php +/* dummy file for 014.phpt */ +?> diff --git a/Zend/tests/014.phpt b/Zend/tests/014.phpt new file mode 100644 index 000000000..f65f2a328 --- /dev/null +++ b/Zend/tests/014.phpt @@ -0,0 +1,52 @@ +--TEST-- +get_included_files() tests +--FILE-- +<?php + +var_dump(get_included_files()); + +include(dirname(__FILE__)."/014.inc"); +var_dump(get_included_files()); + +var_dump(get_included_files(1,1)); + +include_once(dirname(__FILE__)."/014.inc"); +var_dump(get_included_files()); + +var_dump(get_included_files(1)); + +include(dirname(__FILE__)."/014.inc"); +var_dump(get_included_files()); + +echo "Done\n"; +?> +--EXPECTF-- +array(1) { + [0]=> + string(%d) "%s" +} +array(2) { + [0]=> + string(%d) "%s" + [1]=> + string(%d) "%s" +} + +Warning: Wrong parameter count for get_included_files() in %s on line %d +NULL +array(2) { + [0]=> + string(%d) "%s" + [1]=> + string(%d) "%s" +} + +Warning: Wrong parameter count for get_included_files() in %s on line %d +NULL +array(2) { + [0]=> + string(%d) "%s" + [1]=> + string(%d) "%s" +} +Done diff --git a/Zend/tests/015.phpt b/Zend/tests/015.phpt new file mode 100644 index 000000000..a80254281 --- /dev/null +++ b/Zend/tests/015.phpt @@ -0,0 +1,35 @@ +--TEST-- +trigger_error() tests +--FILE-- +<?php + +var_dump(trigger_error()); +var_dump(trigger_error("error")); +var_dump(trigger_error(array())); +var_dump(trigger_error("error", -1)); +var_dump(trigger_error("error", 0)); +var_dump(trigger_error("error", E_USER_WARNING)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for trigger_error() in %s on line %d +NULL + +Notice: error in %s on line %d +bool(true) + +Notice: Array to string conversion in %s on line %d + +Notice: Array in %s on line %d +bool(true) + +Warning: Invalid error type specified in %s on line %d +bool(false) + +Warning: Invalid error type specified in %s on line %d +bool(false) + +Warning: error in %s on line %d +bool(true) +Done diff --git a/Zend/tests/016.phpt b/Zend/tests/016.phpt new file mode 100644 index 000000000..6ec507e6b --- /dev/null +++ b/Zend/tests/016.phpt @@ -0,0 +1,12 @@ +--TEST-- +isset() with object properties when operating on non-object +--FILE-- +<?php + +$foo = NULL; +isset($foo->bar->bar); + +echo "Done\n"; +?> +--EXPECT-- +Done diff --git a/Zend/tests/abstract-static.phpt b/Zend/tests/abstract-static.phpt index 9db88fc4c..c4ab8f248 100644 --- a/Zend/tests/abstract-static.phpt +++ b/Zend/tests/abstract-static.phpt @@ -2,23 +2,13 @@ Test for abstract static classes --FILE-- <?php -abstract class ezcDbHandler extends PDO +abstract class TestClass { - public function __construct( $dbParams, $dsn ) - { - $user = null; - $pass = null; - $driverOptions = null; - } - abstract static public function getName(); - - static public function hasFeature( $feature ) - { - return false; - } } ?> -DONE ---EXPECT-- -DONE +===DONE=== +--EXPECTF-- + +Strict Standards: Static function TestClass::getName() should not be abstract in %sabstract-static.php on line %d +===DONE=== diff --git a/Zend/tests/array_type_hint_001.phpt b/Zend/tests/array_type_hint_001.phpt index b8a8955f2..533319b6e 100755 --- a/Zend/tests/array_type_hint_001.phpt +++ b/Zend/tests/array_type_hint_001.phpt @@ -12,4 +12,4 @@ foo(123); --EXPECTF-- 3 -Fatal error: Argument 1 passed to foo() must be an array, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php on line 2 +Catchable fatal error: Argument 1 passed to foo() must be an array, integer given, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php on line 2 diff --git a/Zend/tests/bug24884.phpt b/Zend/tests/bug24884.phpt index 6d363f2cf..457acd00d 100755 --- a/Zend/tests/bug24884.phpt +++ b/Zend/tests/bug24884.phpt @@ -23,6 +23,6 @@ $test = new Test(); $test2 = $test->__copy(); var_dump($test2); ?> ---EXPECT-- -object(Test)#2 (0) { +--EXPECTF-- +object(Test)#%d (0) { } diff --git a/Zend/tests/bug26166.phpt b/Zend/tests/bug26166.phpt index 01344cfb1..60624ed98 100755 --- a/Zend/tests/bug26166.phpt +++ b/Zend/tests/bug26166.phpt @@ -1,67 +1,74 @@ ---TEST--
-Bug #26166 (__toString() crash when no values returned)
---FILE--
-<?php
-class Foo
-{
- function __toString()
- {
- return "Hello World!\n";
- }
-}
-
-class Bar
-{
- private $obj;
-
- function __construct()
- {
- $this->obj = new Foo();
- }
-
- function __toString()
- {
- return $this->obj->__toString();
- }
-}
-
-$o = new Bar;
-echo $o;
-
-echo "===THROW===\n";
-
-class Error
-{
- function __toString() {
- throw new Exception("This is an error!");
- }
-}
-
-$o = new Error;
-try {
- echo $o;
-}
-catch (Exception $e) {
- echo "Got the exception\n";
-}
-
-echo "===NONE===\n";
-
-class None
-{
- function __toString() {
- }
-}
-
-$o = new None;
-echo $o;
-
-?>
-===DONE===
---EXPECTF--
-Hello World!
-===THROW===
-Got the exception
-===NONE===
-
-Fatal error: Method None::__toString() must return a string value in %sbug26166.php on line %d
+--TEST-- +Bug #26166 (__toString() crash when no values returned) +--FILE-- +<?php + +class Foo +{ + function __toString() + { + return "Hello World!\n"; + } +} + +class Bar +{ + private $obj; + + function __construct() + { + $this->obj = new Foo(); + } + + function __toString() + { + return $this->obj->__toString(); + } +} + +$o = new Bar; +echo $o; + +echo "===NONE===\n"; + +function my_error_handler($errno, $errstr, $errfile, $errline) { + var_dump($errstr); +} + +set_error_handler('my_error_handler'); + +class None +{ + function __toString() { + } +} + +$o = new None; +echo $o; + +echo "===THROW===\n"; + +class Error +{ + function __toString() { + throw new Exception("This is an error!"); + } +} + +$o = new Error; +try { + echo $o; +} +catch (Exception $e) { + echo "Got the exception\n"; +} + +?> +===DONE=== +--EXPECTF-- +Hello World! +===NONE=== +string(52) "Method None::__toString() must return a string value" +===THROW=== + +Fatal error: Method Error::__toString() must not throw an exception in %sbug26166.php on line %d diff --git a/Zend/tests/bug27641.phpt b/Zend/tests/bug27641.phpt deleted file mode 100644 index c3c58696c..000000000 --- a/Zend/tests/bug27641.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -Bug #27641 (zend.ze1_compatibility_mode = On causes object properties to be misreported) ---SKIPIF-- -<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?> ---INI-- -error_reporting=4095 ---FILE-- -<?php - class A { - public $a = "Default for A"; - public $b = "Default for B"; - - function __construct($a, $b) { - $this->a = $a; - $this->b = $b; - } - function A() { - $args = func_get_args(); - call_user_func_array(Array(&$this, '__construct'), $args); - } - } - - $t = new A("New A", "New B"); - print_r($t); - print_r(get_class_vars(get_class($t))); - print_r(get_object_vars($t)); -?> ---EXPECTF-- -Strict Standards: Redefining already defined constructor for class A in %sbug27641.php on line %d -A Object -( - [a] => New A - [b] => New B -) -Array -( - [a] => Default for A - [b] => Default for B -) -Array -( - [a] => New A - [b] => New B -) diff --git a/Zend/tests/bug28444.phpt b/Zend/tests/bug28444.phpt index f8a5513e0..78c08d2fc 100755 --- a/Zend/tests/bug28444.phpt +++ b/Zend/tests/bug28444.phpt @@ -3,6 +3,12 @@ Bug #28444 (Cannot access undefined property for object with overloaded property --FILE-- <?php +function my_error_handler($errno, $errstr, $errfile, $errline) { + var_dump($errstr); +} + +set_error_handler('my_error_handler'); + class Object { public $x; @@ -60,7 +66,8 @@ Overloaded::__set(y,3) int(3) Overloaded::__get(y) int(3) -Overloaded::__set(z,Object id #3) +string(55) "Object of class Object could not be converted to string" +Overloaded::__set(z,) object(Object)#%d (1) { ["x"]=> int(4) diff --git a/Zend/tests/bug30791.phpt b/Zend/tests/bug30791.phpt index 64ee313e4..52261a046 100755 --- a/Zend/tests/bug30791.phpt +++ b/Zend/tests/bug30791.phpt @@ -2,21 +2,33 @@ Bug #30791 magic methods (__sleep/__wakeup/__toString) call __call if object is overloaded
--FILE--
<?php
-class a {
+
+function my_error_handler($errno, $errstr, $errfile, $errline) {
+ var_dump($errstr);
+}
+
+set_error_handler('my_error_handler');
+
+class a
+{
public $a = 4;
function __call($a,$b) {
return "unknown method";
}
}
+
$b = new a;
echo $b,"\n";
$c = unserialize(serialize($b));
echo $c,"\n";
var_dump($c);
+
?>
--EXPECT--
-Object id #1
-Object id #2
+string(50) "Object of class a could not be converted to string"
+
+string(50) "Object of class a could not be converted to string"
+
object(a)#2 (1) {
["a"]=>
int(4)
diff --git a/Zend/tests/bug32660.phpt b/Zend/tests/bug32660.phpt index 36a2f7872..b075e1993 100755 --- a/Zend/tests/bug32660.phpt +++ b/Zend/tests/bug32660.phpt @@ -28,9 +28,12 @@ $b = "much longer"; print_r($a);
?>
--EXPECTF--
+Notice: Indirect modification of overloaded property A::$whatever has no effect in %sbug32660.php on line 20
A Object
(
- [q] => long
+ [q] => 3
)
+Notice: Indirect modification of overloaded property A::$whatever has no effect in %sbug32660.php on line 23
+
Fatal error: Cannot assign by reference to overloaded object in %sbug32660.php on line 23
diff --git a/Zend/tests/bug33732.phpt b/Zend/tests/bug33732.phpt index 58c204411..e723c2064 100755 --- a/Zend/tests/bug33732.phpt +++ b/Zend/tests/bug33732.phpt @@ -27,7 +27,7 @@ interface iB2 extends iA2 { class A2 implements iA2 {
}
-class B2 extends A2 implements iB2 {
+class B2 extends A2 implements iA2 {
}
echo iA2::cA;
diff --git a/Zend/tests/bug33771.phpt b/Zend/tests/bug33771.phpt index 336aee8e8..a786e5806 100644 --- a/Zend/tests/bug33771.phpt +++ b/Zend/tests/bug33771.phpt @@ -1,5 +1,5 @@ --TEST-- -bug #33771 (error_reporting falls to 0 when @ was used inside try/catch block) +Bug #33771 (error_reporting falls to 0 when @ was used inside try/catch block) --FILE-- <?php @@ -14,7 +14,7 @@ function make_exception() function make_exception_and_change_err_reporting() { - error_reporting(E_ALL); + error_reporting(E_ALL & ~E_STRICT); throw new Exception(); } @@ -34,7 +34,7 @@ var_dump(error_reporting()); echo "Done\n"; ?> --EXPECTF-- -int(4095) -int(4095) -int(2047) +int(8191) +int(8191) +int(6143) Done diff --git a/Zend/tests/bug33996.phpt b/Zend/tests/bug33996.phpt index 1f02cae0f..e1677ce78 100755 --- a/Zend/tests/bug33996.phpt +++ b/Zend/tests/bug33996.phpt @@ -1,29 +1,29 @@ ---TEST-- -Bug #33996 (No information given for fatal error on passing invalid value to typed argument) ---INI-- -error_reporting=4095 ---FILE-- -<?php -class Foo -{ - // nothing -} - -function FooTest(Foo $foo) -{ - echo "Hello!"; -} - -function NormalTest($a) -{ - echo "Hi!"; -} - -NormalTest(); -FooTest(); -FooTest(new Foo()); -?> ---EXPECTF-- -Warning: Missing argument 1 for NormalTest(), called in %sbug33996.php on line 17 and defined in %sbug33996.php on line 12 -Hi! -Fatal error: Argument 1 passed to FooTest() must be an object of class Foo, called in %sbug33996.php on line 18 and defined in %sbug33996.php on line 7 +--TEST--
+Bug #33996 (No information given for fatal error on passing invalid value to typed argument)
+--INI--
+error_reporting=8191
+--FILE--
+<?php
+class Foo
+{
+ // nothing
+}
+
+function FooTest(Foo $foo)
+{
+ echo "Hello!";
+}
+
+function NormalTest($a)
+{
+ echo "Hi!";
+}
+
+NormalTest();
+FooTest();
+FooTest(new Foo());
+?>
+--EXPECTF--
+Warning: Missing argument 1 for NormalTest(), called in %sbug33996.php on line %d and defined in %sbug33996.php on line %d
+Hi!
+Catchable fatal error: Argument 1 passed to FooTest() must be an instance of Foo, none given, called in %sbug33996.php on line %d and defined in %sbug33996.php on line %d
diff --git a/Zend/tests/bug34065.phpt b/Zend/tests/bug34065.phpt new file mode 100755 index 000000000..9f6e00e61 --- /dev/null +++ b/Zend/tests/bug34065.phpt @@ -0,0 +1,15 @@ +--TEST--
+Bug #34065 (throw in foreach causes memory leaks)
+--FILE--
+<?php
+$data = file(__FILE__);
+try {
+ foreach ($data as $line) {
+ throw new Exception("error");
+ }
+} catch (Exception $e) {
+ echo "ok\n";
+}
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug36759.phpt b/Zend/tests/bug36759.phpt new file mode 100755 index 000000000..8aa9977a0 --- /dev/null +++ b/Zend/tests/bug36759.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #36759 (Objects destructors are invoked in wrong order when script is finished) +--FILE-- +<?php +class Foo { + private $bar; + function __construct($bar) { + $this->bar = $bar; + } + function __destruct() { + echo __METHOD__,"\n"; + unset($this->bar); + } +} + +class Bar { + function __destruct() { + echo __METHOD__,"\n"; + unset($this->bar); + } +} +$y = new Bar(); +$x = new Foo($y); +?> +--EXPECT-- +Foo::__destruct +Bar::__destruct diff --git a/Zend/tests/bug37144.phpt b/Zend/tests/bug37144.phpt new file mode 100755 index 000000000..6191a2938 --- /dev/null +++ b/Zend/tests/bug37144.phpt @@ -0,0 +1,16 @@ +--TEST--
+Bug #37144 (PHP crashes trying to assign into property of dead object)
+--FILE--
+<?php
+function foo() {
+ $x = new stdClass();
+ $x->bar = array(1);
+ return $x;
+}
+foo()->bar[1] = "123";
+foo()->bar[0]++;
+unset(foo()->bar[0]);
+echo "ok\n";
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug37212.phpt b/Zend/tests/bug37212.phpt new file mode 100755 index 000000000..5320a6173 --- /dev/null +++ b/Zend/tests/bug37212.phpt @@ -0,0 +1,55 @@ +--TEST-- +Bug #3721 (Access to protected property of common base class) +--FILE-- +<?php + +class A +{ + protected $value; + + public function __construct($val) + { + $this->value = $val; + } + + protected function getValue() + { + return $this->value; + } +} + +class B extends A +{ + public function copyValue($obj) + { + $this->value = $obj->getValue(); + $this->value = $obj->value; // value defined in common base class + } +} +class C extends A {} + +$B = new B("B"); +var_dump($B); +$C = new C("C"); +var_dump($C); + +$B->copyValue($C); + +var_dump($B); + +?> +===DONE=== +--EXPECTF-- +object(B)#%d (1) { + ["value:protected"]=> + string(1) "B" +} +object(C)#%d (1) { + ["value:protected"]=> + string(1) "C" +} +object(B)#%d (1) { + ["value:protected"]=> + string(1) "C" +} +===DONE=== diff --git a/Zend/tests/bug37632.phpt b/Zend/tests/bug37632.phpt new file mode 100755 index 000000000..fb72f8934 --- /dev/null +++ b/Zend/tests/bug37632.phpt @@ -0,0 +1,135 @@ +--TEST-- +Bug #37632 (Protected method access problem) +--FILE-- +<?php + +class A1 +{ + protected function test() + { + echo __METHOD__ . "\n"; + } +} + +class B1 extends A1 +{ + public function doTest(A1 $obj) + { + echo __METHOD__ . "\n"; + $obj->test(); + } +} + +class C1 extends A1 +{ + protected function test() + { + echo __METHOD__ . "\n"; + } +} + +$b = new B1; +$b->doTest(new C1); + +class A2 +{ + static protected function test() + { + echo __METHOD__ . "\n"; + } +} + +class B2 extends A2 +{ + static public function doTest(A2 $obj) + { + echo __METHOD__ . "\n"; + $obj->test(); + } +} + +class C2 extends A2 +{ + static protected function test() + { + echo __METHOD__ . "\n"; + } +} + +B2::doTest(new C2); + +/* Right now Ctor's cannot be made protected when defined in a ctor. That is + * we cannot decrease visibility. + * + +interface Ctor +{ + function __construct($x); +} + +class A3 implements Ctor +{ + protected function __construct() + { + echo __METHOD__ . "\n"; + } +} + +class B3 extends A3 +{ + static public function doTest() + { + echo __METHOD__ . "\n"; + new C3; + } +} + +class C3 extends A3 +{ + protected function __construct() + { + echo __METHOD__ . "\n"; + } +} + +B3::doTest(); + +*/ + +class A4 +{ + protected function __construct() + { + echo __METHOD__ . "\n"; + } +} + +class B4 extends A4 +{ + static public function doTest() + { + echo __METHOD__ . "\n"; + new C4; + } +} + +class C4 extends A4 +{ + protected function __construct() + { + echo __METHOD__ . "\n"; + } +} + +B4::doTest(); + +?> +===DONE=== +--EXPECTF-- +B1::doTest +C1::test +B2::doTest +C2::test +B4::doTest + +Fatal error: Call to protected C4::__construct() from context 'B4' in %sbug37632.php on line %d diff --git a/Zend/tests/bug37667.phpt b/Zend/tests/bug37667.phpt new file mode 100755 index 000000000..b05f296f0 --- /dev/null +++ b/Zend/tests/bug37667.phpt @@ -0,0 +1,53 @@ +--TEST-- +Bug #37667 (Object is not added into array returned by __get) +--FILE-- +<?php + +class Test +{ + protected $property = array('foo' => 'bar'); + + function __get($name) + { + return $this->property; + } +} + +$obj = new Test; + +var_dump($obj->property['foo']); +var_dump($obj->property[2]); + +var_dump($obj); + +$obj->property[] = 1; +$obj->property[] = 2; + +var_dump($obj); + +?> +===DONE=== +--EXPECTF-- +string(3) "bar" + +Notice: Undefined offset: 2 in %sbug37667.php on line 16 +NULL +object(Test)#%d (1) { + ["property:protected"]=> + array(1) { + ["foo"]=> + string(3) "bar" + } +} + +Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 20 + +Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 21 +object(Test)#%d (1) { + ["property:protected"]=> + array(1) { + ["foo"]=> + string(3) "bar" + } +} +===DONE=== diff --git a/Zend/tests/bug37707.phpt b/Zend/tests/bug37707.phpt new file mode 100755 index 000000000..196495852 --- /dev/null +++ b/Zend/tests/bug37707.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #37707 (clone without assigning leaks memory) +--FILE-- +<?php +class testme { + function __clone() { + echo "clonned\n"; + } +} +clone new testme(); +echo "NO LEAK\n"; +?> +--EXPECT-- +clonned +NO LEAK + diff --git a/Zend/tests/bug37811.phpt b/Zend/tests/bug37811.phpt new file mode 100755 index 000000000..dc3ef93d6 --- /dev/null +++ b/Zend/tests/bug37811.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #37811 define not using toString on objects +--FILE-- +<?php + +class TestClass +{ + function __toString() + { + return "Foo"; + } +} + +define("Bar",new TestClass); +var_dump(Bar); +define("Baz",new stdClass); +var_dump(Baz); + +?> +===DONE=== +--EXPECTF-- +string(3) "Foo" + +Warning: Constants may only evaluate to scalar values in %sbug37811.php on line %d + +Notice: Use of undefined constant Baz - assumed 'Baz' in %sbug37811.php on line %d +string(3) "Baz" +===DONE=== diff --git a/Zend/tests/bug38047.phpt b/Zend/tests/bug38047.phpt new file mode 100755 index 000000000..00290ee54 --- /dev/null +++ b/Zend/tests/bug38047.phpt @@ -0,0 +1,50 @@ +--TEST-- +Bug #38047 ("file" and "line" sometimes not set in backtrace from inside error handler) +--FILE-- +<?php +error_reporting(E_ALL); +set_error_handler('kalus_error_handler'); +ini_set("display_errors", "on"); + +class A { + function A_ftk($a) { + } +} + +function kalus_error_handler($error_code, $error_string, $filename, $line, $symbols) { + echo "$error_string\n"; + get_error_context(); +} + +function get_error_context() { + $backtrace = debug_backtrace(); + $n = 1; + foreach ($backtrace as $call) { + echo $n++." "; + if (isset($call["file"])) { + echo $call["file"]; + if (isset($call["line"])) { + echo ":".$call["line"]; + } + } + if (isset($call["function"])) { + echo " ".$call["function"]."()"; + } + echo "\n"; + } + echo "\n"; +} + +//This will not create file and line items for the call into the error handler +$page["name"] = A::A_ftk(); +?> +--EXPECTF-- +Non-static method A::A_ftk() should not be called statically +1 %sbug38047.php:13 get_error_context() +2 %sbug38047.php:36 kalus_error_handler() +3 %sbug38047.php:36 A_ftk() + +Missing argument 1 for A::A_ftk(), called in %sbug38047.php on line 36 and defined +1 %sbug38047.php:13 get_error_context() +2 %sbug38047.php:7 kalus_error_handler() +3 %sbug38047.php:36 A_ftk() diff --git a/Zend/tests/bug38146.phpt b/Zend/tests/bug38146.phpt new file mode 100755 index 000000000..1f022f342 --- /dev/null +++ b/Zend/tests/bug38146.phpt @@ -0,0 +1,19 @@ +--TEST--
+Bug #38146 (Cannot use array returned from foo::__get('bar') in write context)
+--FILE--
+<?php
+class foo {
+ public function __get($member) {
+ $f = array("foo"=>"bar","bar"=>"foo");
+ return $f;
+ }
+}
+
+$f = new foo();
+foreach($f->bar as $key => $value) {
+ print "$key => $value\n";
+}
+?>
+--EXPECT--
+foo => bar
+bar => foo
diff --git a/Zend/tests/bug38211.phpt b/Zend/tests/bug38211.phpt new file mode 100755 index 000000000..4b088125a --- /dev/null +++ b/Zend/tests/bug38211.phpt @@ -0,0 +1,10 @@ +--TEST--
+Bug #38211 (variable name and cookie name match breaks script execution)
+--FILE--
+<?php
+$test = 'test';
+unset($$test);
+echo "ok\n";
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug38220.phpt b/Zend/tests/bug38220.phpt new file mode 100755 index 000000000..5b0a7178d --- /dev/null +++ b/Zend/tests/bug38220.phpt @@ -0,0 +1,92 @@ +--TEST--
+Bug #38220 Crash on some object operations
+--FILE--
+<?php
+class drv {
+ public $obj;
+
+ function func1() {
+ echo "func1(): {$this->obj->i}\n";
+ }
+
+ function close() {
+ echo "close(): {$this->obj->i}\n";
+ }
+}
+
+class A {
+ public $i;
+
+ function __construct($i) {
+ $this->i = $i;
+
+ }
+
+ function __call($method, $args) {
+ $drv = myserv::drv();
+
+ $drv->obj = $this;
+
+ echo "before call $method\n";
+ print_r($this);
+ call_user_func_array(array($drv, $method), $args);
+ echo "after call $method\n";
+
+ // Uncomment this line to work without crash
+// $drv->obj = null;
+ }
+
+ function __destruct() {
+ echo "A::__destruct()\n";
+ $this->close();
+ }
+}
+
+class myserv {
+ private static $drv = null;
+
+ static function drv() {
+ if (is_null(self::$drv))
+ self::$drv = new drv;
+ return self::$drv;
+ }
+}
+
+$obj1 = new A(1);
+$obj1->func1();
+
+$obj2 = new A(2);
+unset($obj1);
+$obj2->func1();
+?>
+--EXPECT--
+before call func1
+A Object
+(
+ [i] => 1
+)
+func1(): 1
+after call func1
+A::__destruct()
+before call close
+A Object
+(
+ [i] => 1
+)
+close(): 1
+after call close
+before call func1
+A Object
+(
+ [i] => 2
+)
+func1(): 1
+after call func1
+A::__destruct()
+before call close
+A Object
+(
+ [i] => 2
+)
+close(): 2
+after call close
diff --git a/Zend/tests/bug38234.phpt b/Zend/tests/bug38234.phpt new file mode 100755 index 000000000..337420667 --- /dev/null +++ b/Zend/tests/bug38234.phpt @@ -0,0 +1,18 @@ +--TEST--
+Bug #38234 (Exception in __clone makes memory leak)
+--FILE--
+<?php
+class Foo {
+ function __clone() {
+ throw new Exception();
+ }
+}
+try {
+ $x = new Foo();
+ $y = clone $x;
+} catch (Exception $e) {
+}
+echo "ok\n";
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug38287.phpt b/Zend/tests/bug38287.phpt new file mode 100755 index 000000000..3052fc7f9 --- /dev/null +++ b/Zend/tests/bug38287.phpt @@ -0,0 +1,45 @@ +--TEST--
+Bug #38287 (static variables mess up global vars)
+--FILE--
+<?php
+error_reporting(0);
+
+something::do_something();
+
+// $not_there is really NULL
+var_dump($not_there);
+
+// error occurs here: execution should never get inside the if condition because $not_there is NULL
+if ($not_there["invalid_var"]) {
+ // will print NULL (which is ok, but execution should never get here if the value is NULL)
+ var_dump($not_there["use_authmodule"]);
+ // will print "PATH:Array"
+ print "PATH:".$not_there["use_authmodule"]."\n";
+}
+
+class something {
+ public static function get_object() {
+ static $object=NULL;
+ if ($object===NULL)
+ $object=new something;
+ return $object;
+ }
+
+ public static function do_something() {
+ self::get_object()->vars[]=1;
+ self::get_object()->vars[]=2;
+ self::get_object()->vars[]=3;
+ var_dump(self::get_object()->vars);
+ }
+}
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+NULL
diff --git a/Zend/tests/bug38461.phpt b/Zend/tests/bug38461.phpt new file mode 100644 index 000000000..281d99901 --- /dev/null +++ b/Zend/tests/bug38461.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #38461 (setting private attribute with __set() produces segfault) +--FILE-- +<?php + +class Operation +{ + function __set( $var, $value ) + { + $this->$var = $value; + } +} + +class ExtOperation extends Operation +{ + private $x; +} + +$op = new ExtOperation; +$op->x = 'test'; + +echo "Done\n"; +?> +--EXPECT-- +Done diff --git a/Zend/tests/bug38623.phpt b/Zend/tests/bug38623.phpt new file mode 100755 index 000000000..8b03539db --- /dev/null +++ b/Zend/tests/bug38623.phpt @@ -0,0 +1,16 @@ +--TEST--
+Bug #38623 (leaks in a tricky code with switch() and exceptions)
+--FILE--
+<?php
+try {
+ switch(strtolower("apache")) {
+ case "apache":
+ throw new Exception("test");
+ break;
+ }
+} catch (Exception $e) {
+ echo "ok\n";
+}
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug38624.phpt b/Zend/tests/bug38624.phpt new file mode 100644 index 000000000..081e35c72 --- /dev/null +++ b/Zend/tests/bug38624.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #38624 (Strange warning when incrementing an object property and exception is thrown from __get method) +--FILE-- +<?php + +class impl +{ + public function __construct() + { + $this->counter++; + } + public function __set( $name, $value ) + { + throw new Exception( "doesn't work" ); + } + + public function __get( $name ) + { + throw new Exception( "doesn't work" ); + } + +} + +$impl = new impl(); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'doesn't work' in %s:%d +Stack trace: +#0 %s(%d): impl->__get('counter') +#1 %s(%d): impl->__construct() +#2 {main} + thrown in %s on line %d diff --git a/Zend/tests/bug38772.phpt b/Zend/tests/bug38772.phpt new file mode 100755 index 000000000..0e97c291c --- /dev/null +++ b/Zend/tests/bug38772.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #38772 (inconsistent overriding of methods in different visibility contexts) +--FILE-- +<?php +class A { + + public function __construct() { + $this -> foo(); + } + + private function foo() { + echo __METHOD__ . "\r\n"; + } +} + +class B extends A { + public function foo() { + echo __METHOD__ . "\r\n"; + } +} + +class C extends A { + protected function foo() { + echo __METHOD__ . "\r\n"; + } +} + +class D extends A { + private function foo() { + echo __METHOD__ . "\r\n"; + } +} + +$a = new A(); +$b = new B(); +$c = new C(); +$d = new D(); +--EXPECT-- +A::foo +A::foo +A::foo +A::foo diff --git a/Zend/tests/bug38779.phpt b/Zend/tests/bug38779.phpt new file mode 100644 index 000000000..b551767c9 --- /dev/null +++ b/Zend/tests/bug38779.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #38779 (engine crashes when require()'ing file with syntax error through userspace stream wrapper) +--FILE-- +<?php + +class Loader { + private $position; + private $data; + public function stream_open($path, $mode, $options, &$opened_path) { + $this->data = '<' . "?php \n\"\";ll l\n ?" . '>'; + $this->position = 0; + return true; + } + function stream_read($count) { + $ret = substr($this->data, $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + function stream_eof() { + return $this->position >= strlen($this->data); + } +} +stream_wrapper_register('Loader', 'Loader'); +require 'Loader://qqq.php'; + +echo "Done\n"; +?> +--EXPECTF-- +Parse error: %s error%sin Loader://qqq.php on line %d diff --git a/Zend/tests/bug38779_1.phpt b/Zend/tests/bug38779_1.phpt new file mode 100644 index 000000000..eefa952e3 --- /dev/null +++ b/Zend/tests/bug38779_1.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #38779 (engine crashes when require()'ing file with syntax error through userspace stream wrapper) +--FILE-- +<?php + +class Loader { + private $position; + private $data; + public function stream_open($path, $mode, $options, &$opened_path) { + $this->data = '<' . "?php \n\"\";ll l\n ?" . '>'; + $this->position = 0; + return true; + } + function stream_read($count) { + $ret = substr($this->data, $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + function stream_eof() { + return $this->position >= strlen($this->data); + } + function stream_flush() { + @unlink(dirname(__FILE__)."/bug38779.txt"); + var_dump("flush!"); + } + function stream_close() { + var_dump("close!"); + } +} +stream_wrapper_register('Loader', 'Loader'); +$fp = fopen ('Loader://qqq.php', 'r'); + +$filename = dirname(__FILE__)."/bug38779.txt"; +$fp1 = fopen($filename, "w"); +fwrite($fp1, "<"."?php blah blah?".">"); +fclose($fp1); + +include $filename; + +echo "Done\n"; +?> +--EXPECTF-- +Parse error: %s error%sin %s on line %d +string(6) "flush!" +string(6) "close!" diff --git a/Zend/tests/bug38808.phpt b/Zend/tests/bug38808.phpt new file mode 100755 index 000000000..0fc4bfecd --- /dev/null +++ b/Zend/tests/bug38808.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #38808 ("maybe ref" issue for current() and others) +--FILE-- +<?php +$current = "current"; +$next = "next"; + +$b = array(1=>'one', 2=>'two'); +$a =& $b; + +echo $current($a)."\n"; +$next($a); +echo $current($a)."\n"; +?> +--EXPECT-- +one +two
\ No newline at end of file diff --git a/Zend/tests/bug38942.phpt b/Zend/tests/bug38942.phpt new file mode 100755 index 000000000..5b86e15d7 --- /dev/null +++ b/Zend/tests/bug38942.phpt @@ -0,0 +1,17 @@ +--TEST--
+Bug #38942 (Double old-style-ctor inheritance)
+--FILE--
+<?php
+class foo {
+ public function foo() {}
+}
+
+class bar extends foo {
+}
+print_r(get_class_methods("bar"));
+?>
+--EXPECT--
+Array
+(
+ [0] => foo
+)
diff --git a/Zend/tests/bug39003.phpt b/Zend/tests/bug39003.phpt new file mode 100644 index 000000000..7a3da849b --- /dev/null +++ b/Zend/tests/bug39003.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #39003 (__autoload() is called for type hinting) +--FILE-- +<?php + +class ClassName +{ + public $var = 'bla'; +} + +function test (OtherClassName $object) { } + +function __autoload($class) +{ + var_dump("__autload($class)"); +} + +$obj = new ClassName; +test($obj); + +echo "Done\n"; +?> +--EXPECTF-- +Catchable fatal error: Argument 1 passed to test() must be an instance of OtherClassName, instance of ClassName given, called in %s on line %d and defined in %s on line %d diff --git a/Zend/tests/bug39017.phpt b/Zend/tests/bug39017.phpt new file mode 100755 index 000000000..f38b9a310 --- /dev/null +++ b/Zend/tests/bug39017.phpt @@ -0,0 +1,11 @@ +--TEST--
+Bug #39017 (foreach(($obj = new myClass) as $v); echo $obj; segfaults)
+--FILE--
+<?php
+class A {}
+foreach(($a=(object)new A()) as $v);
+var_dump($a); // UNKNOWN:0
+?>
+--EXPECTF--
+object(A)#%d (0) {
+}
diff --git a/Zend/tests/bug39036.phpt b/Zend/tests/bug39036.phpt new file mode 100644 index 000000000..017012fdd --- /dev/null +++ b/Zend/tests/bug39036.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #39036 (Unsetting key of foreach() yields segmentation fault) +--FILE-- +<?php + +$key = 'asdf'; + +foreach (get_defined_vars() as $key => $value) { + unset($$key); +} + +var_dump($key); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Undefined variable: key in %s on line %d +NULL +Done diff --git a/Zend/tests/bug39304.phpt b/Zend/tests/bug39304.phpt new file mode 100755 index 000000000..5529d700d --- /dev/null +++ b/Zend/tests/bug39304.phpt @@ -0,0 +1,9 @@ +--TEST--
+Bug #39304 (Segmentation fault with list unpacking of string offset)
+--FILE--
+<?php
+ $s = "";
+ list($a, $b) = $s[0];
+?>
+--EXPECTF--
+Fatal error: Cannot use string offset as an array in %sbug39304.php on line 3
diff --git a/Zend/tests/catch_002.phpt b/Zend/tests/catch_002.phpt new file mode 100755 index 000000000..73fa97b0a --- /dev/null +++ b/Zend/tests/catch_002.phpt @@ -0,0 +1,33 @@ +--TEST--
+Catching an exception in a constructor
+--FILE--
+<?php
+
+class MyObject
+{
+ function __construct()
+ {
+ throw new Exception();
+ echo __METHOD__ . "() Must not be reached\n";
+ }
+
+ function __destruct()
+ {
+ echo __METHOD__ . "() Must not be called\n";
+ }
+}
+
+try
+{
+ new MyObject();
+}
+catch(Exception $e)
+{
+ echo "Caught\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Caught
+===DONE===
diff --git a/Zend/tests/catch_003.phpt b/Zend/tests/catch_003.phpt new file mode 100755 index 000000000..9210e3f1f --- /dev/null +++ b/Zend/tests/catch_003.phpt @@ -0,0 +1,38 @@ +--TEST--
+Catching an exception in a constructor fired form a static method
+--FILE--
+<?php
+
+class MyObject
+{
+ function fail()
+ {
+ throw new Exception();
+ }
+
+ function __construct()
+ {
+ self::fail();
+ echo __METHOD__ . "() Must not be reached\n";
+ }
+
+ function __destruct()
+ {
+ echo __METHOD__ . "() Must not be called\n";
+ }
+}
+
+try
+{
+ new MyObject();
+}
+catch(Exception $e)
+{
+ echo "Caught\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Caught
+===DONE===
diff --git a/Zend/tests/catch_004.phpt b/Zend/tests/catch_004.phpt new file mode 100755 index 000000000..f1df06788 --- /dev/null +++ b/Zend/tests/catch_004.phpt @@ -0,0 +1,43 @@ +--TEST--
+Catching an exception in a constructor inside a static method
+--FILE--
+<?php
+
+class MyObject
+{
+ function fail()
+ {
+ throw new Exception();
+ }
+
+ function __construct()
+ {
+ self::fail();
+ echo __METHOD__ . "() Must not be reached\n";
+ }
+
+ function __destruct()
+ {
+ echo __METHOD__ . "() Must not be called\n";
+ }
+
+ static function test()
+ {
+ try
+ {
+ new MyObject();
+ }
+ catch(Exception $e)
+ {
+ echo "Caught\n";
+ }
+ }
+}
+
+MyObject::test();
+
+?>
+===DONE===
+--EXPECT--
+Caught
+===DONE===
diff --git a/Zend/tests/error_reporting01.phpt b/Zend/tests/error_reporting01.phpt index 3944ed129..60be02390 100644 --- a/Zend/tests/error_reporting01.phpt +++ b/Zend/tests/error_reporting01.phpt @@ -22,5 +22,5 @@ var_dump(error_reporting()); echo "Done\n"; ?> --EXPECT-- -int(2047) +int(6143) Done diff --git a/Zend/tests/error_reporting02.phpt b/Zend/tests/error_reporting02.phpt index eb57e4b17..227d8c6f2 100644 --- a/Zend/tests/error_reporting02.phpt +++ b/Zend/tests/error_reporting02.phpt @@ -23,5 +23,5 @@ var_dump(error_reporting()); echo "Done\n"; ?> --EXPECT-- -int(4095) +int(8191) Done diff --git a/Zend/tests/error_reporting03.phpt b/Zend/tests/error_reporting03.phpt index 0bd0b37e1..ec916048d 100644 --- a/Zend/tests/error_reporting03.phpt +++ b/Zend/tests/error_reporting03.phpt @@ -31,5 +31,5 @@ echo "Done\n"; ?> --EXPECTF-- Notice: Undefined variable: undef2 in %s on line %d -int(4095) +int(8191) Done diff --git a/Zend/tests/error_reporting04.phpt b/Zend/tests/error_reporting04.phpt index 79054fe2a..1d7d678b2 100644 --- a/Zend/tests/error_reporting04.phpt +++ b/Zend/tests/error_reporting04.phpt @@ -19,5 +19,5 @@ echo "Done\n"; ?> --EXPECTF-- Notice: Undefined variable: undef in %s on line %d -int(4095) +int(8191) Done diff --git a/Zend/tests/error_reporting05.phpt b/Zend/tests/error_reporting05.phpt index 501cf2ea1..71fee17f4 100644 --- a/Zend/tests/error_reporting05.phpt +++ b/Zend/tests/error_reporting05.phpt @@ -30,5 +30,5 @@ echo "Done\n"; Notice: Undefined variable: undef_value in %s on line %d Notice: Undefined variable: undef_name in %s on line %d -int(2047) +int(6143) Done diff --git a/Zend/tests/error_reporting06.phpt b/Zend/tests/error_reporting06.phpt index effa8305c..f472d3405 100644 --- a/Zend/tests/error_reporting06.phpt +++ b/Zend/tests/error_reporting06.phpt @@ -26,5 +26,5 @@ var_dump(error_reporting()); echo "Done\n"; ?> --EXPECTF-- -int(2047) +int(6143) Done diff --git a/Zend/tests/error_reporting07.phpt b/Zend/tests/error_reporting07.phpt index 8cbca46d1..696a3757e 100644 --- a/Zend/tests/error_reporting07.phpt +++ b/Zend/tests/error_reporting07.phpt @@ -26,5 +26,5 @@ var_dump(error_reporting()); echo "Done\n"; ?> --EXPECTF-- -int(2047) +int(6143) Done diff --git a/Zend/tests/error_reporting08.phpt b/Zend/tests/error_reporting08.phpt index dcc5975fa..362aa3765 100644 --- a/Zend/tests/error_reporting08.phpt +++ b/Zend/tests/error_reporting08.phpt @@ -28,5 +28,5 @@ echo "Done\n"; ?> --EXPECTF-- Notice: Undefined variable: undef3 in %s on line %d -int(4095) +int(8191) Done diff --git a/Zend/tests/error_reporting09.phpt b/Zend/tests/error_reporting09.phpt index d10812c90..193758148 100644 --- a/Zend/tests/error_reporting09.phpt +++ b/Zend/tests/error_reporting09.phpt @@ -27,5 +27,5 @@ echo "Done\n"; Notice: Undefined variable: blah in %s on line %d Notice: Undefined variable: undef2 in %s on line %d -int(4095) +int(8191) Done diff --git a/Zend/tests/error_reporting10.phpt b/Zend/tests/error_reporting10.phpt index a2c13e4ad..1d0abb10f 100644 --- a/Zend/tests/error_reporting10.phpt +++ b/Zend/tests/error_reporting10.phpt @@ -30,6 +30,6 @@ var_dump(error_reporting()); echo "Done\n"; ?> --EXPECTF-- -int(2047) -int(2039) +int(6143) +int(6135) Done diff --git a/Zend/tests/int_overflow_32bit.phpt b/Zend/tests/int_overflow_32bit.phpt new file mode 100644 index 000000000..d9b56495e --- /dev/null +++ b/Zend/tests/int_overflow_32bit.phpt @@ -0,0 +1,29 @@ +--TEST-- +testing integer overflow (32bit) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 2147483648, + 2147483649, + 2147483658, + 2147483748, + 2147484648, + ); + +foreach ($doubles as $d) { + $l = (int)$d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(-2147483648) +int(-2147483647) +int(-2147483638) +int(-2147483548) +int(-2147482648) +Done diff --git a/Zend/tests/int_overflow_64bit.phpt b/Zend/tests/int_overflow_64bit.phpt new file mode 100644 index 000000000..306fbae60 --- /dev/null +++ b/Zend/tests/int_overflow_64bit.phpt @@ -0,0 +1,29 @@ +--TEST-- +testing integer overflow (64bit) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 9223372036854775808, + 9223372036854775809, + 9223372036854775818, + 9223372036854775908, + 9223372036854776808, + ); + +foreach ($doubles as $d) { + $l = (int)$d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(-9223372036854775808) +int(-9223372036854775808) +int(-9223372036854775808) +int(-9223372036854775808) +int(-9223372036854775808) +Done diff --git a/Zend/tests/int_underflow_32bit.phpt b/Zend/tests/int_underflow_32bit.phpt new file mode 100644 index 000000000..901e7cfb5 --- /dev/null +++ b/Zend/tests/int_underflow_32bit.phpt @@ -0,0 +1,29 @@ +--TEST-- +testing integer underflow (32bit) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + -2147483648, + -2147483649, + -2147483658, + -2147483748, + -2147484648, + ); + +foreach ($doubles as $d) { + $l = (int)$d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(-2147483648) +int(-2147483648) +int(-2147483648) +int(-2147483648) +int(-2147483648) +Done diff --git a/Zend/tests/int_underflow_64bit.phpt b/Zend/tests/int_underflow_64bit.phpt new file mode 100644 index 000000000..48a43a3ca --- /dev/null +++ b/Zend/tests/int_underflow_64bit.phpt @@ -0,0 +1,29 @@ +--TEST-- +testing integer underflow (64bit) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + -9223372036854775808, + -9223372036854775809, + -9223372036854775818, + -9223372036854775908, + -9223372036854776808, + ); + +foreach ($doubles as $d) { + $l = (int)$d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(-9223372036854775808) +int(-9223372036854775808) +int(-9223372036854775808) +int(-9223372036854775808) +int(-9223372036854775808) +Done diff --git a/Zend/tests/objects_001.phpt b/Zend/tests/objects_001.phpt new file mode 100644 index 000000000..5cdc3dded --- /dev/null +++ b/Zend/tests/objects_001.phpt @@ -0,0 +1,60 @@ +--TEST-- +comparing objects to other types +--FILE-- +<?php + +class Bar { +} + +$b = new Bar; + +var_dump($b == NULL); +var_dump($b != NULL); +var_dump($b == true); +var_dump($b != true); +var_dump($b == false); +var_dump($b != false); +var_dump($b == ""); +var_dump($b != ""); +var_dump($b == 0); +var_dump($b != 0); +var_dump($b == 1); +var_dump($b != 1); +var_dump($b == 1.0); +var_dump($b != 1.0); +var_dump($b == 1); + + +echo "Done\n"; +?> +--EXPECTF-- +bool(false) +bool(true) +bool(true) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) + +Notice: Object of class Bar could not be converted to int in %s on line %d +bool(false) + +Notice: Object of class Bar could not be converted to int in %s on line %d +bool(true) + +Notice: Object of class Bar could not be converted to int in %s on line %d +bool(true) + +Notice: Object of class Bar could not be converted to int in %s on line %d +bool(false) + +Notice: Object of class Bar could not be converted to double in %s on line %d +bool(true) + +Notice: Object of class Bar could not be converted to double in %s on line %d +bool(false) + +Notice: Object of class Bar could not be converted to int in %s on line %d +bool(true) +Done diff --git a/Zend/tests/objects_002.phpt b/Zend/tests/objects_002.phpt new file mode 100644 index 000000000..87ba0fdc3 --- /dev/null +++ b/Zend/tests/objects_002.phpt @@ -0,0 +1,24 @@ +--TEST-- +method overloading with different method signature +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function foo() {} +} + +class test2 extends test { + function foo() {} +} + +class test3 extends test { + function foo($arg) {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d +Done diff --git a/Zend/tests/objects_003.phpt b/Zend/tests/objects_003.phpt new file mode 100644 index 000000000..1c254290f --- /dev/null +++ b/Zend/tests/objects_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +method overloading with different method signature +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function foo($arg) {} +} + +class test2 extends test { + function foo($arg) {} +} + +class test3 extends test { + function foo($arg, $arg2) {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d +Done diff --git a/Zend/tests/objects_004.phpt b/Zend/tests/objects_004.phpt new file mode 100644 index 000000000..35ab4775b --- /dev/null +++ b/Zend/tests/objects_004.phpt @@ -0,0 +1,24 @@ +--TEST-- +method overloading with different method signature +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function foo($arg) {} +} + +class test2 extends test { + function foo($arg) {} +} + +class test3 extends test { + function foo(&$arg) {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d +Done diff --git a/Zend/tests/objects_005.phpt b/Zend/tests/objects_005.phpt new file mode 100644 index 000000000..d583c9be9 --- /dev/null +++ b/Zend/tests/objects_005.phpt @@ -0,0 +1,24 @@ +--TEST-- +method overloading with different method signature +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function &foo() {} +} + +class test2 extends test { + function &foo() {} +} + +class test3 extends test { + function foo() {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d +Done diff --git a/Zend/tests/objects_006.phpt b/Zend/tests/objects_006.phpt new file mode 100644 index 000000000..fb2e28b3a --- /dev/null +++ b/Zend/tests/objects_006.phpt @@ -0,0 +1,24 @@ +--TEST-- +method overloading with different method signature +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function foo($arg, $arg2 = NULL) {} +} + +class test2 extends test { + function foo($arg, $arg2 = NULL) {} +} + +class test3 extends test { + function foo($arg, $arg2) {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d +Done diff --git a/Zend/tests/objects_007.phpt b/Zend/tests/objects_007.phpt new file mode 100644 index 000000000..2fce04a17 --- /dev/null +++ b/Zend/tests/objects_007.phpt @@ -0,0 +1,24 @@ +--TEST-- +method overloading with different method signature +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function foo($arg, &$arg2 = NULL) {} +} + +class test2 extends test { + function foo($arg, &$arg2 = NULL) {} +} + +class test3 extends test { + function foo($arg, &$arg2) {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d +Done diff --git a/Zend/tests/objects_008.phpt b/Zend/tests/objects_008.phpt new file mode 100644 index 000000000..b61d16786 --- /dev/null +++ b/Zend/tests/objects_008.phpt @@ -0,0 +1,24 @@ +--TEST-- +method overloading with different method signature +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function foo(Test $arg) {} +} + +class test2 extends test { + function foo(Test $arg) {} +} + +class test3 extends test { + function foo(Test3 $arg) {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d +Done diff --git a/Zend/tests/objects_009.phpt b/Zend/tests/objects_009.phpt new file mode 100644 index 000000000..5fad0046a --- /dev/null +++ b/Zend/tests/objects_009.phpt @@ -0,0 +1,24 @@ +--TEST-- +method overloading with different method signature +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function foo(Test $arg) {} +} + +class test2 extends test { + function foo(Test $arg) {} +} + +class test3 extends test { + function foo($arg) {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d +Done diff --git a/Zend/tests/objects_010.phpt b/Zend/tests/objects_010.phpt new file mode 100644 index 000000000..5d004629d --- /dev/null +++ b/Zend/tests/objects_010.phpt @@ -0,0 +1,19 @@ +--TEST-- +redefining constructor (__construct second) +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function test() { + } + function __construct() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Redefining already defined constructor for class test in %s on line %d +Done diff --git a/Zend/tests/objects_011.phpt b/Zend/tests/objects_011.phpt new file mode 100644 index 000000000..eb1fc0c1f --- /dev/null +++ b/Zend/tests/objects_011.phpt @@ -0,0 +1,19 @@ +--TEST-- +redefining constructor (__construct first) +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function __construct() { + } + function test() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Redefining already defined constructor for class test in %s on line %d +Done diff --git a/Zend/tests/objects_012.phpt b/Zend/tests/objects_012.phpt new file mode 100644 index 000000000..95cce3eca --- /dev/null +++ b/Zend/tests/objects_012.phpt @@ -0,0 +1,15 @@ +--TEST-- +implementing a class +--FILE-- +<?php + +class foo { +} + +interface bar extends foo { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: bar cannot implement foo - it is not an interface in %s on line %d diff --git a/Zend/tests/objects_013.phpt b/Zend/tests/objects_013.phpt new file mode 100644 index 000000000..3f7bea81a --- /dev/null +++ b/Zend/tests/objects_013.phpt @@ -0,0 +1,15 @@ +--TEST-- +implementing the same interface twice +--FILE-- +<?php + +interface foo { +} + +class bar implements foo, foo { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Class bar cannot implement previously implemented interface foo in %s on line %d diff --git a/Zend/tests/objects_014.phpt b/Zend/tests/objects_014.phpt new file mode 100644 index 000000000..c422b392e --- /dev/null +++ b/Zend/tests/objects_014.phpt @@ -0,0 +1,15 @@ +--TEST-- +extending the same interface twice +--FILE-- +<?php + +interface foo { +} + +interface bar extends foo, foo { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Class bar cannot implement previously implemented interface foo in %s on line %d diff --git a/Zend/tests/objects_015.phpt b/Zend/tests/objects_015.phpt new file mode 100755 index 000000000..a923ee0c4 --- /dev/null +++ b/Zend/tests/objects_015.phpt @@ -0,0 +1,26 @@ +--TEST-- +comparing objects with strings/NULL +--FILE-- +<?php + +$o=new stdClass; + +var_dump($o == ""); +var_dump($o != ""); +var_dump($o < ""); +var_dump("" < $o); +var_dump("" > $o); +var_dump($o != null); +var_dump(is_null($o)); + +?> +===DONE=== +--EXPECT-- +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +===DONE=== diff --git a/Zend/tests/offset_array.phpt b/Zend/tests/offset_array.phpt new file mode 100644 index 000000000..a7e2f21b1 --- /dev/null +++ b/Zend/tests/offset_array.phpt @@ -0,0 +1,47 @@ +--TEST-- +using different variables to access array offsets +--FILE-- +<?php + +$arr = array(1,2,3,4,5,6,7,8); + +var_dump($arr[1]); +var_dump($arr[0.0836]); +var_dump($arr[NULL]); +var_dump($arr["run away"]); + +var_dump($arr[TRUE]); +var_dump($arr[FALSE]); + +$fp = fopen(__FILE__, "r"); +var_dump($arr[$fp]); + +$obj = new stdClass; +var_dump($arr[$obj]); + +$arr1 = Array(1,2,3); +var_dump($arr[$arr1]); + +echo "Done\n"; +?> +--EXPECTF-- +int(2) +int(1) + +Notice: Undefined index: in %s on line %d +NULL + +Notice: Undefined index: run away in %s on line %d +NULL +int(2) +int(1) + +Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +int(%d) + +Warning: Illegal offset type in %s on line %d +NULL + +Warning: Illegal offset type in %s on line %d +NULL +Done diff --git a/Zend/tests/offset_bool.phpt b/Zend/tests/offset_bool.phpt new file mode 100644 index 000000000..9bf8a89da --- /dev/null +++ b/Zend/tests/offset_bool.phpt @@ -0,0 +1,37 @@ +--TEST-- +using different variables to access boolean offsets +--FILE-- +<?php + +$bool = TRUE; + +var_dump($bool[1]); +var_dump($bool[0.0836]); +var_dump($bool[NULL]); +var_dump($bool["run away"]); + +var_dump($bool[TRUE]); +var_dump($bool[FALSE]); + +$fp = fopen(__FILE__, "r"); +var_dump($bool[$fp]); + +$obj = new stdClass; +var_dump($bool[$obj]); + +$arr = Array(1,2,3); +var_dump($bool[$arr]); + +echo "Done\n"; +?> +--EXPECTF-- +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +Done diff --git a/Zend/tests/offset_long.phpt b/Zend/tests/offset_long.phpt new file mode 100644 index 000000000..c65a5ba3f --- /dev/null +++ b/Zend/tests/offset_long.phpt @@ -0,0 +1,37 @@ +--TEST-- +using different variables to access long offsets +--FILE-- +<?php + +$long = 1; + +var_dump($long[1]); +var_dump($long[0.0836]); +var_dump($long[NULL]); +var_dump($long["run away"]); + +var_dump($long[TRUE]); +var_dump($long[FALSE]); + +$fp = fopen(__FILE__, "r"); +var_dump($long[$fp]); + +$obj = new stdClass; +var_dump($long[$obj]); + +$arr = Array(1,2,3); +var_dump($long[$arr]); + +echo "Done\n"; +?> +--EXPECTF-- +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +Done diff --git a/Zend/tests/offset_null.phpt b/Zend/tests/offset_null.phpt new file mode 100644 index 000000000..9364f0a2e --- /dev/null +++ b/Zend/tests/offset_null.phpt @@ -0,0 +1,37 @@ +--TEST-- +using different variables to access null offsets +--FILE-- +<?php + +$null = NULL; + +var_dump($null[1]); +var_dump($null[0.0836]); +var_dump($null[NULL]); +var_dump($null["run away"]); + +var_dump($null[TRUE]); +var_dump($null[FALSE]); + +$fp = fopen(__FILE__, "r"); +var_dump($null[$fp]); + +$obj = new stdClass; +var_dump($null[$obj]); + +$arr = Array(1,2,3); +var_dump($null[$arr]); + +echo "Done\n"; +?> +--EXPECTF-- +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +Done diff --git a/Zend/tests/offset_object.phpt b/Zend/tests/offset_object.phpt new file mode 100644 index 000000000..b570fd2a2 --- /dev/null +++ b/Zend/tests/offset_object.phpt @@ -0,0 +1,11 @@ +--TEST-- +accessing object dimension +--FILE-- +<?php + +$object = new stdClass; +var_dump($object[1]); + +?> +--EXPECTF-- +Fatal error: Cannot use object of type stdClass as array in %s on line %d diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt new file mode 100644 index 000000000..63d8abe8d --- /dev/null +++ b/Zend/tests/offset_string.phpt @@ -0,0 +1,45 @@ +--TEST-- +using different variables to access string offsets +--FILE-- +<?php + +$str = "Sitting on a corner all alone, staring from the bottom of his soul"; + +var_dump($str[1]); +var_dump($str[0.0836]); +var_dump($str[NULL]); +var_dump($str["run away"]); + +var_dump($str[TRUE]); +var_dump($str[FALSE]); + +$fp = fopen(__FILE__, "r"); +var_dump($str[$fp]); + +$obj = new stdClass; +var_dump($str[$obj]); + +$arr = Array(1,2,3); +var_dump($str[$arr]); + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "i" +string(1) "S" +string(1) "S" +string(1) "S" +string(1) "i" +string(1) "S" + +Warning: Illegal offset type in %s on line %d +string(1) "%s" + +Warning: Illegal offset type in %s on line %d + +Notice: Object of class stdClass could not be converted to int in %s on line %d +string(1) "%s" + +Warning: Illegal offset type in %s on line %d +string(1) "i" +Done diff --git a/Zend/tests/strict_001.phpt b/Zend/tests/strict_001.phpt new file mode 100644 index 000000000..8070eb9fe --- /dev/null +++ b/Zend/tests/strict_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +using resource as array offset +--INI-- +error_reporting=8191 +--FILE-- +<?php + +$fp = fopen(__FILE__, 'r'); + +$array = array(1,2,3,4,5,6,7); + +var_dump($array[$fp]); + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +int(%d) +Done diff --git a/Zend/tests/strict_002.phpt b/Zend/tests/strict_002.phpt new file mode 100644 index 000000000..d8a5af2f4 --- /dev/null +++ b/Zend/tests/strict_002.phpt @@ -0,0 +1,27 @@ +--TEST-- +assigning static property as non static +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + static $foo = 1; +} + +$t = new test; +$t->foo = 5; + +$fp = fopen(__FILE__, 'r'); + +var_dump($t); + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Accessing static property test::$foo as non static in %s on line %d +object(test)#%d (1) { + ["foo"]=> + int(5) +} +Done |
