diff options
Diffstat (limited to 'Zend/tests')
1310 files changed, 42488 insertions, 0 deletions
diff --git a/Zend/tests/001.phpt b/Zend/tests/001.phpt new file mode 100644 index 0000000..78d982a --- /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 0000000..73c8d3e --- /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 0000000..81f70b8 --- /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 0000000..6beafe7 --- /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: strncmp() expects exactly 3 parameters, 2 given 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 0000000..00f320e --- /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: strcasecmp() expects exactly 2 parameters, 1 given 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 0000000..eedb849 --- /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: strncasecmp() expects exactly 3 parameters, 1 given 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 0000000..3fff2b8 --- /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: each() expects exactly 1 parameter, 0 given 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 0000000..4f58e80 --- /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: define() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: define() expects at least 2 parameters, 1 given in %s on line %d +NULL +bool(true) + +Warning: define() expects parameter 3 to be boolean, array given in %s on line %d +NULL + +Warning: define() expects parameter 1 to be string, array given in %s on line %d +NULL +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 0000000..f122b71 --- /dev/null +++ b/Zend/tests/009.phpt @@ -0,0 +1,48 @@ +--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) + +Warning: get_class() expects parameter 1 to be object, string given in %s on line %d +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 0000000..45e1832 --- /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 0000000..57c6214 --- /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: property_exists() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: property_exists() expects exactly 2 parameters, 1 given in %s on line %d +NULL +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +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(true) +bool(true) +Done diff --git a/Zend/tests/012.phpt b/Zend/tests/012.phpt new file mode 100644 index 0000000..b192bc1 --- /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 0000000..1fc4af7 --- /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 0000000..69c9bc0 --- /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 0000000..25995b7 --- /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: get_included_files() expects exactly 0 parameters, 2 given in %s on line %d +NULL +array(2) { + [0]=> + string(%d) "%s" + [1]=> + string(%d) "%s" +} + +Warning: get_included_files() expects exactly 0 parameters, 1 given 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 0000000..ffe1a4f --- /dev/null +++ b/Zend/tests/015.phpt @@ -0,0 +1,37 @@ +--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)); +var_dump(trigger_error("error", E_USER_DEPRECATED)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: trigger_error() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Notice: error in %s on line %d +bool(true) + +Warning: trigger_error() expects parameter 1 to be string, array given in %s on line %d +NULL + +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) + +Deprecated: 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 0000000..6ec507e --- /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/017.phpt b/Zend/tests/017.phpt new file mode 100644 index 0000000..03c1e73 --- /dev/null +++ b/Zend/tests/017.phpt @@ -0,0 +1,86 @@ +--TEST-- +builtin functions tests +--FILE-- +<?php + +var_dump(get_resource_type()); +var_dump(get_resource_type("")); +$fp = fopen(__FILE__, "r"); +var_dump(get_resource_type($fp)); +fclose($fp); +var_dump(get_resource_type($fp)); + +var_dump(gettype(get_loaded_extensions())); +var_dump(count(get_loaded_extensions())); +var_dump(gettype(get_loaded_extensions(true))); +var_dump(count(get_loaded_extensions(true))); +var_dump(get_loaded_extensions(true, true)); + +define("USER_CONSTANT", "test"); + +var_dump(get_defined_constants(true, true)); +var_dump(gettype(get_defined_constants(true))); +var_dump(gettype(get_defined_constants())); +var_dump(count(get_defined_constants())); + +function test () { +} + +var_dump(get_defined_functions(true)); +var_dump(gettype(get_defined_functions())); +var_dump(count(get_defined_functions())); + +var_dump(get_declared_interfaces(true)); +var_dump(gettype(get_declared_interfaces())); +var_dump(count(get_declared_interfaces())); + +var_dump(get_extension_funcs()); +var_dump(get_extension_funcs(true)); +var_dump(gettype(get_extension_funcs("standard"))); +var_dump(count(get_extension_funcs("standard"))); +var_dump(gettype(get_extension_funcs("zend"))); +var_dump(count(get_extension_funcs("zend"))); + + +echo "Done\n"; +?> +--EXPECTF-- +Warning: get_resource_type() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: get_resource_type() expects parameter 1 to be resource, string given in %s on line %d +NULL +string(6) "stream" +string(7) "Unknown" +string(5) "array" +int(%d) +string(5) "array" +int(%d) + +Warning: get_loaded_extensions() expects at most 1 parameter, 2 given in %s on line %d +NULL + +Warning: get_defined_constants() expects at most 1 parameter, 2 given in %s on line %d +NULL +string(5) "array" +string(5) "array" +int(%d) + +Warning: get_defined_functions() expects exactly 0 parameters, 1 given in %s on line %d +NULL +string(5) "array" +int(%d) + +Warning: get_declared_interfaces() expects exactly 0 parameters, 1 given in %s on line %d +NULL +string(5) "array" +int(%d) + +Warning: get_extension_funcs() expects exactly 1 parameter, 0 given in %s on line %d +NULL +bool(false) +string(5) "array" +int(%d) +string(5) "array" +int(%d) +Done diff --git a/Zend/tests/018.phpt b/Zend/tests/018.phpt new file mode 100644 index 0000000..9543cc4 --- /dev/null +++ b/Zend/tests/018.phpt @@ -0,0 +1,34 @@ +--TEST-- +constant() tests +--FILE-- +<?php + +var_dump(constant()); +var_dump(constant("", "")); +var_dump(constant("")); + +var_dump(constant(array())); + +define("TEST_CONST", 1); +var_dump(constant("TEST_CONST")); + +define("TEST_CONST2", "test"); +var_dump(constant("TEST_CONST2")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: constant() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: constant() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: constant(): Couldn't find constant in %s on line %d +NULL + +Warning: constant() expects parameter 1 to be string, array given in %s on line %d +NULL +int(1) +string(4) "test" +Done diff --git a/Zend/tests/019.phpt b/Zend/tests/019.phpt new file mode 100644 index 0000000..70093cd --- /dev/null +++ b/Zend/tests/019.phpt @@ -0,0 +1,1333 @@ +--TEST-- +Test unset(), empty() and isset() functions +--FILE-- +<?php +/* Prototype: void unset ( mixed $var [, mixed $var [, mixed $...]] ); + Description: unset() destroys the specified variables + + Prototype: bool empty( mixed $var ); + Description: Determine whether a variable is considered to be empty + + Prototype: bool isset ( mixed $var [, mixed $var [, $...]] ); + Description: Returns TRUE if var exists; FALSE otherwise +*/ + +echo "*** Testing unset(), empty() & isset() with scalar variables ***\n"; + +// testing scalar variables +$scalar_variables = array( + 0, + 1, + +1 + -1, + 0x55, + -0xFA, + 0123, + -0563, + 0.0, + 1e5, + 1E-5, + -1.5e5, + +5.6, + "", + '', + " ", + ' ', + "string", + "123", + "0", + "ture", + "FALSE", + "NULL", + "null", + true, + false, + TRUE, + FALSE +); + +$loop_counter = 1; +foreach ($scalar_variables as $scalar_var) { + $set_var = 10; // this variable to use with isset + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + + // checking with isset before unsetting, expected: bool(true) + var_dump( isset($scalar_var) ); + var_dump( isset($scalar_var, $set_var) ); + // checking if the var is empty, expected: bool(false) on most + // except "", 0, "0", NULL, FALSE + var_dump( empty($scalar_var) ); + + // destroy the variable using unset + unset( $scalar_var ); + // dump and see if its destroyed, expcted: NULL + var_dump( $scalar_var ); + + // check using isset to see if unset, expected: bool(false) + var_dump( isset($scalar_var) ); + var_dump( isset($scalar_var, $set_var) ); + + // empty to check if empty, expecting bool(true) + var_dump( empty($scalar_var) ); + + // isset() with two args, one arg only unset, expected: bool(false) + var_dump( isset($scalar_var, $set_var) ); + + // isset() with two args, both args already unset, expected: bool(false); + unset($set_var); + var_dump( isset($scalar_var, $set_var) ); +} + +echo "\n*** Testing unset(), empty() & isset() with arrays ***\n"; +$array_variables = array( + array(), + array(NULL), + array(0), + array("0"), + array(""), + array(1,2,3,4), + array(1.4,2.5,5.6), + array(1 => "One", 2 => "two"), + array("Name" => "Jack", "Age" => "30"), + array(1,2, "One" => "1", 2 => "two", ""=>"empty", "" => '') +); + +$outer_loop_counter = 1; +foreach ($array_variables as $array_var) { + echo "--- Outerloop Iteration $outer_loop_counter ---\n"; + + // check the isset and unset on non existing key + $var = 1; // a var which is defined + // try to unset the element which is non-existent + unset($array_var['non_existent']); + // check using isset() & empty() on a non_existent element in the array + var_dump( isset($array_var['non_existent']) ); + var_dump( isset($array_var['non_existent'], $var) ); + var_dump( isset($array_var['non_existent'], $array_var['none']) ); + var_dump( empty($array_var['non_existent']) ); + + // testing empty and isset on arrays + var_dump( empty($array_var) ); // expecting bool(false), except: array(), which is considered empty + var_dump( isset($array_var) ); // expecting bool(true), except: array(), which is not set + + // get the keys of the $array_var + $keys = array_keys($array_var); + // unset each element in the array and see the working of unset, isset & empty + $inner_loop_counter = 1; + foreach ($keys as $key_value) { + echo "-- Innerloop Iteration $inner_loop_counter of Outerloop Iteration $outer_loop_counter --\n"; + $inner_loop_counter++; + + // unset the element + unset($array_var[$key_value]); + // dump the array after element was unset + var_dump($array_var); + // check using isset for the element that was unset + var_dump( isset($array_var[$key_val]) ); // expected: bool(false) + // calling isset with more args + var_dump( isset($array_var[$key_val], $array_var) ); //expected: bool(false) + + // calling empty, expected bool(true) + var_dump( empty($array_var[$key_val]) ); + + // dump the array to see that that array did not get modified + // because of using isset, empty and unset on its element + var_dump($array_var); + } + + $outer_loop_counter++; + + // unset the whole array + unset($array_var); + // dump the array to see its unset + var_dump($array_var); + // use isset to see that array is not set + var_dump( isset($array_var) ); //expected: bool(false) + var_dump( isset($array_var, $array_var[$key_val]) ); // expected: bool(false) + + // empty() to see if the array is empty + var_dump( empty($array_var) ); // expected: bool(true) +} + +echo "\n*** Testing unset(), emtpy() & isset() with resource variables ***\n"; +$fp = fopen(__FILE__, "r"); +$dfp = opendir( dirname(__FILE__) ); +$resources = array ( + $fp, + $dfp +); +$loop_counter = 1; +foreach ($resources as $resource) { + $temp_var = 10; + echo "-- Iteration $loop_counter --\n"; $loop_counter++; + //dump the resource first + var_dump($resource); + + // check using isset() and empty() + var_dump( isset($resource) ); // expected: bool(true) + var_dump( empty($resource) ); // expected: bool(false) + // call isset() with two args, both set + var_dump( isset($resource, $temp_var) ); // expected: bool(true) + + // dump the resource to see using isset() and empty () had no effect on it + var_dump($resource); + + // unset the resource + unset($resource); + // check using isset() and empty() + var_dump( isset($resource) ); // expected: bool(flase) + var_dump( empty($resource) ); // expected: bool(true) + // call isset() with two args, but one set + var_dump( isset($resource, $temp_var) ); // expected: bool(false) + // uset the temp_var + unset($temp_var); + // now the isset() with both the args as unset + var_dump( isset($resource, $temp_var) ); // expected: bool(false); + + // dump the resource to see if there any effect on it + var_dump($resource); +} +// unset and dump the array containing all the resources to see that +// unset works correctly +unset($resources); +var_dump($resources); +var_dump( isset($resources) ); //expected: bool(false) +var_dump( empty($resources) ); // expected: bool(true) + +echo "\n*** Testing unset(), empty() & isset() with objects ***\n"; +class Point +{ + var $x; + var $y; + var $lable; + + function Point($x, $y) { + $this->x = $x; + $this->y = $y; + } + + function setLable($lable) { + $this->lable = $lable; + } + function testPoint() { + echo "\nPoint::testPoint() called\n"; + } +} +$point1 = new Point(30,40); + +// use unset/empty/isset to check the object +var_dump($point1); // dump the object + +// check the object and member that is not set +var_dump( isset($point1) ); // expected: bool(true) +var_dump( empty($point1) ); // expected: bool(false) +var_dump( isset($point1->$lable) ); //expected: bool(flase) +var_dump( empty($point1->$lable) ); //expected: bool(true) + +//set the member variable lable and check +$point1->setLable("Point1"); +var_dump( isset($point1->$lable) ); //expected: bool(true) +var_dump( empty($point1->$lable) ); //expected: bool(false) + +// dump the object to see that obj was not harmed +// because of the usage of the isset & empty +var_dump($point1); + +//unset a member and check +unset($point1->x); +// dump the point to see that variable was unset +var_dump($point1); +var_dump( isset($point1->x) ); // expected: bool(false) +var_dump( empty($point1->x) ); // expected: bool(true) + +// unset all members and check +unset($point1->y); +unset($point1->lable); +// dump the objec to check that all variables are unset +var_dump($point1); +var_dump( isset($point1) ); // expected: bool(ture) +var_dump( empty($point1) ); // expected: bool(false) + +//unset the object and check +unset($point1); +var_dump( isset($point1) ); // expected: bool(false) +var_dump( empty($point1) ); // expected: bool(true) +// dump to see that object is unset +var_dump($point1); + +// try isset/unset/empty on a member function +$point2 = new Point(5,6); +var_dump( isset($point2->testPoint) ); +var_dump( empty($point2->testPoint) ); +unset($point2->testPoint); +var_dump( isset($point2->testPoint) ); +var_dump( empty($point2->testPoint) ); + +// use get_class_methods to see effect if any +var_dump( get_class_methods($point2) ); +// dump the object to see the effect, none expected +var_dump($point2); + +/* testing variation in operation for isset(), empty() & unset(). +Note: Most of the variation for function unset() is testing by a + set of testcases named "Zend/tests/unset_cv??.phpt", only + variation not tested are attempted here */ + +echo "\n*** Testing possible variation in operation for isset(), empty() & unset() ***\n"; +/* unset() variation1: checking unset on static variable inside a function. + * unset() destroys the variable only in the context of the rest of a function + * Following calls will restore the previous value of a variable. + */ +echo "\n** Testing unset() variation 1: unset on static variable inside a function **\n"; +function test_unset1() { + static $static_var; + + // increment the value of the static. this change is in function context + $static_var ++; + + echo "value of static_var before unset: $static_var\n"; + // check using isset and empty + var_dump( isset($static_var) ); + var_dump( empty($static_var) ); + + // unset the static var + unset($static_var); + echo "value of static_var after unset: $static_var\n"; + // check using isset and empty + var_dump( isset($static_var) ); + var_dump( empty($static_var) ); + + // assign a value to static var + $static_var = 20; + echo "value of static_var after new assignment: $static_var\n"; +} +// call the functiont +test_unset1(); +test_unset1(); +test_unset1(); + + +echo "\n** Testing unset() variation 2: unset on a variable passed by ref. inside of a function **\n"; +/* unset() variation2: Pass by reference + * If a variable that is PASSED BY REFERENCE is unset() inside of a function, + * only the local variable is destroyed. The variable in the calling environment + * will retain the same value as before unset() was called. + */ +function test_unset2( &$ref_val ) { + // unset the variable passed + unset($ref_val); + // check using isset and empty to confirm + var_dump( isset($ref_val) ); + var_dump( empty($ref_val) ); + + // set the value ot a new one + $ref_val = "new value by ref"; +} + +$value = "value"; +var_dump($value); +test_unset2($value); +var_dump($value); + + +echo "\n** Testing unset() variation 3: unset on a global variable inside of a function **\n"; +/* unset() variation2: unset on a global variable inside a function + * If a globalized variable is unset() inside of a function, only the + * local variable is destroyed. The variable in the calling environment + * will retain the same value as before unset() was called. + */ +$global_var = 10; + +function test_unset3() { + global $global_var; + + // check the $global_var using isset and empty + var_dump( isset($global_var) ); + var_dump( empty($global_var) ); + + // unset the global var + unset($global_var); + + // check the $global_var using isset and empty + var_dump( isset($global_var) ); + var_dump( empty($global_var) ); +} + +var_dump($global_var); +test_unset3(); +var_dump($global_var); + +//Note: No error conditions relating to passing arugments can be tested +// because these are not functions but statements, it will result in syntax error. +?> +===DONE=== +--EXPECTF-- +*** Testing unset(), empty() & isset() with scalar variables *** +-- Iteration 1 -- +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 2 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 3 -- +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 4 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 5 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 6 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 7 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 8 -- +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 9 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 10 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 11 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 12 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 13 -- +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 14 -- +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 15 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 16 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 17 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 18 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 19 -- +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 20 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 21 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 22 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 23 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 24 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 25 -- +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 26 -- +bool(true) +bool(true) +bool(false) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 27 -- +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: scalar_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) + +*** Testing unset(), empty() & isset() with arrays *** +--- Outerloop Iteration 1 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 2 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 2 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 3 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 3 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 4 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 4 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 5 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 5 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 6 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 6 -- +array(3) { + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(3) { + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) +} +-- Innerloop Iteration 2 of Outerloop Iteration 6 -- +array(2) { + [2]=> + int(3) + [3]=> + int(4) +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(2) { + [2]=> + int(3) + [3]=> + int(4) +} +-- Innerloop Iteration 3 of Outerloop Iteration 6 -- +array(1) { + [3]=> + int(4) +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(1) { + [3]=> + int(4) +} +-- Innerloop Iteration 4 of Outerloop Iteration 6 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 7 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 7 -- +array(2) { + [1]=> + float(2.5) + [2]=> + float(5.6) +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(2) { + [1]=> + float(2.5) + [2]=> + float(5.6) +} +-- Innerloop Iteration 2 of Outerloop Iteration 7 -- +array(1) { + [2]=> + float(5.6) +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(1) { + [2]=> + float(5.6) +} +-- Innerloop Iteration 3 of Outerloop Iteration 7 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 8 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 8 -- +array(1) { + [2]=> + string(3) "two" +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(1) { + [2]=> + string(3) "two" +} +-- Innerloop Iteration 2 of Outerloop Iteration 8 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 9 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 9 -- +array(1) { + ["Age"]=> + string(2) "30" +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(1) { + ["Age"]=> + string(2) "30" +} +-- Innerloop Iteration 2 of Outerloop Iteration 9 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) +--- Outerloop Iteration 10 --- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +-- Innerloop Iteration 1 of Outerloop Iteration 10 -- +array(4) { + [1]=> + int(2) + ["One"]=> + string(1) "1" + [2]=> + string(3) "two" + [""]=> + string(0) "" +} + +Notice: Undefined variable: key_val in %s on line %d +bool(true) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(4) { + [1]=> + int(2) + ["One"]=> + string(1) "1" + [2]=> + string(3) "two" + [""]=> + string(0) "" +} +-- Innerloop Iteration 2 of Outerloop Iteration 10 -- +array(3) { + ["One"]=> + string(1) "1" + [2]=> + string(3) "two" + [""]=> + string(0) "" +} + +Notice: Undefined variable: key_val in %s on line %d +bool(true) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(3) { + ["One"]=> + string(1) "1" + [2]=> + string(3) "two" + [""]=> + string(0) "" +} +-- Innerloop Iteration 3 of Outerloop Iteration 10 -- +array(2) { + [2]=> + string(3) "two" + [""]=> + string(0) "" +} + +Notice: Undefined variable: key_val in %s on line %d +bool(true) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(2) { + [2]=> + string(3) "two" + [""]=> + string(0) "" +} +-- Innerloop Iteration 4 of Outerloop Iteration 10 -- +array(1) { + [""]=> + string(0) "" +} + +Notice: Undefined variable: key_val in %s on line %d +bool(true) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(1) { + [""]=> + string(0) "" +} +-- Innerloop Iteration 5 of Outerloop Iteration 10 -- +array(0) { +} + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(false) + +Notice: Undefined variable: key_val in %s on line %d +bool(true) +array(0) { +} + +Notice: Undefined variable: array_var in %s on line %d +NULL +bool(false) +bool(false) +bool(true) + +*** Testing unset(), emtpy() & isset() with resource variables *** +-- Iteration 1 -- +resource(%d) of type (stream) +bool(true) +bool(false) +bool(true) +resource(%d) of type (stream) +bool(false) +bool(true) +bool(false) +bool(false) + +Notice: Undefined variable: resource in %s on line %d +NULL +-- Iteration 2 -- +resource(%d) of type (stream) +bool(true) +bool(false) +bool(true) +resource(%d) of type (stream) +bool(false) +bool(true) +bool(false) +bool(false) + +Notice: Undefined variable: resource in %s on line %d +NULL + +Notice: Undefined variable: resources in %s on line %d +NULL +bool(false) +bool(true) + +*** Testing unset(), empty() & isset() with objects *** +object(Point)#%d (3) { + ["x"]=> + int(30) + ["y"]=> + int(40) + ["lable"]=> + NULL +} +bool(true) +bool(false) + +Notice: Undefined variable: lable in %s on line %d +bool(false) + +Notice: Undefined variable: lable in %s on line %d +bool(true) + +Notice: Undefined variable: lable in %s on line %d +bool(false) + +Notice: Undefined variable: lable in %s on line %d +bool(true) +object(Point)#%d (3) { + ["x"]=> + int(30) + ["y"]=> + int(40) + ["lable"]=> + string(6) "Point1" +} +object(Point)#%d (2) { + ["y"]=> + int(40) + ["lable"]=> + string(6) "Point1" +} +bool(false) +bool(true) +object(Point)#%d (0) { +} +bool(true) +bool(false) +bool(false) +bool(true) + +Notice: Undefined variable: point1 in %s on line %d +NULL +bool(false) +bool(true) +bool(false) +bool(true) +array(3) { + [0]=> + string(5) "Point" + [1]=> + string(8) "setLable" + [2]=> + string(9) "testPoint" +} +object(Point)#%d (3) { + ["x"]=> + int(5) + ["y"]=> + int(6) + ["lable"]=> + NULL +} + +*** Testing possible variation in operation for isset(), empty() & unset() *** + +** Testing unset() variation 1: unset on static variable inside a function ** +value of static_var before unset: 1 +bool(true) +bool(false) + +Notice: Undefined variable: static_var in %s on line %d +value of static_var after unset: +bool(false) +bool(true) +value of static_var after new assignment: 20 +value of static_var before unset: 2 +bool(true) +bool(false) + +Notice: Undefined variable: static_var in %s on line %d +value of static_var after unset: +bool(false) +bool(true) +value of static_var after new assignment: 20 +value of static_var before unset: 3 +bool(true) +bool(false) + +Notice: Undefined variable: static_var in %s on line %d +value of static_var after unset: +bool(false) +bool(true) +value of static_var after new assignment: 20 + +** Testing unset() variation 2: unset on a variable passed by ref. inside of a function ** +string(5) "value" +bool(false) +bool(true) +string(5) "value" + +** Testing unset() variation 3: unset on a global variable inside of a function ** +int(10) +bool(true) +bool(false) +bool(false) +bool(true) +int(10) +===DONE=== diff --git a/Zend/tests/020.phpt b/Zend/tests/020.phpt new file mode 100644 index 0000000..73a3a17 --- /dev/null +++ b/Zend/tests/020.phpt @@ -0,0 +1,34 @@ +--TEST-- +func_get_arg() invalid usage +--FILE-- +<?php + +var_dump(func_get_arg(1,2,3)); +var_dump(func_get_arg(1)); +var_dump(func_get_arg()); + +function bar() { + var_dump(func_get_arg(1)); +} + +function foo() { + bar(func_get_arg(1)); +} + +foo(1,2); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: func_get_arg() expects exactly 1 parameter, 3 given in %s on line %d +NULL + +Warning: func_get_arg(): Called from the global scope - no function context in %s on line %d +bool(false) + +Warning: func_get_arg() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d +bool(false) +Done diff --git a/Zend/tests/021.phpt b/Zend/tests/021.phpt new file mode 100644 index 0000000..a40a411 --- /dev/null +++ b/Zend/tests/021.phpt @@ -0,0 +1,37 @@ +--TEST-- +?: operator +--FILE-- +<?php +var_dump(true ?: false); +var_dump(false ?: true); +var_dump(23 ?: 42); +var_dump(0 ?: "bar"); + +$a = 23; +$b = 0; +$c = ""; +$d = 23.5; + +var_dump($a ?: $b); +var_dump($c ?: $d); + +var_dump(1 ?: print(2)); + +$e = array(); + +$e['e'] = 'e'; +$e['e'] = $e['e'] ?: 'e'; +print_r($e); +?> +--EXPECT-- +bool(true) +bool(true) +int(23) +string(3) "bar" +int(23) +float(23.5) +int(1) +Array +( + [e] => e +) diff --git a/Zend/tests/022.phpt b/Zend/tests/022.phpt new file mode 100644 index 0000000..1226e27 --- /dev/null +++ b/Zend/tests/022.phpt @@ -0,0 +1,24 @@ +--TEST-- +Implementating abstracting methods and optional parameters +--FILE-- +<?php + +abstract class Base +{ + abstract function someMethod($param); +} + +class Ext extends Base +{ + function someMethod($param = "default") + { + echo $param, "\n"; + } +} + +$a = new Ext(); +$a->someMethod("foo"); +$a->someMethod(); +--EXPECT-- +foo +default diff --git a/Zend/tests/023.phpt b/Zend/tests/023.phpt new file mode 100644 index 0000000..6f975c6 --- /dev/null +++ b/Zend/tests/023.phpt @@ -0,0 +1,45 @@ +--TEST-- +Testing variable variables as function name +--FILE-- +<?php + +$a = 'ucfirst'; +$b = 'a'; +print $$b('test'); +print "\n"; + + +class bar { + public function a() { + return "bar!"; + } +} + +class foo { + public function test() { + print "foo!\n"; + return new bar; + } +} + +function test() { + return new foo; +} + +$a = 'test'; +$b = 'a'; +var_dump($$b()->$$b()->$b()); + + +$a = 'strtoupper'; +$b = 'a'; +$c = 'b'; +$d = 'c'; +var_dump($$$$d('foo')); + +?> +--EXPECT-- +Test +foo! +string(4) "bar!" +string(3) "FOO" diff --git a/Zend/tests/024.phpt b/Zend/tests/024.phpt new file mode 100644 index 0000000..ff35a5c --- /dev/null +++ b/Zend/tests/024.phpt @@ -0,0 +1,51 @@ +--TEST-- +Testing operations with undefined variable +--FILE-- +<?php + +var_dump($a[1]); +var_dump($a[$c]); +var_dump($a + 1); +var_dump($a + $b); +var_dump($a++); +var_dump(++$b); +var_dump($a->$b); +var_dump($a->$b); +var_dump($a->$b->$c[1]); + +?> +--EXPECTF-- +Notice: Undefined variable: a in %s on line %d +NULL + +Notice: Undefined variable: %s in %s on line %d + +Notice: Undefined variable: %s in %s on line %d +NULL + +Notice: Undefined variable: a in %s on line %d +int(1) + +Notice: Undefined variable: %s in %s on line %d + +Notice: Undefined variable: %s in %s on line %d +int(0) + +Notice: Undefined variable: a in %s on line %d +NULL + +Notice: Undefined variable: b in %s on line %d +int(1) + +Notice: Trying to get property of non-object in %s on line %d +NULL + +Notice: Trying to get property of non-object in %s on line %d +NULL + +Notice: Undefined variable: c in %s on line %d + +Notice: Trying to get property of non-object in %s on line %d + +Notice: Trying to get property of non-object in %s on line %d +NULL diff --git a/Zend/tests/025.phpt b/Zend/tests/025.phpt new file mode 100644 index 0000000..24e5520 --- /dev/null +++ b/Zend/tests/025.phpt @@ -0,0 +1,32 @@ +--TEST-- +Testing dynamic calls +--FILE-- +<?php + +class foo { + static public function a() { + print "ok\n"; + } +} + +$a = 'a'; +$b = 'a'; + +$class = 'foo'; + +foo::a(); +foo::$a(); +foo::$$b(); + +$class::a(); +$class::$a(); +$class::$$b(); + +?> +--EXPECT-- +ok +ok +ok +ok +ok +ok diff --git a/Zend/tests/026.phpt b/Zend/tests/026.phpt new file mode 100644 index 0000000..5fa0e16 --- /dev/null +++ b/Zend/tests/026.phpt @@ -0,0 +1,25 @@ +--TEST-- +Trying assign value to property when an object is not returned in a function +--FILE-- +<?php + +class foo { + public function a() { + } +} + +$test = new foo; + +$test->a()->a; +print "ok\n"; + +$test->a()->a = 1; +print "ok\n"; + +?> +--EXPECTF-- +Notice: Trying to get property of non-object in %s on line %d +ok + +Warning: Creating default object from empty value in %s on line %d +ok diff --git a/Zend/tests/027.phpt b/Zend/tests/027.phpt new file mode 100644 index 0000000..a862d68 --- /dev/null +++ b/Zend/tests/027.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing dynamic calls using variable variables with curly syntax +--FILE-- +<?php + +$a = 'b'; +$b = 'c'; +$c = 'strtoupper'; + +var_dump(${${$a}}('foo') == 'FOO'); + +$a = 'b'; +$b = 'c'; +$c = 'strtoupper'; +$strtoupper = 'strtolower'; + +var_dump(${${++$a}}('FOO') == 'foo'); + +?> +--EXPECT-- +bool(true) +bool(true) diff --git a/Zend/tests/028.phpt b/Zend/tests/028.phpt new file mode 100644 index 0000000..2c58a87 --- /dev/null +++ b/Zend/tests/028.phpt @@ -0,0 +1,23 @@ +--TEST-- +Testing function call through of array item +--FILE-- +<?php + +$arr = array('strtoupper', 'strtolower'); + +$k = 0; + +var_dump($arr[0]('foo') == 'FOO'); +var_dump($arr[$k]('foo') == 'FOO'); +var_dump($arr[++$k]('FOO') == 'foo'); +var_dump($arr[++$k]('FOO') == 'foo'); + +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) + +Notice: Undefined offset: 2 in %s on line %d + +Fatal error: Function name must be a string in %s on line %d diff --git a/Zend/tests/029.phpt b/Zend/tests/029.phpt new file mode 100644 index 0000000..8ef56fa --- /dev/null +++ b/Zend/tests/029.phpt @@ -0,0 +1,51 @@ +--TEST-- +Testing assign to property of an object in an array +--FILE-- +<?php + +$arr = array(new stdClass); + +$arr[0]->a = clone $arr[0]; +var_dump($arr); + +$arr[0]->b = new $arr[0]; +var_dump($arr); + +$arr[0]->c = $arr[0]->a; +var_dump($arr); + +?> +--EXPECT-- +array(1) { + [0]=> + object(stdClass)#1 (1) { + ["a"]=> + object(stdClass)#2 (0) { + } + } +} +array(1) { + [0]=> + object(stdClass)#1 (2) { + ["a"]=> + object(stdClass)#2 (0) { + } + ["b"]=> + object(stdClass)#3 (0) { + } + } +} +array(1) { + [0]=> + object(stdClass)#1 (3) { + ["a"]=> + object(stdClass)#2 (0) { + } + ["b"]=> + object(stdClass)#3 (0) { + } + ["c"]=> + object(stdClass)#2 (0) { + } + } +} diff --git a/Zend/tests/030.phpt b/Zend/tests/030.phpt new file mode 100644 index 0000000..8afcb66 --- /dev/null +++ b/Zend/tests/030.phpt @@ -0,0 +1,70 @@ +--TEST-- +Overriding $this in catch and checking the object properties later. +--FILE-- +<?php + +class foo { + public $test = 0; + private $test_2 = 1; + protected $test_3 = 2; + + public function bar() { + try { + throw new Exception('foo'); + } catch (Exception $this) { + var_dump($this); + } + + $this->baz(); + } + + public function baz() { + foreach ($this as $k => $v) { + printf("'%s' => '%s'\n", $k, $v); + } + print "ok\n"; + } +} + +$test = new foo; +$test->bar(); + +?> +--EXPECTF-- +object(Exception)#%d (7) { + ["message":protected]=> + string(3) "foo" + ["string":"Exception":private]=> + string(0) "" + ["code":protected]=> + int(0) + ["file":protected]=> + string(%d) "%s030.php" + ["line":protected]=> + int(%d) + ["trace":"Exception":private]=> + array(1) { + [0]=> + array(6) { + ["file"]=> + string(%d) "%s030.php" + ["line"]=> + int(%d) + ["function"]=> + string(3) "bar" + ["class"]=> + string(3) "foo" + ["type"]=> + string(2) "->" + ["args"]=> + array(0) { + } + } + } + ["previous":"Exception":private]=> + NULL +} +'test' => '0' +'test_2' => '1' +'test_3' => '2' +ok diff --git a/Zend/tests/031.phpt b/Zend/tests/031.phpt new file mode 100644 index 0000000..8db52a5 --- /dev/null +++ b/Zend/tests/031.phpt @@ -0,0 +1,11 @@ +--TEST-- +Testing array with '[]' passed as argument by value +--FILE-- +<?php + +function test($var) { } +test($arr[]); + +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s on line %d diff --git a/Zend/tests/032.phpt b/Zend/tests/032.phpt new file mode 100644 index 0000000..8f7f994 --- /dev/null +++ b/Zend/tests/032.phpt @@ -0,0 +1,13 @@ +--TEST-- +Testing array with '[]' passed as argument by reference +--FILE-- +<?php + +function test(&$var) { } +test($arr[]); + +print "ok!\n"; + +?> +--EXPECT-- +ok! diff --git a/Zend/tests/033.phpt b/Zend/tests/033.phpt new file mode 100644 index 0000000..17319e0 --- /dev/null +++ b/Zend/tests/033.phpt @@ -0,0 +1,31 @@ +--TEST-- +Using undefined multidimensional array +--FILE-- +<?php + +$arr[1][2][3][4][5]; + +echo $arr[1][2][3][4][5]; + +$arr[1][2][3][4][5]->foo; + +$arr[1][2][3][4][5]->foo = 1; + +$arr[][] = 2; + +$arr[][]->bar = 2; + +?> +--EXPECTF-- + +Notice: Undefined variable: arr in %s on line %d + +Notice: Undefined variable: arr in %s on line %d + +Notice: Undefined variable: arr in %s on line %d + +Notice: Trying to get property of non-object in %s on line %d + +Warning: Creating default object from empty value in %s on line %d + +Warning: Creating default object from empty value in %s on line %d diff --git a/Zend/tests/034.phpt b/Zend/tests/034.phpt new file mode 100644 index 0000000..6e46f26 --- /dev/null +++ b/Zend/tests/034.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing multiples 'default:' in switch +--FILE-- +<?php + +switch (1) { + case 2: + print 'foo'; + break; + case 3: + print 'bar'; + break; + default: + print 1; + break; + default: + print 2; + break; + default: + print 3; + break; +} + +?> +--EXPECT-- +3 diff --git a/Zend/tests/035.phpt b/Zend/tests/035.phpt new file mode 100644 index 0000000..75df786 --- /dev/null +++ b/Zend/tests/035.phpt @@ -0,0 +1,18 @@ +--TEST-- +Using 'static' and 'global' in global scope +--FILE-- +<?php + +static $var, $var, $var = -1; +var_dump($var); + +global $var, $var, $var; +var_dump($var); + +var_dump($GLOBALS['var']); + +?> +--EXPECT-- +int(-1) +int(-1) +int(-1) diff --git a/Zend/tests/036.phpt b/Zend/tests/036.phpt new file mode 100644 index 0000000..6feb23f --- /dev/null +++ b/Zend/tests/036.phpt @@ -0,0 +1,13 @@ +--TEST-- +Trying to use lambda in array offset +--FILE-- +<?php + +$test[function(){}] = 1; +$a{function() { }} = 1; + +?> +--EXPECTF-- +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d diff --git a/Zend/tests/037.phpt b/Zend/tests/037.phpt new file mode 100644 index 0000000..d7057b4 --- /dev/null +++ b/Zend/tests/037.phpt @@ -0,0 +1,19 @@ +--TEST-- +Trying to access inexistent static property of Closure +--FILE-- +<?php + +namespace closure; + +class closure { static $x = 1;} + +$x = __NAMESPACE__; +var_dump(closure::$x); + +var_dump($x::$x); + +?> +--EXPECTF-- +int(1) + +Fatal error: Access to undeclared static property: Closure::$x in %s on line %d diff --git a/Zend/tests/038.phpt b/Zend/tests/038.phpt new file mode 100644 index 0000000..963e73f --- /dev/null +++ b/Zend/tests/038.phpt @@ -0,0 +1,12 @@ +--TEST-- +Trying to use lambda as array key +--FILE-- +<?php + +var_dump(array(function() { } => 1)); + +?> +--EXPECTF-- +Warning: Illegal offset type in %s on line %d +array(0) { +} diff --git a/Zend/tests/abstract-static.phpt b/Zend/tests/abstract-static.phpt new file mode 100644 index 0000000..c4ab8f2 --- /dev/null +++ b/Zend/tests/abstract-static.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test for abstract static classes +--FILE-- +<?php +abstract class TestClass +{ + abstract static public function getName(); +} +?> +===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/access_modifiers_001.phpt b/Zend/tests/access_modifiers_001.phpt new file mode 100644 index 0000000..989b926 --- /dev/null +++ b/Zend/tests/access_modifiers_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +using multiple access modifiers (methods) +--FILE-- +<?php + +class test { + static public public static final public final function foo() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple access type modifiers are not allowed in %s on line %d diff --git a/Zend/tests/access_modifiers_002.phpt b/Zend/tests/access_modifiers_002.phpt new file mode 100644 index 0000000..cc5df30 --- /dev/null +++ b/Zend/tests/access_modifiers_002.phpt @@ -0,0 +1,13 @@ +--TEST-- +using multiple access modifiers (attributes) +--FILE-- +<?php + +class test { + static public public static final public final $var; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple access type modifiers are not allowed in %s on line %d diff --git a/Zend/tests/access_modifiers_003.phpt b/Zend/tests/access_modifiers_003.phpt new file mode 100644 index 0000000..dc21278 --- /dev/null +++ b/Zend/tests/access_modifiers_003.phpt @@ -0,0 +1,13 @@ +--TEST-- +using multiple access modifiers (classes) +--FILE-- +<?php + +final final class test { + function foo() {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Parse error: %s error,%sexpecting %s in %s on line %d diff --git a/Zend/tests/access_modifiers_004.phpt b/Zend/tests/access_modifiers_004.phpt new file mode 100644 index 0000000..c023d2c --- /dev/null +++ b/Zend/tests/access_modifiers_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +using multiple access modifiers (abstract methods) +--FILE-- +<?php + +class test { + abstract abstract function foo() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple abstract modifiers are not allowed in %s on line %d diff --git a/Zend/tests/access_modifiers_005.phpt b/Zend/tests/access_modifiers_005.phpt new file mode 100644 index 0000000..b32394d --- /dev/null +++ b/Zend/tests/access_modifiers_005.phpt @@ -0,0 +1,14 @@ +--TEST-- +using multiple access modifiers (final methods) +--FILE-- +<?php + +class test { + final final function foo() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple final modifiers are not allowed in %s on line %d diff --git a/Zend/tests/access_modifiers_006.phpt b/Zend/tests/access_modifiers_006.phpt new file mode 100644 index 0000000..293fc1c --- /dev/null +++ b/Zend/tests/access_modifiers_006.phpt @@ -0,0 +1,14 @@ +--TEST-- +using multiple access modifiers (static methods) +--FILE-- +<?php + +class test { + static static function foo() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple static modifiers are not allowed in %s on line %d diff --git a/Zend/tests/access_modifiers_007.phpt b/Zend/tests/access_modifiers_007.phpt new file mode 100644 index 0000000..26779e6 --- /dev/null +++ b/Zend/tests/access_modifiers_007.phpt @@ -0,0 +1,13 @@ +--TEST-- +abstract final methods errmsg +--FILE-- +<?php + +class test { + final abstract function foo(); +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use the final modifier on an abstract class member in %s on line %d diff --git a/Zend/tests/access_modifiers_008.phpt b/Zend/tests/access_modifiers_008.phpt new file mode 100644 index 0000000..67886cf --- /dev/null +++ b/Zend/tests/access_modifiers_008.phpt @@ -0,0 +1,21 @@ +--TEST-- +Inconsistencies when accessing protected members +--XFAIL-- +Discussion: http://marc.info/?l=php-internals&m=120221184420957&w=2 +--FILE-- +<?php + +class A { + static protected function f() {return 'A::f()';} +} +class B1 extends A { + static protected function f() {return 'B1::f()';} +} +class B2 extends A { + static public function test() {echo B1::f();} +} +B2::test(); + +?> +--EXPECTF-- +Fatal error: Call to protected method B1::f() from context 'B2' in %s on line %d diff --git a/Zend/tests/access_modifiers_009.phpt b/Zend/tests/access_modifiers_009.phpt new file mode 100644 index 0000000..cb01fa1 --- /dev/null +++ b/Zend/tests/access_modifiers_009.phpt @@ -0,0 +1,26 @@ +--TEST-- +Inconsistencies when accessing protected members - 2 +--XFAIL-- +Discussion: http://marc.info/?l=php-internals&m=120221184420957&w=2 +--FILE-- +<?php + +class A { + static protected function f() {return 'A::f()';} +} +class B1 extends A { + static protected function f() {return 'B1::f()';} +} +class B2 extends A { + static public function test() { + var_dump(is_callable('B1::f')); + B1::f(); + } +} +B2::test(); + +?> +--EXPECTF-- +bool(false) + +Fatal error: Call to protected method B1::f() from context 'B2' in %s on line %d diff --git a/Zend/tests/access_modifiers_010.phpt b/Zend/tests/access_modifiers_010.phpt new file mode 100644 index 0000000..637ea36 --- /dev/null +++ b/Zend/tests/access_modifiers_010.phpt @@ -0,0 +1,31 @@ +--TEST-- +Testing visibility of methods +--FILE-- +<?php + +class d { + private function test2() { + print "Bar\n"; + } +} + +abstract class a extends d { + public function test() { + $this->test2(); + } +} + +abstract class b extends a { +} + +class c extends b { + public function __construct() { + $this->test(); + } +} + +new c; + +?> +--EXPECTF-- +Fatal error: Call to private method d::test2() from context 'a' in %s on line %d diff --git a/Zend/tests/access_modifiers_011.phpt b/Zend/tests/access_modifiers_011.phpt new file mode 100644 index 0000000..4ed154f --- /dev/null +++ b/Zend/tests/access_modifiers_011.phpt @@ -0,0 +1,39 @@ +--TEST-- +__call() for private/protected methods +--FILE-- +<?php + +class A { + private $var1 = 'var1 value'; + protected $var2 = 'var2 value'; + + private function func1() + { + return "in func1"; + } + protected function func2() + { + return "in func2"; + } + public function __get($var) + { + return $this->$var; + } + public function __call($func, array $args = array()) + { + return call_user_func_array(array($this, $func), $args); + } +} + +$a = new A(); +echo $a->var1,"\n"; +echo $a->var2,"\n"; +echo $a->func1(),"\n"; +echo $a->func2(),"\n"; + +?> +--EXPECTF-- +var1 value +var2 value +in func1 +in func2 diff --git a/Zend/tests/access_modifiers_012.phpt b/Zend/tests/access_modifiers_012.phpt new file mode 100644 index 0000000..ac4d72c --- /dev/null +++ b/Zend/tests/access_modifiers_012.phpt @@ -0,0 +1,21 @@ +--TEST-- +Trigger __call() in lieu of non visible methods when called via a callback. +--FILE-- +<?php +class C { + protected function prot() { } + private function priv() { } + public function __call($name, $args) { + echo "In __call() for method $name()\n"; + } +} + +$c = new C; +call_user_func(array($c, 'none')); +call_user_func(array($c, 'prot')); +call_user_func(array($c, 'priv')); +?> +--EXPECTF-- +In __call() for method none() +In __call() for method prot() +In __call() for method priv() diff --git a/Zend/tests/add_001.phpt b/Zend/tests/add_001.phpt new file mode 100644 index 0000000..8d12aea --- /dev/null +++ b/Zend/tests/add_001.phpt @@ -0,0 +1,73 @@ +--TEST-- +adding arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array("str", "here"); + +$c = $a + $b; +var_dump($c); + +$a = array(1,2,3); +$b = array(1,2,4); + +$c = $a + $b; +var_dump($c); + +$a = array("a"=>"aaa",2,3); +$b = array(1,2,"a"=>"bbbbbb"); + +$c = $a + $b; +var_dump($c); + +$a += $b; +var_dump($c); + +$a += $a; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +Done diff --git a/Zend/tests/add_002.phpt b/Zend/tests/add_002.phpt new file mode 100644 index 0000000..437ac91 --- /dev/null +++ b/Zend/tests/add_002.phpt @@ -0,0 +1,19 @@ +--TEST-- +adding objects to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$o = new stdclass; +$o->prop = "value"; + +$c = $a + $o; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Object of class stdClass could not be converted to int in %s on line %d + +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_003.phpt b/Zend/tests/add_003.phpt new file mode 100644 index 0000000..4223af3 --- /dev/null +++ b/Zend/tests/add_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +adding arrays to objects +--FILE-- +<?php + +$a = array(1,2,3); + +$o = new stdclass; +$o->prop = "value"; + +$c = $o + $a; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Object of class stdClass could not be converted to int in %s on line %d + +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_004.phpt b/Zend/tests/add_004.phpt new file mode 100644 index 0000000..492ff31 --- /dev/null +++ b/Zend/tests/add_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +adding numbers to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$c = $a + 5; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_005.phpt b/Zend/tests/add_005.phpt new file mode 100644 index 0000000..7e9bc25 --- /dev/null +++ b/Zend/tests/add_005.phpt @@ -0,0 +1,22 @@ +--TEST-- +adding integers to doubles +--INI-- +precision=14 +--FILE-- +<?php + +$i = 75636; +$d = 2834681123.123123; + +$c = $i + $d; +var_dump($c); + +$c = $d + $i; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +float(2834756759.1231) +float(2834756759.1231) +Done diff --git a/Zend/tests/add_006.phpt b/Zend/tests/add_006.phpt new file mode 100644 index 0000000..d56df2f --- /dev/null +++ b/Zend/tests/add_006.phpt @@ -0,0 +1,49 @@ +--TEST-- +adding numbers to strings +--INI-- +precision=14 +--FILE-- +<?php + +$i = 75636; +$s1 = "this is a string"; +$s2 = "876222numeric"; +$s3 = "48474874"; +$s4 = "25.68"; + +$c = $i + $s1; +var_dump($c); + +$c = $i + $s2; +var_dump($c); + +$c = $i + $s3; +var_dump($c); + +$c = $i + $s4; +var_dump($c); + +$c = $s1 + $i; +var_dump($c); + +$c = $s2 + $i; +var_dump($c); + +$c = $s3 + $i; +var_dump($c); + +$c = $s4 + $i; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +int(75636) +int(951858) +int(48550510) +float(75661.68) +int(75636) +int(951858) +int(48550510) +float(75661.68) +Done diff --git a/Zend/tests/add_007.phpt b/Zend/tests/add_007.phpt new file mode 100644 index 0000000..b2f1559 --- /dev/null +++ b/Zend/tests/add_007.phpt @@ -0,0 +1,16 @@ +--TEST-- +adding strings to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$s1 = "some string"; + +$c = $a + $s1; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/and_001.phpt b/Zend/tests/and_001.phpt new file mode 100644 index 0000000..109b2ce --- /dev/null +++ b/Zend/tests/and_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +bitwise AND and strings +--FILE-- +<?php + +$s = "123"; +$s1 = "234"; + +var_dump($s & $s1); + +$s = "test"; +$s1 = "some"; + +var_dump($s & $s1); + +$s = "test long"; +$s1 = "some"; + +var_dump($s & $s1); + +$s = "test"; +$s1 = "some long"; + +var_dump($s & $s1); + +$s = "test"; +$s &= "some long"; + +var_dump($s); + +echo "Done\n"; +?> +--EXPECTF-- +string(3) "020" +string(4) "pead" +string(4) "pead" +string(4) "pead" +string(4) "pead" +Done diff --git a/Zend/tests/anonymous_func_001.phpt b/Zend/tests/anonymous_func_001.phpt new file mode 100644 index 0000000..644a7f4 --- /dev/null +++ b/Zend/tests/anonymous_func_001.phpt @@ -0,0 +1,35 @@ +--TEST-- +Testing calls to anonymous function +--FILE-- +<?php + +for ($i = 0; $i < 10; $i++) { + $a = create_function('', 'return '. $i .';'); + var_dump($a()); + + $b = "\0lambda_". ($i + 1); + var_dump($b()); +} + +?> +--EXPECT-- +int(0) +int(0) +int(1) +int(1) +int(2) +int(2) +int(3) +int(3) +int(4) +int(4) +int(5) +int(5) +int(6) +int(6) +int(7) +int(7) +int(8) +int(8) +int(9) +int(9) diff --git a/Zend/tests/anonymous_func_002.phpt b/Zend/tests/anonymous_func_002.phpt new file mode 100644 index 0000000..4c40b62 --- /dev/null +++ b/Zend/tests/anonymous_func_002.phpt @@ -0,0 +1,16 @@ +--TEST-- +Testing anonymous function return as array key and accessing $GLOBALS +--FILE-- +<?php + +$test = create_function('$v', 'return $v;'); + +$arr = array(create_function('', 'return $GLOBALS["arr"];'), 2); + +var_dump($arr[$test(1)]); +var_dump($arr[$test(0)]() == $arr); + +?> +--EXPECT-- +int(2) +bool(true) diff --git a/Zend/tests/anonymous_func_003.phpt b/Zend/tests/anonymous_func_003.phpt new file mode 100644 index 0000000..32c5cf0 --- /dev/null +++ b/Zend/tests/anonymous_func_003.phpt @@ -0,0 +1,15 @@ +--TEST-- +Using throw $var with anonymous function return +--FILE-- +<?php + +try { + $a = create_function('', 'return new Exception("test");'); + throw $a(); +} catch (Exception $e) { + var_dump($e->getMessage() == 'test'); +} + +?> +--EXPECT-- +bool(true) diff --git a/Zend/tests/argument_restriction_001.phpt b/Zend/tests/argument_restriction_001.phpt new file mode 100644 index 0000000..e62ad30 --- /dev/null +++ b/Zend/tests/argument_restriction_001.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #55719 (Argument restriction should come with a more specific error message) +--FILE-- +<?php +Class Base { + public function &test($foo, array $bar, $option = NULL, $extra = "lllllllllllllllllllllllllllllllllllllllllllllllllll") { + } +} + +class Sub extends Base { + public function &test() { + } +} +?> +--EXPECTF-- +Strict Standards: Declaration of Sub::test() should be compatible with & Base::test($foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_001.php on line %d diff --git a/Zend/tests/argument_restriction_002.phpt b/Zend/tests/argument_restriction_002.phpt new file mode 100644 index 0000000..c6a472e --- /dev/null +++ b/Zend/tests/argument_restriction_002.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #55719 (Argument restriction should come with a more specific error message) +--FILE-- +<?php +Abstract Class Base { + public function test($foo, array &$bar, $option = NULL, $extra = 3.141592653589793238462643383279502884197169399375105 ) { + } +} + +class Sub extends Base { + public function test($foo, array &$bar) { + } +} +?> +--EXPECTF-- +Strict Standards: Declaration of Sub::test() should be compatible with Base::test($foo, array &$bar, $option = NULL, $extra = 3.1415926535898) in %sargument_restriction_002.php on line %d diff --git a/Zend/tests/argument_restriction_003.phpt b/Zend/tests/argument_restriction_003.phpt new file mode 100644 index 0000000..393581f --- /dev/null +++ b/Zend/tests/argument_restriction_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #55719 (Argument restriction should come with a more specific error message) +--FILE-- +<?php +class Foo { +} + +Abstract Class Base { + public function test(Foo $foo, array $bar, $option = NULL, $extra = "lllllllllllllllllllllllllllllllllllllllllllllllllll") { + } +} + +class Sub extends Base { + public function test() { + } +} +?> +--EXPECTF-- +Strict Standards: Declaration of Sub::test() should be compatible with Base::test(Foo $foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_003.php on line %d diff --git a/Zend/tests/argument_restriction_004.phpt b/Zend/tests/argument_restriction_004.phpt new file mode 100644 index 0000000..599b3e1 --- /dev/null +++ b/Zend/tests/argument_restriction_004.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #55719 (Argument restriction should come with a more specific error message) +--FILE-- +<?php +class Foo { +} + +Abstract Class Base { + abstract public function test(Foo $foo, array $bar, $option = NULL, $extra = 16777215) ; +} + +class Sub extends Base { + public function test(Foo $foo, array $bar, $option = NULL, $extra = 0xffffff ) { + } +} +?> +--EXPECTF-- diff --git a/Zend/tests/argument_restriction_005.phpt b/Zend/tests/argument_restriction_005.phpt new file mode 100644 index 0000000..2826fe6 --- /dev/null +++ b/Zend/tests/argument_restriction_005.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #55719 (Argument restriction should come with a more specific error message) +--FILE-- +<?php +class Sub implements ArrayAccess { + public function offsetSet() { + } +} +?> +--EXPECTF-- +Fatal error: Declaration of Sub::offsetSet() must be compatible with ArrayAccess::offsetSet($offset, $value) in %sargument_restriction_005.php on line %d diff --git a/Zend/tests/argument_restriction_006.phpt b/Zend/tests/argument_restriction_006.phpt new file mode 100644 index 0000000..948fc30 --- /dev/null +++ b/Zend/tests/argument_restriction_006.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #60174 (Notice when array in method prototype error) +--FILE-- +<?php +Abstract Class Base { + public function test($foo, $extra = array("test")) { + } +} + +class Sub extends Base { + public function test($foo, $extra) { + } +} +?> +--EXPECTF-- +Strict Standards: Declaration of Sub::test() should be compatible with Base::test($foo, $extra = Array) in %sargument_restriction_006.php on line %d diff --git a/Zend/tests/array_append_COW.phpt b/Zend/tests/array_append_COW.phpt new file mode 100644 index 0000000..0e30085 --- /dev/null +++ b/Zend/tests/array_append_COW.phpt @@ -0,0 +1,16 @@ +--TEST-- +Tests that array manipulation code is correctly dealing with copy on write and splitting on reference +--FILE-- +<?php + $a=array(); + $b=1; + $c=&$b; + $a[]=$b; + $b=2; + var_dump ($a); +?> +--EXPECT-- +array(1) { + [0]=> + int(1) +} diff --git a/Zend/tests/array_type_hint_001.phpt b/Zend/tests/array_type_hint_001.phpt new file mode 100644 index 0000000..a676992 --- /dev/null +++ b/Zend/tests/array_type_hint_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +Array type hint +--FILE-- +<?php +function foo(array $a) { + echo count($a)."\n"; +} + +foo(array(1,2,3)); +foo(123); +?> +--EXPECTF-- +3 + +Catchable fatal error: Argument 1 passed to foo() must be of the type 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/array_unshift_COW.phpt b/Zend/tests/array_unshift_COW.phpt new file mode 100644 index 0000000..ecc42bb --- /dev/null +++ b/Zend/tests/array_unshift_COW.phpt @@ -0,0 +1,16 @@ +--TEST-- +Tests that array unshift code is correctly dealing with copy on write and splitting on reference +--FILE-- +<?php + $a=array(); + $b=1; + $c=&$b; + array_unshift ($a,$b); + $b=2; + var_dump ($a); +?> +--EXPECT-- +array(1) { + [0]=> + int(1) +} diff --git a/Zend/tests/assign_to_var_001.phpt b/Zend/tests/assign_to_var_001.phpt new file mode 100644 index 0000000..d37ebbc --- /dev/null +++ b/Zend/tests/assign_to_var_001.phpt @@ -0,0 +1,18 @@ +--TEST-- +complex cases of variable assignment - 001 +--FILE-- +<?php + +$var = array(1,2,3); +$var1 = &$var; +$var = $var[1]; + +var_dump($var); +var_dump($var1); + +echo "Done\n"; +?> +--EXPECTF-- +int(2) +int(2) +Done diff --git a/Zend/tests/assign_to_var_002.phpt b/Zend/tests/assign_to_var_002.phpt new file mode 100644 index 0000000..e682765 --- /dev/null +++ b/Zend/tests/assign_to_var_002.phpt @@ -0,0 +1,18 @@ +--TEST-- +complex cases of variable assignment - 002 +--FILE-- +<?php + +$var = "intergalactic"; +$var1 = &$var; +$var = $var[5]; + +var_dump($var); +var_dump($var1); + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "g" +string(1) "g" +Done diff --git a/Zend/tests/assign_to_var_003.phpt b/Zend/tests/assign_to_var_003.phpt new file mode 100644 index 0000000..911ee0b --- /dev/null +++ b/Zend/tests/assign_to_var_003.phpt @@ -0,0 +1,18 @@ +--TEST-- +complex cases of variable assignment - 003 +--FILE-- +<?php + +$var = 0.213123123; +$var1 = &$var; +$var = $var[1]; + +var_dump($var); +var_dump($var1); + +echo "Done\n"; +?> +--EXPECTF-- +NULL +NULL +Done diff --git a/Zend/tests/assign_to_var_004.phpt b/Zend/tests/assign_to_var_004.phpt new file mode 100644 index 0000000..787362a --- /dev/null +++ b/Zend/tests/assign_to_var_004.phpt @@ -0,0 +1,22 @@ +--TEST-- +complex cases of variable assignment - 004 +--FILE-- +<?php + +$var = "intergalactic"; +$var1 = "space"; +$var2 = &$var1; + +$var = $var2; + +var_dump($var); +var_dump($var1); +var_dump($var2); + +echo "Done\n"; +?> +--EXPECTF-- +string(5) "space" +string(5) "space" +string(5) "space" +Done diff --git a/Zend/tests/binary-32bit.phpt b/Zend/tests/binary-32bit.phpt new file mode 100644 index 0000000..4b87ade --- /dev/null +++ b/Zend/tests/binary-32bit.phpt @@ -0,0 +1,154 @@ +--TEST-- +testing binary literals +--INI-- +precision=14 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php +var_dump(0b1); +var_dump(0b11); +var_dump(0b111); +var_dump(0b1111); +var_dump(0b11111); +var_dump(0b111111); +var_dump(0b1111111); +var_dump(0b11111111); +var_dump(0b111111111); +var_dump(0b1111111111); +var_dump(0b11111111111); +var_dump(0b111111111111); +var_dump(0b1111111111111); +var_dump(0b11111111111111); +var_dump(0b111111111111111); +var_dump(0b1111111111111111); +var_dump(0b11111111111111111); +var_dump(0b111111111111111111); +var_dump(0b1111111111111111111); +var_dump(0b11111111111111111111); +var_dump(0b111111111111111111111); +var_dump(0b1111111111111111111111); +var_dump(0b11111111111111111111111); +var_dump(0b111111111111111111111111); +var_dump(0b1111111111111111111111111); +var_dump(0b11111111111111111111111111); +var_dump(0b111111111111111111111111111); +var_dump(0b1111111111111111111111111111); +var_dump(0b11111111111111111111111111111); +var_dump(0b111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111111111111111); + +var_dump(-0b1111111111111111111111111111111111111111111111111111111111111111); +var_dump(-0b111111111111111111111111111111111111111111111111111111111111111); +var_dump(-0b11111111111111111111111111111111111111111111111111111111111111); +var_dump(-0b111111111111111111111111111111111); +var_dump(-0b11111111111111111111111111111111); +var_dump(-0b1111111111111111111111111111111); +var_dump(-0b111111111111111111111111111111); +var_dump(-0b1); +--EXPECT-- +int(1) +int(3) +int(7) +int(15) +int(31) +int(63) +int(127) +int(255) +int(511) +int(1023) +int(2047) +int(4095) +int(8191) +int(16383) +int(32767) +int(65535) +int(131071) +int(262143) +int(524287) +int(1048575) +int(2097151) +int(4194303) +int(8388607) +int(16777215) +int(33554431) +int(67108863) +int(134217727) +int(268435455) +int(536870911) +int(1073741823) +int(2147483647) +float(4294967295) +float(8589934591) +float(17179869183) +float(34359738367) +float(68719476735) +float(137438953471) +float(274877906943) +float(549755813887) +float(1099511627775) +float(2199023255551) +float(4398046511103) +float(8796093022207) +float(17592186044415) +float(35184372088831) +float(70368744177663) +float(1.4073748835533E+14) +float(2.8147497671066E+14) +float(5.6294995342131E+14) +float(1.1258999068426E+15) +float(2.2517998136852E+15) +float(4.5035996273705E+15) +float(9.007199254741E+15) +float(1.8014398509482E+16) +float(3.6028797018964E+16) +float(7.2057594037928E+16) +float(1.4411518807586E+17) +float(2.8823037615171E+17) +float(5.7646075230342E+17) +float(1.1529215046068E+18) +float(2.3058430092137E+18) +float(4.6116860184274E+18) +float(9.2233720368548E+18) +float(1.844674407371E+19) +float(-1.844674407371E+19) +float(-9.2233720368548E+18) +float(-4.6116860184274E+18) +float(-8589934591) +float(-4294967295) +int(-2147483647) +int(-1073741823) +int(-1) diff --git a/Zend/tests/binary.phpt b/Zend/tests/binary.phpt new file mode 100644 index 0000000..039cf80 --- /dev/null +++ b/Zend/tests/binary.phpt @@ -0,0 +1,154 @@ +--TEST-- +testing binary literals +--INI-- +precision=32 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php +var_dump(0b1); +var_dump(0b11); +var_dump(0b111); +var_dump(0b1111); +var_dump(0b11111); +var_dump(0b111111); +var_dump(0b1111111); +var_dump(0b11111111); +var_dump(0b111111111); +var_dump(0b1111111111); +var_dump(0b11111111111); +var_dump(0b111111111111); +var_dump(0b1111111111111); +var_dump(0b11111111111111); +var_dump(0b111111111111111); +var_dump(0b1111111111111111); +var_dump(0b11111111111111111); +var_dump(0b111111111111111111); +var_dump(0b1111111111111111111); +var_dump(0b11111111111111111111); +var_dump(0b111111111111111111111); +var_dump(0b1111111111111111111111); +var_dump(0b11111111111111111111111); +var_dump(0b111111111111111111111111); +var_dump(0b1111111111111111111111111); +var_dump(0b11111111111111111111111111); +var_dump(0b111111111111111111111111111); +var_dump(0b1111111111111111111111111111); +var_dump(0b11111111111111111111111111111); +var_dump(0b111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111111111111); +var_dump(0b111111111111111111111111111111111111111111111111111111111111111 + 1); +var_dump(0b1111111111111111111111111111111111111111111111111111111111111111); +var_dump(0b1111111111111111111111111111111111111111111111111111111111111111 + 1); +var_dump(0b11111111111111111111111111111111111111111111111111111111111111111); +var_dump(0b11111111111111111111111111111111111111111111111111111111111111111 + 1); + +var_dump(-0b1111111111111111111111111111111111111111111111111111111111111111); +var_dump(-0b111111111111111111111111111111111111111111111111111111111111111); +var_dump(-0b11111111111111111111111111111111111111111111111111111111111111); +var_dump(-0b1); +--EXPECT-- +int(1) +int(3) +int(7) +int(15) +int(31) +int(63) +int(127) +int(255) +int(511) +int(1023) +int(2047) +int(4095) +int(8191) +int(16383) +int(32767) +int(65535) +int(131071) +int(262143) +int(524287) +int(1048575) +int(2097151) +int(4194303) +int(8388607) +int(16777215) +int(33554431) +int(67108863) +int(134217727) +int(268435455) +int(536870911) +int(1073741823) +int(2147483647) +int(4294967295) +int(8589934591) +int(17179869183) +int(34359738367) +int(68719476735) +int(137438953471) +int(274877906943) +int(549755813887) +int(1099511627775) +int(2199023255551) +int(4398046511103) +int(8796093022207) +int(17592186044415) +int(35184372088831) +int(70368744177663) +int(140737488355327) +int(281474976710655) +int(562949953421311) +int(1125899906842623) +int(2251799813685247) +int(4503599627370495) +int(9007199254740991) +int(18014398509481983) +int(36028797018963967) +int(72057594037927935) +int(144115188075855871) +int(288230376151711743) +int(576460752303423487) +int(1152921504606846975) +int(2305843009213693951) +int(4611686018427387903) +int(9223372036854775807) +float(9223372036854775808) +float(18446744073709549568) +float(18446744073709549568) +float(36893488147419099136) +float(36893488147419099136) +float(-18446744073709549568) +int(-9223372036854775807) +int(-4611686018427387903) +int(-1) diff --git a/Zend/tests/bug19859.phpt b/Zend/tests/bug19859.phpt new file mode 100644 index 0000000..d961b75 --- /dev/null +++ b/Zend/tests/bug19859.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #19859 (__call() does not catch call_user_func_array() calls) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?> +--FILE-- +<?php +class test +{ + function __call($method,$args) + { + print "test::__call invoked for method '$method'\n"; + } +} +$x = new test; +$x->fake(1); +call_user_func_array(array($x,'fake'),array(1)); +call_user_func(array($x,'fake'),2); +?> +--EXPECT-- +test::__call invoked for method 'fake' +test::__call invoked for method 'fake' +test::__call invoked for method 'fake' diff --git a/Zend/tests/bug20240.phpt b/Zend/tests/bug20240.phpt new file mode 100644 index 0000000..acf673a --- /dev/null +++ b/Zend/tests/bug20240.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #20240 (order of destructor calls) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?> +--FILE-- +<?php + +class test +{ + public $member; + + function test() { + $this->member = 1; + register_shutdown_function(array($this, 'destructor')); + } + + function destructor() { + print __METHOD__ . "\n"; + } + + function __destruct() { + print __METHOD__ . "\n"; + } + + function add() { + $this->member += 1; + print $this->member."\n"; + } +} + +$t = new test(); + +$t->add(); +$t->add(); + +echo "Done\n"; +?> +--EXPECT-- +2 +3 +Done +test::destructor +test::__destruct diff --git a/Zend/tests/bug20242.phpt b/Zend/tests/bug20242.phpt new file mode 100644 index 0000000..064f823 --- /dev/null +++ b/Zend/tests/bug20242.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #20242 (Method call in front of class definition) +--FILE-- +<?php +test::show_static(); + +$t = new test; +$t->show_method(); + +class test { + static function show_static() { + echo "static\n"; + } + function show_method() { + echo "method\n"; + } +} +?> +--EXPECT-- +static +method diff --git a/Zend/tests/bug21478.phpt b/Zend/tests/bug21478.phpt new file mode 100644 index 0000000..8b38f24 --- /dev/null +++ b/Zend/tests/bug21478.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #21478 (Zend/zend_alloc.c :: shutdown_memory_manager produces segfault) +--SKIPIF-- +<?php + if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); + if (!function_exists('stream_filter_register')) die('skip stream_filter_register() not available'); +?> +--FILE-- +<?php +class debugfilter extends php_user_filter { + function filter($in, $out, &$consumed, $closing) { + while ($bucket = stream_bucket_make_writeable($in)) { + $bucket->data = strtoupper($bucket->data); + stream_bucket_append($out, $bucket); + $consumed += strlen($bucket->data); + } + return PSFS_PASS_ON; + } +} + +stream_filter_register("myfilter","debugfilter"); + +$fp = fopen(dirname(__FILE__)."/test.txt","w"); +stream_filter_append($fp, "myfilter"); +stream_filter_append($fp, "myfilter"); +stream_filter_append($fp, "myfilter"); +fwrite($fp, "This is a test.\n"); +print "Done.\n"; +fclose($fp); +// Uncommenting the following 'print' line causes the segfault to stop occuring +// print "2\n"; +readfile(dirname(__FILE__)."/test.txt"); +unlink(dirname(__FILE__)."/test.txt"); +?> +--EXPECT-- +Done. +THIS IS A TEST. diff --git a/Zend/tests/bug21888.phpt b/Zend/tests/bug21888.phpt new file mode 100644 index 0000000..a13da19 --- /dev/null +++ b/Zend/tests/bug21888.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #21888 (protected property and protected method of the same name) +--SKIPIF-- +<?php + if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); +?> +--FILE-- +<?php +class mom { + + protected $prot = "protected property\n"; + + protected function prot() { + print "protected method\n"; + } +} + +class child extends mom { + + public function callMom() { + $this->prot(); + } + + public function viewMom() { + print $this->prot; + } + +} + +$c = new child(); +$c->callMom(); +$c->viewMom(); +?> +--EXPECT-- +protected method +protected property diff --git a/Zend/tests/bug22725.phpt b/Zend/tests/bug22725.phpt new file mode 100644 index 0000000..5f3c258 --- /dev/null +++ b/Zend/tests/bug22725.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #22725 (A derived class can call a parent's protected method that calls a private method) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> +--FILE-- +<?php +class Foo { + private function aPrivateMethod() { + echo "Foo::aPrivateMethod() called.\n"; + } + + protected function aProtectedMethod() { + echo "Foo::aProtectedMethod() called.\n"; + $this->aPrivateMethod(); + } +} + +class Bar extends Foo { + public function aPublicMethod() { + echo "Bar::aPublicMethod() called.\n"; + $this->aProtectedMethod(); + } +} + +$o = new Bar; +$o->aPublicMethod(); +?> +--EXPECT-- +Bar::aPublicMethod() called. +Foo::aProtectedMethod() called. +Foo::aPrivateMethod() called. diff --git a/Zend/tests/bug22836.phpt b/Zend/tests/bug22836.phpt new file mode 100644 index 0000000..06a5c32 --- /dev/null +++ b/Zend/tests/bug22836.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #22836 (returning references to NULL) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?> +--FILE-- +<?php +function &f() +{ + $x = "foo"; + var_dump($x); + print "'$x'\n"; + return ($a); +} +for ($i = 0; $i < 8; $i++) { + $h =& f(); +} +?> +--EXPECTF-- +string(3) "foo" +'foo' +string(3) "foo" +'foo' +string(3) "foo" +'foo' +string(3) "foo" +'foo' +string(3) "foo" +'foo' +string(3) "foo" +'foo' +string(3) "foo" +'foo' +string(3) "foo" +'foo' diff --git a/Zend/tests/bug23104.phpt b/Zend/tests/bug23104.phpt new file mode 100644 index 0000000..04df3bd --- /dev/null +++ b/Zend/tests/bug23104.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #23104 (Hash position not reset for constant arrays) +--FILE-- +<?php +function foo($bar = array("a", "b", "c")) +{ + var_dump(current($bar)); +} +foo(); +?> +--EXPECT-- +string(1) "a" diff --git a/Zend/tests/bug24436.phpt b/Zend/tests/bug24436.phpt new file mode 100644 index 0000000..0c261b6 --- /dev/null +++ b/Zend/tests/bug24436.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #24436 (isset()/empty() produce errors with non-existent variables in classes) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?> +--INI-- +error_reporting=2047 +--FILE-- +<?php +class test { + function __construct() { + if (empty($this->test[0][0])) { print "test1\n";} + if (!isset($this->test[0][0])) { print "test2\n";} + if (empty($this->test)) { print "test1\n";} + if (!isset($this->test)) { print "test2\n";} + } +} + +$test1 = new test(); +?> +--EXPECT-- +test1 +test2 +test1 +test2 diff --git a/Zend/tests/bug24635.phpt b/Zend/tests/bug24635.phpt new file mode 100644 index 0000000..d9466d9 --- /dev/null +++ b/Zend/tests/bug24635.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #24635 (crash on dtor calling other functions) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?> +--FILE-- +<?php +class SiteClass { + function __construct() { $this->page = new PageClass(); } +} +class PageClass { + function Display() { + $section = new SectionClass("PageClass::Display"); + } +} +class SectionClass { + function __construct($comment) { + $this->Comment = $comment; + } + function __destruct() { + out($this->Comment); // this line doesn't crash PHP + out("\n<!-- End Section: " . $this->Comment . "-->"); // this line + } +} +function out($code) { return; } +$site = new SiteClass(); +$site->page->Display(); +echo "OK\n"; +?> +--EXPECT-- +OK diff --git a/Zend/tests/bug24699.phpt b/Zend/tests/bug24699.phpt new file mode 100644 index 0000000..81ca4f5 --- /dev/null +++ b/Zend/tests/bug24699.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #24699 (Memory Leak with per-class constants) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?> +--FILE-- +<?php +class TEST { const FOO = SEEK_CUR; }; +class TEST2 { const FOO = 1; }; +class TEST3 { const FOO = PHP_VERSION; }; +print TEST::FOO."\n"; +?> +--EXPECT-- +1 diff --git a/Zend/tests/bug24773.phpt b/Zend/tests/bug24773.phpt new file mode 100644 index 0000000..c0bb632 --- /dev/null +++ b/Zend/tests/bug24773.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #24773 (unset() of integers treated as arrays causes a crash) +--FILE-- +<?php + $array = 'test'; + unset($array["lvl1"]["lvl2"]["b"]); +?> +--EXPECTF-- +Fatal error: Cannot unset string offsets in %s on line %d diff --git a/Zend/tests/bug24884.phpt b/Zend/tests/bug24884.phpt new file mode 100644 index 0000000..457acd0 --- /dev/null +++ b/Zend/tests/bug24884.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #24884 (calling $this->__clone(); crashes php) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> +--FILE-- +<?php +class Test { + function __copy() + { + $string = PHP_VERSION; + $version = $string[0]; + if($string < 5) + { + return $this; + } + else + { + return clone $this; + } + } +} +$test = new Test(); +$test2 = $test->__copy(); +var_dump($test2); +?> +--EXPECTF-- +object(Test)#%d (0) { +} diff --git a/Zend/tests/bug26010.phpt b/Zend/tests/bug26010.phpt new file mode 100644 index 0000000..a3c41fa --- /dev/null +++ b/Zend/tests/bug26010.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #26010 (private / protected variables get exposed by get_object_vars()) +--FILE-- +<?php +class foo { + private $private = 'private'; + protected $protected = 'protected'; + public $public = 'public'; +} +$data = new foo(); +$obj_vars = get_object_vars($data); +var_dump($obj_vars); +?> +--EXPECT-- +array(1) { + ["public"]=> + string(6) "public" +} + diff --git a/Zend/tests/bug26077.phpt b/Zend/tests/bug26077.phpt new file mode 100644 index 0000000..dc7686e --- /dev/null +++ b/Zend/tests/bug26077.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #26077 (Memory leaks when creating an instance of an object) +--FILE-- +<?php +class foo {} new foo(); +?> +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/tests/bug26166.phpt b/Zend/tests/bug26166.phpt new file mode 100644 index 0000000..60624ed --- /dev/null +++ b/Zend/tests/bug26166.phpt @@ -0,0 +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 "===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/bug26229.phpt b/Zend/tests/bug26229.phpt new file mode 100644 index 0000000..347eb55 --- /dev/null +++ b/Zend/tests/bug26229.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #26229 (getIterator() segfaults when it returns arrays or scalars) +--FILE-- +<?php + +class array_iterator implements IteratorAggregate { + public function getIterator() { + return array('foo', 'bar'); + } +} + +$obj = new array_iterator; + +try +{ + foreach ($obj as $property => $value) + { + var_dump($value); + } +} +catch(Exception $e) +{ + echo $e->getMessage() . "\n"; +} +?> +===DONE=== +--EXPECTF-- +Objects returned by array_iterator::getIterator() must be traversable or implement interface Iterator +===DONE=== diff --git a/Zend/tests/bug26281.phpt b/Zend/tests/bug26281.phpt new file mode 100644 index 0000000..e1888a8 --- /dev/null +++ b/Zend/tests/bug26281.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #26281 (switch() crash when condition is a string offset) +--FILE-- +<?php + $x = 'abc'; + switch ($x[0]) { + case 'a': + echo "no crash\n"; + break; + } +?> +--EXPECT-- +no crash diff --git a/Zend/tests/bug26696.phpt b/Zend/tests/bug26696.phpt new file mode 100644 index 0000000..62ceacd --- /dev/null +++ b/Zend/tests/bug26696.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #26696 (crash in switch() when string index is used) +--FILE-- +<?php +$str = 'asdd/?'; +$len = strlen($str); +for ($i = 0; $i < $len; $i++) { + switch ($str[$i]) { + case '?': + echo "?+\n"; + break; + default: + echo $str[$i].'-'; + break; + } +} + +?> +===DONE=== +--EXPECT-- +a-s-d-d-/-?+ +===DONE===
\ No newline at end of file diff --git a/Zend/tests/bug26697.phpt b/Zend/tests/bug26697.phpt new file mode 100644 index 0000000..8266a23 --- /dev/null +++ b/Zend/tests/bug26697.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #26697 (calling class_exists on a nonexistent class in __autoload results in segfault) +--SKIPIF-- +<?php if (function_exists('__autoload')) die('skip __autoload() declared in auto_prepend_file');?> +--FILE-- +<?php + +function __autoload($name) +{ + echo __METHOD__ . "($name)\n"; + var_dump(class_exists('NotExistingClass')); + echo __METHOD__ . "($name), done\n"; +} + +var_dump(class_exists('NotExistingClass')); + +?> +===DONE=== +--EXPECTF-- +__autoload(NotExistingClass) +bool(false) +__autoload(NotExistingClass), done +bool(false) +===DONE=== diff --git a/Zend/tests/bug26698.phpt b/Zend/tests/bug26698.phpt new file mode 100644 index 0000000..aecc708 --- /dev/null +++ b/Zend/tests/bug26698.phpt @@ -0,0 +1,73 @@ +--TEST-- +Bug #26698 (Thrown exceptions while evaluting argument to pass as parameter crash PHP) +--FILE-- +<?php + +ini_set("report_memleaks", 0); // the exception thrown in this test results in a memory leak, which is fine + +class Object +{ + function getNone() + { + throw new Exception('NONE'); + } +} + +class Proxy +{ + function three($a, $b, $c) + { + } + + function callOne() + { + try + { + $res = new Object(); + $this->three($res->getNone()); + } + catch(Exception $e) + { + echo 'Caught: '.$e->getMessage()."\n"; + } + } + + function callTwo() + { + try + { + $res = new Object(); + $this->three(1, $res->getNone()); + } + catch(Exception $e) + { + echo 'Caught: '.$e->getMessage()."\n"; + } + } + + function callThree() + { + try + { + $res = new Object(); + $this->three(1, 2, $res->getNone()); + } + catch(Exception $e) + { + echo 'Caught: '.$e->getMessage()."\n"; + } + } +} + +$p = new Proxy(); + +$p->callOne(); +$p->callTwo(); +$p->callThree(); +?> +===DONE=== +--EXPECT-- +Caught: NONE +Caught: NONE +Caught: NONE +===DONE=== diff --git a/Zend/tests/bug26801.phpt b/Zend/tests/bug26801.phpt new file mode 100644 index 0000000..b8cc37a --- /dev/null +++ b/Zend/tests/bug26801.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #26801 (switch ($a{0}) crash) +--FILE-- +<?php + +$a = '11'; +$b = $a[0]; +switch ($b) { + case '-': + break; +} + +$a = '22'; +switch ($a[0]) { + case '-': + break; +} + +?> +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/tests/bug26802.phpt b/Zend/tests/bug26802.phpt new file mode 100644 index 0000000..ab0ad25 --- /dev/null +++ b/Zend/tests/bug26802.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #26802 (Can't call static method using a variable) +--FILE-- +<?php + +function global_func() +{ + echo __METHOD__ . "\n"; +} + +$function = 'global_func'; +$function(); + +class foo +{ + static $method = 'global_func'; + + static public function foo_func() + { + echo __METHOD__ . "\n"; + } +} + +/* The following is a BC break with PHP 4 where it would + * call foo::fail. In PHP 5 we first evaluate static class + * properties and then do the function call. + */ +$method = 'foo_func'; +foo::$method(); + + +?> +===DONE=== +--EXPECT-- +global_func +foo::foo_func +===DONE=== diff --git a/Zend/tests/bug27268.phpt b/Zend/tests/bug27268.phpt new file mode 100644 index 0000000..a86e8d0 --- /dev/null +++ b/Zend/tests/bug27268.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #27268 (Bad references accentuated by clone) +--FILE-- +<?php +class A +{ + public function &getA() + { + return $this->a; + } +} + +$A = new A; +$A->a = array(1); +$x = $A->getA(); +$clone = clone $A; +$clone->a = array(); +print_r($A); +?> +--EXPECT-- +A Object +( + [a] => Array + ( + [0] => 1 + ) + +) diff --git a/Zend/tests/bug27304.phpt b/Zend/tests/bug27304.phpt new file mode 100644 index 0000000..0f24834 --- /dev/null +++ b/Zend/tests/bug27304.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #27304 (Static functions don't function properly) +--FILE-- +<?php + +class Staticexample +{ + static function test() + { + var_dump(isset($this)); + } +} + +$b = new Staticexample(); +Staticexample::test(); +$b->test(); + +?> +===DONE=== +--EXPECT-- +bool(false) +bool(false) +===DONE=== diff --git a/Zend/tests/bug27598.phpt b/Zend/tests/bug27598.phpt new file mode 100644 index 0000000..534e8cf --- /dev/null +++ b/Zend/tests/bug27598.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #27598 (list() array key assignment causes HUGE memory leak) +--FILE-- +<?php +list($out[0]) = array(1); +var_dump($out); +?> +--EXPECT-- +array(1) { + [0]=> + int(1) +} diff --git a/Zend/tests/bug27669.phpt b/Zend/tests/bug27669.phpt new file mode 100644 index 0000000..4d513e9 --- /dev/null +++ b/Zend/tests/bug27669.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #27669 (PHP 5 didn't support all possibilities for calling static methods dynamically) +--FILE-- +<?php + error_reporting(E_ALL & !E_STRICT); + + class A { + function hello() { + echo "Hello World\n"; + } + } + $y[0] = 'hello'; + A::$y[0](); +?> +===DONE=== +--EXPECTF-- +Hello World +===DONE=== diff --git a/Zend/tests/bug27731.phpt b/Zend/tests/bug27731.phpt new file mode 100644 index 0000000..408e424 --- /dev/null +++ b/Zend/tests/bug27731.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #27731 (error_reporing() call inside @ block does not work correctly) +--FILE-- +<?php + error_reporting(E_ALL ^ E_NOTICE); + @error_reporting(E_WARNING); + var_dump(error_reporting()); +?> +--EXPECT-- +int(2) diff --git a/Zend/tests/bug27798.phpt b/Zend/tests/bug27798.phpt new file mode 100644 index 0000000..9e54efa --- /dev/null +++ b/Zend/tests/bug27798.phpt @@ -0,0 +1,72 @@ +--TEST-- +Bug #27798 (private / protected variables not exposed by get_object_vars() inside class) +--FILE-- +<?php + +class Base +{ + public $Foo = 1; + protected $Bar = 2; + private $Baz = 3; + + function __construct() + { + echo __METHOD__ . "\n"; + var_dump(get_object_vars($this)); + } +} + +class Child extends Base +{ + private $Baz = 4; + + function __construct() + { + parent::__construct(); + echo __METHOD__ . "\n"; + var_dump(get_object_vars($this)); + } +} + +var_dump(get_object_vars(new Base)); +var_dump(get_object_vars(new Child)); + +?> +===DONE=== +--EXPECT-- +Base::__construct +array(3) { + ["Foo"]=> + int(1) + ["Bar"]=> + int(2) + ["Baz"]=> + int(3) +} +array(1) { + ["Foo"]=> + int(1) +} +Base::__construct +array(3) { + ["Foo"]=> + int(1) + ["Bar"]=> + int(2) + ["Baz"]=> + int(3) +} +Child::__construct +array(3) { + ["Baz"]=> + int(4) + ["Foo"]=> + int(1) + ["Bar"]=> + int(2) +} +array(1) { + ["Foo"]=> + int(1) +} +===DONE=== diff --git a/Zend/tests/bug28072.phpt b/Zend/tests/bug28072.phpt new file mode 100644 index 0000000..7620873 --- /dev/null +++ b/Zend/tests/bug28072.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #28072 (static array with some constant keys will be incorrectly ordered) +--FILE-- +<?php +define("FIRST_KEY", "a"); +define("THIRD_KEY", "c"); + + +function test() +{ + static $arr = array( + FIRST_KEY => "111", + "b" => "222", + THIRD_KEY => "333", + "d" => "444" + ); + print_r($arr); +} + +function test2() +{ + static $arr = array( + FIRST_KEY => "111", + "a" => "222", + "c" => "333", + THIRD_KEY => "444" + ); + print_r($arr); +} + +test(); +test2(); +?> +--EXPECT-- +Array +( + [a] => 111 + [b] => 222 + [c] => 333 + [d] => 444 +) +Array +( + [a] => 222 + [c] => 444 +) diff --git a/Zend/tests/bug28377.phpt b/Zend/tests/bug28377.phpt new file mode 100644 index 0000000..9d1b434 --- /dev/null +++ b/Zend/tests/bug28377.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #28377 (debug_backtrace is intermittently passing args) +--FILE-- +<?php +function doit($a, $b) +{ + $trace = debug_backtrace(); + custom_callback('dereferenced', $trace); + custom_callback('direct', debug_backtrace()); +} + +function custom_callback($traceName, $btInfo) +{ + echo $traceName ." -- args: "; + echo isset($btInfo[0]['args']) ? count($btInfo[0]['args']) : 'does not exist'; + echo "\n"; +} + +doit('a','b'); +?> +--EXPECT-- +dereferenced -- args: 2 +direct -- args: 2 diff --git a/Zend/tests/bug28442.phpt b/Zend/tests/bug28442.phpt new file mode 100644 index 0000000..1237357 --- /dev/null +++ b/Zend/tests/bug28442.phpt @@ -0,0 +1,65 @@ +--TEST-- +Bug #28442 (Changing a static variables in a class changes it across sub/super classes.) +--FILE-- +<?php + +class ClassA +{ + static $prop; +} + +class ClassB extends ClassA +{ + static $prop; +} + +class ClassC extends ClassB +{ +} + +echo "===INIT===\n"; +ClassA::$prop = 'A'; +ClassB::$prop = 'B'; +ClassC::$prop = 'C'; +var_dump(ClassA::$prop); +var_dump(ClassB::$prop); +var_dump(ClassC::$prop); + +echo "===SetA===\n"; +ClassA::$prop = 'A2'; +var_dump(ClassA::$prop); +var_dump(ClassB::$prop); +var_dump(ClassC::$prop); + +echo "===SetB===\n"; +ClassB::$prop = 'B2'; +var_dump(ClassA::$prop); +var_dump(ClassB::$prop); +var_dump(ClassC::$prop); + +echo "===SetC===\n"; +ClassC::$prop = 'C2'; +var_dump(ClassA::$prop); +var_dump(ClassB::$prop); +var_dump(ClassC::$prop); + +?> +===DONE=== +--EXPECTF-- +===INIT=== +string(1) "A" +string(1) "C" +string(1) "C" +===SetA=== +string(2) "A2" +string(1) "C" +string(1) "C" +===SetB=== +string(2) "A2" +string(2) "B2" +string(2) "B2" +===SetC=== +string(2) "A2" +string(2) "C2" +string(2) "C2" +===DONE=== diff --git a/Zend/tests/bug28444.phpt b/Zend/tests/bug28444.phpt new file mode 100644 index 0000000..78c08d2 --- /dev/null +++ b/Zend/tests/bug28444.phpt @@ -0,0 +1,81 @@ +--TEST-- +Bug #28444 (Cannot access undefined property for object with overloaded property access) +--FILE-- +<?php + +function my_error_handler($errno, $errstr, $errfile, $errline) { + var_dump($errstr); +} + +set_error_handler('my_error_handler'); + +class Object +{ + public $x; + + function __construct($x) + { + $this->x = $x; + } +} + +class Overloaded +{ + public $props = array(); + public $x; + + function __construct($x) + { + $this->x = new Object($x); + } + + function __get($prop) + { + echo __METHOD__ . "($prop)\n"; + return $this->props[$prop]; + } + + function __set($prop, $val) + { + echo __METHOD__ . "($prop,$val)\n"; + $this->props[$prop] = $val; + } +} +$y = new Overloaded(2); +var_dump($y->x); +var_dump($y->x->x); +var_dump($y->x->x = 3); +var_dump($y->y = 3); +var_dump($y->y); +var_dump($y->z = new Object(4)); +var_dump($y->z->x); +$t = $y->z; +var_dump($t->x = 5); +var_dump($y->z->x = 6); + +?> +===DONE=== +--EXPECTF-- +object(Object)#%d (1) { + ["x"]=> + int(2) +} +int(2) +int(3) +Overloaded::__set(y,3) +int(3) +Overloaded::__get(y) +int(3) +string(55) "Object of class Object could not be converted to string" +Overloaded::__set(z,) +object(Object)#%d (1) { + ["x"]=> + int(4) +} +Overloaded::__get(z) +int(4) +Overloaded::__get(z) +int(5) +Overloaded::__get(z) +int(6) +===DONE=== diff --git a/Zend/tests/bug29015.phpt b/Zend/tests/bug29015.phpt new file mode 100644 index 0000000..6c18ab8 --- /dev/null +++ b/Zend/tests/bug29015.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #29015 (Incorrect behavior of member vars(non string ones)-numeric mem vars und others) +--FILE-- +<?php +$a = new stdClass(); +$x = ""; +$a->$x = "string('')"; +var_dump($a); +?> +--EXPECTF-- +Fatal error: Cannot access empty property in %sbug29015.php on line 4 diff --git a/Zend/tests/bug29104.phpt b/Zend/tests/bug29104.phpt new file mode 100644 index 0000000..788b219 --- /dev/null +++ b/Zend/tests/bug29104.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #29104 (Function declaration in method doesn't work) +--FILE-- +<?php +class A +{ + function g() + { + echo "function g - begin\n"; + + function f() + { + echo "function f\n"; + } + + echo "function g - end\n"; + } +} + +$a = new A; +$a->g(); +f(); +?> +--EXPECT-- +function g - begin +function g - end +function f diff --git a/Zend/tests/bug29210.phpt b/Zend/tests/bug29210.phpt new file mode 100644 index 0000000..3bae806 --- /dev/null +++ b/Zend/tests/bug29210.phpt @@ -0,0 +1,104 @@ +--TEST-- +Bug #29210 (Function is_callable does not support private and protected methods) +--FILE-- +<?php +class test_class { + private function test_func1() { + echo "test_func1\n"; + } + protected function test_func2() { + echo "test_func2\n"; + } + static private function test_func3() { + echo "test_func3\n"; + } + static protected function test_func4() { + echo "test_func4\n"; + } + function test() { + if (is_callable(array($this,'test_func1'))) { + $this->test_func1(); + } else { + echo "test_func1 isn't callable from inside\n"; + } + if (is_callable(array($this,'test_func2'))) { + $this->test_func2(); + } else { + echo "test_func2 isn't callable from inside\n"; + } + if (is_callable(array('test_class','test_func3'))) { + test_class::test_func3(); + } else { + echo "test_func3 isn't callable from inside\n"; + } + if (is_callable(array('test_class','test_func4'))) { + test_class::test_func4(); + } else { + echo "test_func4 isn't callable from inside\n"; + } + } +} + +class foo extends test_class { + function test() { + if (is_callable(array($this,'test_func1'))) { + $this->test_func1(); + } else { + echo "test_func1 isn't callable from child\n"; + } + if (is_callable(array($this,'test_func2'))) { + $this->test_func2(); + } else { + echo "test_func2 isn't callable from child\n"; + } + if (is_callable(array('test_class','test_func3'))) { + test_class::test_func3(); + } else { + echo "test_func3 isn't callable from child\n"; + } + if (is_callable(array('test_class','test_func4'))) { + test_class::test_func4(); + } else { + echo "test_func4 isn't callable from child\n"; + } + } +} + +$object = new test_class; +$object->test(); +if (is_callable(array($object,'test_func1'))) { + $object->test_func1(); +} else { + echo "test_func1 isn't callable from outside\n"; +} +if (is_callable(array($object,'test_func2'))) { + $object->test_func2(); +} else { + echo "test_func2 isn't callable from outside\n"; +} +if (is_callable(array('test_class','test_func3'))) { + test_class::test_func3(); +} else { + echo "test_func3 isn't callable from outside\n"; +} +if (is_callable(array('test_class','test_func4'))) { + test_class::test_func4(); +} else { + echo "test_func4 isn't callable from outside\n"; +} +$object = new foo(); +$object->test(); +?> +--EXPECTF-- +test_func1 +test_func2 +test_func3 +test_func4 +test_func1 isn't callable from outside +test_func2 isn't callable from outside +test_func3 isn't callable from outside +test_func4 isn't callable from outside +test_func1 isn't callable from child +test_func2 +test_func3 isn't callable from child +test_func4 diff --git a/Zend/tests/bug29368.phpt b/Zend/tests/bug29368.phpt new file mode 100644 index 0000000..c16399a --- /dev/null +++ b/Zend/tests/bug29368.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #29368 (The destructor is called when an exception is thrown from the constructor) +--FILE-- +<?php + +class Foo +{ + function __construct() + { + echo __METHOD__ . "\n"; + throw new Exception; + } + function __destruct() + { + echo __METHOD__ . "\n"; + } +} + +try +{ + $bar = new Foo; +} catch(Exception $exc) +{ + echo "Caught exception!\n"; +} + +unset($bar); + +?> +===DONE=== +--EXPECTF-- +Foo::__construct +Caught exception! +===DONE=== diff --git a/Zend/tests/bug29505.phpt b/Zend/tests/bug29505.phpt new file mode 100644 index 0000000..4d7c053 --- /dev/null +++ b/Zend/tests/bug29505.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #29505 (get_class_vars() severely broken when used with arrays) +--FILE-- +<?php + +class Test { + public $empty = array(); + public $three = array(1, "b"=>"c", 3=>array()); +} + +var_dump(get_class_vars('Test')); + +?> +===DONE=== +--EXPECT-- +array(2) { + ["empty"]=> + array(0) { + } + ["three"]=> + array(3) { + [0]=> + int(1) + ["b"]=> + string(1) "c" + [3]=> + array(0) { + } + } +} +===DONE=== diff --git a/Zend/tests/bug29674.phpt b/Zend/tests/bug29674.phpt new file mode 100644 index 0000000..30c23fa --- /dev/null +++ b/Zend/tests/bug29674.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #29674 (inherited method doesn't have access to private variables of the derived class) +--FILE-- +<?php + +class BaseClass +{ + private $private_base = "Base"; + + function printVars () + { + var_dump($this->private_base); + var_dump($this->private_child); + } +} + +class ChildClass extends BaseClass +{ + private $private_child = "Child"; +} + +echo "===BASE===\n"; +$obj = new BaseClass; +$obj->printVars(); + +echo "===CHILD===\n"; +$obj = new ChildClass; +$obj->printVars(); + +?> +===DONE=== +--EXPECTF-- +===BASE=== +string(4) "Base" + +Notice: Undefined property: BaseClass::$private_child in %sbug29674.php on line %d +NULL +===CHILD=== +string(4) "Base" + +Fatal error: Cannot access private property ChildClass::$private_child in %sbug29674.php on line %d diff --git a/Zend/tests/bug29689.phpt b/Zend/tests/bug29689.phpt new file mode 100644 index 0000000..12b3430 --- /dev/null +++ b/Zend/tests/bug29689.phpt @@ -0,0 +1,62 @@ +--TEST-- +Bug #29689 (default value of protected member overrides default value of private) +--FILE-- +<?php +class foo { + private $foo = 'foo'; + private $foo2 = 'foo2'; + + function printFoo() + { + echo __CLASS__, ': ', $this->foo, " ", $this->foo2, "\n"; + } +} + +class bar extends foo { + protected $foo = 'bar'; + + function printFoo() + { + parent::printFoo(); + echo __CLASS__, ': ', $this->foo, " ", $this->foo2, "\n"; + } +} + +class baz extends bar { + protected $foo = 'baz'; + protected $foo2 = 'baz2'; +} + +class bar2 extends foo { + function printFoo() + { + parent::printFoo(); + echo __CLASS__, ': ', $this->foo, " ", $this->foo2, "\n"; + } +} + +class baz2 extends bar2 { + protected $foo = 'baz2'; + protected $foo2 = 'baz22'; +} + +$bar = new bar; +$bar->printFoo(); +echo "---baz--\n"; +$baz = new baz(); +$baz->printFoo(); +echo "---baz2--\n"; +$baz = new baz2(); +$baz->printFoo(); +?> +--EXPECTF-- +foo: foo foo2 +bar: bar +Notice: Undefined property: bar::$foo2 in %s on line %d + +---baz-- +foo: foo foo2 +bar: baz baz2 +---baz2-- +foo: foo foo2 +bar2: baz2 baz22 diff --git a/Zend/tests/bug29883.phpt b/Zend/tests/bug29883.phpt new file mode 100644 index 0000000..c92f147 --- /dev/null +++ b/Zend/tests/bug29883.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #29883 (isset gives invalid values on strings) +--FILE-- +<?php +$x = "bug"; +var_dump(isset($x[-1])); +var_dump(isset($x["1"])); +echo $x["1"]."\n"; +?> +--EXPECT-- +bool(false) +bool(true) +u diff --git a/Zend/tests/bug29890.phpt b/Zend/tests/bug29890.phpt new file mode 100644 index 0000000..32e8e1b --- /dev/null +++ b/Zend/tests/bug29890.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #29890 (crash if error handler fails) +--FILE-- +<?php +function customErrorHandler($fErrNo,$fErrStr,$fErrFile,$fErrLine,&$fClass) { +echo "error :".$fErrStr."\n"; +} + +set_time_limit(5); + +error_reporting(E_ALL); + +set_error_handler("customErrorHandler"); + +define("TEST",2); + +//should return a notice that the constant is already defined + +define("TEST",3); + +?> +--EXPECT-- +error :Constant TEST already defined diff --git a/Zend/tests/bug29896.phpt b/Zend/tests/bug29896.phpt new file mode 100644 index 0000000..1e2eb0b --- /dev/null +++ b/Zend/tests/bug29896.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #29896 (Backtrace argument list out of sync) +--FILE-- +<?php +function userErrorHandler($num, $msg, $file, $line, $vars) +{ + debug_print_backtrace(); +} + +$OldErrorHandler = set_error_handler("userErrorHandler"); + +function GenerateError1($A1) +{ + $a = $b; +} + +function GenerateError2($A1) +{ + GenerateError1("Test1"); +} + +GenerateError2("Test2"); +?> +--EXPECTF-- +#0 userErrorHandler(8, Undefined variable: b, %sbug29896.php, 11, Array ([A1] => Test1)) called at [%sbug29896.php:11] +#1 GenerateError1(Test1) called at [%sbug29896.php:16] +#2 GenerateError2(Test2) called at [%sbug29896.php:19] + diff --git a/Zend/tests/bug29944.phpt b/Zend/tests/bug29944.phpt new file mode 100644 index 0000000..6c0cf1e --- /dev/null +++ b/Zend/tests/bug29944.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #29944 (Function defined in switch, crashes) +--FILE-- +<?php +$a = 1; +switch ($a) { + case 1: + function foo($a) { + return "ok\n"; + } + echo foo($a); +} +?> +--EXPECT-- +ok + diff --git a/Zend/tests/bug30080.phpt b/Zend/tests/bug30080.phpt new file mode 100644 index 0000000..bd8401e --- /dev/null +++ b/Zend/tests/bug30080.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #30080 (Passing array or non array of objects) +--FILE-- +<?php +class foo { + function foo($arrayobj) { + var_dump($arrayobj); + } +} + +new foo(array(new stdClass)); +?> +--EXPECT-- +array(1) { + [0]=> + object(stdClass)#2 (0) { + } +} diff --git a/Zend/tests/bug30140.phpt b/Zend/tests/bug30140.phpt new file mode 100644 index 0000000..1dfb835 --- /dev/null +++ b/Zend/tests/bug30140.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #30140 (Problem with array in static properties) +--FILE-- +<?php +class A { + public static $test1 = true; + public static $test2 = array(); + public static $test3 = "str"; +} + +class B extends A { +} + +A::$test1 = "x"; +A::$test2 = "y"; +A::$test3 = "z"; +var_dump(A::$test1); +var_dump(A::$test2); +var_dump(A::$test3); +var_dump(B::$test1); +var_dump(B::$test2); +var_dump(B::$test3); +?> +--EXPECT-- +string(1) "x" +string(1) "y" +string(1) "z" +string(1) "x" +string(1) "y" +string(1) "z" diff --git a/Zend/tests/bug30161.phpt b/Zend/tests/bug30161.phpt new file mode 100644 index 0000000..22f8fb5 --- /dev/null +++ b/Zend/tests/bug30161.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #30161 (Segmentation fault with exceptions) +--FILE-- +<?php +class FIIFO { + + public function __construct() { + throw new Exception; + } + +} + +class hariCow extends FIIFO { + + public function __construct() { + try { + parent::__construct(); + } catch(Exception $e) { + } + } + + public function __toString() { + return "ok\n"; + } + +} + + +$db = new hariCow; + +echo $db; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug30162.phpt b/Zend/tests/bug30162.phpt new file mode 100644 index 0000000..a011292 --- /dev/null +++ b/Zend/tests/bug30162.phpt @@ -0,0 +1,54 @@ +--TEST-- +Bug #30162 (Catching exception in constructor couses lose of $this) +--FILE-- +<?php +class FIIFO { + + public function __construct() { + $this->x = "x"; + throw new Exception; + } + +} + +class hariCow extends FIIFO { + + public function __construct() { + try { + parent::__construct(); + } catch(Exception $e) { + } + $this->y = "y"; + try { + $this->z = new FIIFO; + } catch(Exception $e) { + } + } + + public function __toString() { + return "Rusticus in asino sedet."; + } + +} + +try { + $db = new FIIFO(); +} catch(Exception $e) { +} +var_dump($db); + +$db = new hariCow; + +var_dump($db); +?> +===DONE=== +--EXPECTF-- +Notice: Undefined variable: db in %sbug30162.php on line 35 +NULL +object(hariCow)#%d (2) { + ["x"]=> + string(1) "x" + ["y"]=> + string(1) "y" +} +===DONE===
\ No newline at end of file diff --git a/Zend/tests/bug30346.phpt b/Zend/tests/bug30346.phpt new file mode 100644 index 0000000..30f36fb --- /dev/null +++ b/Zend/tests/bug30346.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #30346 (arrayAccess and using $this) +--FILE-- +<?php + +class Test implements ArrayAccess +{ + public function __construct() { } + public function offsetExists( $offset ) { return false; } + public function offsetGet( $offset ) { return $offset; } + public function offsetSet( $offset, $data ) { } + public function offsetUnset( $offset ) { } +} + +$post = new Test; +$id = 'page'; +echo $post[$id.'_show']; +echo "\n"; + +?> +===DONE=== +--EXPECT-- +page_show +===DONE=== diff --git a/Zend/tests/bug30394.phpt b/Zend/tests/bug30394.phpt new file mode 100644 index 0000000..b69eda4 --- /dev/null +++ b/Zend/tests/bug30394.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #30394 (Assignment operators yield wrong result with __get/__set) +--FILE-- +<?php +class Container +{ + public function __get( $what ) + { + return $this->_p[ $what ]; + } + + public function __set( $what, $value ) + { + $this->_p[ $what ] = $value; + } + + private $_p = array(); +} + +$c = new Container(); +$c->a = 1; +$c->a += 1; +print $c->a; // --> 2 + +print " - "; +$c->a += max( 0, 1 ); +print $c->a; // --> 4 (!) +?> +--EXPECT-- +2 - 3 diff --git a/Zend/tests/bug30407.phpt b/Zend/tests/bug30407.phpt new file mode 100644 index 0000000..6dcc6b3 --- /dev/null +++ b/Zend/tests/bug30407.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #30407 (Strange behaviour of default arguments) +--FILE-- +<?php + +function haricow($a = 'one') { + var_dump($a); + $a = 'two'; +} + +haricow(); +haricow(); +?> +===DONE=== +--EXPECT-- +string(3) "one" +string(3) "one" +===DONE=== diff --git a/Zend/tests/bug30451.phpt b/Zend/tests/bug30451.phpt new file mode 100644 index 0000000..210f087 --- /dev/null +++ b/Zend/tests/bug30451.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #30451 (static properties permissions broken) +--FILE-- +<?php + +class A { + + protected static $property = TRUE; + + protected static function method() { + return TRUE; + } + +} + +class B extends A { + + public function __construct() { + + var_dump(self::method()); + var_dump(parent::method()); + + var_dump(self::$property); + var_dump(parent::$property); + + } + +} + +new B; +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/bug30519.phpt b/Zend/tests/bug30519.phpt new file mode 100644 index 0000000..7d70cba --- /dev/null +++ b/Zend/tests/bug30519.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #30519 (Interface not existing says Class not found) +--FILE-- +<?php +class test implements a { +} +?> +--EXPECTF-- +Fatal error: Interface 'a' not found in %sbug30519.php on line 2 + diff --git a/Zend/tests/bug30702.phpt b/Zend/tests/bug30702.phpt new file mode 100644 index 0000000..f23b1ec --- /dev/null +++ b/Zend/tests/bug30702.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #30702 (cannot initialize class variable from class constant) +--FILE-- +<?php +class foo { + const C1=1; +} + +class bar extends foo { + const C2=2; + + public $c1=bar::C1; + public $c2=bar::C2; + + public $c3=self::C1; + public $c4=self::C2; + + public $c5=foo::C1; + public $c6=parent::C1; +} + +$x= new bar(); +var_dump($x); +?> +--EXPECT-- +object(bar)#1 (6) { + ["c1"]=> + int(1) + ["c2"]=> + int(2) + ["c3"]=> + int(1) + ["c4"]=> + int(2) + ["c5"]=> + int(1) + ["c6"]=> + int(1) +} diff --git a/Zend/tests/bug30707.phpt b/Zend/tests/bug30707.phpt new file mode 100644 index 0000000..d37d329 --- /dev/null +++ b/Zend/tests/bug30707.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #30707 (Segmentation fault on exception in method) +--FILE-- +<?php +class C { + function byePHP($plop) { + echo "ok\n"; + } + + function plip() { + try { + $this->plap($this->plop()); + } catch(Exception $e) { + } + } + + function plap($a) { + } + + function plop() { + throw new Exception; + } +} + +$x = new C; +$x->byePHP($x->plip()); +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug30725.phpt b/Zend/tests/bug30725.phpt new file mode 100644 index 0000000..ce6c9a5 --- /dev/null +++ b/Zend/tests/bug30725.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #30725 (PHP segfaults when an exception is thrown in getIterator() within foreach) +--FILE-- +<?php + +class Test implements IteratorAggregate +{ + function getIterator() + { + throw new Exception(); + } +} + +try +{ + $it = new Test; + foreach($it as $v) + { + echo "Fail\n"; + } + echo "Wrong\n"; +} +catch(Exception $e) +{ + echo "Caught\n"; +} + +?> +===DONE=== +--EXPECT-- +Caught +===DONE=== diff --git a/Zend/tests/bug30791.phpt b/Zend/tests/bug30791.phpt new file mode 100644 index 0000000..e9991f3 --- /dev/null +++ b/Zend/tests/bug30791.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #30791 (magic methods (__sleep/__wakeup/__toString) call __call if object is overloaded) +--FILE-- +<?php + +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-- +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/bug30820.phpt b/Zend/tests/bug30820.phpt new file mode 100644 index 0000000..97e46e9 --- /dev/null +++ b/Zend/tests/bug30820.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #30820 (static member conflict with $this->member silently ignored) +--INI-- +error_reporting=4095 +--FILE-- +<?php +class Blah { + private static $x; + + public function show() { + Blah::$x = 1; + $this->x = 5; // no warning, but refers to different variable + + echo 'Blah::$x = '. Blah::$x ."\n"; + echo '$this->x = '. $this->x ."\n"; + } +} + +$b = new Blah(); +$b->show(); +?> +--EXPECTF-- +Strict Standards: Accessing static property Blah::$x as non static in %sbug30820.php on line 7 +Blah::$x = 1 + +Strict Standards: Accessing static property Blah::$x as non static in %sbug30820.php on line 10 +$this->x = 5 diff --git a/Zend/tests/bug30828.phpt b/Zend/tests/bug30828.phpt new file mode 100644 index 0000000..d05dbb6 --- /dev/null +++ b/Zend/tests/bug30828.phpt @@ -0,0 +1,61 @@ +--TEST-- +Bug #30828 (debug_backtrace() reports incorrect class in overridden methods) +--FILE-- +<?php +class A { + function __construct() { + debug_print_backtrace(); + $bt = debug_backtrace(); + foreach ($bt as $t) { + print $t['class'].$t['type'].$t['function']."\n"; + } + } + + function foo() { + debug_print_backtrace(); + $bt = debug_backtrace(); + foreach ($bt as $t) { + print $t['class'].$t['type'].$t['function']."\n"; + } + } + + static function bar() { + debug_print_backtrace(); + $bt = debug_backtrace(); + foreach ($bt as $t) { + print $t['class'].$t['type'].$t['function']."\n"; + } + } +} + +class B extends A { + function __construct() { + parent::__construct(); + } + + function foo() { + parent::foo(); + } + + static function bar() { + parent::bar(); + } +} + +$b = new B(); +$b->foo(); +B::bar(); +?> +--EXPECTF-- +#0 A->__construct() called at [%sbug30828.php:30] +#1 B->__construct() called at [%sbug30828.php:42] +A->__construct +B->__construct +#0 A->foo() called at [%sbug30828.php:34] +#1 B->foo() called at [%sbug30828.php:43] +A->foo +B->foo +#0 A::bar() called at [%sbug30828.php:38] +#1 B::bar() called at [%sbug30828.php:44] +A::bar +B::bar diff --git a/Zend/tests/bug30889.phpt b/Zend/tests/bug30889.phpt new file mode 100644 index 0000000..fb92edf --- /dev/null +++ b/Zend/tests/bug30889.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #30889 (Conflict between __get/__set and ++ operator) +--FILE-- +<?php +class overloaded +{ + private $values; + function __construct() + { + $this->values = array('a' => 0); + } + function __set($name, $value) + { + print "set $name = $value ($name was ".$this->values[$name].")\n"; + $this->values[$name] = $value; + } + function __get($name) + { + print "get $name (returns ".$this->values[$name].")\n"; + return $this->values[$name]; + } +} +$test = new overloaded(); +$test->a++; // __get(), then __set() +++$test->a; +?> +--EXPECT-- +get a (returns 0) +set a = 1 (a was 0) +get a (returns 1) +set a = 2 (a was 1) diff --git a/Zend/tests/bug30922.phpt b/Zend/tests/bug30922.phpt new file mode 100644 index 0000000..8da0f21 --- /dev/null +++ b/Zend/tests/bug30922.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #30922 (reflective functions crash PHP when interfaces extend themselves) +--FILE-- +<?php +interface RecurisiveFooFar extends RecurisiveFooFar {} +class A implements RecurisiveFooFar {} + +$a = new A(); +var_dump($a instanceOf A); +echo "ok\n"; +?> +--EXPECTF-- +Fatal error: Interface RecurisiveFooFar cannot implement itself in %sbug30922.php on line %d diff --git a/Zend/tests/bug30998.phpt b/Zend/tests/bug30998.phpt new file mode 100644 index 0000000..032da3d --- /dev/null +++ b/Zend/tests/bug30998.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #30998 (Crash when user error handler returns false) +--FILE-- +<?php +error_reporting(-1); + +function my_error($errno, $errstr, $errfile, $errline) +{ + print "$errstr ($errno) in $errfile:$errline\n"; + return false; +} +set_error_handler('my_error'); + +$f = fopen("/tmp/blah", "r"); +?> +===DONE=== +--EXPECTF-- +fopen(/tmp/blah): failed to open stream: %s (2) in %s:%d + +Warning: fopen(/tmp/blah): failed to open stream: %s in %s on line %d +===DONE=== diff --git a/Zend/tests/bug31098.phpt b/Zend/tests/bug31098.phpt new file mode 100644 index 0000000..23cec9b --- /dev/null +++ b/Zend/tests/bug31098.phpt @@ -0,0 +1,55 @@ +--TEST-- +Bug #31098 (isset() / empty() incorrectly returns true in dereference of a wrong type) +--FILE-- +<?php +$a = ''; +var_dump(isset($a->b)); +$a = 'a'; +var_dump(isset($a->b)); +$a = '0'; +var_dump(isset($a->b)); +$a = ''; +var_dump(isset($a['b'])); +$a = 'a'; +var_dump(isset($a['b'])); +$a = '0'; +var_dump(isset($a['b'])); + +$simpleString = "Bogus String Text"; +echo isset($simpleString->wrong)?"bug\n":"ok\n"; +echo isset($simpleString["wrong"])?"bug\n":"ok\n"; +echo isset($simpleString[-1])?"bug\n":"ok\n"; +echo isset($simpleString[0])?"ok\n":"bug\n"; +echo isset($simpleString["0"])?"ok\n":"bug\n"; +echo isset($simpleString["16"])?"ok\n":"bug\n"; +echo isset($simpleString["17"])?"bug\n":"ok\n"; +echo $simpleString->wrong === null?"ok\n":"bug\n"; +echo $simpleString["wrong"] === "B"?"ok\n":"bug\n"; +echo $simpleString["0"] === "B"?"ok\n":"bug\n"; +$simpleString["wrong"] = "f"; +echo $simpleString["0"] === "f"?"ok\n":"bug\n"; +?> +--EXPECTF-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +ok +ok +ok +ok +ok +ok +ok + +Notice: Trying to get property of non-object in %s on line %d +ok + +Warning: Illegal string offset 'wrong' in %s on line %d +ok +ok + +Warning: Illegal string offset 'wrong' in %s on line %d +ok
\ No newline at end of file diff --git a/Zend/tests/bug31102.phpt b/Zend/tests/bug31102.phpt new file mode 100644 index 0000000..b7911be --- /dev/null +++ b/Zend/tests/bug31102.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #31102 (Exception not handled when thrown inside __autoload()) +--FILE-- +<?php + +$test = 0; + +function __autoload($class) +{ + global $test; + + echo __METHOD__ . "($class,$test)\n"; + switch($test) + { + case 1: + eval("class $class { function __construct(){throw new Exception('$class::__construct');}}"); + return; + case 2: + eval("class $class { function __construct(){throw new Exception('$class::__construct');}}"); + throw new Exception(__METHOD__); + return; + case 3: + return; + } +} + +while($test++ < 5) +{ + try + { + eval("\$bug = new Test$test();"); + } + catch (Exception $e) + { + echo "Caught: " . $e->getMessage() . "\n"; + } +} +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +__autoload(Test1,1) +Caught: Test1::__construct +__autoload(Test2,2) +Caught: __autoload +__autoload(Test3,3) + +Fatal error: Class 'Test3' not found in %sbug31102.php(%d) : eval()'d code on line 1 diff --git a/Zend/tests/bug31177-2.phpt b/Zend/tests/bug31177-2.phpt new file mode 100644 index 0000000..10083c5 --- /dev/null +++ b/Zend/tests/bug31177-2.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #31177 (memory corruption because of incorrect refcounting) +--FILE-- +<?php +class foo { + function foo($n=0) { + if($n) throw new Exception("new"); + } +} +$x = new foo(); +try { + $y=$x->foo(1); +} catch (Exception $e) { + var_dump($x); +} +--EXPECT-- +object(foo)#1 (0) { +} diff --git a/Zend/tests/bug31177.phpt b/Zend/tests/bug31177.phpt new file mode 100644 index 0000000..5e84573 --- /dev/null +++ b/Zend/tests/bug31177.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #31177 (Memory leak) +--FILE-- +<?php +class DbGow { + + public function query() { + throw new Exception; + } + + public function select() { + return new DbGowRecordSet($this->query()); + } + + public function select2() { + new DbGowRecordSet($this->query()); + } + +} + +class DbGowRecordSet { + + public function __construct($resource) { + } + +} + +$db = new DbGow; + +try { + $rs = $db->select(); +} catch(Exception $e) { + echo "ok\n"; +} + +try { + $db->select2(); +} catch(Exception $e) { + echo "ok\n"; +} +?> +--EXPECT-- +ok +ok diff --git a/Zend/tests/bug31341.phpt b/Zend/tests/bug31341.phpt new file mode 100644 index 0000000..309a54d --- /dev/null +++ b/Zend/tests/bug31341.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #31341 (escape on curly inconsistent) +--FILE-- +<?php +$a = array( + "$ \{ ", + " \{ $", + " \{$ ", + " $\{ ", + " \$\{ ", + " \{\$ ", + "\$ \{ ", + " \{ \$", + "% \{ "); + +foreach ($a as $v) { + echo("'$v'\n"); +} +?> +--EXPECT-- +'$ \{ ' +' \{ $' +' \{$ ' +' $\{ ' +' $\{ ' +' \{$ ' +'$ \{ ' +' \{ $' +'% \{ ' diff --git a/Zend/tests/bug31525.phpt b/Zend/tests/bug31525.phpt new file mode 100644 index 0000000..b1a01b6 --- /dev/null +++ b/Zend/tests/bug31525.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #31525 (object reference being dropped. $this getting lost) +--INI-- +error_reporting=4095 +--FILE-- +<?php +class Foo { + function getThis() { + return $this; + } + function destroyThis() { + $baz =& $this->getThis(); + } +} +$bar = new Foo(); +$bar->destroyThis(); +var_dump($bar); +?> +--EXPECTF-- +Strict Standards: Only variables should be assigned by reference in %sbug31525.php on line 7 +object(Foo)#1 (0) { +} diff --git a/Zend/tests/bug31683.phpt b/Zend/tests/bug31683.phpt new file mode 100644 index 0000000..205aca0 --- /dev/null +++ b/Zend/tests/bug31683.phpt @@ -0,0 +1,95 @@ +--TEST-- +Bug #31683 (changes to $name in __get($name) override future parameters) +--FILE-- +<?php + +class Foo implements ArrayAccess { + + function __get($test) { + var_dump($test); + $test = 'bug'; + } + + function __set($test, $val) { + var_dump($test); + var_dump($val); + $test = 'bug'; + $val = 'bug'; + } + + function __call($test, $arg) { + var_dump($test); + $test = 'bug'; + } + + function offsetget($test) { + var_dump($test); + $test = 'bug'; + return 123; + } + + function offsetset($test, $val) { + var_dump($test); + var_dump($val); + $test = 'bug'; + $val = 'bug'; + } + + function offsetexists($test) { + var_dump($test); + $test = 'bug'; + } + + function offsetunset($test) { + var_dump($test); + $test = 'bug'; + } + +} + +$foo = new Foo(); +$a = "ok"; + +for ($i=0; $i < 2; $i++) { + $foo->ok("ok"); + $foo->ok; + $foo->ok = "ok"; + $x = $foo["ok"]; + $foo["ok"] = "ok"; + isset($foo["ok"]); + unset($foo["ok"]); +// $foo[]; + $foo[] = "ok"; +// isset($foo[]); +// unset($foo[]); + $foo->$a; + echo "---\n"; +} +?> +--EXPECT-- +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +NULL +string(2) "ok" +string(2) "ok" +--- +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +string(2) "ok" +NULL +string(2) "ok" +string(2) "ok" +--- diff --git a/Zend/tests/bug31720.phpt b/Zend/tests/bug31720.phpt new file mode 100644 index 0000000..c4680a4 --- /dev/null +++ b/Zend/tests/bug31720.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #31720 (Invalid object callbacks not caught in array_walk()) +--FILE-- +<?php +$array = array('at least one element'); + +array_walk($array, array($nonesuchvar,'show')); +?> +===DONE=== +--EXPECTF-- +Notice: Undefined variable: nonesuchvar in %s on line %d + +Warning: array_walk() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in %s on line %d +===DONE=== diff --git a/Zend/tests/bug32226.phpt b/Zend/tests/bug32226.phpt new file mode 100644 index 0000000..9536c92 --- /dev/null +++ b/Zend/tests/bug32226.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #32226 (SEGV with exception handler on non existing instance) +--FILE-- +<?php + +class A +{ + public function A() + { + set_exception_handler(array($this, 'EH')); + + throw new Exception(); + } + + public function EH() + { + restore_exception_handler(); + + throw new Exception(); + } +} + +try +{ +$a = new A(); +} +catch(Exception $e) +{ + echo "Caught\n"; +} + +?> +===DONE=== +--EXPECT-- +Caught +===DONE=== diff --git a/Zend/tests/bug32252.phpt b/Zend/tests/bug32252.phpt new file mode 100644 index 0000000..706da18 --- /dev/null +++ b/Zend/tests/bug32252.phpt @@ -0,0 +1,47 @@ +--TEST-- +Bug #32252 (Segfault when offsetSet throws an Exception (only without debug)) +--FILE-- +<?php + +class Test implements ArrayAccess +{ + function offsetExists($offset) + { + echo __METHOD__ . "($offset)\n"; + return false; + } + + function offsetGet($offset) + { + echo __METHOD__ . "($offset)\n"; + return null; + } + + function offsetSet($offset, $value) + { + echo __METHOD__ . "($offset, $value)\n"; + throw new Exception("Ooops"); + } + + function offsetUnset($offset) + { + echo __METHOD__ . "($offset)\n"; + } +} + +$list = new Test(); +try +{ + $list[-1] = 123; +} +catch (Exception $e) +{ + echo "CAUGHT\n"; +} + +?> +===DONE=== +--EXPECT-- +Test::offsetSet(-1, 123) +CAUGHT +===DONE=== diff --git a/Zend/tests/bug32290.phpt b/Zend/tests/bug32290.phpt new file mode 100644 index 0000000..89da67b --- /dev/null +++ b/Zend/tests/bug32290.phpt @@ -0,0 +1,124 @@ +--TEST-- +Bug #32290 (calling call_user_func_array() ends in infinite loop within child class) +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class TestA +{ + public function doSomething($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } + + public function doSomethingThis($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } + + public function doSomethingParent($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } + + public function doSomethingParentThis($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } + + public static function doSomethingStatic($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } +} + +class TestB extends TestA +{ + public function doSomething($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array("TestA", "doSomething"), array($i)); + } + + public function doSomethingThis($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array($this, "TestA::doSomethingThis"), array($i)); + } + + public function doSomethingParent($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array("parent", "doSomethingParent"), array($i)); + } + + public function doSomethingParentThis($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array($this, "parent::doSomethingParentThis"), array($i)); + } + + public static function doSomethingStatic($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array("TestA", "doSomethingStatic"), array($i)); + } +} + +$x = new TestB(); +echo "===A===\n"; +var_dump($x->doSomething(1)); +echo "\n===B===\n"; +var_dump($x->doSomethingThis(1)); +echo "\n===C===\n"; +var_dump($x->doSomethingParent(1)); +echo "\n===D===\n"; +var_dump($x->doSomethingParentThis(1)); +echo "\n===E===\n"; +var_dump($x->doSomethingStatic(1)); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +===A=== +TestB::doSomething(1) +TestA::doSomething(2) +int(1) + +===B=== +TestB::doSomethingThis(1) +TestA::doSomethingThis(2) +int(1) + +===C=== +TestB::doSomethingParent(1) +TestA::doSomethingParent(2) +int(1) + +===D=== +TestB::doSomethingParentThis(1) +TestA::doSomethingParentThis(2) +int(1) + +===E=== +TestB::doSomethingStatic(1) +TestA::doSomethingStatic(2) +int(1) +===DONE=== diff --git a/Zend/tests/bug32296.phpt b/Zend/tests/bug32296.phpt new file mode 100644 index 0000000..b3e705e --- /dev/null +++ b/Zend/tests/bug32296.phpt @@ -0,0 +1,60 @@ +--TEST-- +Bug #32296 (get_class_methods output has changed between 5.0.2 and 5.0.3) +--FILE-- +<?php +abstract class space{ + function __construct(){} + abstract protected function unfold(); +} + +abstract class shape extends space{ + private function x1() {} + protected final function unfold(){} +} + +abstract class quad extends shape{ + private function x2() {} + function buggy(){ + $c = get_class($this); + $a = get_class_methods(get_class($this)); + $b = get_class_methods($this); + print($c."\n".'a:'); + print_r($a); + print('b:'); + print_r($b); + } +} + +class square extends quad{} + +$a = new square(); +$a->buggy(); +print_r(get_class_methods("square")); +print_r(get_class_methods($a)); +?> +--EXPECT-- +square +a:Array +( + [0] => x2 + [1] => buggy + [2] => unfold + [3] => __construct +) +b:Array +( + [0] => x2 + [1] => buggy + [2] => unfold + [3] => __construct +) +Array +( + [0] => buggy + [1] => __construct +) +Array +( + [0] => buggy + [1] => __construct +) diff --git a/Zend/tests/bug32322.phpt b/Zend/tests/bug32322.phpt new file mode 100644 index 0000000..f69c525 --- /dev/null +++ b/Zend/tests/bug32322.phpt @@ -0,0 +1,80 @@ +--TEST-- +Bug #32322 (Return values by reference broken( using self::),example singleton instance) +--INI-- +error_reporting=4095 +--FILE-- +<?php +class test +{ + private static $instance = null; + private $myname = ''; + + private function __construct( $value = '' ) + { + echo "New class $value created \n"; + $this -> myname = $value; + } + private function __clone() {} + static public function getInstance() + { + if ( self::$instance == null ) + { + self::$instance = new test('Singleton1'); + } + else { + echo "Using old class " . self::$instance -> myname . "\n"; + } + return self::$instance; + } + static public function getInstance2() + { + static $instance2 = null; + if ( $instance2 == null ) + { + $instance2 = new test('Singleton2'); + } + else { + echo "Using old class " . $instance2 -> myname . "\n"; + } + return $instance2; + } + public function __destruct() + { + if ( defined('SCRIPT_END') ) + { + echo "Class " . $this -> myname . " destroyed at script end\n"; + } else { + echo "Class " . $this -> myname . " destroyed beforce script end\n"; + } + } +} +echo "Try static instance inside class :\n"; +$getCopyofSingleton = test::getInstance(); +$getCopyofSingleton = null; +$getCopyofSingleton = &test::getInstance(); +$getCopyofSingleton = null; +$getCopyofSingleton = test::getInstance(); +echo "Try static instance inside function :\n"; +$getCopyofSingleton2 = test::getInstance2(); +$getCopyofSingleton2 = null; +$getCopyofSingleton2 = &test::getInstance2(); +$getCopyofSingleton2 = null; +$getCopyofSingleton2 = test::getInstance2(); + +define('SCRIPT_END',1); +?> +--EXPECTF-- +Try static instance inside class : +New class Singleton1 created +Using old class Singleton1 + +Strict Standards: Only variables should be assigned by reference in %sbug32322.php on line 49 +Using old class Singleton1 +Try static instance inside function : +New class Singleton2 created +Using old class Singleton2 + +Strict Standards: Only variables should be assigned by reference in %sbug32322.php on line 55 +Using old class Singleton2 +Class Singleton1 destroyed at script end +Class Singleton2 destroyed at script end diff --git a/Zend/tests/bug32427.phpt b/Zend/tests/bug32427.phpt new file mode 100644 index 0000000..9b2d818 --- /dev/null +++ b/Zend/tests/bug32427.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #32427 (Interfaces are not allowed 'static' access modifier) +--FILE-- +<?php + +interface Example { + public static function sillyError(); +} + +class ExampleImpl implements Example { + public static function sillyError() { + echo "I am a silly error\n"; + } +} + +ExampleImpl::sillyError(); +?> +--EXPECT-- +I am a silly error diff --git a/Zend/tests/bug32428.phpt b/Zend/tests/bug32428.phpt new file mode 100644 index 0000000..0b5ca6a --- /dev/null +++ b/Zend/tests/bug32428.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #32428 (The @ warning error supression operator is broken) +--FILE-- +<?php + $data = @$not_exists; + $data = @($not_exists); + $data = @!$not_exists; + $data = !@$not_exists; + $data = @($not_exists+1); + echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug32429.phpt b/Zend/tests/bug32429.phpt new file mode 100644 index 0000000..b711831 --- /dev/null +++ b/Zend/tests/bug32429.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #32429 (method_exists() always return TRUE if __call method exists) +--FILE-- +<?php + +class TestClass { + public function __construct() { + var_dump(method_exists($this, 'test')); + + if (method_exists($this, 'test')) { + $this->test(); + } + } + + public function __call($name, $args) { + throw new Exception('Call to undefined method'.get_class($this).'::'.$name.'()'); + } +} + +try { + $test = new TestClass; +} catch (Exception $e) { + exit($e->getMessage()); +} + +?> +--EXPECT-- +bool(false) diff --git a/Zend/tests/bug32596.phpt b/Zend/tests/bug32596.phpt new file mode 100644 index 0000000..2dd0cfe --- /dev/null +++ b/Zend/tests/bug32596.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #32596 (Segfault/Memory Leak by getClass (etc) in __destruct) +--FILE-- +<?php +class BUG { + public $error = "please fix this thing, it wasted a nice part of my life!\n"; + static function instance() {return new BUG();} + + function __destruct() + { + $c=get_class($this); unset($c); + echo get_class($this) ."\n"; + if(defined('DEBUG_'.__CLASS__)){} + $c=get_class($this); //memory leak only + echo $this->error; + } +} + + +BUG::instance()->error; +echo "this is still executed\n"; +?> +--EXPECT-- +BUG +please fix this thing, it wasted a nice part of my life! +this is still executed + diff --git a/Zend/tests/bug32660.phpt b/Zend/tests/bug32660.phpt new file mode 100644 index 0000000..3a30718 --- /dev/null +++ b/Zend/tests/bug32660.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #32660 (Assignment by reference causes crash when field access is overloaded (__get)) +--FILE-- +<?php +class A +{ + public $q; + + function __construct() + { + $this->q = 3;//array(); + } + + function __get($name) + { + return $this->q; + } +} + +$a = new A; + +$b = "short"; +$c =& $a->whatever; +$c = "long"; +print_r($a); +$a->whatever =& $b; +$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] => 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/bug32674.phpt b/Zend/tests/bug32674.phpt new file mode 100644 index 0000000..771270f --- /dev/null +++ b/Zend/tests/bug32674.phpt @@ -0,0 +1,62 @@ +--TEST-- +Bug #32674 (exception in iterator causes crash) +--FILE-- +<?php +class collection implements Iterator { + + private $_elements = array(); + + public function __construct() { + } + + public function rewind() { + reset($this->_elements); + } + + public function count() { + return count($this->_elements); + } + + public function current() { + $element = current($this->_elements); + return $element; + } + + public function next() { + $element = next($this->_elements); + return $element; + } + + public function key() { + $this->_fillCollection(); + $element = key($this->_elements); + return $element; + } + + public function valid() { + throw new Exception('shit happend'); + + return ($this->current() !== false); + } +} + +class class2 { + public $dummy; +} + +$obj = new class2(); +$col = new collection(); + +try { + foreach($col as $co) { + //irrelevant + } + echo 'shouldn`t get here'; + //$dummy = 'this will not crash'; + $obj->dummy = 'this will crash'; +} catch (Exception $e) { + echo "ok\n"; +} +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug32799.phpt b/Zend/tests/bug32799.phpt new file mode 100644 index 0000000..c76daed --- /dev/null +++ b/Zend/tests/bug32799.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #32799 (crash: calling the corresponding global var during the destruct) +--FILE-- +<?php +class test{ + public $c=1; + function __destruct (){ + if (!isset($GLOBALS['p'])) { + echo "NULL\n"; + } else { + $GLOBALS['p']->c++; // no warning + print $GLOBALS['p']->c."\n"; // segfault + var_dump($GLOBALS['p']); + } + } +} +$p=new test; +$p=null; //destroy the object by a new assignment (segfault) +?> +--EXPECT-- +NULL diff --git a/Zend/tests/bug32833.phpt b/Zend/tests/bug32833.phpt new file mode 100644 index 0000000..e58c845 --- /dev/null +++ b/Zend/tests/bug32833.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #32833 (Invalid opcode with $a[] .= '') +--FILE-- +<?php +$test = array(); +$test[] .= "ok\n"; +echo $test[0]; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug32993.phpt b/Zend/tests/bug32993.phpt new file mode 100644 index 0000000..88fb023 --- /dev/null +++ b/Zend/tests/bug32993.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #32993 (implemented Iterator function current() don't throw exception) +--FILE-- +<?php +class Test implements Iterator { + + public $arr = array(); + + public function rewind() { return reset($this->arr); } + public function current() { throw new Exception(); } + public function key() { return key($this->arr); } + public function next() { return next($this->arr); } + public function valid() { return (current($this->arr) !== false); } +} + +$t = new Test(); +$t->arr = array(1, 2, 3); + +try { + foreach ($t as $v) { + echo "$v\n"; + } +} catch (Exception $e) { + ; // handle exception +} +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug33116.phpt b/Zend/tests/bug33116.phpt new file mode 100644 index 0000000..aa714a1 --- /dev/null +++ b/Zend/tests/bug33116.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #33116 (crash when assigning class name to global variable in __autoload) +--FILE-- +<?php +function __autoload($class) +{ + $GLOBALS['include'][] = $class; + eval("class DefClass{}"); +} + +$a = new DefClass; +print_r($a); +print_r($GLOBALS['include']); +?> +--EXPECT-- +DefClass Object +( +) +Array +( + [0] => DefClass +) diff --git a/Zend/tests/bug33171.phpt b/Zend/tests/bug33171.phpt new file mode 100644 index 0000000..27f5264 --- /dev/null +++ b/Zend/tests/bug33171.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #33171 (foreach enumerates private fields declared in base classes) +--FILE-- +<?php +class A +{ + private $c = "A's c"; +} + +class B extends A +{ + private $c = "B's c"; + + public function go() + { + foreach ($this as $key => $val) + { + echo "$key => $val\n"; + } + } +}; + +$x = new B; +$x->go(); +?> +--EXPECT-- +c => B's c diff --git a/Zend/tests/bug33257.phpt b/Zend/tests/bug33257.phpt new file mode 100644 index 0000000..c17ddfd --- /dev/null +++ b/Zend/tests/bug33257.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #33257 (array_splice() inconsistent when passed function instead of variable) +--INI-- +error_reporting=4095 +--FILE-- +<?php +class X { + protected static $arr = array("a", "b", "c"); + public static function getArr() { + return self::$arr; + } +} + +//$arr1 = X::getArr(); +array_splice(X::getArr(), 1, 1); +print_r(X::getArr()); +?> +--EXPECTF-- +Strict Standards: Only variables should be passed by reference in %sbug33257.php on line 10 +Array +( + [0] => a + [1] => b + [2] => c +) diff --git a/Zend/tests/bug33277.phpt b/Zend/tests/bug33277.phpt new file mode 100644 index 0000000..859c449 --- /dev/null +++ b/Zend/tests/bug33277.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #33277 (private method accessed by child class) +--FILE-- +<?php +class foo { + private function bar() { + echo "private!\n"; + } +} + +class fooson extends foo { + function barson() { + $this->bar(); + } +} + +class foo2son extends fooson { + + function bar() { + echo "public!\n"; + } +} + +$b = new foo2son(); +$b->barson(); +?> +--EXPECT-- +public! diff --git a/Zend/tests/bug33282.phpt b/Zend/tests/bug33282.phpt new file mode 100644 index 0000000..65e3c16 --- /dev/null +++ b/Zend/tests/bug33282.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #33282 (Re-assignment by reference does not clear the is_ref flag) +--FILE-- +<?php + $a = array(1, 2, 3); + $r = &$a[0]; + $r = &$a[1]; + $r = &$a[2]; + var_dump($a); +?> +--EXPECT-- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + &int(3) +} diff --git a/Zend/tests/bug33318.phpt b/Zend/tests/bug33318.phpt new file mode 100644 index 0000000..dc1afbb --- /dev/null +++ b/Zend/tests/bug33318.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #33318 (throw 1; results in Invalid opcode 108/1/8) +--FILE-- +<?php +throw 1; +?> +--EXPECTF-- +Fatal error: Can only throw objects in %sbug33318.php on line 2
\ No newline at end of file diff --git a/Zend/tests/bug33512.phpt b/Zend/tests/bug33512.phpt new file mode 100644 index 0000000..9dd4e4e --- /dev/null +++ b/Zend/tests/bug33512.phpt @@ -0,0 +1,66 @@ +--TEST-- +Bug #33512 (unset() overloaded properties doesn't work) +--FILE-- +<?php +class TheObj { + public $RealVar1, $RealVar2, $RealVar3, $RealVar4; + public $Var = array(); + + function __set($var, $val) { + $this->Var[$var] = $val; + } + function __get($var) { + if(isset($this->Var[$var])) return $this->Var[$var]; + else return -1; + } + function __unset($var) { + unset($this->Var[$var]); + } + } + + $SomeObj = new TheObj; + + // this will fine + $SomeObj->RealVar1 = 'somevalue'; + $SomeObj->{'RealVar2'} = 'othervalue'; + $SomeObj->{'RealVar'.(3)} = 'othervaluetoo'; + $SomeObj->{'RealVar'.'4'} = 'anothervalue'; + + // this will fine too + $SomeObj->Virtual1 = 'somevalue'; + $SomeObj->{'Virtual2'} = 'othervalue'; + + // it's can't be used since this will encounter error + $SomeObj->{'Virtual'.(3)} = 'othervaluetoo'; + $SomeObj->{'Virtual'.'4'} = 'anothervalue'; + + // but this will fine, ofcourse + $SomeObj->Var['Virtual'.(3)] = 'othervaluetoo'; + $SomeObj->Var['Virtual'.'4'] = 'anothervalue'; + + + var_dump($SomeObj->RealVar1); + print $SomeObj->{'RealVar'.(3)}."\n"; + + unset($SomeObj->RealVar1); + unset($SomeObj->{'RealVar'.(3)}); + + //the lines below will catch by '__get' magic method since these variables are unavailable anymore + var_dump($SomeObj->RealVar1); + print $SomeObj->{'RealVar'.(3)}."\n"; + + // now we will try to unset these variables + unset($SomeObj->Virtual1); + unset($SomeObj->{'Virtual'.(3)}); + + //but, these variables are still available??? eventhough they're "unset"-ed + print $SomeObj->Virtual1."\n"; + print $SomeObj->{'Virtual'.(3)}."\n"; +?> +--EXPECT-- +string(9) "somevalue" +othervaluetoo +int(-1) +-1 +-1 +-1 diff --git a/Zend/tests/bug33558.phpt b/Zend/tests/bug33558.phpt new file mode 100644 index 0000000..9c87fc6 --- /dev/null +++ b/Zend/tests/bug33558.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #33558 (warning with nested calls to functions returning by reference) +--INI-- +error_reporting=4095 +--FILE-- +<?php +function & foo() { + $var = 'ok'; + return $var; +} + +function & bar() { + return foo(); +} + +$a =& bar(); +echo "$a\n"; +?> +--EXPECT-- +ok + diff --git a/Zend/tests/bug33710.phpt b/Zend/tests/bug33710.phpt new file mode 100644 index 0000000..330bb58 --- /dev/null +++ b/Zend/tests/bug33710.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #33710 (ArrayAccess objects doesn't initialize $this) +--FILE-- +<?php + +class Foo implements ArrayAccess +{ + function offsetExists($offset) {/*...*/} + function offsetGet($offset) {/*...*/} + function offsetSet($offset, $value) {/*...*/} + function offsetUnset($offset) {/*...*/} + + function fail() + { + $this['blah']; + } + + function succeed() + { + $this; + $this['blah']; + } +} + +$bar = new Foo(); +$bar->succeed(); +$bar->fail(); + +?> +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/tests/bug33732.phpt b/Zend/tests/bug33732.phpt new file mode 100644 index 0000000..4969791 --- /dev/null +++ b/Zend/tests/bug33732.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #33732 (Wrong behavior of constants in class and interface extending) +--FILE-- +<?php +interface iA { + const cA = "const of iA\n"; +} + +class A implements iA { +} + +class B extends A implements iA { +} + +echo iA::cA; +echo A::cA; +echo B::cA; + + +interface iA2 { + const cA = "const of iA2\n"; +} + +interface iB2 extends iA2 { +} + +class A2 implements iA2 { +} + +class B2 extends A2 implements iA2 { +} + +echo iA2::cA; +echo A2::cA; +echo iB2::cA; +echo B2::cA; +?> +--EXPECT-- +const of iA +const of iA +const of iA +const of iA2 +const of iA2 +const of iA2 +const of iA2 diff --git a/Zend/tests/bug33771.phpt b/Zend/tests/bug33771.phpt new file mode 100644 index 0000000..72d953c --- /dev/null +++ b/Zend/tests/bug33771.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #33771 (error_reporting falls to 0 when @ was used inside try/catch block) +--FILE-- +<?php + +error_reporting(E_ALL | E_STRICT); + +var_dump(error_reporting()); + +function make_exception() +{ + throw new Exception(); +} + +function make_exception_and_change_err_reporting() +{ + error_reporting(E_ALL & ~E_STRICT); + throw new Exception(); +} + + +try { + @make_exception(); +} catch (Exception $e) {} + +var_dump(error_reporting()); + +try { + @make_exception_and_change_err_reporting(); +} catch (Exception $e) {} + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +int(32767) +int(32767) +int(30719) +Done diff --git a/Zend/tests/bug33802.phpt b/Zend/tests/bug33802.phpt new file mode 100644 index 0000000..d2f8cd7 --- /dev/null +++ b/Zend/tests/bug33802.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #33802 (throw Exception in error handler causes crash) +--FILE-- +<?php +set_error_handler('errorHandler', E_USER_ERROR); +try{ + test(); +}catch(Exception $e){ +} +restore_error_handler(); + +function test(){ + trigger_error("error", E_USER_ERROR); +} + +function errorHandler($errno, $errstr, $errfile, $errline) { + throw new Exception(); +} +?> +ok +--EXPECT-- +ok diff --git a/Zend/tests/bug33996.phpt b/Zend/tests/bug33996.phpt new file mode 100644 index 0000000..e722ece --- /dev/null +++ b/Zend/tests/bug33996.phpt @@ -0,0 +1,29 @@ +--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/bug33999.phpt b/Zend/tests/bug33999.phpt new file mode 100644 index 0000000..1946280 --- /dev/null +++ b/Zend/tests/bug33999.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #33999 (object remains object when cast to int) +--INI-- +error_reporting=4095 +--FILE-- +<?php +class Foo { + public $bar = "bat"; +} + +$foo = new Foo; +var_dump($foo); + +$bar = (int)$foo; +var_dump($bar); + +$baz = (float)$foo; +var_dump($baz); +?> +--EXPECTF-- +object(Foo)#1 (1) { + ["bar"]=> + string(3) "bat" +} + +Notice: Object of class Foo could not be converted to int in %sbug33999.php on line 9 +int(1) + +Notice: Object of class Foo could not be converted to double in %sbug33999.php on line 12 +float(1) diff --git a/Zend/tests/bug34045.phpt b/Zend/tests/bug34045.phpt new file mode 100644 index 0000000..61886cf --- /dev/null +++ b/Zend/tests/bug34045.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #34045 (Buffer overflow with serialized object) +--FILE-- +<?php +class BasicSingleton +{ + private static $instance; + + public function __wakeup() { + self::$instance = $this; + } + + public static function singleton() { + if (!(self::$instance instanceof BasicSingleton)) { + $c = __CLASS__; + self::$instance = new $c; + } + return self::$instance; + } +} + +$db = BasicSingleton::singleton(); +$db_str = serialize($db); +$db2 = unserialize($db_str); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug34062.phpt b/Zend/tests/bug34062.phpt new file mode 100644 index 0000000..bcb4ad8 --- /dev/null +++ b/Zend/tests/bug34062.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #34062 (Crash in catch block when many arguments are used) +--FILE-- +<?php +function f1() { throw new Exception; } +function f2() { echo "here\n"; } + +try { + // Currently it's the minimum required number of zeros + // If you remove one, it won't crash + max(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, f1()); +} catch (Exception $e) { + echo "(((\n"; + f2(0, 0, 0); // Won't crash if less than 3 zeros here + echo ")))\n"; +} +?> +--EXPECT-- +((( +here +))) + diff --git a/Zend/tests/bug34064.phpt b/Zend/tests/bug34064.phpt new file mode 100644 index 0000000..84208a5 --- /dev/null +++ b/Zend/tests/bug34064.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #34064 (arr[] as param to function in class gives invalid opcode) +--FILE-- +<?php +class XmlTest { + + function test_ref(&$test) + { + $test = "ok"; + } + + function test($test) + { + } + + function run() + { + $ar = array(); + $this->test_ref($ar[]); + var_dump($ar); + $this->test($ar[]); + } +} + +$o = new XmlTest(); +$o->run(); +?> +--EXPECTF-- +array(1) { + [0]=> + string(2) "ok" +} + +Fatal error: Cannot use [] for reading in %sbug34064.php on line 18 + diff --git a/Zend/tests/bug34065.phpt b/Zend/tests/bug34065.phpt new file mode 100644 index 0000000..9d76fca --- /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/bug34137.phpt b/Zend/tests/bug34137.phpt new file mode 100644 index 0000000..5856333 --- /dev/null +++ b/Zend/tests/bug34137.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #34137 (assigning array element by reference causes binary mess) +--FILE-- +<?php +$arr1 = array('a1' => array('alfa' => 'ok')); +$arr1 =& $arr1['a1']; +echo '-'.$arr1['alfa']."-\n"; +?> +--EXPECT-- +-ok- diff --git a/Zend/tests/bug34199.phpt b/Zend/tests/bug34199.phpt new file mode 100644 index 0000000..3012d80 --- /dev/null +++ b/Zend/tests/bug34199.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #34199 (if($obj)/if(!$obj) inconsistency because of cast handler) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip SimpleXML extension required"; ?> +--FILE-- +<?php +$xml = "<root></root>"; +$xml = simplexml_load_string($xml); +$kids = $xml->children(); +var_dump((bool)$kids); +if($kids) echo "bug\n"; else echo "ok\n"; +if(!$kids) echo "ok\n"; else echo "bug\n"; +?> +--EXPECT-- +bool(false) +ok +ok + diff --git a/Zend/tests/bug34260.phpt b/Zend/tests/bug34260.phpt new file mode 100644 index 0000000..fa393d0 --- /dev/null +++ b/Zend/tests/bug34260.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #34260 (Segfault with callbacks (array_map) + overloading) +--FILE-- +<?php +class Faulty +{ + function __call($Method,$Args) + { + switch($Method) + { + case 'seg': + echo "I hate me\n"; + break; + } + } + + function NormalMethod($Args) + { + echo "I heart me\n"; + } +} + +$Faulty = new Faulty(); +$Array = array('Some junk','Some other junk'); + +// This causes a seg fault. +$Failure = array_map(array($Faulty,'seg'),$Array); + +// This does not. +$Failure = array_map(array($Faulty,'NormalMethod'),$Array); +?> +--EXPECT-- +I hate me +I hate me +I heart me +I heart me diff --git a/Zend/tests/bug34310.phpt b/Zend/tests/bug34310.phpt new file mode 100644 index 0000000..1d2bb03 --- /dev/null +++ b/Zend/tests/bug34310.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #34310 (foreach($arr as $c->d => $x) crashes) +--FILE-- +<?php + +class C +{ + public $d; +} + +$c = new C(); + +$arr = array (1 => 'a', 2 => 'b', 3 => 'c'); + +// Works fine: +foreach($arr as $x => $c->d) +{ + echo "{$x} => {$c->d}\n"; +} + +// Crashes: +foreach($arr as $c->d => $x) +{ + echo "{$c->d} => {$x}\n"; +} + +?> +--EXPECT-- +1 => a +2 => b +3 => c +1 => a +2 => b +3 => c diff --git a/Zend/tests/bug34358.phpt b/Zend/tests/bug34358.phpt new file mode 100644 index 0000000..b9c6565 --- /dev/null +++ b/Zend/tests/bug34358.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #34358 (Fatal error: Cannot re-assign $this(again)) +--FILE-- +<?php +class foo { + function bar() { + $ref = &$this; + } +} +$x = new foo(); +$x->bar(); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug34467.phpt b/Zend/tests/bug34467.phpt new file mode 100644 index 0000000..5f0ccaf --- /dev/null +++ b/Zend/tests/bug34467.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #34467 (foreach + __get + __set incosistency) +--FILE-- +<?php +class abc { + private $arr; + + function __set ($key, $value) { + $this->arr[$key] = $value; + } + + function __get ($key) { + return $this->arr[$key]; + } +} +$abc = new abc(); +foreach (array (1,2,3) as $abc->k => $abc->v) { + var_dump($abc->k,$abc->v); +} +?> +--EXPECT-- +int(0) +int(1) +int(1) +int(2) +int(2) +int(3) diff --git a/Zend/tests/bug34518.phpt b/Zend/tests/bug34518.phpt new file mode 100644 index 0000000..b94fdf4 --- /dev/null +++ b/Zend/tests/bug34518.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #34518 (Unset doesn't separate container in CV) +--FILE-- +<?php +$arr = array(1,2,3); +$arr["foo"] = array(4,5,6); +$copy = $arr; + +unset($copy["foo"][0]); +print_r($arr); +print_r($copy); +?> +--EXPECT-- +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [foo] => Array + ( + [0] => 4 + [1] => 5 + [2] => 6 + ) + +) +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [foo] => Array + ( + [1] => 5 + [2] => 6 + ) + +) diff --git a/Zend/tests/bug34617.phpt b/Zend/tests/bug34617.phpt new file mode 100644 index 0000000..25f785f --- /dev/null +++ b/Zend/tests/bug34617.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #34617 (zend_deactivate: objects_store used after zend_objects_store_destroy is called) +--SKIPIF-- +<?php if (!extension_loaded("xml")) print "skip the xml extension not available"; ?> +--FILE-- +<?php +class Thing {} +function boom() +{ + $reader = xml_parser_create(); + xml_set_object($reader, new Thing()); + die("ok\n"); + xml_parser_free($reader); +} +boom(); +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug34678.phpt b/Zend/tests/bug34678.phpt new file mode 100644 index 0000000..2a13201 --- /dev/null +++ b/Zend/tests/bug34678.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #34678 (__call(), is_callable() and static methods) +--FILE-- +<?php +class A { + public function __call($m, $a) { + echo "__call\n"; + } +} + +class B extends A { + public static function foo() { + echo "foo\n"; + } +} + +if (is_callable(array('B', 'foo'))) { + call_user_func(array('B', 'foo')); +} +if (is_callable(array('A', 'foo'))) { + call_user_func(array('A', 'foo')); +} +?> +--EXPECT-- +foo diff --git a/Zend/tests/bug34786.phpt b/Zend/tests/bug34786.phpt new file mode 100644 index 0000000..1864284 --- /dev/null +++ b/Zend/tests/bug34786.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #34786 (2 @ results in change to error_reporting() to random value) +--FILE-- +<?php +function foo($a,$b,$c) { +echo "foo: ".error_reporting()."\n"; +} + +function bar() { +echo "bar: ".error_reporting()."\n"; +} + +error_reporting(1); +echo "before: ".error_reporting()."\n"; +@foo(1,@bar(),3); +echo "after: ".error_reporting()."\n"; +?> +--EXPECT-- +before: 1 +bar: 0 +foo: 0 +after: 1 diff --git a/Zend/tests/bug34873.phpt b/Zend/tests/bug34873.phpt new file mode 100644 index 0000000..7d9eb78 --- /dev/null +++ b/Zend/tests/bug34873.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #34873 (Segmentation Fault on foreach in object) +--FILE-- +<?php +class pwa { + public $var; + + function __construct(){ + $this->var = array(); + } + + function test (){ + $cont = array(); + $cont["mykey"] = "myvalue"; + + foreach ($cont as $this->var['key'] => $this->var['value']) + var_dump($this->var['value']); + } +} +$myPwa = new Pwa(); +$myPwa->test(); + +echo "Done\n"; +?> +--EXPECT-- +string(7) "myvalue" +Done diff --git a/Zend/tests/bug34879.phpt b/Zend/tests/bug34879.phpt new file mode 100644 index 0000000..606142b --- /dev/null +++ b/Zend/tests/bug34879.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #34879 (str_replace, array_map corrupt negative array indexes on 64-bit platforms) +--FILE-- +<?php +print_r(str_replace('a', 'b', array(-1 =>-1))); +?> +--EXPECT-- +Array +( + [-1] => -1 +)
\ No newline at end of file diff --git a/Zend/tests/bug34893.phpt b/Zend/tests/bug34893.phpt new file mode 100644 index 0000000..bbe0235 --- /dev/null +++ b/Zend/tests/bug34893.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #34893 (PHP5.1 overloading, Cannot access private property) +--FILE-- +<?php +class A { + private $p; + function __get($name){ + return $this->$name; + } + function __set($name, $value) { + $this->$name = $value; + } +} +class B { + private $t; + function __get($name){ + return $this->$name; + } + function __set($name, $value) { + $this->$name = $value; + } +} +$a = new A; +$b = new B; +$a->p = $b; +$b->t = "foo"; + +echo $a->p->t; +$a->p->t = "bar"; +echo $a->p->t; +?> +--EXPECT-- +foobar diff --git a/Zend/tests/bug35017.phpt b/Zend/tests/bug35017.phpt new file mode 100644 index 0000000..0a89d23 --- /dev/null +++ b/Zend/tests/bug35017.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #35017 (Exception thrown in error handler may cause unexpected behavior) +--FILE-- +<?php +set_error_handler('errorHandler'); +try { + if ($a) { + echo "1\n"; + } else { + echo "0\n"; + } + echo "?\n"; +} catch(Exception $e) { + echo "This Exception should be catched\n"; +} +function errorHandler($errno, $errstr, $errfile, $errline, $vars) { + throw new Exception('Some Exception'); +} +?> +--EXPECT-- +This Exception should be catched diff --git a/Zend/tests/bug35106.phpt b/Zend/tests/bug35106.phpt new file mode 100644 index 0000000..61a66d0 --- /dev/null +++ b/Zend/tests/bug35106.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #35106 (nested foreach fails when array variable has a reference) +--FILE-- +<?php +$a=array("1","2"); +$b=&$a; +foreach($a as $i){ + echo $i; + foreach($a as $p); +} +echo "\n"; +?> +--EXPECT-- +12 diff --git a/Zend/tests/bug35163.phpt b/Zend/tests/bug35163.phpt new file mode 100644 index 0000000..6a10d24 --- /dev/null +++ b/Zend/tests/bug35163.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #35163 (Array elements can lose references) +--FILE-- +<?php +$a = array(array(1)); +$a[0][] =& $a[0]; +$a[0][] =& $a[0]; +$a[0][0] = 2; +var_dump($a); +$a[0] = null; +$a = null; +?> +--EXPECT-- +array(1) { + [0]=> + &array(3) { + [0]=> + int(2) + [1]=> + *RECURSION* + [2]=> + *RECURSION* + } +} diff --git a/Zend/tests/bug35163_2.phpt b/Zend/tests/bug35163_2.phpt new file mode 100644 index 0000000..0138720 --- /dev/null +++ b/Zend/tests/bug35163_2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #35163.2 (Array elements can lose references) +--FILE-- +<?php +$a = array(1); +$b = 'a'; +${$b}[] =& $$b; +${$b}[] =& $$b; +${$b}[0] = 2; +var_dump($a); +$a[0] = null; +$a = null; +?> +--EXPECT-- +array(3) { + [0]=> + int(2) + [1]=> + &array(3) { + [0]=> + int(2) + [1]=> + *RECURSION* + [2]=> + *RECURSION* + } + [2]=> + &array(3) { + [0]=> + int(2) + [1]=> + *RECURSION* + [2]=> + *RECURSION* + } +} diff --git a/Zend/tests/bug35163_3.phpt b/Zend/tests/bug35163_3.phpt new file mode 100644 index 0000000..6c6a57f --- /dev/null +++ b/Zend/tests/bug35163_3.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #35163.3 (Array elements can lose references) +--FILE-- +<?php +$a = new stdClass; +$a->b = array(1); +$a->b[] =& $a->b; +$a->b[] =& $a->b; +$a->b[0] = 2; +var_dump($a); +$a->b = null; +$a = null; +?> +--EXPECTF-- +object(stdClass)#%d (1) { + ["b"]=> + &array(3) { + [0]=> + int(2) + [1]=> + *RECURSION* + [2]=> + *RECURSION* + } +} diff --git a/Zend/tests/bug35239.phpt b/Zend/tests/bug35239.phpt new file mode 100644 index 0000000..869971e --- /dev/null +++ b/Zend/tests/bug35239.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #35239 (Objects can lose references) +--FILE-- +<?php +$a = new stdClass; +$a->x0 = new stdClass; +$a->x0->y0 = 'a'; +$a->x0->y1 =& $a->x0; +$a->x0->y2 =& $a->x0; +$a->x0->y0 = 'b'; +var_dump($a); +$a->x0->y1 = "ok\n"; +echo $a->x0; +?> +--EXPECTF-- +object(stdClass)#%d (1) { + ["x0"]=> + &object(stdClass)#%d (3) { + ["y0"]=> + string(1) "b" + ["y1"]=> + *RECURSION* + ["y2"]=> + *RECURSION* + } +} +ok diff --git a/Zend/tests/bug35393.phpt b/Zend/tests/bug35393.phpt new file mode 100644 index 0000000..ce3bdd0 --- /dev/null +++ b/Zend/tests/bug35393.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #35393 (changing static protected members from outside the class) +--INI-- +error_reporting=4095 +--FILE-- +<?php +class ObjectPath +{ + static protected $type = array(0=>'main'); + + static function getType() + { + return self::$type; + } +} +print_r(ObjectPath::getType()); +$object_type = array_pop((ObjectPath::getType())); +print_r(ObjectPath::getType()); +?> +--EXPECTF-- +Array +( + [0] => main +) + +Strict Standards: Only variables should be passed by reference in %sbug35393.php on line 12 +Array +( + [0] => main +) diff --git a/Zend/tests/bug35411.phpt b/Zend/tests/bug35411.phpt new file mode 100644 index 0000000..90957aa --- /dev/null +++ b/Zend/tests/bug35411.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #35411 (Regression with \{$ handling) +--FILE-- +<?php +$abc = "bar"; +echo "foo\{$abc}baz\n"; +echo "foo\{ $abc}baz\n"; +echo <<<TEST +foo{$abc}baz +foo\{$abc}baz +foo\{ $abc}baz +TEST; +?> +--EXPECT-- +foo\{bar}baz +foo\{ bar}baz +foobarbaz +foo\{bar}baz +foo\{ bar}baz diff --git a/Zend/tests/bug35437.phpt b/Zend/tests/bug35437.phpt new file mode 100644 index 0000000..73222a9 --- /dev/null +++ b/Zend/tests/bug35437.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #35437 (Segfault or Invalid Opcode 137/1/4) +--FILE-- +<?php +function err2exception($errno, $errstr) +{ + throw new Exception("Error occuried: " . $errstr); +} + +set_error_handler('err2exception'); + +class TestClass +{ + function testMethod() + { + $GLOBALS['t'] = new stdClass; + } +} + +try { + TestClass::testMethod(); +} catch (Exception $e) { + echo "Catched: ".$e->getMessage()."\n"; +} +?> +--EXPECT-- +Catched: Error occuried: Non-static method TestClass::testMethod() should not be called statically diff --git a/Zend/tests/bug35470.phpt b/Zend/tests/bug35470.phpt new file mode 100644 index 0000000..5a85455 --- /dev/null +++ b/Zend/tests/bug35470.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #35470 (Assigning global using variable name from array doesn't function) +--FILE-- +<?php +$x = array("test", "55"); +global ${$x[0]}; +${$x[0]} = $x[1]; +echo "Test: $test\n";; +?> +--EXPECT-- +Test: 55 diff --git a/Zend/tests/bug35509.phpt b/Zend/tests/bug35509.phpt new file mode 100644 index 0000000..6cb54c0 --- /dev/null +++ b/Zend/tests/bug35509.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #35509 (string constant as array key has different behavior inside object) +--FILE-- +<?php +class mytest +{ + const classConstant = '01'; + + private $classArray = array( mytest::classConstant => 'value' ); + + public function __construct() + { + print_r($this->classArray); + } +} + +$classtest = new mytest(); + +define( "normalConstant", '01' ); +$normalArray = array( normalConstant => 'value' ); +print_r($normalArray); +?> +--EXPECT-- +Array +( + [01] => value +) +Array +( + [01] => value +) diff --git a/Zend/tests/bug35634.phpt b/Zend/tests/bug35634.phpt new file mode 100644 index 0000000..1437017 --- /dev/null +++ b/Zend/tests/bug35634.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #35634 (Erroneous "Class declarations may not be nested" error raised) +--INI-- +error_reporting=0 +--FILE-- +<?php +if (defined("pass3")) { + + class ErrorClass { + } + +} else if (defined("pass2")) { + + class TestClass { + function __construct() { + } + function TestClass() { + $this->__construct(); + } + } + +} else { + + function errorHandler($errorNumber, $errorMessage, $fileName, $lineNumber) { + define("pass3", 1); + include(__FILE__); + die("Error: $errorMessage ($fileName:$lineNumber)\n"); + } + + set_error_handler('errorHandler'); + define("pass2", 1); + include(__FILE__); + print "ok\n"; +} + +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug35655.phpt b/Zend/tests/bug35655.phpt new file mode 100644 index 0000000..bbb1377 --- /dev/null +++ b/Zend/tests/bug35655.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #35655 (whitespace following end of heredoc is lost) +--INI-- +highlight.string = #DD0000 +highlight.comment = #FF8000 +highlight.keyword = #007700 +highlight.default = #0000BB +highlight.html = #000000 +--FILE-- +<?php +$code = ' +<?php + $x = <<<EOT +some string +EOT + $y = 2; +?>'; +highlight_string($code); +?> +--EXPECT-- +<code><span style="color: #000000"> +<br /><span style="color: #0000BB"><?php<br /> $x </span><span style="color: #007700">= <<<EOT<br /></span><span style="color: #DD0000">some string <br /></span><span style="color: #007700">EOT<br /> </span><span style="color: #0000BB">$y </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> +</span> +</code> diff --git a/Zend/tests/bug36006.phpt b/Zend/tests/bug36006.phpt new file mode 100644 index 0000000..79f9897 --- /dev/null +++ b/Zend/tests/bug36006.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #36006 (Problem with $this in __destruct()) +--FILE-- +<?php + +class Person { + public $dad; + public function __destruct() { + $this->dad = null; /* no segfault if this is commented out */ + } +} + +class Dad extends Person { + public $son; + public function __construct() { + $this->son = new Person; + $this->son->dad = $this; /* no segfault if this is commented out */ + } + public function __destruct() { + $this->son = null; + parent::__destruct(); /* segfault here */ + } +} + +$o = new Dad; +unset($o); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug36037.phpt b/Zend/tests/bug36037.phpt new file mode 100644 index 0000000..3ccebf6 --- /dev/null +++ b/Zend/tests/bug36037.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #36037 (heredoc adds extra line number) +--FILE-- +<?php +echo __LINE__, "\n"; +$x=<<<XXX +123 +YYY; +XXX; +echo __LINE__, "\n"; +?> +--EXPECT-- +2 +7 diff --git a/Zend/tests/bug36071.phpt b/Zend/tests/bug36071.phpt new file mode 100644 index 0000000..e514609 --- /dev/null +++ b/Zend/tests/bug36071.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #36071 (Engine Crash related with 'clone') +--INI-- +error_reporting=4095 +--FILE-- +<?php +$a = clone 0; +$a[0]->b = 0; +?> +--EXPECTF-- +Fatal error: __clone method called on non-object in %sbug36071.php on line 2
\ No newline at end of file diff --git a/Zend/tests/bug36214.phpt b/Zend/tests/bug36214.phpt new file mode 100644 index 0000000..6307737 --- /dev/null +++ b/Zend/tests/bug36214.phpt @@ -0,0 +1,57 @@ +--TEST-- +Bug #36214 (__get method works properly only when conditional operator is used) +--SKIPIF-- +<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?> +--FILE-- +<?php +class context { + public $stack = array(); + + public function __set($name,$var) { + $this->stack[$name] = $var;return; + } + + public function &__get($name) { + return $this->stack[$name]; + } +} + +$ctx = new context; +$ctx->comment_preview = array(); +$ctx->comment_preview[0] = 1; +$ctx->comment_preview[1] = 2; +var_dump($ctx->comment_preview); + +$comment_preview = array(); +$comment_preview[0] = 1; +$comment_preview[1] = 2; +$ctx->comment_preview = $comment_preview; +var_dump($ctx->comment_preview); + +$ctx->comment_preview = new ArrayObject(); +$ctx->comment_preview[0] = 1; +$ctx->comment_preview[1] = 2; +var_dump($ctx->comment_preview); +?> +--EXPECTF-- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +object(ArrayObject)#%d (1) { + ["storage":"ArrayObject":private]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } +} diff --git a/Zend/tests/bug36268.phpt b/Zend/tests/bug36268.phpt new file mode 100644 index 0000000..5276d50 --- /dev/null +++ b/Zend/tests/bug36268.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #36268 (Object destructors called even after fatal errors) +--FILE-- +<?php +class Foo { + function __destruct() { + echo "Ha!\n"; + } +} +$x = new Foo(); +bar(); +?> +--EXPECTF-- +Fatal error: Call to undefined function bar() in %sbug36268.php on line 8 diff --git a/Zend/tests/bug36303.phpt b/Zend/tests/bug36303.phpt new file mode 100644 index 0000000..0f92323 --- /dev/null +++ b/Zend/tests/bug36303.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #36303 (foreach on error_zval produces segfault) +--FILE-- +<?php +$x="test"; +foreach($x->a->b as &$v) { +} +echo "ok\n"; +?> +--EXPECTF-- +Warning: Attempt to modify property of non-object in %sbug36303.php on line 3 + +Warning: Invalid argument supplied for foreach() in %sbug36303.php on line 3 +ok diff --git a/Zend/tests/bug36513.phpt b/Zend/tests/bug36513.phpt new file mode 100644 index 0000000..f46da4e --- /dev/null +++ b/Zend/tests/bug36513.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #36513 (comment will be outputed in last line) +--FILE-- +<?php +function test($s) { + echo "'".trim(str_replace(" ", " ", htmlspecialchars_decode(strip_tags(highlight_string($s,1)))))."'\n"; +} + +eval('echo "1";//2'); +eval('echo 3; //{ 4?>5'); +echo "\n"; + +//test('<?php echo "1";//'); +test('<?php echo "1";//2'); +test('<?php echo "1";//22'); +test('<?php echo 3; // 4 ?>5'); +?> +--EXPECT-- +135 +'<?php echo "1";//2' +'<?php echo "1";//22' +'<?php echo 3; // 4 ?>5' diff --git a/Zend/tests/bug36568.phpt b/Zend/tests/bug36568.phpt new file mode 100644 index 0000000..d621491 --- /dev/null +++ b/Zend/tests/bug36568.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #36568 (memory_limit has no effect) +--SKIPIF-- +<?php + if (!function_exists('memory_get_usage')) die('skip PHP is configured without memory_limit'); +?> +--INI-- +memory_limit=16M +--FILE-- +<?php +ini_set("memory_limit", "32M"); +echo ini_get("memory_limit"); +?> +--EXPECT-- +32M diff --git a/Zend/tests/bug36759.phpt b/Zend/tests/bug36759.phpt new file mode 100644 index 0000000..8aa9977 --- /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/bug37046.phpt b/Zend/tests/bug37046.phpt new file mode 100644 index 0000000..09b8f0c --- /dev/null +++ b/Zend/tests/bug37046.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #37046 (foreach breaks static scope) +--FILE-- +<?php +function s() { + static $storage = array(array('x', 'y')); + return $storage[0]; +} + +foreach (s() as $k => $function) { + echo "op1 $k\n"; + if ($k == 0) { + foreach (s() as $k => $function) { + echo "op2 $k\n"; + } + } +} +?> +--EXPECT-- +op1 0 +op2 0 +op2 1 +op1 1 diff --git a/Zend/tests/bug37138.phpt b/Zend/tests/bug37138.phpt new file mode 100644 index 0000000..f8503f8 --- /dev/null +++ b/Zend/tests/bug37138.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #37138 (__autoload tries to load callback'ed self and parent) +--FILE-- +<?php +function __autoload ($CN) {var_dump ($CN);} +class st { + public static function e () {echo ("EHLO\n");} + public static function e2 () {call_user_func (array ('self', 'e'));} +} +class stch extends st { + public static function g () {call_user_func (array ('parent', 'e'));} +} +st::e (); +st::e2 (); +stch::g (); +?> +--EXPECT-- +EHLO +EHLO +EHLO + diff --git a/Zend/tests/bug37144.phpt b/Zend/tests/bug37144.phpt new file mode 100644 index 0000000..b3e5489 --- /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 100644 index 0000000..212ef23 --- /dev/null +++ b/Zend/tests/bug37212.phpt @@ -0,0 +1,55 @@ +--TEST-- +Bug #37212 (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/bug37251.phpt b/Zend/tests/bug37251.phpt new file mode 100644 index 0000000..320d544 --- /dev/null +++ b/Zend/tests/bug37251.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #37251 (deadlock when custom error handler is to catch array type hint error) +--FILE-- +<?php +function error_handler($errno, $errstr, $errfile, $errline, $context) { + echo 'OK'; +} + +set_error_handler('error_handler'); + +class Foo { + function bar(array $foo) { + } +} + +$foo = new Foo(); +$foo->bar(); +--EXPECT-- +OK diff --git a/Zend/tests/bug37632.phpt b/Zend/tests/bug37632.phpt new file mode 100644 index 0000000..fb72f89 --- /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 100644 index 0000000..ecf43c5 --- /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 100644 index 0000000..1964958 --- /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/bug37715.phpt b/Zend/tests/bug37715.phpt new file mode 100644 index 0000000..a585c78 --- /dev/null +++ b/Zend/tests/bug37715.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #37715 (array pointers resetting on copy) +--FILE-- +<?php +$a = array( + 'a' => array( + 'A', 'B', 'C', 'D', + ), + 'b' => array( + 'AA', 'BB', 'CC', 'DD', + ), +); + +// Set the pointer of $a to 'b' and the pointer of 'b' to 'CC' +reset($a); +next($a); +next($a['b']); +next($a['b']); +next($a['b']); + +var_dump(key($a['b'])); +foreach($a as $k => $d) +{ +} +// Alternatively $c = $a; and foreachloop removal will cause identical results. +var_dump(key($a['b'])); +--EXPECT-- +int(3) +int(3) diff --git a/Zend/tests/bug37811.phpt b/Zend/tests/bug37811.phpt new file mode 100644 index 0000000..70c4c90 --- /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 100644 index 0000000..00290ee --- /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 100644 index 0000000..e321e11 --- /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 100644 index 0000000..6ae9430 --- /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 100644 index 0000000..bee3ffc --- /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 100644 index 0000000..a81a3aa --- /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 100644 index 0000000..9a53a93 --- /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 0000000..281d999 --- /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/bug38469.phpt b/Zend/tests/bug38469.phpt new file mode 100644 index 0000000..6afcaf5 --- /dev/null +++ b/Zend/tests/bug38469.phpt @@ -0,0 +1,54 @@ +--TEST-- +Bug #38469 (Unexpected creation of cycle) +--FILE-- +<?php +$a = array(); +$a[0] = $a; +var_dump($a); +$b = array(array()); +$b[0][0] = $b; +var_dump($b); + +function f() { + $a = array(); + $a[0] = $a; + var_dump($a); + $b = array(array()); + $b[0][0] = $b; + var_dump($b); +} +f(); +?> +--EXPECT-- +array(1) { + [0]=> + array(0) { + } +} +array(1) { + [0]=> + array(1) { + [0]=> + array(1) { + [0]=> + array(0) { + } + } + } +} +array(1) { + [0]=> + array(0) { + } +} +array(1) { + [0]=> + array(1) { + [0]=> + array(1) { + [0]=> + array(0) { + } + } + } +} diff --git a/Zend/tests/bug38623.phpt b/Zend/tests/bug38623.phpt new file mode 100644 index 0000000..9b042a9 --- /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 0000000..081e35c --- /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 100644 index 0000000..0e97c29 --- /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 0000000..5ffe990 --- /dev/null +++ b/Zend/tests/bug38779.phpt @@ -0,0 +1,32 @@ +--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_stat() { + return array('size' => 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 0000000..eefa952 --- /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 100644 index 0000000..0fc4bfe --- /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 100644 index 0000000..85bb56d --- /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 0000000..7a3da84 --- /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 100644 index 0000000..7020475 --- /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/bug39018.phpt b/Zend/tests/bug39018.phpt new file mode 100644 index 0000000..32566ba --- /dev/null +++ b/Zend/tests/bug39018.phpt @@ -0,0 +1,103 @@ +--TEST-- +Bug #39018 (Error control operator '@' fails to suppress "Uninitialized string offset") +--FILE-- +<?php + +error_reporting(E_ALL); + +$a = 'foo'; +$a[111111111111111111111]; + +$a = ''; + +$a[0]; + +print $a[0]; // 12 + +$a[-11111111111111111111111]; + +print $a[-11111111111111111111111]; // 16 + +$a[-0]; + +$x = 'test'; + +@$x[4]; + +@$y = $x[4]; + +@('a' == $x[4]); + +$x[4] == 'a'; // 28 + +@$x[4] == 'a'; + +(@$x[4]) == 'a'; + +($x[4]) == 'a'; // 34 + +(@($x[4])) == 'a'; + +(($x[4])) == 'a'; // 38 + +@($x[4]) == 'a'; + +($x[4]) == 'a'; // 42 + +@($x[4] == 'a'); + +($x[4] == 'a'); // 46 + +$y = 'foobar'; + +$y[12.2]; + +print $y[12.2]; // 52 + +$y[3.5]; + +print $y[3.5]; // 56 + +print "\nDone\n"; + +?> +--EXPECTF-- +Notice: String offset cast occurred in %s on line %d + +Notice: Uninitialized string offset: 0 in %s on line %d + +Notice: Uninitialized string offset: 0 in %s on line %d + +Notice: String offset cast occurred in %s on line %d + +Notice: Uninitialized string offset: %i in %s on line %d + +Notice: String offset cast occurred in %s on line %d + +Notice: Uninitialized string offset: %i in %s on line %d + +Notice: Uninitialized string offset: 0 in %s on line %d + +Notice: Uninitialized string offset: 4 in %s on line %d + +Notice: Uninitialized string offset: 4 in %s on line %d + +Notice: Uninitialized string offset: 4 in %s on line %d + +Notice: Uninitialized string offset: 4 in %s on line %d + +Notice: Uninitialized string offset: 4 in %s on line %d + +Notice: String offset cast occurred in %s on line %d + +Notice: Uninitialized string offset: 12 in %s on line %d + +Notice: String offset cast occurred in %s on line %d + +Notice: Uninitialized string offset: 12 in %s on line %d + +Notice: String offset cast occurred in %s on line %d + +Notice: String offset cast occurred in %s on line %d +b +Done diff --git a/Zend/tests/bug39018_2.phpt b/Zend/tests/bug39018_2.phpt new file mode 100644 index 0000000..81831d5 --- /dev/null +++ b/Zend/tests/bug39018_2.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #39018 [2] (Error control operator '@' fails to suppress "Uninitialized string offset") +--FILE-- +<?php + +error_reporting(E_ALL); + +$foo = 'test'; +$x = @$foo[6]; + +print @($foo[100] + $foo[130]); + +print "\nDone\n"; + +?> +--EXPECT-- +0 +Done diff --git a/Zend/tests/bug39036.phpt b/Zend/tests/bug39036.phpt new file mode 100644 index 0000000..017012f --- /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/bug39127.phpt b/Zend/tests/bug39127.phpt new file mode 100644 index 0000000..a013da1 --- /dev/null +++ b/Zend/tests/bug39127.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #39127 (Old-style constructor fallbacks produce strange results) +--FILE-- +<?php + +class a { function a() { var_dump("a::a() called"); } } +class b extends a {} + +$b = new b; +var_dump(is_callable(array($b,"a"))); +var_dump(is_callable(array($b,"b"))); +var_dump(is_callable(array($b,"__construct"))); + +echo "Done\n"; +?> +--EXPECTF-- +string(13) "a::a() called" +bool(true) +bool(false) +bool(false) +Done diff --git a/Zend/tests/bug39297.phpt b/Zend/tests/bug39297.phpt new file mode 100644 index 0000000..92f91a5 --- /dev/null +++ b/Zend/tests/bug39297.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #39297 (Memory corryption because of indirect modification of overloaded array) +--FILE-- +<?php +function compareByRef(&$first, &$second) { + return $first === $second; +} + +class MyTree implements ArrayAccess { + public $parent; + public $children = array(); + + public function offsetExists($offset) { + } + + public function offsetUnset($offset) { + } + + public function offsetSet($offset, $value) { + echo "offsetSet()\n"; + $cannonicalName = strtolower($offset); + $this->children[$cannonicalName] = $value; + $value->parent = $this; + } + + public function offsetGet($offset) { + echo "offsetGet()\n"; + $cannonicalName = strtolower($offset); + return $this->children[$cannonicalName]; + } + +} + +$id = 'Test'; + +$root = new MyTree(); +$child = new MyTree(); +$root[$id] = $child; + +var_dump(compareByRef($root[$id], $child)); +?> +--EXPECT-- +offsetSet() +offsetGet() +bool(true) diff --git a/Zend/tests/bug39304.phpt b/Zend/tests/bug39304.phpt new file mode 100644 index 0000000..8303b82 --- /dev/null +++ b/Zend/tests/bug39304.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #39304 (Segmentation fault with list unpacking of string offset) +--FILE-- +<?php + $s = ""; + list($a, $b) = $s[0]; +echo "I am alive"; +?> +--EXPECTF-- +Notice: Uninitialized string offset: 0 in %sbug39304.php on line %d + +Notice: Uninitialized string offset: 1 in %sbug39304.php on line %d + +Notice: Uninitialized string offset: 0 in %sbug39304.php on line %d +I am alive + diff --git a/Zend/tests/bug39304_2_4.phpt b/Zend/tests/bug39304_2_4.phpt new file mode 100644 index 0000000..b0e6ddc --- /dev/null +++ b/Zend/tests/bug39304_2_4.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #39304 (Segmentation fault with list unpacking of string offset) +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.4.0', '<')) die('skip ZendEngine 2.4 needed'); ?> +--FILE-- +<?php + $s = ""; + list($a, $b) = $s[0]; + var_dump($a,$b); +?> +--EXPECTF-- +Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line %d + +Notice: Uninitialized string offset: 1 in %sbug39304_2_4.php on line %d + +Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line %d +string(0) "" +string(0) "" diff --git a/Zend/tests/bug39346.phpt b/Zend/tests/bug39346.phpt new file mode 100644 index 0000000..4a614c9 --- /dev/null +++ b/Zend/tests/bug39346.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #39346 (Unsetting a static variable inside a destructor causes segfault later on) +--FILE-- +<?php +class test +{ + protected $_id; + static $instances; + + public function __construct($id) { + $this->_id = $id; + self::$instances[$this->_id] = $this; + } + + function __destruct() { + unset(self::$instances[$this->_id]); + } +} +$test = new test(2); +$test = new test(1); +$test = new test(2); +$test = new test(3); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug39438.phpt b/Zend/tests/bug39438.phpt new file mode 100644 index 0000000..e1ed8e8 --- /dev/null +++ b/Zend/tests/bug39438.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #39438 (Fatal error: Out of memory) +--INI-- +memory_limit=16M +--FILE-- +<?php +$i=0; +$test2=array( + 'a1_teasermenu' => array( + 'downloadcounter' => 2777, + 'versions' => array( + '0.1.0' => array ( + 'title' => 'A1 Teasermenu', + 'description' => 'Displays a teaser for advanced subpages or a selection of advanced pages', + 'state' => 'stable', + 'reviewstate' => 0, + 'category' => 'plugin', + 'downloadcounter' => 2787, + 'lastuploaddate' => 1088427240, + 'dependencies' => array ( + 'depends' => array( + 'typo3' =>'', + 'php' =>'', + 'cms' => '' + ), + 'conflicts' => array('' =>'') + ), + 'authorname' => 'Mirko Balluff', + 'authoremail' => 'balluff@amt1.de', + 'ownerusername' => 'amt1', + 't3xfilemd5' => '3a4ec198b6ea8d0bc2d69d9b7400398f', + ) + ) + ) +); +$test=array(); +while($i<1200) { + $test[]=$test2; + $i++; +} +$out=serialize($test); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug39445.phpt b/Zend/tests/bug39445.phpt new file mode 100644 index 0000000..cf1607f --- /dev/null +++ b/Zend/tests/bug39445.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #39445 (Calling debug_backtrace() in the __toString() function produces a crash) +--FILE-- +<?php +class test { + public function __toString() { + debug_backtrace(); + return 'lowercase'; + } +} + + $test = new test(); + echo strtoupper($test); +?> +--EXPECT-- +LOWERCASE diff --git a/Zend/tests/bug39449.phpt b/Zend/tests/bug39449.phpt new file mode 100644 index 0000000..c725147 --- /dev/null +++ b/Zend/tests/bug39449.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #39449 (Overloaded array properties do not work correctly) +--FILE-- +<?php +class A { + private $keys = array(); + public function & __get($val) { + return $this->keys[$val]; + } + public function __set($k, $v) { + $this->keys[$k] = $v; + } +} + +$a =new A(); +$a->arr = array('a','b','c'); + +$b = &$a->arr; +$b[]= 'd'; + +foreach ($a->arr as $k => $v) { + echo "$k => $v\n"; +} + +$a->arr[]='d'; + +foreach ($a->arr as $k => $v) { + echo "$k => $v\n"; +} +?> +--EXPECT-- +0 => a +1 => b +2 => c +3 => d +0 => a +1 => b +2 => c +3 => d +4 => d diff --git a/Zend/tests/bug39542.phpt b/Zend/tests/bug39542.phpt new file mode 100644 index 0000000..13ddc0a --- /dev/null +++ b/Zend/tests/bug39542.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #39542 (Behaviour of require_once/include_once different to < 5.2.0) +--FILE-- +<?php +$oldcwd = getcwd(); +chdir(dirname(__FILE__)); +if (substr(PHP_OS, 0, 3) == 'WIN') { + set_include_path(dirname(__FILE__).'/bug39542;.'); +} else { + set_include_path(dirname(__FILE__).'/bug39542:.'); +} + +function __autoload($class) { + if (!require_once($class.'.php')) { + error_log('Error: Autoload class: '.$class.' not found!'); + } +} + +new bug39542(); + +chdir($oldcwd); +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug39542/bug39542.php b/Zend/tests/bug39542/bug39542.php new file mode 100755 index 0000000..90cb36c --- /dev/null +++ b/Zend/tests/bug39542/bug39542.php @@ -0,0 +1,7 @@ +<?php +class bug39542 { + function bug39542() { + echo "ok\n"; + } +} +?> diff --git a/Zend/tests/bug39602.phpt b/Zend/tests/bug39602.phpt new file mode 100644 index 0000000..db8763d --- /dev/null +++ b/Zend/tests/bug39602.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #39602 (Invalid session.save_handler crashes PHP) +--SKIPIF-- +<?php if (!extension_loaded("session")) die("skip session extension required"); ?> +--INI-- +session.save_handler=qwerty +error_reporting=0 +--FILE-- +<?php +ini_set("session.save_handler","files"); +$x = new stdClass(); +echo "ok"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug39721.phpt b/Zend/tests/bug39721.phpt new file mode 100644 index 0000000..63edfc2 --- /dev/null +++ b/Zend/tests/bug39721.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #39721 (Runtime inheritance causes data corruption) +--FILE-- +<?php +class test2 { + private static $instances = 0; + public $instance; + + public function __construct() { + $this->instance = ++self::$instances; + } + +} + +$foo = new test2(); + +if (is_object($foo)) { + class test2_child extends test2 { + + } +} + +$child = new test2_child(); + +echo $foo->instance . "\n"; +echo $child->instance . "\n"; +?> +--EXPECT-- +1 +2 diff --git a/Zend/tests/bug39775.phpt b/Zend/tests/bug39775.phpt new file mode 100644 index 0000000..4c6ce6b --- /dev/null +++ b/Zend/tests/bug39775.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #39775 ("Indirect modification ..." message is not shown) +--FILE-- +<?php +class test { + var $array = array(); + function __get($var) { + $v =& $this->array; + return $this->array; + } +} +$t = new test; +$t->anything[] = 'bar'; +print_r($t->anything); +?> +--EXPECTF-- +Notice: Indirect modification of overloaded property test::$anything has no effect in %sbug39775.php on line 10 +Array +( +) diff --git a/Zend/tests/bug39825.phpt b/Zend/tests/bug39825.phpt new file mode 100644 index 0000000..791b329 --- /dev/null +++ b/Zend/tests/bug39825.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #39825 (foreach produces memory error) +--FILE-- +<?php +$array = array(1 => 2, "foo" => "bar"); +$obj = (object)$array; +foreach ($obj as $name => $value) { + echo "$name -> $value\n"; +} +?> +--EXPECT-- +1 -> 2 +foo -> bar diff --git a/Zend/tests/bug39944.phpt b/Zend/tests/bug39944.phpt new file mode 100644 index 0000000..4249988 --- /dev/null +++ b/Zend/tests/bug39944.phpt @@ -0,0 +1,88 @@ +--TEST-- +Bug #39944 (References broken) +--FILE-- +<?php +$intTheValue = 0; + +function &getValue() { + global $intTheValue; + return $intTheValue; +} + +function setValue(&$int, $iNewValue) { + $int = $iNewValue; +} + +setValue(getValue(), 10); +echo "intTheValue = {$intTheValue}\n"; + +$b = &$intTheValue; + +setValue(getValue(), 10); +echo "intTheValue = {$intTheValue}\n"; + +/****/ + +$arrTheArray = array(); + +function &getArray() { + global $arrTheArray; + return $arrTheArray; +} + +function addToArray(&$arr, $strToAdd) { + $arr[] = $strToAdd; +} + +addToArray(getArray(), "xx1"); +$a = getArray(); +addToArray($a, "xx2"); +$b = &$arrTheArray; +addToArray($b, "xx3"); +addToArray(getArray(), "xx4"); +$a = getArray(); +addToArray($a, "xx5"); +echo "arrTheArray = " . print_r($arrTheArray, 1); + +/****/ + +class RefTest { + protected $arr; + + function Add($strToAdd) { + $this->addToArray($this->getArray(), $strToAdd); + } + + function &getArray() { + if (!$this->arr) + $this->arr = array(); + return $this->arr; + } + + private function addToArray(&$arr, $strToAdd) { + $arr[] = $strToAdd; + } +} + +$objRefTest = new RefTest(); +$objRefTest->Add("xx1"); +$objRefTest->Add("xx2"); +$objRefTest->Add("xx3"); + +echo "objRefTest->getArray() = " . print_r($objRefTest->getArray(), 1); +?> +--EXPECT-- +intTheValue = 10 +intTheValue = 10 +arrTheArray = Array +( + [0] => xx1 + [1] => xx3 + [2] => xx4 +) +objRefTest->getArray() = Array +( + [0] => xx1 + [1] => xx2 + [2] => xx3 +) diff --git a/Zend/tests/bug39990.phpt b/Zend/tests/bug39990.phpt new file mode 100644 index 0000000..d7545ee --- /dev/null +++ b/Zend/tests/bug39990.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #39990 (Cannot "foreach" over overloaded properties) +--FILE-- +<?php + class Foo { + public function __get($name) { + return array('Hello', 'World'); + } + } + + $obj=new Foo(); + foreach($obj->arr as $value) + echo "$value\n"; +?> +--EXPECT-- +Hello +World diff --git a/Zend/tests/bug40236.inc b/Zend/tests/bug40236.inc new file mode 100644 index 0000000..fc03349 --- /dev/null +++ b/Zend/tests/bug40236.inc @@ -0,0 +1,10 @@ +<?php +function func1() { } +function func2() { } +function func3() { } +function func4() { } +function func5() { } +function func6() { } +function func7() { } +print ("ok\n"); +?>
\ No newline at end of file diff --git a/Zend/tests/bug40236.phpt b/Zend/tests/bug40236.phpt new file mode 100644 index 0000000..f9a4277 --- /dev/null +++ b/Zend/tests/bug40236.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #40236 (php -a function allocation eats memory) +--SKIPIF-- +<?php +if (php_sapi_name() != "cli") die("skip CLI only"); +if (extension_loaded("readline")) die("skip Test doesn't support readline"); +?> +--FILE-- +<?php +$php = getenv('TEST_PHP_EXECUTABLE'); +$cmd = "\"$php\" -n -d memory_limit=4M -a \"".dirname(__FILE__)."\"/bug40236.inc"; +echo `$cmd`; +?> +--EXPECTF-- +Interactive %s + +ok diff --git a/Zend/tests/bug40261.phpt b/Zend/tests/bug40261.phpt new file mode 100644 index 0000000..b7e2c98 --- /dev/null +++ b/Zend/tests/bug40261.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #40261 (Extremely slow data handling due to memory fragmentation) +--INI-- +memory_limit=128M +--FILE-- +<?php +$num = 100000; + +$a = Array(); +for ($i=0; $i<$num; $i++) { + $a[$i] = Array(1); +} + +for ($i=0; $i<$num; $i++) { + $b[$i] = $a[$i][0]; +} + +unset($a); +for ($i=0; $i<$num; $i++) { + $b[$i] = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +} +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug40509.phpt b/Zend/tests/bug40509.phpt new file mode 100644 index 0000000..21eaae9 --- /dev/null +++ b/Zend/tests/bug40509.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #40509 (key() function changed behaviour if global array is used within function) +--FILE-- +<?php +function foo() +{ + global $arr; + + $c = $arr["v"]; + foreach ($c as $v) {} +} + +$arr["v"] = array("a"); + +var_dump(key($arr["v"])); +foo(); +var_dump(key($arr["v"])); +foreach ($arr["v"] as $k => $v) { + var_dump($k); +} +var_dump(key($arr["v"])); +--EXPECT-- +int(0) +int(0) +int(0) +NULL diff --git a/Zend/tests/bug40621.phpt b/Zend/tests/bug40621.phpt new file mode 100644 index 0000000..564ba55 --- /dev/null +++ b/Zend/tests/bug40621.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #40621 (Crash when constructor called inappropriately (statically)) +--FILE-- +<?php + +class Foo { + private function __construct() { } + function get() { + self::__construct(); + } +} + +Foo::get(); + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Non-static method Foo::get() should not be called statically in %s on line %d + +Fatal error: Non-static method Foo::__construct() cannot be called statically in %s on line %d diff --git a/Zend/tests/bug40705.phpt b/Zend/tests/bug40705.phpt new file mode 100644 index 0000000..374f73b --- /dev/null +++ b/Zend/tests/bug40705.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #40705 (Iterating within function moves original array pointer) +--FILE-- +<?php +function doForeach($array) +{ + foreach ($array as $k => $v) { + // do stuff + } +} + +$foo = array('foo', 'bar', 'baz'); +var_dump(key($foo)); +doForeach($foo); +var_dump(key($foo)); +foreach ($foo as $k => $v) { + var_dump($k); +} +var_dump(key($foo)); +--EXPECT-- +int(0) +int(0) +int(0) +int(1) +int(2) +NULL diff --git a/Zend/tests/bug40757.phpt b/Zend/tests/bug40757.phpt new file mode 100644 index 0000000..b5c91c7 --- /dev/null +++ b/Zend/tests/bug40757.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #40757 (get_object_vars() get nothing in child class) +--FILE-- +<?php +class Base { + private $p1='sadf'; + + function getFields($obj){ + return get_object_vars($obj); + } +} + +class Child extends Base { } + +$base=new Base(); +print_r($base->getFields(new Base())); +$child=new Child(); +print_r($child->getFields(new Base())); +?> +--EXPECT-- +Array +( + [p1] => sadf +) +Array +( + [p1] => sadf +) diff --git a/Zend/tests/bug40770.phpt b/Zend/tests/bug40770.phpt new file mode 100644 index 0000000..c4c78c2 --- /dev/null +++ b/Zend/tests/bug40770.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #40770 (Apache child exits when PHP memory limit reached) +--INI-- +memory_limit=8M +--SKIPIF-- +<?php +$zend_mm_enabled = getenv("USE_ZEND_ALLOC"); +if ($zend_mm_enabled === "0") { + die("skip Zend MM disabled"); +} +?> +--FILE-- +<?php +ini_set('display_errors',true); +$mb=148; +$var = ''; +for ($i=0; $i<=$mb; $i++) { + $var.= str_repeat('a',1*1024*1024); +} +?> +--EXPECTF-- +Fatal error: Allowed memory size of 8388608 bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/Zend/tests/bug40784.phpt b/Zend/tests/bug40784.phpt new file mode 100644 index 0000000..6da8f2a --- /dev/null +++ b/Zend/tests/bug40784.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #40784 (Case sensivity in constructor's fallback) +--FILE-- +<?php + +class A { + function A () { echo "I'm A\n"; } +} + +class B extends A { + function __construct() { + parent::__construct(); + parent::__constrUct(); + } +} + +$b = new B; + +echo "Done\n"; +?> +--EXPECTF-- +I'm A +I'm A +Done diff --git a/Zend/tests/bug40809.phpt b/Zend/tests/bug40809.phpt new file mode 100644 index 0000000..08fc89f --- /dev/null +++ b/Zend/tests/bug40809.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #40809 (Poor perfomance of ".=") +--FILE-- +<?php +error_reporting(E_ALL|E_STRICT); + +$num_increments = 100; +$num_repeats = 1000; +$increment = 50; + +/* Create some more holes to give the memory allocator something to + * work with. */ +$num = 5000; +$a = Array(); +for ($i=0; $i<$num; $i++) { + $a[$i] = Array(1); +} +for ($i=0; $i<$num; $i++) { + $b[$i] = $a[$i][0]; +} +unset($a); + +for ($i=0;$i<$num_repeats;$i++) { + $evil = ""; + for ($j=0;$j<$num_increments;$j++) { + $evil .= str_repeat("a", $increment); + } + unset($evil); +} +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug40815.phpt b/Zend/tests/bug40815.phpt new file mode 100644 index 0000000..6f7477a --- /dev/null +++ b/Zend/tests/bug40815.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #40815 (using strings like "class::func" and static methods in set_exception_handler() might result in crash). +--FILE-- +<?php + +class ehandle{ + static public function exh ($ex) { + echo 'foo'; + } +} + +set_exception_handler("ehandle::exh"); + +throw new Exception ("Whiii"); +echo "Done\n"; +?> +--EXPECTF-- +foo diff --git a/Zend/tests/bug40833.phpt b/Zend/tests/bug40833.phpt new file mode 100644 index 0000000..c56ca4c --- /dev/null +++ b/Zend/tests/bug40833.phpt @@ -0,0 +1,72 @@ +--TEST-- +Bug #40833 (Crash when using unset() on an ArrayAccess object retrieved via __get) +--FILE-- +<?php + class entity + { + private $data; + private $modified; + + function __get($name) + { + if ( isset($this->data[$name]) ) + return $this->data[$name]; + else + return $this->data[$name] = new set($this); + } + + function __set($name, $value) + { + $this->modified[$name] = $value; + } + } + + class set implements ArrayAccess + { + private $entity; + + function __construct($entity) + { + $this->entity = $entity; + $this->entity->whatever = $this; + } + + function clear() { + $this->entity->whatever = null; + } + + function offsetUnset($offset) + { + $this->clear(); +// $this->entity->{$this->name} = null; + } + + function offsetSet($offset, $value) + { + } + + function offsetGet($offset) + { + return 'Bogus '; + } + + function offsetExists($offset) + { + } + } + + $entity = new entity(); + echo($entity->whatever[0]); + + //This will crash +// $entity->whatever->clear(); + unset($entity->whatever[0]); + + //This will not crash (comment previous & uncomment this to test +// $test = $entity->whatever; unset($test[0]); + + echo($entity->whatever[0]); + echo "ok\n"; +?> +--EXPECT-- +Bogus Bogus ok diff --git a/Zend/tests/bug40899.phpt b/Zend/tests/bug40899.phpt new file mode 100644 index 0000000..7be0f6b --- /dev/null +++ b/Zend/tests/bug40899.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #40899 (memory leak when nesting list()) +--FILE-- +<?php +list(list($a,$b),$c)=array(array('a','b'),'c'); +echo "$a$b$c\n"; +?> +--EXPECT-- +abc diff --git a/Zend/tests/bug41026.phpt b/Zend/tests/bug41026.phpt new file mode 100644 index 0000000..7caac21 --- /dev/null +++ b/Zend/tests/bug41026.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #41026 (segfault when calling "self::method()" in shutdown functions) +--FILE-- +<?php + +class try_class +{ + static public function main () + { + register_shutdown_function (array ("self", "on_shutdown")); + } + + static public function on_shutdown () + { + printf ("CHECKPOINT\n"); /* never reached */ + } +} + +try_class::main (); + +echo "Done\n"; +?> +--EXPECTF-- +Done + +Warning: (Registered shutdown functions) Unable to call self::on_shutdown() - function does not exist in Unknown on line 0 diff --git a/Zend/tests/bug41075.phpt b/Zend/tests/bug41075.phpt new file mode 100644 index 0000000..0751cbd --- /dev/null +++ b/Zend/tests/bug41075.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #41075 (memleak when creating default object caused exception) +--FILE-- +<?php + +function err($errno, $errstr, $errfile, $errline) +{ + throw new Exception($errstr); +} + +set_error_handler("err"); + +class test { + function foo() { + $var = $this->blah->prop = "string"; + var_dump($this->blah); + } +} + +$t = new test; +try { + $t->foo(); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(40) "Creating default object from empty value" +Done diff --git a/Zend/tests/bug41117_1.phpt b/Zend/tests/bug41117_1.phpt new file mode 100644 index 0000000..f555b63 --- /dev/null +++ b/Zend/tests/bug41117_1.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #41117 (Altering $this via argument) +--FILE-- +<?php +class foo { + function __construct($this) { + echo $this."\n"; + } +} +$obj = new foo("Hello world"); +?> +--EXPECTF-- +Fatal error: Cannot re-assign $this in %sbug41117_1.php on line 3 + diff --git a/Zend/tests/bug41209.phpt b/Zend/tests/bug41209.phpt new file mode 100644 index 0000000..5498ede --- /dev/null +++ b/Zend/tests/bug41209.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #41209 (Segmentation fault with ArrayAccess, set_error_handler and undefined var) +--FILE-- +<?php + +class env +{ + public function __construct() + { + set_error_handler(array(__CLASS__, 'errorHandler')); + } + + public static function errorHandler($errno, $errstr, $errfile, $errline) + { + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); + } +} + +class cache implements ArrayAccess +{ + private $container = array(); + + public function offsetGet($id) {} + + public function offsetSet($id, $value) {} + + public function offsetUnset($id) {} + + public function offsetExists($id) + { + return isset($this->containers[(string) $id]); + } +} + +$env = new env(); +$cache = new cache(); +var_dump(isset($cache[$id])); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: id' in %s:%d +Stack trace: +#0 %s(%d): env::errorHandler(8, '%s', '%s', 34, Array) +#1 {main} + thrown in %s on line %d diff --git a/Zend/tests/bug41351.phpt b/Zend/tests/bug41351.phpt new file mode 100644 index 0000000..62af6a0 --- /dev/null +++ b/Zend/tests/bug41351.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #41351 (Invalid opcode with foreach ($a[] as $b)) +--FILE-- +<?php + +$a = array(); + +foreach($a[] as $b) { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s on line %d diff --git a/Zend/tests/bug41351_2.phpt b/Zend/tests/bug41351_2.phpt new file mode 100644 index 0000000..7009eaa --- /dev/null +++ b/Zend/tests/bug41351_2.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #41351 (Invalid opcode with foreach ($a[] as $b)) - 2 +--FILE-- +<?php + +$a = array(); + +foreach($a[]['test'] as $b) { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s on line %d diff --git a/Zend/tests/bug41351_3.phpt b/Zend/tests/bug41351_3.phpt new file mode 100644 index 0000000..9cb2388 --- /dev/null +++ b/Zend/tests/bug41351_3.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #41351 (Invalid opcode with foreach ($a[] as $b)) - 3 +--FILE-- +<?php + +$a = array(); + +foreach($a['test'][] as $b) { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s on line %d diff --git a/Zend/tests/bug41372.phpt b/Zend/tests/bug41372.phpt new file mode 100644 index 0000000..3446150 --- /dev/null +++ b/Zend/tests/bug41372.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #41372 (Internal pointer of source array resets during array copying) +--FILE-- +<?php +$Foo = array('val1', 'val2', 'val3'); +end($Foo); +echo key($Foo),"\n"; +$MagicInternalPointerResetter = $Foo; +echo key($Foo),"\n"; +?> +--EXPECT-- +2 +2 diff --git a/Zend/tests/bug41401.phpt b/Zend/tests/bug41401.phpt new file mode 100644 index 0000000..50d2109 --- /dev/null +++ b/Zend/tests/bug41401.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #41401 (wrong precedence for unary minus) +--FILE-- +<?php +echo 1/-2*5; +echo "\n"; +echo 6/+2*-3; +--EXPECT-- +-2.5 +-9
\ No newline at end of file diff --git a/Zend/tests/bug41421.phpt b/Zend/tests/bug41421.phpt new file mode 100644 index 0000000..f10db10 --- /dev/null +++ b/Zend/tests/bug41421.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #41421 (Uncaught exception from a stream wrapper segfaults) +--FILE-- +<?php + +class wrapper { + function stream_open() { + return true; + } + function stream_eof() { + throw new exception(); + } +} + +stream_wrapper_register("wrap", "wrapper"); +$fp = fopen("wrap://...", "r"); +feof($fp); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: feof(): wrapper::stream_eof is not implemented! Assuming EOF in %s on line %d + +Fatal error: Uncaught exception 'Exception' in %s:%d +Stack trace: +#0 [internal function]: wrapper->stream_eof() +#1 %s(%d): feof(Resource id #6) +#2 {main} + thrown in %s on line %d diff --git a/Zend/tests/bug41633_1.phpt b/Zend/tests/bug41633_1.phpt new file mode 100644 index 0000000..1c1d552 --- /dev/null +++ b/Zend/tests/bug41633_1.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #41633.1 (self:: doesn't work for constants) +--FILE-- +<?php +class Foo { + const A = self::B; + const B = "ok"; +} +echo Foo::A."\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug41633_2.phpt b/Zend/tests/bug41633_2.phpt new file mode 100644 index 0000000..3deb451 --- /dev/null +++ b/Zend/tests/bug41633_2.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #41633.2 (Undefined class constants must not be substituted by strings) +--FILE-- +<?php +class Foo { + const A = self::B; +} +echo Foo::A."\n"; +?> +--EXPECTF-- +Fatal error: Undefined class constant 'self::B' in %sbug41633_2.php on line 5 diff --git a/Zend/tests/bug41633_3.phpt b/Zend/tests/bug41633_3.phpt new file mode 100644 index 0000000..7b9452d --- /dev/null +++ b/Zend/tests/bug41633_3.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #41633.3 (Crash instantiating classes with self-referencing constants) +--FILE-- +<?php +class Foo { + const A = Foo::B; + const B = Foo::A; +} +echo Foo::A; +?> +--EXPECTF-- +Fatal error: Cannot declare self-referencing constant 'Foo::B' in %sbug41633_3.php on line %d diff --git a/Zend/tests/bug41633_4.phpt b/Zend/tests/bug41633_4.phpt new file mode 100644 index 0000000..3507f6a --- /dev/null +++ b/Zend/tests/bug41633_4.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #41633.4 (self:: doesn't work for constants) +--FILE-- +<?php +class Foo { + const A = self::B; + const B = "ok"; +} +var_dump(defined("Foo::A")); +?> +--EXPECT-- +bool(true) diff --git a/Zend/tests/bug41640.phpt b/Zend/tests/bug41640.phpt new file mode 100644 index 0000000..c859d90 --- /dev/null +++ b/Zend/tests/bug41640.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #41640 (get_class_vars produces error on class constants) +--FILE-- +<?php +class foo { + const FOO = 1; + public $x = self::FOO; +} + +var_dump(get_class_vars("foo")); +--EXPECT-- +array(1) { + ["x"]=> + int(1) +} diff --git a/Zend/tests/bug41813.phpt b/Zend/tests/bug41813.phpt new file mode 100644 index 0000000..c330b14 --- /dev/null +++ b/Zend/tests/bug41813.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #41813 (segmentation fault when using string offset as an object) +--FILE-- +<?php + +$foo = "50"; +$foo[0]->bar = "xyz"; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use string offset as an array in %s on line %d diff --git a/Zend/tests/bug41919.phpt b/Zend/tests/bug41919.phpt new file mode 100644 index 0000000..0ac3276 --- /dev/null +++ b/Zend/tests/bug41919.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #41919 (crash in string to array conversion) +--FILE-- +<?php +$foo="50"; +$foo[3]->bar[1] = "bang"; + +echo "ok\n"; +?> +--EXPECTF-- +Fatal error: Cannot use string offset as an object in %sbug41919.php on line %d diff --git a/Zend/tests/bug41929.phpt b/Zend/tests/bug41929.phpt new file mode 100644 index 0000000..c332aba --- /dev/null +++ b/Zend/tests/bug41929.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #41929 (Foreach on object does not iterate over all visible properties) +--FILE-- +<?php +class C { + private $priv = "ok"; + + function doLoop() { + echo $this->priv,"\n"; + foreach ($this as $k=>$v) { + echo "$k: $v\n"; + } + } +} + +class D extends C { +} + +$myD = new D; +$myD->doLoop(); +?> +--EXPECT-- +ok +priv: ok diff --git a/Zend/tests/bug41961.phpt b/Zend/tests/bug41961.phpt new file mode 100644 index 0000000..514265b --- /dev/null +++ b/Zend/tests/bug41961.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #41961 (Ensure search for hidden private methods does not stray from class hierarchy) +--FILE-- +<?php +X::test(); + +/** Class X is related to neither ParentClass nor ChildClass. */ +class X { + public static function test() { + $myChild = new ChildClass; + $myChild->secret(); // bug - invokes X::secret() instead of ChildClass::secret() + } + private function secret() { + echo "Called private " . __METHOD__ . "() on an instance of: " . get_class($this) . "\n"; + } +} + +class ParentClass { + private function secret() { } +} + +class ChildClass extends ParentClass { + public function secret() { + echo "Called public " . __METHOD__ . "() on an instance of: " . get_class($this) . "\n"; + } +} +?> +--EXPECT-- +Called public ChildClass::secret() on an instance of: ChildClass diff --git a/Zend/tests/bug42143.phpt b/Zend/tests/bug42143.phpt new file mode 100644 index 0000000..8a73d41 --- /dev/null +++ b/Zend/tests/bug42143.phpt @@ -0,0 +1,38 @@ +--TEST-- +bug #42143 (The constant NAN is reported as 0 on Windows build) +--CREDITS-- +Venkat Raman Don +--FILE-- +<?php +echo "Testing NAN:\n"; +echo "NAN= "; +var_dump(NAN); +var_dump(tan(-1) == 123); +var_dump(cos(-100) == "PHP String"); +var_dump(deg2rad(-5.6) == null); +var_dump(sqrt(-0.1) == false); +var_dump(sqrt(cos(M_PI)) == 0.1); +var_dump(NAN); +var_dump(is_nan(sqrt(-1.005)) == false); +var_dump(is_nan(floor(1)) == true); +var_dump(log10(-1) == log(-1)); +var_dump(log10(-1) != log10(-1)); +var_dump(is_finite(log10(-1)) == false); +var_dump(NAN == NAN); +?> +--EXPECT-- +Testing NAN: +NAN= float(NAN) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +float(NAN) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) + diff --git a/Zend/tests/bug42211.phpt b/Zend/tests/bug42211.phpt new file mode 100644 index 0000000..c6ea106 --- /dev/null +++ b/Zend/tests/bug42211.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #42211 (property_exists() fails to find protected properties from a parent class) +--FILE-- +<?php +class A { + function foo() { + var_dump(property_exists('B', 'publicBar')); + var_dump(property_exists('B', 'protectedBar')); + var_dump(property_exists('B', 'privateBar')); + } +} + +class B extends A { + static public $publicBar = "ok"; + static protected $protectedBar = "ok"; + static private $privateBar = "fail"; +} + +$a = new A(); +$a->foo(); +$b = new B(); +$b->foo(); +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/bug42767.phpt b/Zend/tests/bug42767.phpt new file mode 100644 index 0000000..b57177e --- /dev/null +++ b/Zend/tests/bug42767.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #42767 (highlight_string() truncates trailing comments) +--INI-- +highlight.string = #DD0000 +highlight.comment = #FF8000 +highlight.keyword = #007700 +highlight.default = #0000BB +highlight.html = #000000 +--FILE-- +<?php +highlight_string('<?php /*some comment..'); +?> +--EXPECT-- +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php </span><span style="color: #FF8000">/*some comment..</span> +</span> +</code> diff --git a/Zend/tests/bug42772.phpt b/Zend/tests/bug42772.phpt new file mode 100644 index 0000000..8887bdb --- /dev/null +++ b/Zend/tests/bug42772.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #42772 (Storing $this in a static var fails while handling a cast to string) +--FILE-- +<?php +class Foo { + static public $foo; + function __toString() { + self::$foo = $this; + return 'foo'; + } +} + +$foo = (string)new Foo(); +var_dump(Foo::$foo); +?> +--EXPECT-- +object(Foo)#1 (0) { +} diff --git a/Zend/tests/bug42798.phpt b/Zend/tests/bug42798.phpt new file mode 100644 index 0000000..1c45867 --- /dev/null +++ b/Zend/tests/bug42798.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #42798 (_autoload() not triggered for classes used in method signature) +--FILE-- +<?php +function __autoload($className) { + print "$className\n"; + exit(); +} + +function foo($c = ok::constant) { +} + +foo(); +--EXPECT-- +ok diff --git a/Zend/tests/bug42802.phpt b/Zend/tests/bug42802.phpt new file mode 100644 index 0000000..2aa7061 --- /dev/null +++ b/Zend/tests/bug42802.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #42802 (Namespace not supported in typehints) +--FILE-- +<?php +namespace foo; + +class bar { +} + +function test1(bar $bar) { + echo "ok\n"; +} + +function test2(\foo\bar $bar) { + echo "ok\n"; +} +function test3(\foo\bar $bar) { + echo "ok\n"; +} +function test4(\Exception $e) { + echo "ok\n"; +} +function test5(\bar $bar) { + echo "bug\n"; +} + +$x = new bar(); +$y = new \Exception(); +test1($x); +test2($x); +test3($x); +test4($y); +test5($x); +--EXPECTF-- +ok +ok +ok +ok + +Catchable fatal error: Argument 1 passed to foo\test5() must be an instance of bar, instance of foo\bar given, called in %sbug42802.php on line %d and defined in %sbug42802.php on line %d diff --git a/Zend/tests/bug42817.phpt b/Zend/tests/bug42817.phpt new file mode 100644 index 0000000..b1beca4 --- /dev/null +++ b/Zend/tests/bug42817.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #42817 (clone() on a non-object does not result in a fatal error) +--FILE-- +<?php +$a = clone(null); +array_push($a->b, $c); +?> +--EXPECTF-- +Fatal error: __clone method called on non-object in %sbug42817.php on line 2 diff --git a/Zend/tests/bug42818.phpt b/Zend/tests/bug42818.phpt new file mode 100644 index 0000000..09ad693 --- /dev/null +++ b/Zend/tests/bug42818.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #42818 ($foo = clone(array()); leaks memory) +--FILE-- +<?php +$foo = clone(array()); +?> +--EXPECTF-- +Fatal error: __clone method called on non-object in %sbug42818.php on line 2 + diff --git a/Zend/tests/bug42819.phpt b/Zend/tests/bug42819.phpt new file mode 100644 index 0000000..e526603 --- /dev/null +++ b/Zend/tests/bug42819.phpt @@ -0,0 +1,302 @@ +--TEST-- +Bug #42819 (namespaces in indexes of constant arrays) +--SKIPIF-- +<?php if (!extension_loaded("spl")) print "skip SPL extension required"; ?> +--FILE-- +<?php +namespace foo\foo; + +const C = "foo\\foo\\C\n"; +const I = 12; + +class foo { +const I = 32; +const C = "foo\\foo\\foo::C\n"; +} + +namespace foo; +use \ArrayObject; + +const C = "foo\\C\n"; +const I = 11; + +class foo { + const C = "foo\\foo::C\n"; + const I = 22; + const C1 = C; + const C2 = foo\C; + const C3 = foo\foo::C; + const C4 = \foo\C; + const C5 = \foo\foo::C; + const C6 = ArrayObject::STD_PROP_LIST; + const C7 = E_ERROR; +} + +class bar1 { + static $a1 = array(I => 0); + static $a2 = array(foo\I => 0); + static $a3 = array(foo\foo::I => 0); + static $a4 = array(\foo\I => 0); + static $a5 = array(\foo\foo::I => 0); + static $a6 = array(ArrayObject::STD_PROP_LIST => 0); + static $a7 = array(E_ERROR => 0); +} + +class bar2 { + static $a1 = array(I => I); + static $a2 = array(foo\I => I); + static $a3 = array(foo\foo::I => I); + static $a4 = array(\foo\I => I); + static $a5 = array(\foo\foo::I => I); + static $a6 = array(ArrayObject::STD_PROP_LIST => I); + static $a7 = array(E_ERROR => I); +} + +class bar3 { + static $a1 = array(I => foo\I); + static $a2 = array(foo\I => foo\I); + static $a3 = array(foo\foo::I => foo\I); + static $a4 = array(\foo\I => foo\I); + static $a5 = array(\foo\foo::I => foo\I); + static $a6 = array(ArrayObject::STD_PROP_LIST => foo\I); + static $a7 = array(E_ERROR => foo\I); +} + +class bar4 { + static $a1 = array(I => ArrayObject::STD_PROP_LIST); + static $a2 = array(foo\I => ArrayObject::STD_PROP_LIST); + static $a3 = array(foo\foo::I => ArrayObject::STD_PROP_LIST); + static $a4 = array(\foo\I => ArrayObject::STD_PROP_LIST); + static $a5 = array(\foo\foo::I => ArrayObject::STD_PROP_LIST); + static $a6 = array(ArrayObject::STD_PROP_LIST => ArrayObject::STD_PROP_LIST); + static $a7 = array(E_ERROR => ArrayObject::STD_PROP_LIST); +} + +class bar5 { + static $a1 = array(I => E_ERROR); + static $a2 = array(foo\I => E_ERROR); + static $a3 = array(foo\foo::I => E_ERROR); + static $a4 = array(\foo\I => E_ERROR); + static $a5 = array(\foo\foo::I => E_ERROR); + static $a6 = array(ArrayObject::STD_PROP_LIST => E_ERROR); + static $a7 = array(E_ERROR => E_ERROR); +} + +echo "first\n"; +echo C; +echo foo\C; +echo foo\foo::C; +echo foo::C; +echo \foo\foo::C; +echo ArrayObject::STD_PROP_LIST . "\n"; +echo E_ERROR . "\n"; +echo "second\n"; +echo \foo\foo::C1; +echo \foo\foo::C2; +echo \foo\foo::C3; +echo \foo\foo::C4; +echo \foo\foo::C5; +echo \foo\foo::C6 . "\n"; +echo \foo\foo::C7 . "\n"; + +print_r(bar1::$a1); +print_r(bar1::$a2); +print_r(bar1::$a3); +print_r(bar1::$a4); +print_r(bar1::$a5); +print_r(bar1::$a6); +print_r(bar1::$a7); + +print_r(bar2::$a1); +print_r(bar2::$a2); +print_r(bar2::$a3); +print_r(bar2::$a4); +print_r(bar2::$a5); +print_r(bar2::$a6); +print_r(bar2::$a7); + +print_r(bar3::$a1); +print_r(bar3::$a2); +print_r(bar3::$a3); +print_r(bar3::$a4); +print_r(bar3::$a5); +print_r(bar3::$a6); +print_r(bar3::$a7); + +print_r(bar4::$a1); +print_r(bar4::$a2); +print_r(bar4::$a3); +print_r(bar4::$a4); +print_r(bar4::$a5); +print_r(bar4::$a6); +print_r(bar4::$a7); + +print_r(bar5::$a1); +print_r(bar5::$a2); +print_r(bar5::$a3); +print_r(bar5::$a4); +print_r(bar5::$a5); +print_r(bar5::$a6); +print_r(bar5::$a7); +function oops($a = array(foo\unknown)){} +oops(); +?> +--EXPECTF-- +first +foo\C +foo\foo\C +foo\foo\foo::C +foo\foo::C +foo\foo::C +1 +1 +second +foo\C +foo\foo\C +foo\foo\foo::C +foo\C +foo\foo::C +1 +1 +Array +( + [11] => 0 +) +Array +( + [12] => 0 +) +Array +( + [32] => 0 +) +Array +( + [11] => 0 +) +Array +( + [22] => 0 +) +Array +( + [1] => 0 +) +Array +( + [1] => 0 +) +Array +( + [11] => 11 +) +Array +( + [12] => 11 +) +Array +( + [32] => 11 +) +Array +( + [11] => 11 +) +Array +( + [22] => 11 +) +Array +( + [1] => 11 +) +Array +( + [1] => 11 +) +Array +( + [11] => 12 +) +Array +( + [12] => 12 +) +Array +( + [32] => 12 +) +Array +( + [11] => 12 +) +Array +( + [22] => 12 +) +Array +( + [1] => 12 +) +Array +( + [1] => 12 +) +Array +( + [11] => 1 +) +Array +( + [12] => 1 +) +Array +( + [32] => 1 +) +Array +( + [11] => 1 +) +Array +( + [22] => 1 +) +Array +( + [1] => 1 +) +Array +( + [1] => 1 +) +Array +( + [11] => 1 +) +Array +( + [12] => 1 +) +Array +( + [32] => 1 +) +Array +( + [11] => 1 +) +Array +( + [22] => 1 +) +Array +( + [1] => 1 +) +Array +( + [1] => 1 +) + +Fatal error: Undefined constant 'foo\foo\unknown' in %sbug42819.php on line %d
\ No newline at end of file diff --git a/Zend/tests/bug42820.phpt b/Zend/tests/bug42820.phpt new file mode 100644 index 0000000..921f009 --- /dev/null +++ b/Zend/tests/bug42820.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #42820 (defined() on constant with namespace prefixes tries to load class) +--FILE-- +<?php +namespace ns; +const ok = 0; +class foo { + const ok = 0; +} +var_dump(defined('ns\\ok')); +var_dump(defined('ns\\bug')); +var_dump(defined('\\ns\\ok')); +var_dump(defined('\\ns\\bug')); +var_dump(defined('ns\\foo::ok')); +var_dump(defined('ns\\foo::bug')); +var_dump(defined('\\ns\\foo::ok')); +var_dump(defined('\\ns\\foo::bug')); +var_dump(defined('ns\\bar::bug')); +var_dump(defined('\\ns\\bar::bug')); +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(false) +bool(false) + diff --git a/Zend/tests/bug42859.phpt b/Zend/tests/bug42859.phpt new file mode 100644 index 0000000..755f41f --- /dev/null +++ b/Zend/tests/bug42859.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #42859 (import always conflicts with internal classes) +--FILE-- +<?php +namespace Foo; +class Ex {} + +use Blah\Exception; +use Blah\Ex; +?> +--EXPECTF-- +Fatal error: Cannot use Blah\Ex as Ex because the name is already in use in %sbug42859.php on line 6 diff --git a/Zend/tests/bug42937.phpt b/Zend/tests/bug42937.phpt new file mode 100644 index 0000000..537c567 --- /dev/null +++ b/Zend/tests/bug42937.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #42937 (__call() method not invoked when methods are called on parent from child class) +--FILE-- +<?php +class A { + function __call($strMethod, $arrArgs) { + echo "$strMethod\n"; + } +} + +class C { + function __call($strMethod, $arrArgs) { + echo "$strMethod\n"; + } +} + +class B extends A { + function test() { + self::test1(); + parent::test2(); + static::test3(); + A::test4(); + B::test5(); + C::test6(); + } +} + +$a = new A(); +$a->test(); + +$b = new B(); +$b->test(); +?> +--EXPECTF-- +test +test1 +test2 +test3 +test4 +test5 + +Fatal error: Call to undefined method C::test6() in %sbug42937.php on line 21 diff --git a/Zend/tests/bug43027.phpt b/Zend/tests/bug43027.phpt new file mode 100644 index 0000000..adecf3e --- /dev/null +++ b/Zend/tests/bug43027.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #43027 (Declare cause fatal error) +--FILE-- +<?php +declare(ticks=1); +namespace test; +echo "ok\n"; +?> +--EXPECTF-- +ok diff --git a/Zend/tests/bug43053.phpt b/Zend/tests/bug43053.phpt new file mode 100644 index 0000000..646aa97 --- /dev/null +++ b/Zend/tests/bug43053.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #43053 (Regression: some numbers shown in scientific notation) +--FILE-- +<?php +echo 1200000.00."\n"; +echo 1300000.00."\n"; +echo 1400000.00."\n"; +echo 1500000.00."\n"; +?> +--EXPECT-- +1200000 +1300000 +1400000 +1500000 diff --git a/Zend/tests/bug43128.phpt b/Zend/tests/bug43128.phpt new file mode 100644 index 0000000..629f46c --- /dev/null +++ b/Zend/tests/bug43128.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #43128 (Very long class name causes segfault) +--INI-- +memory_limit=128000000 +--FILE-- +<?php + +$a = str_repeat("a", 10 * 1024 * 1024); + +eval("class $a {}"); + +# call_user_func($a); // Warning +# $a->$a(); // Fatal error + +if ($a instanceof $a); // Segmentation fault +new $a; // Segmentation fault +echo "ok\n"; +--EXPECT-- +ok diff --git a/Zend/tests/bug43175.phpt b/Zend/tests/bug43175.phpt new file mode 100644 index 0000000..3bf6bef --- /dev/null +++ b/Zend/tests/bug43175.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #43175 (__destruct() throwing an exception with __call() causes segfault) +--FILE-- +<?php + +class foobar { + public function __destruct() { + throw new Exception(); + } + public function __call($m, $a) { + return $this; + } +} +function foobar() { + return new foobar(); +} +try { + foobar()->unknown(); +} catch (Exception $e) { + echo "__call via traditional factory should be caught\n"; +} +?> +--EXPECT-- +__call via traditional factory should be caught diff --git a/Zend/tests/bug43183.phpt b/Zend/tests/bug43183.phpt new file mode 100644 index 0000000..a8ca698 --- /dev/null +++ b/Zend/tests/bug43183.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #43183 ("use" of the same class in difference scripts results in a fatal error) +--FILE-- +<?php +namespace Test; +use Test\Foo; +class Foo {} +class Bar {} +use Test\Bar; +echo "ok\n"; +--EXPECT-- +ok
\ No newline at end of file diff --git a/Zend/tests/bug43200.phpt b/Zend/tests/bug43200.phpt new file mode 100644 index 0000000..24a8bbb --- /dev/null +++ b/Zend/tests/bug43200.phpt @@ -0,0 +1,51 @@ +--TEST-- +Bug #43200 (Interface implementation / inheritence not possible in abstract classes) +--FILE-- +<?php + +interface a { + function foo(); + function bar(); +} +interface b { + function foo(); +} + +abstract class c { + function bar() { } +} + +class x extends c implements a, b { + function foo() { } +} + +ReflectionClass::export('x'); + +?> +--EXPECTF-- +Class [ <user> class x extends c implements a, b ] { + @@ %s 15-17 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [2] { + Method [ <user, prototype b> public method foo ] { + @@ %s 16 - 16 + } + + Method [ <user, inherits c, prototype a> public method bar ] { + @@ %s 12 - 12 + } + } +} + diff --git a/Zend/tests/bug43200_2.phpt b/Zend/tests/bug43200_2.phpt new file mode 100644 index 0000000..5efc5fa --- /dev/null +++ b/Zend/tests/bug43200_2.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #43200.2 (Interface implementation / inheritence not possible in abstract classes) +--FILE-- +<?php + +interface A { + function foo(); +} + +abstract class B implements A { + abstract public function foo(); +} + +class C extends B { + public function foo() { + echo 'works'; + } +} + +$o = new C(); +$o->foo(); + +?> +--EXPECTF-- +works diff --git a/Zend/tests/bug43201.phpt b/Zend/tests/bug43201.phpt new file mode 100644 index 0000000..89e1b66 --- /dev/null +++ b/Zend/tests/bug43201.phpt @@ -0,0 +1,54 @@ +--TEST-- +Bug #43201 (Crash on using unitialized vals and __get/__set) +--FILE-- +<?php +class Foo { + function __get($k) { + return null; + } + function __set($k, $v) { + $this->$k = $v; + } +} + +$c = new Foo(); + +$c->arr[0]["k"] = 1; +$c->arr[0]["k2"] = $ref; +for($cnt=0;$cnt<6;$cnt++) { + $ref = chop($undef); + $c->arr[$cnt]["k2"] = $ref; +} +echo "ok\n"; +?> +--EXPECTF-- +Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 13 + +Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 14 + +Notice: Undefined variable: ref in %sbug43201.php on line 14 + +Notice: Undefined variable: undef in %sbug43201.php on line 16 + +Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17 + +Notice: Undefined variable: undef in %sbug43201.php on line 16 + +Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17 + +Notice: Undefined variable: undef in %sbug43201.php on line 16 + +Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17 + +Notice: Undefined variable: undef in %sbug43201.php on line 16 + +Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17 + +Notice: Undefined variable: undef in %sbug43201.php on line 16 + +Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17 + +Notice: Undefined variable: undef in %sbug43201.php on line 16 + +Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17 +ok diff --git a/Zend/tests/bug43323.phpt b/Zend/tests/bug43323.phpt new file mode 100644 index 0000000..d366a6d --- /dev/null +++ b/Zend/tests/bug43323.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #43323 (Wrong count abstract methods) +--FILE-- +<?php +abstract class bar { + abstract public function bar(); +} + +class foo extends bar { +} +--EXPECTF-- +Fatal error: Class foo contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (bar::bar) in %sbug43323.php on line 7 diff --git a/Zend/tests/bug43332_1.phpt b/Zend/tests/bug43332_1.phpt new file mode 100644 index 0000000..807c6cb --- /dev/null +++ b/Zend/tests/bug43332_1.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #43332.1 (self and parent as type hint in namespace) +--FILE-- +<?php +namespace foobar; + +class foo { + public function bar(self $a) { } +} + +$foo = new foo; +$foo->bar($foo); // Ok! +$foo->bar(new \stdclass); // Error, ok! +--EXPECTF-- +Catchable fatal error: Argument 1 passed to foobar\foo::bar() must be an instance of foobar\foo, instance of stdClass given, called in %sbug43332_1.php on line 10 and defined in %sbug43332_1.php on line 5 diff --git a/Zend/tests/bug43332_2.phpt b/Zend/tests/bug43332_2.phpt new file mode 100644 index 0000000..b8adef3 --- /dev/null +++ b/Zend/tests/bug43332_2.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #43332.2 (self and parent as type hint in namespace) +--FILE-- +<?php +namespace foobar; + +class foo { + public function bar(\self $a) { } +} + +$foo = new foo; +$foo->bar($foo); // Ok! +$foo->bar(new stdclass); // Error, ok! +--EXPECTF-- +Fatal error: '\self' is an invalid class name in %sbug43332_2.php on line 5 diff --git a/Zend/tests/bug43343.phpt b/Zend/tests/bug43343.phpt new file mode 100644 index 0000000..79b3e5a --- /dev/null +++ b/Zend/tests/bug43343.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #43343 (Variable class name) +--FILE-- +<?php +namespace Foo; +class Bar { } +$foo = 'bar'; +var_dump(new namespace::$foo); +?> +--EXPECTF-- +Parse error: %s error%sexpecting%sT_NS_SEPARATOR%sin %sbug43343.php on line 5 diff --git a/Zend/tests/bug43344_1.phpt b/Zend/tests/bug43344_1.phpt new file mode 100644 index 0000000..59129d7 --- /dev/null +++ b/Zend/tests/bug43344_1.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #43344.1 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +function f1($a=bar) { + return $a; +} +function f2($a=array(bar)) { + return $a[0]; +} +function f3($a=array(bar=>0)) { + reset($a); + return key($a); +} +echo bar."\n"; +echo f1()."\n"; +echo f2()."\n"; +echo f3()."\n"; +?> +--EXPECTF-- +Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 13 +bar + +Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 3 +bar + +Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 6 +bar + +Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 9 +bar diff --git a/Zend/tests/bug43344_10.phpt b/Zend/tests/bug43344_10.phpt new file mode 100644 index 0000000..e9f918c --- /dev/null +++ b/Zend/tests/bug43344_10.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #43344.10 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +echo namespace\bar."\n"; +?> +--EXPECTF-- +Fatal error: Undefined constant 'bar' in %sbug43344_10.php on line %d diff --git a/Zend/tests/bug43344_11.phpt b/Zend/tests/bug43344_11.phpt new file mode 100644 index 0000000..b55cdcc --- /dev/null +++ b/Zend/tests/bug43344_11.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #43344.11 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +function f($a=namespace\bar) { + return $a; +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Undefined constant 'bar' in %sbug43344_11.php on line %d diff --git a/Zend/tests/bug43344_12.phpt b/Zend/tests/bug43344_12.phpt new file mode 100644 index 0000000..4d1e154 --- /dev/null +++ b/Zend/tests/bug43344_12.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #43344.12 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +function f($a=array(namespace\bar)) { + return $a[0]; +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Undefined constant 'bar' in %sbug43344_12.php on line %d diff --git a/Zend/tests/bug43344_13.phpt b/Zend/tests/bug43344_13.phpt new file mode 100644 index 0000000..c6aaf92 --- /dev/null +++ b/Zend/tests/bug43344_13.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #43344.13 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +function f($a=array(namespace\bar=>0)) { + reset($a); + return key($a); +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Undefined constant 'bar' in %sbug43344_13.php on line %d diff --git a/Zend/tests/bug43344_2.phpt b/Zend/tests/bug43344_2.phpt new file mode 100644 index 0000000..57766af --- /dev/null +++ b/Zend/tests/bug43344_2.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #43344.2 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +echo Foo::bar."\n"; +?> +--EXPECTF-- +Fatal error: Class 'Foo\Foo' not found in %sbug43344_2.php on line %d diff --git a/Zend/tests/bug43344_3.phpt b/Zend/tests/bug43344_3.phpt new file mode 100644 index 0000000..579ed81 --- /dev/null +++ b/Zend/tests/bug43344_3.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #43344.3 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +function f($a=Foo::bar) { + return $a; +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Class 'Foo\Foo' not found in %sbug43344_3.php on line %d diff --git a/Zend/tests/bug43344_4.phpt b/Zend/tests/bug43344_4.phpt new file mode 100644 index 0000000..97e08b3 --- /dev/null +++ b/Zend/tests/bug43344_4.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #43344.4 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +function f($a=array(Foo::bar)) { + return $a[0]; +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Class 'Foo\Foo' not found in %sbug43344_4.php on line %d diff --git a/Zend/tests/bug43344_5.phpt b/Zend/tests/bug43344_5.phpt new file mode 100644 index 0000000..645ef33 --- /dev/null +++ b/Zend/tests/bug43344_5.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #43344.5 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +function f($a=array(Foo::bar=>0)) { + reset($a); + return key($a); +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Class 'Foo\Foo' not found in %sbug43344_5.php on line %d diff --git a/Zend/tests/bug43344_6.phpt b/Zend/tests/bug43344_6.phpt new file mode 100644 index 0000000..38e1961 --- /dev/null +++ b/Zend/tests/bug43344_6.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #43344.6 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +echo namespace\bar."\n"; +?> +--EXPECTF-- +Fatal error: Undefined constant 'Foo\bar' in %sbug43344_6.php on line %d diff --git a/Zend/tests/bug43344_7.phpt b/Zend/tests/bug43344_7.phpt new file mode 100644 index 0000000..94e00d9 --- /dev/null +++ b/Zend/tests/bug43344_7.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #43344.7 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +function f($a=namespace\bar) { + return $a; +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Undefined constant 'Foo\bar' in %sbug43344_7.php on line %d diff --git a/Zend/tests/bug43344_8.phpt b/Zend/tests/bug43344_8.phpt new file mode 100644 index 0000000..eb694f7 --- /dev/null +++ b/Zend/tests/bug43344_8.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #43344.8 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +function f($a=array(namespace\bar)) { + return $a[0]; +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Undefined constant 'Foo\bar' in %sbug43344_8.php on line %d diff --git a/Zend/tests/bug43344_9.phpt b/Zend/tests/bug43344_9.phpt new file mode 100644 index 0000000..31604e7 --- /dev/null +++ b/Zend/tests/bug43344_9.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #43344.9 (Wrong error message for undefined namespace constant) +--FILE-- +<?php +namespace Foo; +function f($a=array(namespace\bar=>0)) { + reset($a); + return key($a); +} +echo f()."\n"; +?> +--EXPECTF-- +Fatal error: Undefined constant 'Foo\bar' in %sbug43344_9.php on line %d diff --git a/Zend/tests/bug43426.phpt b/Zend/tests/bug43426.phpt new file mode 100644 index 0000000..73c38df --- /dev/null +++ b/Zend/tests/bug43426.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #43426 (crash on nested call_user_func calls) +--FILE-- +<?php +$c = 1; // doesn't matter +call_user_func("foo2", $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, +$c, + $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c, $c); +function foo2($d) {} +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug43450.phpt b/Zend/tests/bug43450.phpt new file mode 100644 index 0000000..926e146 --- /dev/null +++ b/Zend/tests/bug43450.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #43450 (Memory leak on some functions with implicit object __toString() call) +--SKIPIF-- +<?php if (!function_exists('memory_get_usage')) die('memory_get_usage() not installed'); ?> +--FILE-- +<?php +error_reporting(E_ALL|E_STRICT); + +class Foo +{ + public function __toString() + { + return __CLASS__; + } +} + +$num_repeats = 100000; + +$start = (memory_get_usage() / 1024) + 16; +for ($i=1;$i<$num_repeats;$i++) +{ + $foo = new Foo(); + md5($foo); +} +$end = memory_get_peak_usage() / 1024; + +if ($start < $end) { + echo 'FAIL'; +} else { + echo 'PASS'; +} + +?> +--EXPECT-- +PASS diff --git a/Zend/tests/bug43483.phpt b/Zend/tests/bug43483.phpt new file mode 100644 index 0000000..0cfbfe8 --- /dev/null +++ b/Zend/tests/bug43483.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #43483 (get_class_methods() does not list all visible methods) +--FILE-- +<?php +class C { + public static function test() { + D::prot(); + print_r(get_class_methods("D")); + } +} +class D extends C { + protected static function prot() { + echo "Successfully called D::prot().\n"; + } +} +D::test(); +?> +--EXPECT-- +Successfully called D::prot(). +Array +( + [0] => prot + [1] => test +) diff --git a/Zend/tests/bug43651.phpt b/Zend/tests/bug43651.phpt new file mode 100644 index 0000000..ea70cf1 --- /dev/null +++ b/Zend/tests/bug43651.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #43651 (is_callable() with one or more nonconsecutive colons crashes) +--FILE-- +<?php +class Test { + static function foo() {} +} + +var_dump(is_callable("\\\\")); +var_dump(is_callable("\\")); +var_dump(is_callable("x\\")); +var_dump(is_callable("\\x")); +var_dump(is_callable("x\\x")); +var_dump(is_callable("x\\\\")); +var_dump(is_callable("\\x")); +var_dump(is_callable("x\\\\x")); +var_dump(is_callable("cd")); +var_dump(is_callable("Test\\")); +var_dump(is_callable("\\Test")); +var_dump(is_callable("\\Test\\")); +var_dump(is_callable("Test::foo")); +var_dump(is_callable("\\Test::foo")); +var_dump(is_callable("is_string")); +var_dump(is_callable("\\is_string")); +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/bug43703.phpt b/Zend/tests/bug43703.phpt new file mode 100644 index 0000000..de4f8a8 --- /dev/null +++ b/Zend/tests/bug43703.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #43703 (Signature compatibility check broken) +--FILE-- +<?php +class JoinPoint +{ +} + +abstract class Pointcut +{ + abstract public function evaluate(JoinPoint $joinPoint); +} + +class Read extends Pointcut +{ + public function evaluate(Joinpoint $joinPoint) + { + } +} +?> +DONE +--EXPECT-- +DONE diff --git a/Zend/tests/bug43851.phpt b/Zend/tests/bug43851.phpt new file mode 100644 index 0000000..e19e393 --- /dev/null +++ b/Zend/tests/bug43851.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #43851 (Memory corrution on reuse of assigned value) +--FILE-- +<?php +foo(); +function foo() { + global $LAST; + ($LAST = $LAST + 0) * 1; + echo "ok\n"; +} +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug43918.phpt b/Zend/tests/bug43918.phpt new file mode 100644 index 0000000..e338981 --- /dev/null +++ b/Zend/tests/bug43918.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #43918 (Segmentation fault in garbage collector) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip SimpleXML extension required"; ?> +--FILE-- +<?php +$xmlstr = <<<XML +<?xml version='1.0' standalone='yes'?> +<movies> + <movie> + <title>TEST</title> + </movie> + <movie> + <title>TEST</title> + </movie> + <movie> + <title>TEST</title> + </movie> + <movie> + <title>TEST</title> + </movie> + <movie> + <title>TEST</title> + </movie> + <movie> + <title>TEST</title> + </movie> + <movie> + <title>TEST</title> + </movie> +</movies> +XML; + +$Array = array( ); +for( $XX = 0; $XX < 2000; ++$XX ) +{ + $Array[] = $xml = new SimpleXMLElement($xmlstr); +} + +gc_collect_cycles( ); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug44069.phpt b/Zend/tests/bug44069.phpt new file mode 100644 index 0000000..75beaaf --- /dev/null +++ b/Zend/tests/bug44069.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #44069 (Huge memory usage with concatenation using . instead of .=) +--FILE-- +<?php +$array = array(); +$newstring = ""; +$string = str_repeat('This is a teststring.', 50); +for($i = 1; $i <= 2000; $i++) +{ +// $newstring .= $string; //This uses an expected amount of mem. + $newstring = $newstring . $string; //This uses very much mem. + + for($j = 1; $j <= 10; $j++) + { + $array[] = 'test'; + } +} +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug44141.phpt b/Zend/tests/bug44141.phpt new file mode 100644 index 0000000..1a9ee89 --- /dev/null +++ b/Zend/tests/bug44141.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #44141 (private parent constructor callable through static function) +--FILE-- +<?php +class X +{ + public $x; + private function __construct($x) + { + $this->x = $x; + } +} + +class Y extends X +{ + static public function cheat($x) + { + return new Y($x); + } +} + +$y = Y::cheat(5); +echo $y->x, PHP_EOL; +--EXPECTF-- +Fatal error: Call to private X::__construct() from context 'Y' in %sbug44141.php on line 15 diff --git a/Zend/tests/bug44184.phpt b/Zend/tests/bug44184.phpt new file mode 100644 index 0000000..7f277ac --- /dev/null +++ b/Zend/tests/bug44184.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #44184 (Double free of loop-variable on exception) +--FILE-- +<?php +function foo() { + $x = array(1,2,3); + foreach ($x as $a) { + while (1) { + throw new Exception(); + } + return; + } +} +try { + foo(); +} catch (Exception $ex) { + echo "ok\n"; +} +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug44414.phpt b/Zend/tests/bug44414.phpt new file mode 100644 index 0000000..1f3a258 --- /dev/null +++ b/Zend/tests/bug44414.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #44414 (incomplete reporting about abstract methods) +--FILE-- +<?php +abstract class A { + abstract function foo(); +} +interface B { + function bar(); +} +class C extends A implements B { +} +?> +--EXPECTF-- +Fatal error: Class C contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (A::foo, B::bar) in %sbug44414.php on line 9 diff --git a/Zend/tests/bug44653.phpt b/Zend/tests/bug44653.phpt new file mode 100644 index 0000000..1abf974 --- /dev/null +++ b/Zend/tests/bug44653.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #44653 (Invalid namespace name resolution) +--FILE-- +<?php +namespace A; +const XX=1; +function fooBar() { echo __FUNCTION__ . PHP_EOL; } + +namespace B; +class A { + static function fooBar() { echo "bag1\n"; } +} +class B { + static function fooBar() { echo "bag2\n"; } +} +function fooBar() { echo __FUNCTION__ . PHP_EOL; } +var_dump(\A\XX); +A::fooBar(); +\A\fooBar(); +B::fooBar(); +fooBar(); +\B\fooBar(); +?> +--EXPECT-- +int(1) +bag1 +A\fooBar +bag2 +B\fooBar +B\fooBar diff --git a/Zend/tests/bug44660.phpt b/Zend/tests/bug44660.phpt new file mode 100644 index 0000000..1027377 --- /dev/null +++ b/Zend/tests/bug44660.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #44660 (Indexed and reference assignment to propery of non-object don't trigger warning) +--FILE-- +<?php +$s = "hello"; +$a = true; + +echo "--> read access: "; +echo $a->p; + +echo "\n--> direct assignment: "; +$a->p = $s; + +echo "\n--> increment: "; +$a->p++; + +echo "\n--> reference assignment:"; +$a->p =& $s; + +echo "\n--> reference assignment:"; +$s =& $a->p; + +echo "\n--> indexed assignment:"; +$a->p[0] = $s; + +echo "\n--> Confirm assignments have had no impact:\n"; +var_dump($a); +?> +--EXPECTF-- +--> read access: +Notice: Trying to get property of non-object in %sbug44660.php on line 6 + +--> direct assignment: +Warning: Attempt to assign property of non-object in %sbug44660.php on line 9 + +--> increment: +Warning: Attempt to increment/decrement property of non-object in %sbug44660.php on line 12 + +--> reference assignment: +Warning: Attempt to modify property of non-object in %sbug44660.php on line 15 + +--> reference assignment: +Warning: Attempt to modify property of non-object in %sbug44660.php on line 18 + +--> indexed assignment: +Warning: Attempt to modify property of non-object in %sbug44660.php on line 21 + +--> Confirm assignments have had no impact: +bool(true) diff --git a/Zend/tests/bug44827.phpt b/Zend/tests/bug44827.phpt new file mode 100644 index 0000000..a9f1d87 --- /dev/null +++ b/Zend/tests/bug44827.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #44827 (define() allows :: in constant names) +--FILE-- +<?php +define('foo::bar', 1); +define('::', 1); +?> +--EXPECTF-- +Warning: Class constants cannot be defined or redefined in %sbug44827.php on line %d + +Warning: Class constants cannot be defined or redefined in %sbug44827.php on line %d diff --git a/Zend/tests/bug44830.phpt b/Zend/tests/bug44830.phpt new file mode 100644 index 0000000..21a35ff --- /dev/null +++ b/Zend/tests/bug44830.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #44830 (Very minor issue with backslash in heredoc) +--FILE-- +<?php + +$backslash = <<<EOT +\ +EOT; + +var_dump($backslash); + +?> +--EXPECT-- +string(1) "\" diff --git a/Zend/tests/bug44899.phpt b/Zend/tests/bug44899.phpt new file mode 100644 index 0000000..d62033a --- /dev/null +++ b/Zend/tests/bug44899.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #44899 (__isset usage changes behavior of empty()) +--FILE-- +<?php + +class myclass +{ + private $_data = array(); + + function __construct($data) + { + $this->_data = $data; + } + + function __isset($field_name) + { + return isset($this->_data[$field_name]); + } +} + +$arr = array('foo' => ''); + +$myclass = new myclass($arr) ; + +echo (isset($myclass->foo)) ? 'isset' : 'not isset'; +echo "\n"; +echo (empty($myclass->foo)) ? 'empty' : 'not empty'; +echo "\n"; +echo ($myclass->foo) ? 'not empty' : 'empty'; +echo "\n"; + +?> +--EXPECTF-- +isset +empty + +Notice: Undefined property: myclass::$foo in %s on line %d +empty diff --git a/Zend/tests/bug44899_2.phpt b/Zend/tests/bug44899_2.phpt new file mode 100644 index 0000000..e987149 --- /dev/null +++ b/Zend/tests/bug44899_2.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #44899 (__isset usage changes behavior of empty()) - 2 +--FILE-- +<?php + +class myclass +{ + private $_data = array(); + + function __construct($data) + { + $this->_data = $data; + } + + function __isset($field_name) + { + return isset($this->_data[$field_name]); + } + + function __get($var) { + var_dump(empty($this->_data[$var])); + return $this->_data[$var]; + } +} + +$arr = array('foo' => ''); + +$myclass = new myclass($arr) ; + +echo (isset($myclass->foo)) ? 'isset' : 'not isset'; +echo "\n"; +echo (empty($myclass->foo)) ? 'empty' : 'not empty'; +echo "\n"; +echo ($myclass->foo) ? 'not empty' : 'empty'; +echo "\n"; + +?> +--EXPECT-- +isset +bool(true) +empty +bool(true) +empty diff --git a/Zend/tests/bug44913.phpt b/Zend/tests/bug44913.phpt new file mode 100644 index 0000000..0c2551f --- /dev/null +++ b/Zend/tests/bug44913.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #44913 (Segfault when using return in combination with nested loops and continue 2) +--FILE-- +<?php +function something() { + foreach(array(1, 2) as $value) { + for($i = 0; $i < 1; $i++) { + continue 2; + } + return; + } +} +something(); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug45147.phpt b/Zend/tests/bug45147.phpt new file mode 100644 index 0000000..b940777 --- /dev/null +++ b/Zend/tests/bug45147.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #45147 (unexpected T_ENDFOR) +--FILE-- +<?php for ($i = 0; $i == 0; $i++): ?> + <?php if (true): ?>#<?php else: ?>#<?php endif; ?> +<?php endfor; ?> +--EXPECT-- + # diff --git a/Zend/tests/bug45178.phpt b/Zend/tests/bug45178.phpt new file mode 100644 index 0000000..5ce1859 --- /dev/null +++ b/Zend/tests/bug45178.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #45178 memory corruption on assignment result of "new" by reference +--FILE-- +<?php +class Foo { + function __construct() { + $this->error = array($this,$this); + } +} +$a =& new Foo(); + +class Bar { + function __construct() { + $this->_rme2 = $this; + } +} + +$b =& new Bar(); +$b->_rme2 = 0; +var_dump($b); +?> +--EXPECTF-- +Deprecated: Assigning the return value of new by reference is deprecated in %sbug45178.php on line 7 + +Deprecated: Assigning the return value of new by reference is deprecated in %sbug45178.php on line 15 +object(Bar)#%d (1) { + ["_rme2"]=> + int(0) +} diff --git a/Zend/tests/bug45180.phpt b/Zend/tests/bug45180.phpt new file mode 100644 index 0000000..f1ca434 --- /dev/null +++ b/Zend/tests/bug45180.phpt @@ -0,0 +1,61 @@ +--TEST-- +Testing callback formats within class method +--FILE-- +<?php + +class foo { + public function test() { + call_user_func(array('FOO', 'ABC')); + call_user_func(array($this, 'ABC')); + foo::XYZ(); + self::WWW(); + call_user_func('FOO::ABC'); + } + function __call($a, $b) { + print "__call:\n"; + var_dump($a); + } + static public function __callStatic($a, $b) { + print "__callstatic:\n"; + var_dump($a); + } +} + +$x = new foo; + +$x->test(); + +$x::A(); + +foo::B(); + +$f = 'FOO'; + +$f::C(); + +$f::$f(); + +foo::$f(); + +?> +--EXPECT-- +__call: +string(3) "ABC" +__call: +string(3) "ABC" +__call: +string(3) "XYZ" +__call: +string(3) "WWW" +__call: +string(3) "ABC" +__callstatic: +string(1) "A" +__callstatic: +string(1) "B" +__callstatic: +string(1) "C" +__callstatic: +string(3) "FOO" +__callstatic: +string(3) "FOO"
\ No newline at end of file diff --git a/Zend/tests/bug45186.phpt b/Zend/tests/bug45186.phpt new file mode 100644 index 0000000..bcf88a1 --- /dev/null +++ b/Zend/tests/bug45186.phpt @@ -0,0 +1,54 @@ +--TEST-- +Bug #45186 (__call depends on __callstatic in class scope) +--FILE-- +<?php + +class bar { + public function __call($a, $b) { + print "__call:\n"; + var_dump($a); + } + static public function __callstatic($a, $b) { + print "__callstatic:\n"; + var_dump($a); + } + public function test() { + self::ABC(); + bar::ABC(); + call_user_func(array('BAR', 'xyz')); + call_user_func('BAR::www'); + call_user_func(array('self', 'y')); + call_user_func('self::y'); + } + static function x() { + print "ok\n"; + } +} + +$x = new bar; + +$x->test(); + +call_user_func(array('BAR','x')); +call_user_func('BAR::www'); +call_user_func('self::y'); + +?> +--EXPECTF-- +__call: +string(3) "ABC" +__call: +string(3) "ABC" +__call: +string(3) "xyz" +__call: +string(3) "www" +__call: +string(1) "y" +__call: +string(1) "y" +ok +__callstatic: +string(3) "www" + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access self:: when no class scope is active in %sbug45186.php on line 31 diff --git a/Zend/tests/bug45186_2.phpt b/Zend/tests/bug45186_2.phpt new file mode 100644 index 0000000..9a707ac --- /dev/null +++ b/Zend/tests/bug45186_2.phpt @@ -0,0 +1,50 @@ +--TEST-- +Bug #45186.2 (__call depends on __callstatic in class scope) +--FILE-- +<?php + +class bar { + public function __call($a, $b) { + print "__call:\n"; + var_dump($a); + } + public function test() { + self::ABC(); + bar::ABC(); + call_user_func(array('BAR', 'xyz')); + call_user_func('BAR::www'); + call_user_func(array('self', 'y')); + call_user_func('self::y'); + } + static function x() { + print "ok\n"; + } +} + +$x = new bar; + +$x->test(); + +call_user_func(array('BAR','x')); +call_user_func('BAR::www'); +call_user_func('self::y'); + +?> +--EXPECTF-- +__call: +string(3) "ABC" +__call: +string(3) "ABC" +__call: +string(3) "xyz" +__call: +string(3) "www" +__call: +string(1) "y" +__call: +string(1) "y" +ok + +Warning: call_user_func() expects parameter 1 to be a valid callback, class 'bar' does not have a method 'www' in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access self:: when no class scope is active in %sbug45186_2.php on line 27 diff --git a/Zend/tests/bug45742.phpt b/Zend/tests/bug45742.phpt new file mode 100644 index 0000000..bde690b --- /dev/null +++ b/Zend/tests/bug45742.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #45742 Wrong class array inpretetion using constant indexes +--FILE-- +<?php +class Constants { + // Needs to be equal + const A = 1; + const B = 1; +} + +class ArrayProperty { + public static $array = array( + Constants::A => 23, + Constants::B => 42, + ); +} + +var_dump( ArrayProperty::$array ); +?> +--EXPECT-- +array(1) { + [1]=> + int(42) +} diff --git a/Zend/tests/bug45744.phpt b/Zend/tests/bug45744.phpt new file mode 100644 index 0000000..029efcf --- /dev/null +++ b/Zend/tests/bug45744.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #45744 (Case sensitive callback behaviour) +--FILE-- +<?php +class Foo { + public function __construct(array $data) { + var_dump(array_map(array($this, 'callback'), $data)); + } + + private function callback($value) { + if (!is_array($value)) { + return stripslashes($value); + } + return array_map(array($this, 'callback'), $value); + } +} + +class Bar extends Foo { +} + +new Bar(array()); + +class Foo2 { + public function __construct(array $data) { + var_dump(array_map(array($this, 'callBack'), $data)); + } + + private function callBack($value) { + } +} + +class Bar2 extends Foo2 { +} + +new Bar2(array()); +--EXPECT-- +array(0) { +} +array(0) { +} diff --git a/Zend/tests/bug45805.phpt b/Zend/tests/bug45805.phpt new file mode 100644 index 0000000..986187e --- /dev/null +++ b/Zend/tests/bug45805.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #45805 (Crash on throwing exception from error handler) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php +class PHPUnit_Util_ErrorHandler +{ + public static function handleError($errno, $errstr, $errfile, $errline) + { + throw new RuntimeException; + } +} + +class A { + public function getX() { + return NULL; + } +} + +class B { + public function foo() { + $obj = new A; + $source = &$obj->getX(); + } + + public function bar() { + $m = new ReflectionMethod('B', 'foo'); + $m->invoke($this); + } +} + +set_error_handler( + array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT +); + +$o = new B; +$o->bar(); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' in %sbug45805.php:%d +Stack trace: +#0 %sbug45805.php(%d): PHPUnit_Util_ErrorHandler::handleError(2048, 'Only variables ...', '%s', %d, Array) +#1 [internal function]: B->foo() +#2 %sbug45805.php(%d): ReflectionMethod->invoke(Object(B)) +#3 %sbug45805.php(%d): B->bar() +#4 {main} + thrown in %sbug45805.php on line %d diff --git a/Zend/tests/bug45862.phpt b/Zend/tests/bug45862.phpt new file mode 100644 index 0000000..f70c142 --- /dev/null +++ b/Zend/tests/bug45862.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #45862 (get_class_vars is inconsistent with 'protected' and 'private' variables) +--FILE-- +<?php + +class Ancestor { + function test() { + var_dump(get_class_vars("Tester")); + var_dump(Tester::$prot); + } +} + +class Tester extends Ancestor { + static protected $prot = "protected var"; + static private $priv = "private var"; +} + +class Child extends Tester { + function test() { var_dump(get_class_vars("Tester")); } +} + +echo "\n From parent scope\n"; +$parent = new Ancestor(); +$parent->test(); +echo "\n From child scope\n"; +$child = new Child(); +$child->test(); + +?> +--EXPECT-- + + From parent scope +array(1) { + ["prot"]=> + string(13) "protected var" +} +string(13) "protected var" + + From child scope +array(1) { + ["prot"]=> + string(13) "protected var" +} diff --git a/Zend/tests/bug45877.phpt b/Zend/tests/bug45877.phpt new file mode 100644 index 0000000..ec44cb0 --- /dev/null +++ b/Zend/tests/bug45877.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #45877 (Array key '2147483647' left as string) +--INI-- +precision=16 +--FILE-- +<?php +$keys = array(PHP_INT_MAX, + (string) PHP_INT_MAX, + (string) (-PHP_INT_MAX - 1), + -PHP_INT_MAX - 1, + (string) (PHP_INT_MAX + 1)); + +var_dump(array_fill_keys($keys, 1)); +?> +--EXPECTF-- +array(3) { + [%d7]=> + int(1) + [-%d8]=> + int(1) + ["%s"]=> + int(1) +} diff --git a/Zend/tests/bug45910.phpt b/Zend/tests/bug45910.phpt new file mode 100644 index 0000000..1041877 --- /dev/null +++ b/Zend/tests/bug45910.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #45910 (Cannot declare self-referencing constant) +--FILE-- +<?php + +class foo { + const AAA = 'x'; + const BBB = 'a'; + const CCC = 'a'; + const DDD = self::AAA; + + private static $foo = array( + self::BBB => 'a', + self::CCC => 'b', + self::DDD => self::AAA + ); + + public static function test() { + self::$foo; + } +} + +foo::test(); + +print 1; +?> +--EXPECT-- +1 diff --git a/Zend/tests/bug45910_2.phpt b/Zend/tests/bug45910_2.phpt new file mode 100644 index 0000000..68ca9a1 --- /dev/null +++ b/Zend/tests/bug45910_2.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #45910.2 (Cannot declare self-referencing constant) +--FILE-- +<?php + +class foo { + const AAA = 'x'; + const BBB = 'a'; + const CCC = 'a'; + const DDD = self::AAA; + + private static $foo = array( + self::BBB => 'a', + self::CCC => 'b', + self::DDD => 11 + ); + + public static function test() { + self::$foo; + } +} + +foo::test(); + +print 1; +?> +--EXPECT-- +1 diff --git a/Zend/tests/bug46106.phpt b/Zend/tests/bug46106.phpt new file mode 100644 index 0000000..f18c25a --- /dev/null +++ b/Zend/tests/bug46106.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #46106 (Memory leaks when using global statement) +--FILE-- +<?php +$foo = array(1); + +function foobar($errno, $errstr, $errfile, $errline) { } + +set_error_handler('foobar'); + +function test($x) { + global $foo; + + $x->invokeArgs(array(0)); +} + +$x = new ReflectionFunction('str_pad'); +test($x); +?> +DONE +--EXPECT-- +DONE diff --git a/Zend/tests/bug46196.phpt b/Zend/tests/bug46196.phpt new file mode 100644 index 0000000..7526d80 --- /dev/null +++ b/Zend/tests/bug46196.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test restore_error_handler() function : bug #46196 +--CREDITS-- +Olivier Doucet +--FILE-- +<?php +/* Prototype : void restore_error_handler(void) + * Description: Restores the previously defined error handler function + * Source code: Zend/zend_builtin_functions.c + * Alias to functions: + */ + +echo "*** Testing restore_error_handler() : error bug #46196 ***\n"; + +var_dump( set_error_handler( 'myErrorHandler' ) ); +var_dump( restore_error_handler() ); +var_dump( set_error_handler( 'myErrorHandler' ) ); + +function myErrorHandler($errno, $errstr, $errfile, $errline) +{ + return true; +} + +?> +===DONE=== +--EXPECTF-- +*** Testing restore_error_handler() : error bug #46196 *** +NULL +bool(true) +NULL +===DONE=== diff --git a/Zend/tests/bug46238.phpt b/Zend/tests/bug46238.phpt new file mode 100644 index 0000000..87a1c15 --- /dev/null +++ b/Zend/tests/bug46238.phpt @@ -0,0 +1,120 @@ +--TEST-- +Bug #46238 (Segmentation fault on static call with empty string method) +--FILE-- +<?php + +class a { + static function __callStatic($name, $arguments) + { + var_dump(array($name, $arguments)); + } +} + +$a = 'a'; +$b = ''; + +$a::$b($a); +$a::$b(array()); +$a::$b(NULL); +$a::$b(1); +$a::$b(); + + +$b = "\0"; + +$a::$b($a); +$a::$b(array()); +$a::$b(NULL); +$a::$b(1); +$a::$b(); + +?> +--EXPECT-- +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + string(1) "a" + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + array(0) { + } + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + NULL + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + int(1) + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(0) { + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + string(1) "a" + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + array(0) { + } + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + NULL + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + int(1) + } +} +array(2) { + [0]=> + string(0) "" + [1]=> + array(0) { + } +} diff --git a/Zend/tests/bug46241.phpt b/Zend/tests/bug46241.phpt new file mode 100644 index 0000000..40ed7c8 --- /dev/null +++ b/Zend/tests/bug46241.phpt @@ -0,0 +1,50 @@ +--TEST-- +Bug #46241 (error handler stacks) +--FILE-- +<?php + +class ErrorHandling +{ + + public function errorHandler1( $errno, $errstr ) + { + echo "Caught on first level: '$errstr'\n"; + return true; + } + + public function errorHandler2( $errno, $errstr ) + { + echo "Caught on second level: '$errstr'\n"; + return true; + } +} + +$err = new ErrorHandling(); + +set_error_handler( array( $err, 'errorHandler1' ) ); +set_error_handler( array( $err, 'errorHandler2' ) ); + +trigger_error( 'Foo', E_USER_WARNING ); + +function errorHandler1( $errno, $errstr ) +{ + echo "Caught on first level: '$errstr'\n"; + return true; +} + +function errorHandler2( $errno, $errstr ) +{ + echo "Caught on second level: '$errstr'\n"; + return true; +} + +set_error_handler( 'errorHandler1' ); +set_error_handler( 'errorHandler2' ); + +trigger_error( 'Foo', E_USER_WARNING ); +?> +==END== +--EXPECT-- +Caught on second level: 'Foo' +Caught on second level: 'Foo' +==END== diff --git a/Zend/tests/bug46246.phpt b/Zend/tests/bug46246.phpt new file mode 100644 index 0000000..a57222b --- /dev/null +++ b/Zend/tests/bug46246.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #46246 (difference between call_user_func(array($this, $method)) and $this->$method()) +--FILE-- +<?php +class A +{ + private function Test() + { + echo 'Hello from '.get_class($this)."\n"; + } + + public function call($method, $args = array()) + { + $this->Test(); + $this->$method(); + call_user_func(array($this, $method)); + } +} + +class B extends A +{ + protected function Test() + { + echo 'Overridden hello from '.get_class($this)."\n"; + } +} + +$a = new A; +$b = new B; + +$a->call('Test'); +$b->call('Test'); +?> +--EXPECT-- +Hello from A +Hello from A +Hello from A +Hello from B +Hello from B +Hello from B diff --git a/Zend/tests/bug46304.phpt b/Zend/tests/bug46304.phpt new file mode 100644 index 0000000..0a6e3bf --- /dev/null +++ b/Zend/tests/bug46304.phpt @@ -0,0 +1,65 @@ +--TEST-- +Bug #46304 (defining namespaced constant using define()) +--FILE-- +<?php + +define('NS1\ns2\const1','value1'); +define('ns1\ns2\const2','value2'); +define('ns1\NS2\coNSt3','value3'); +define('NS1\ns2\const4','value4', true); +define('ns1\ns2\const5','value5', true); +define('ns1\NS2\coNSt6','value6', true); + +print NS1\ns2\const1 . "\n"; +print ns1\ns2\const1 . "\n"; +print ns1\NS2\const1 . "\n"; + +print NS1\ns2\const2 . "\n"; +print ns1\ns2\const2 . "\n"; +print ns1\NS2\const2 . "\n"; + +print NS1\ns2\coNSt3 . "\n"; +print ns1\ns2\coNSt3 . "\n"; +print ns1\ns2\coNSt3 . "\n"; + +print NS1\ns2\const4 . "\n"; +print ns1\ns2\const4 . "\n"; +print ns1\NS2\const4 . "\n"; +print ns1\ns2\coNSt4 . "\n"; + +print NS1\ns2\const5 . "\n"; +print ns1\ns2\const5 . "\n"; +print ns1\NS2\const5 . "\n"; +print ns1\ns2\coNSt5 . "\n"; + +print NS1\ns2\const6 . "\n"; +print ns1\ns2\const6 . "\n"; +print ns1\NS2\const6 . "\n"; +print ns1\ns2\coNSt6 . "\n"; + +print NS1\ns2\coNSt1 . "\n"; +?> +--EXPECTF-- +value1 +value1 +value1 +value2 +value2 +value2 +value3 +value3 +value3 +value4 +value4 +value4 +value4 +value5 +value5 +value5 +value5 +value6 +value6 +value6 +value6 + +Fatal error: Undefined constant 'NS1\ns2\coNSt1' in %sbug46304.php on line %d diff --git a/Zend/tests/bug46308.phpt b/Zend/tests/bug46308.phpt new file mode 100644 index 0000000..3722738 --- /dev/null +++ b/Zend/tests/bug46308.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #46308 (Invalid write when changing property from inside getter) +--FILE-- +<?php +class main +{ + public static $dummy = NULL ; + public static $dataAccessor = NULL ; +} + +class dataAccessor +{ +} + +class relay +{ + public function __get( $name ) + { + main::$dataAccessor = new dataAccessor; + } +} + +class dummy +{ +} + +main::$dummy = new dummy(); +main::$dataAccessor = new relay(); +main::$dataAccessor->bar; +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug46381.phpt b/Zend/tests/bug46381.phpt new file mode 100644 index 0000000..4d58e9f --- /dev/null +++ b/Zend/tests/bug46381.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #46381 (wrong $this passed to internal methods causes segfault) +--SKIPIF-- +<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?> +--FILE-- +<?php + +class test { + public function test() { + return ArrayIterator::current(); + } +} +$test = new test(); +$test->test(); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Non-static method ArrayIterator::current() cannot be called statically, assuming $this from incompatible context in %s on line %d diff --git a/Zend/tests/bug46409.phpt b/Zend/tests/bug46409.phpt new file mode 100644 index 0000000..1986e88 --- /dev/null +++ b/Zend/tests/bug46409.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #46409 (__invoke method called outside of object context when using array_map) +--FILE-- +<?php +class Callback { + protected $val = 'hello, world'; + + public function __invoke() { + return $this->val; + } +} + +$cb = new Callback(); +echo $cb(),"\n"; +$a = array(1, 2); +$b = array_map($cb, $a); +print_r($b); +?> +--EXPECT-- +hello, world +Array +( + [0] => hello, world + [1] => hello, world +) diff --git a/Zend/tests/bug46665.phpt b/Zend/tests/bug46665.phpt new file mode 100644 index 0000000..1f82454 --- /dev/null +++ b/Zend/tests/bug46665.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #46665 (Triggering autoload with a variable classname causes truncated autoload param) +--FILE-- +<?php + +$baz = '\\Foo\\Bar\\Baz'; +new $baz(); +function __autoload($class) { + var_dump($class); + require __DIR__ .'/bug46665_autoload.inc'; +} + +?> +--EXPECTF-- +%string|unicode%(11) "Foo\Bar\Baz" diff --git a/Zend/tests/bug46665_autoload.inc b/Zend/tests/bug46665_autoload.inc new file mode 100644 index 0000000..092b272 --- /dev/null +++ b/Zend/tests/bug46665_autoload.inc @@ -0,0 +1,5 @@ +<?php + +namespace Foo\Bar; +class Baz { +} diff --git a/Zend/tests/bug46701.phpt b/Zend/tests/bug46701.phpt new file mode 100644 index 0000000..e9cb99e --- /dev/null +++ b/Zend/tests/bug46701.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #46701 (Creating associative array with long values in the key fails on 32bit linux) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die('skip this test is for 32bit platforms only'); ?> +--FILE-- +<?php + +$test_array = array( + 0xcc5c4600 => 1, + 0xce331a00 => 2 +); +$test_array[0xce359000] = 3; + +var_dump($test_array); +var_dump($test_array[0xce331a00]); + +class foo { + public $x; + + public function __construct() { + $this->x[0xce359000] = 3; + var_dump($this->x); + } +} + +new foo; + +?> +--EXPECT-- +array(3) { + [-866368000]=> + int(1) + [-835511808]=> + int(2) + [-835350528]=> + int(3) +} +int(2) +array(1) { + [-835350528]=> + int(3) +} diff --git a/Zend/tests/bug46811.phpt b/Zend/tests/bug46811.phpt new file mode 100644 index 0000000..e98f6e7 --- /dev/null +++ b/Zend/tests/bug46811.phpt @@ -0,0 +1,13 @@ +--TEST-- +ini_set() function +--INI-- +arg_separator.output=& +--FILE-- +<?php +var_dump(ini_set("arg_separator.output", "")); +var_dump(ini_get("arg_separator.output")); +?> +--EXPECTF-- +bool(false) +%unicode|string%(1) "&" + diff --git a/Zend/tests/bug46813.phpt b/Zend/tests/bug46813.phpt new file mode 100644 index 0000000..91837db --- /dev/null +++ b/Zend/tests/bug46813.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #46813: class_exists doesn`t work with fully qualified namespace +--FILE-- +<?php +namespace test; +{ + class inner + { + + } +} + +$inner = new \test\inner(); + +echo "autoload == true:\n"; +var_dump(class_exists('\test\inner', true)); +echo "autoload == false:\n"; +var_dump(class_exists('\test\inner', true)); +?> +--EXPECT-- +autoload == true: +bool(true) +autoload == false: +bool(true) diff --git a/Zend/tests/bug47054.phpt b/Zend/tests/bug47054.phpt new file mode 100644 index 0000000..ab6c6e1 --- /dev/null +++ b/Zend/tests/bug47054.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #47054 (BC break in static functions called as dynamic) +--FILE-- +<?php + +class C { + final static function s() { + print "Called class: " . get_called_class() . "\n"; + } +} +class D extends C { + public function m() { + $this->s(); + } +} + +$d = new D(); +$d->m(); + +C::s(); + +$c = new C(); +$c->s(); + +get_called_class(); + +D::m(); + +?> +--EXPECTF-- +Called class: D +Called class: C +Called class: C + +Warning: get_called_class() called from outside a class in %s on line %d + +Strict Standards: Non-static method D::m() should not be called statically in %s on line %d + +Fatal error: Using $this when not in object context in %s on line %d diff --git a/Zend/tests/bug47109.phpt b/Zend/tests/bug47109.phpt new file mode 100644 index 0000000..8f810d7 --- /dev/null +++ b/Zend/tests/bug47109.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #47109 (Memory leak on $a->{"a"."b"} when $a is not an object) +--FILE-- +<?php +$a->{"a"."b"}; +?> +--EXPECTF-- +Notice: Undefined variable: a in %sbug47109.php on line 2 + +Notice: Trying to get property of non-object in %sbug47109.php on line 2 + diff --git a/Zend/tests/bug47165.phpt b/Zend/tests/bug47165.phpt new file mode 100644 index 0000000..2cf648d --- /dev/null +++ b/Zend/tests/bug47165.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #47165 (Possible memory corruption when passing return value by reference) +--FILE-- +<?php +class Foo { + var $bar = array(); + + static function bar() { + static $instance = null; + $instance = new Foo(); + return $instance->bar; + } +} +extract(Foo::bar()); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug47320.phpt b/Zend/tests/bug47320.phpt new file mode 100644 index 0000000..47db35e --- /dev/null +++ b/Zend/tests/bug47320.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #47320 ($php_errormsg out of scope in functions) +--INI-- +display_errors=0 +track_errors=1 +--FILE-- +<?php +if (!@substr('no 2nd parameter')) { + echo '$php_errormsg in global: ' . $php_errormsg . "\n"; +} + +function foo() { + if (!@strpos('no 2nd parameter')) { + echo '$php_errormsg in function: ' . $php_errormsg . "\n"; + + echo '$GLOBALS[php_errormsg] in function: ' . + $GLOBALS['php_errormsg'] . "\n"; + } +} + +foo(); +?> +--EXPECT-- +$php_errormsg in global: substr() expects at least 2 parameters, 1 given +$php_errormsg in function: strpos() expects at least 2 parameters, 1 given +$GLOBALS[php_errormsg] in function: substr() expects at least 2 parameters, 1 given diff --git a/Zend/tests/bug47343.phpt b/Zend/tests/bug47343.phpt new file mode 100644 index 0000000..07a3b4e --- /dev/null +++ b/Zend/tests/bug47343.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #47343 (gc_collect_cycles causes a segfault when called within a destructor in one case) +--FILE-- +<?php +class A +{ + public function __destruct() + { + gc_collect_cycles(); + } + + public function getB() + { + $this->data['foo'] = new B($this); + $this->data['bar'] = new B($this); + // Return either of the above + return $this->data['foo']; + } +} + +class B +{ + public function B($A) + { + $this->A = $A; + } + + public function __destruct() + { + } +} + +for ($i = 0; $i < 2; $i++) +{ + $Aobj = new A; + $Bobj = $Aobj->getB(); + unset($Bobj); + unset($Aobj); +} + +echo "DONE\n"; +?> +--EXPECT-- +DONE diff --git a/Zend/tests/bug47353.phpt b/Zend/tests/bug47353.phpt new file mode 100644 index 0000000..4196fc7 --- /dev/null +++ b/Zend/tests/bug47353.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #47353 (crash when creating a lot of objects in object destructor) +--FILE-- +<?php + +class A +{ + function __destruct() + { + $myArray = array(); + + for($i = 1; $i <= 3000; $i++) { + if(!isset($myArray[$i])) + $myArray[$i] = array(); + $ref = & $myArray[$i]; + $ref[] = new stdClass(); + } + } +} + +$a = new A(); + +echo "Done\n"; +?> +--EXPECTF-- +Done diff --git a/Zend/tests/bug47516.phpt b/Zend/tests/bug47516.phpt new file mode 100644 index 0000000..a9a2071 --- /dev/null +++ b/Zend/tests/bug47516.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #47516 (nowdoc can not be embed in heredoc but can be embed in double quote) +--FILE-- +<?php +$s='substr'; + +$htm=<<<DOC +{$s(<<<'ppp' +abcdefg +ppp +,0,3)} +DOC; + +echo "$htm\n"; + +$htm=<<<DOC +{$s(<<<ppp +abcdefg +ppp +,0,3)} +DOC; + +echo "$htm\n"; + +$htm="{$s(<<<'ppp' +abcdefg +ppp +,0,3)} +"; + +echo "$htm\n"; +?> +--EXPECT-- +abc +abc +abc diff --git a/Zend/tests/bug47572.phpt b/Zend/tests/bug47572.phpt new file mode 100644 index 0000000..695cc3a --- /dev/null +++ b/Zend/tests/bug47572.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #47572 (zval_update_constant_ex: Segmentation fault) +--FILE-- +<?php + +class Foo { + public static $bar = array( + FOO => "bar" + ); + +} + +$foo = new Foo(); + +?> +--EXPECTF-- +Notice: Use of undefined constant FOO - assumed 'FOO' in %s on line %d diff --git a/Zend/tests/bug47593.phpt b/Zend/tests/bug47593.phpt new file mode 100644 index 0000000..98aa19a --- /dev/null +++ b/Zend/tests/bug47593.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #47593 (interface_exists() returns false when using absolute namespace path) +--FILE-- +<?php + +namespace test; +const TEST = 11; + +class foo { + public function xyz() { + } +} + +interface baz { +} + +function bar() { +} + + +var_dump(interface_exists('\test\baz')); +var_dump(function_exists('\test\bar')); +var_dump(constant('\test\TEST')); +var_dump(defined('\test\TEST')); +var_dump(defined('TEST')); + + +?> +--EXPECT-- +bool(true) +bool(true) +int(11) +bool(true) +bool(false) diff --git a/Zend/tests/bug47596.phpt b/Zend/tests/bug47596.phpt new file mode 100644 index 0000000..1fcba21 --- /dev/null +++ b/Zend/tests/bug47596.phpt @@ -0,0 +1,63 @@ +--TEST-- +Bug #47596 (Bus error on parsing file, when file size is equal to page size) +--FILE-- +<?php +echo "ok\n"; +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comment comment comment comment comment comment comment +// comment comment comm +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug47699.phpt b/Zend/tests/bug47699.phpt new file mode 100644 index 0000000..23ea5a4 --- /dev/null +++ b/Zend/tests/bug47699.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #47699 (autoload and late static binding) +--FILE-- +<?php +class A { + static function test($v='') { + print_r(get_called_class()); + } +} +class B extends A { +} +B::test(); +spl_autoload_register('B::test'); +new X(); +?> +--EXPECTF-- +BB +Fatal error: Class 'X' not found in %sbug47699.php on line %d diff --git a/Zend/tests/bug47704.phpt b/Zend/tests/bug47704.phpt new file mode 100644 index 0000000..151754a --- /dev/null +++ b/Zend/tests/bug47704.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #47704 (crashes on some "bad" operations with string offsets) +--FILE-- +<?php +$s = "abd"; +$s[0]->a += 1; +?> +--EXPECTF-- +Fatal error: Cannot use string offset as an object in %sbug47704.php on line %d diff --git a/Zend/tests/bug47714.phpt b/Zend/tests/bug47714.phpt new file mode 100644 index 0000000..e8ef8c3 --- /dev/null +++ b/Zend/tests/bug47714.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing lambda function in set_exception_handler() +--FILE-- +<?php +function au($class) { + eval('class handler { + function handle($e) { + echo $e->getMessage()."\n"; + } + }'); +} + +function __autoload($class) { + au($class); +} + +//spl_autoload_register('au'); + +set_exception_handler(function($exception) { + $h = new handler(); + $h->handle($exception); +}); + +throw new Exception('exception'); +?> +--EXPECT-- +exception diff --git a/Zend/tests/bug47771.phpt b/Zend/tests/bug47771.phpt new file mode 100644 index 0000000..a17fcf3 --- /dev/null +++ b/Zend/tests/bug47771.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #47771 (Exception during object construction from arg call calls object's destructor) +--FILE-- +<?php +function throw_exc() { + throw new Exception('TEST_EXCEPTION'); +} + +class Test { + + public function __construct() { + echo 'Constr' ."\n"; + } + + public function __destruct() { + echo 'Destr' ."\n"; + } + +} + +try { + + $T =new Test(throw_exc()); + +} catch( Exception $e) { + echo 'Exception: ' . $e->getMessage() . "\n"; +} +?> +--EXPECT-- +Exception: TEST_EXCEPTION diff --git a/Zend/tests/bug47801.phpt b/Zend/tests/bug47801.phpt new file mode 100644 index 0000000..3230819 --- /dev/null +++ b/Zend/tests/bug47801.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #47801 (__call() accessed via parent:: operator is provided incorrect method name) +--FILE-- +<?php + +class A +{ + function __call($name, $args) + { + echo("magic method called: $name\n"); + } +} + +class B extends A +{ + function getFoo() + { + parent::getFoo(); + } +} + +$a = new A(); +$a->getFoo(); + +$b = new B(); +$b->getFoo(); + +?> +--EXPECT-- +magic method called: getFoo +magic method called: getFoo diff --git a/Zend/tests/bug47836.phpt b/Zend/tests/bug47836.phpt new file mode 100644 index 0000000..5a93a44 --- /dev/null +++ b/Zend/tests/bug47836.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #47836 (array operator [] inconsistency when the array has PHP_INT_MAX index value) +--FILE-- +<?php + +$arr[PHP_INT_MAX] = 1; +$arr[] = 2; + +var_dump($arr); +?> +--EXPECTF-- +Warning: Cannot add element to the array as the next element is already occupied in %s on line 4 +array(1) { + [%d]=> + int(1) +} diff --git a/Zend/tests/bug47880.phpt b/Zend/tests/bug47880.phpt new file mode 100644 index 0000000..bf2022c --- /dev/null +++ b/Zend/tests/bug47880.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #47880 (crashes in call_user_func_array()) +--FILE-- +<?php +class bomb { + static function go($n) { + $backtrace = debug_backtrace(false); + $backtrace[1]['args'][1] = 'bomb'; + } +} +call_user_func_array(array('bomb', 'go'), array(0)); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug47981.phpt b/Zend/tests/bug47981.phpt new file mode 100644 index 0000000..c0fd69a --- /dev/null +++ b/Zend/tests/bug47981.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #47981 (error handler not called regardless) +--INI-- +error_reporting=0 +--FILE-- +<?php +function errh($errno, $errstr) { + var_dump($errstr); +} +set_error_handler("errh"); + +interface a{} +class b implements a { function f($a=1) {}} +class c extends b {function f() {}} +?> +--EXPECTF-- +string(60) "Declaration of c::f() should be compatible with b::f($a = 1)" diff --git a/Zend/tests/bug48004.phpt b/Zend/tests/bug48004.phpt new file mode 100644 index 0000000..5968876 --- /dev/null +++ b/Zend/tests/bug48004.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #48004 (Error handler prevents creation of default object) +--FILE-- +<?php +function error_handler($errno, $errstr, $errfile, $errline, $errcontext) { + return true; +} + +function test() { + $data->id = 1; + print_r($data); +} + +set_error_handler("error_handler"); +test(); +?> +--EXPECT-- +stdClass Object +( + [id] => 1 +) diff --git a/Zend/tests/bug48215.phpt b/Zend/tests/bug48215.phpt new file mode 100644 index 0000000..2e156ad --- /dev/null +++ b/Zend/tests/bug48215.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #48215 - parent::method() calls __construct +--FILE-- +<?php +class A +{ + public function __construct() { + echo __METHOD__ . "\n"; + } + protected function A() + { + echo __METHOD__ . "\n"; + } +} +class B extends A +{ + public function __construct() { + echo __METHOD__ . "\n"; + parent::__construct(); + } + public function A() + { + echo __METHOD__ . "\n"; + parent::A(); + } +} +$b = new B(); +$b->A(); +?> +===DONE=== +--EXPECTF-- +B::__construct +A::__construct +B::A +A::A +===DONE=== diff --git a/Zend/tests/bug48215_2.phpt b/Zend/tests/bug48215_2.phpt new file mode 100644 index 0000000..199a252 --- /dev/null +++ b/Zend/tests/bug48215_2.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #48215 - parent::method() calls __construct, case sensitive test +--FILE-- +<?php +class a { + public function __CONSTRUCT() { echo __METHOD__ . "\n"; } + public function a() { echo __METHOD__ . "\n"; } +} +class b extends a {} +class c extends b { + function C() { + b::b(); + } +} +$c = new c(); +?> +===DONE=== +--EXPECTF-- +Fatal error: Call to undefined method b::b() in %s on line %d diff --git a/Zend/tests/bug48228.phpt b/Zend/tests/bug48228.phpt new file mode 100644 index 0000000..ae8ba61 --- /dev/null +++ b/Zend/tests/bug48228.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #48228 (crash when exception is thrown while passing function arguments) +--FILE-- +<?php + +function do_throw() { + throw new Exception(); +} + +class aa +{ + function check() + { + } + + function dosome() + { + $this->check(do_throw()); + } +} +$l_aa=new aa(); + +$l_aa->dosome(); +?> +--EXPECTF-- + +Fatal error: Uncaught exception 'Exception' in %s +Stack trace: +#0 %s(%d): do_throw() +#1 %s(%d): aa->dosome() +#2 {main} + thrown in %s diff --git a/Zend/tests/bug48248.phpt b/Zend/tests/bug48248.phpt new file mode 100644 index 0000000..9cdb7c1 --- /dev/null +++ b/Zend/tests/bug48248.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #48248 (SIGSEGV when access to private property via &__get) +--FILE-- +<?php + +class A +{ + public function & __get($name) + { + return $this->test; + } +} + +class B extends A +{ + private $test; +} + +$b = new B; +var_dump($b->test); + +?> +--EXPECTF-- +Notice: Undefined property: B::$test in %s on line %d + +Notice: Only variable references should be returned by reference in %s on line %d +NULL diff --git a/Zend/tests/bug48408.phpt b/Zend/tests/bug48408.phpt new file mode 100644 index 0000000..20a0198 --- /dev/null +++ b/Zend/tests/bug48408.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #48408 (crash when exception is thrown while passing function arguments) +--FILE-- +<?php +class B{ + public function process($x){ + return $x; + } +} +class C{ + public function generate($x){ + throw new Exception; + } +} +$b = new B; +$c = new C; +try{ + $b->process($c->generate(0)); +} +catch(Exception $e){ + $c->generate(0); +} +?> +--EXPECTF-- + +Fatal error: Uncaught exception 'Exception' in %s +Stack trace: +#0 %s(%d): C->generate(0) +#1 {main} + thrown in %s diff --git a/Zend/tests/bug48409.phpt b/Zend/tests/bug48409.phpt new file mode 100644 index 0000000..238b52e --- /dev/null +++ b/Zend/tests/bug48409.phpt @@ -0,0 +1,67 @@ +--TEST-- +Bug #48409 (crash when exception is thrown while passing function arguments) +--FILE-- +<?php + +class ABCException extends Exception {} + +class BBB +{ + public function xyz($d, $x) + { + if ($x == 34) { + throw new ABCException; + } + return array('foo' => 'xyz'); + } +} + +class CCC +{ + public function process($p) + { + return $p; + } +} + +class AAA +{ + public function func() + { + $b = new BBB; + $c = new CCC; + $i = 34; + $item = array('foo' => 'bar'); + try { + $c->process($b->xyz($item['foo'], $i)); + } + catch(ABCException $e) { + $b->xyz($item['foo'], $i); + } + } // end func(); +} + +class Runner +{ + public function run($x) + { + try { + $x->func(); + } + catch(ABCException $e) { + throw new Exception; + } + } +} + +try { + $runner = new Runner; + $runner->run(new AAA); +} +catch(Exception $e) { + die('Exception thrown'); +} + +?> +--EXPECT-- +Exception thrown diff --git a/Zend/tests/bug48428.phpt b/Zend/tests/bug48428.phpt new file mode 100644 index 0000000..ae9ac93 --- /dev/null +++ b/Zend/tests/bug48428.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #48428 (crash when exception is thrown while passing function arguments) +--FILE-- +<?php +try { + function x() { throw new Exception("ERROR"); } + x(x()); +} catch(Exception $e) { + echo($e -> getMessage()); +} +?> +--EXPECT-- +ERROR diff --git a/Zend/tests/bug48533.phpt b/Zend/tests/bug48533.phpt new file mode 100644 index 0000000..274013c --- /dev/null +++ b/Zend/tests/bug48533.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #48533 (__callStatic is not invoked for private/protected methods) +--FILE-- +<?php + +class foo { + private function a() { + var_dump(1); + } + public function b() { + var_dump(2); + } + protected function c() { + var_dump(3); + } + static function __callstatic($a, $b) { + var_dump('__callStatic::'. $a); + } + public function __call($a, $b) { + var_dump('__call::'. $a); + } +} + +$x = new foo; +$x->a(); +$x->b(); +$x->c(); +$x::a(); +$x::b(); +$x::c(); + +?> +--EXPECTF-- +%unicode|string%(9) "__call::a" +int(2) +%unicode|string%(9) "__call::c" +%unicode|string%(15) "__callStatic::a" + +Strict Standards: Non-static method foo::b() should not be called statically in %s on line %d +int(2) +%unicode|string%(15) "__callStatic::c" diff --git a/Zend/tests/bug48667_1.phpt b/Zend/tests/bug48667_1.phpt new file mode 100644 index 0000000..2d94aed --- /dev/null +++ b/Zend/tests/bug48667_1.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #48667 (Implementing both iterator and iteratoraggregate) +--FILE-- +<?php + +abstract class A implements Iterator, IteratorAggregate { } + +?> +--EXPECTF-- +Fatal error: Class A cannot implement both IteratorAggregate and Iterator at the same time in %s on line %d diff --git a/Zend/tests/bug48667_2.phpt b/Zend/tests/bug48667_2.phpt new file mode 100644 index 0000000..57cd5eb --- /dev/null +++ b/Zend/tests/bug48667_2.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #48667 (Implementing both iterator and iteratoraggregate) +--FILE-- +<?php + +abstract class A implements IteratorAggregate, Iterator { } + +?> +--EXPECTF-- +Fatal error: Class A cannot implement both Iterator and IteratorAggregate at the same time in %s on line %d diff --git a/Zend/tests/bug48693.phpt b/Zend/tests/bug48693.phpt new file mode 100644 index 0000000..e5f7ce8 --- /dev/null +++ b/Zend/tests/bug48693.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #48693 (Double declaration of __lambda_func when lambda wrongly formatted) +--FILE-- +<?php + +$x = create_function('', 'return 1; }'); +$y = create_function('', 'function a() { }; return 2;'); +$z = create_function('', '{'); +$w = create_function('', 'return 3;'); + +var_dump( + $x, + $y(), + $z, + $w(), + $y != $z +); + +?> +--EXPECTF-- +Parse error: %s in %s(%d) : runtime-created function on line 1 + +Parse error: %s %s(%d) : runtime-created function on line 1 +bool(false) +int(2) +bool(false) +int(3) +bool(true) diff --git a/Zend/tests/bug48770.phpt b/Zend/tests/bug48770.phpt new file mode 100644 index 0000000..40fa841 --- /dev/null +++ b/Zend/tests/bug48770.phpt @@ -0,0 +1,53 @@ +--TEST-- +Bug #48770 (call_user_func_array() fails to call parent from inheriting class) +--XFAIL-- +See Bug #48770 +--FILE-- +<?php + +class A { + public function func($str) { + var_dump(__METHOD__ .': '. $str); + } + private function func2($str) { + var_dump(__METHOD__ .': '. $str); + } + protected function func3($str) { + var_dump(__METHOD__ .': '. $str); + } + private function func22($str) { + var_dump(__METHOD__ .': '. $str); + } +} + +class B extends A { + public function func($str) { + static $avoid_crash = 0; + + if ($avoid_crash++ == 1) { + print "This method shouldn't be called when using parent::func!\n"; + return; + } + + call_user_func_array(array($this, 'parent::func'), array($str)); + } + private function func2($str) { + var_dump(__METHOD__ .': '. $str); + } + protected function func3($str) { + var_dump(__METHOD__ .': '. $str); + } +} + +class C extends B { + public function func($str) { + parent::func($str); + } +} + +$c = new C; +$c->func('This should work!'); + +?> +--EXPECTF-- +%unicode|string%(26) "A::func: This should work!" diff --git a/Zend/tests/bug48770_2.phpt b/Zend/tests/bug48770_2.phpt new file mode 100644 index 0000000..dff54e1 --- /dev/null +++ b/Zend/tests/bug48770_2.phpt @@ -0,0 +1,54 @@ +--TEST-- +Bug #48770 (call_user_func_array() fails to call parent from inheriting class) +--XFAIL-- +See Bug #48770 +--FILE-- +<?php + +class A { + public function func($str) { + var_dump(__METHOD__ .': '. $str); + } + private function func2($str) { + var_dump(__METHOD__ .': '. $str); + } + protected function func3($str) { + var_dump(__METHOD__ .': '. $str); + } + private function func22($str) { + var_dump(__METHOD__ .': '. $str); + } +} + +class B extends A { + public function func($str) { + call_user_func_array(array($this, 'parent::func2'), array($str)); + call_user_func_array(array($this, 'parent::func3'), array($str)); + call_user_func_array(array($this, 'parent::func22'), array($str)); + call_user_func_array(array($this, 'parent::inexistent'), array($str)); + } + private function func2($str) { + var_dump(__METHOD__ .': '. $str); + } + protected function func3($str) { + var_dump(__METHOD__ .': '. $str); + } +} + +class C extends B { + public function func($str) { + parent::func($str); + } +} + +$c = new C; +$c->func('This should work!'); + +?> +--EXPECTF-- +%unicode|string%(27) "A::func2: This should work!" +%unicode|string%(27) "A::func3: This should work!" + +Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method A::func22() in %s on line %d + +Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'A' does not have a method 'inexistent' in %s on line %d diff --git a/Zend/tests/bug48770_3.phpt b/Zend/tests/bug48770_3.phpt new file mode 100644 index 0000000..68fe843 --- /dev/null +++ b/Zend/tests/bug48770_3.phpt @@ -0,0 +1,51 @@ +--TEST-- +Bug #48770 (call_user_func_array() fails to call parent from inheriting class) +--XFAIL-- +See Bug #48770 +--FILE-- +<?php + +class A { + public function func($str) { + var_dump(__METHOD__ .': '. $str); + } + private function func2($str) { + var_dump(__METHOD__ .': '. $str); + } + protected function func3($str) { + var_dump(__METHOD__ .': '. $str); + } + private function func22($str) { + var_dump(__METHOD__ .': '. $str); + } +} + +class B extends A { + public function func($str) { + call_user_func_array(array($this, 'self::func2'), array($str)); + call_user_func_array(array($this, 'self::func3'), array($str)); + call_user_func_array(array($this, 'self::inexistent'), array($str)); + } + private function func2($str) { + var_dump(__METHOD__ .': '. $str); + } + protected function func3($str) { + var_dump(__METHOD__ .': '. $str); + } +} + +class C extends B { + public function func($str) { + parent::func($str); + } +} + +$c = new C; +$c->func('This should work!'); + +?> +--EXPECTF-- +%unicode|string%(27) "B::func2: This should work!" +%unicode|string%(27) "B::func3: This should work!" + +Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'B' does not have a method 'inexistent' in %s on line %d diff --git a/Zend/tests/bug48899.phpt b/Zend/tests/bug48899.phpt new file mode 100644 index 0000000..ff64054 --- /dev/null +++ b/Zend/tests/bug48899.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #48899 (is_callable returns true even if method does not exist in parent class) +--FILE-- +<?php + +class ParentClass { } + +class ChildClass extends ParentClass { + public function testIsCallable() { + var_dump(is_callable(array($this, 'parent::testIsCallable'))); + } + public function testIsCallable2() { + var_dump(is_callable(array($this, 'static::testIsCallable2'))); + } +} + +$child = new ChildClass(); +$child->testIsCallable(); +$child->testIsCallable2(); + +?> +--EXPECT-- +bool(false) +bool(true) diff --git a/Zend/tests/bug48912.phpt b/Zend/tests/bug48912.phpt new file mode 100644 index 0000000..dc021a2 --- /dev/null +++ b/Zend/tests/bug48912.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #48912 (Namespace causes unexpected strict behaviour with extract()) +--FILE-- +<?php +namespace A; + +function test() +{ + extract(func_get_arg(0)); +} + +test(array('x' => 1)); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug48930.phpt b/Zend/tests/bug48930.phpt new file mode 100644 index 0000000..13b67f2 --- /dev/null +++ b/Zend/tests/bug48930.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #48930 (__COMPILER_HALT_OFFSET__ incorrect in PHP>=5.3) +--FILE-- +#!php +<?php + +/* + * Test + */ +printf("__COMPILER_HALT_OFFSET__ is %d\n",__COMPILER_HALT_OFFSET__); + +__halt_compiler(); + +?> +--EXPECT-- +__COMPILER_HALT_OFFSET__ is 116 diff --git a/Zend/tests/bug49269.phpt b/Zend/tests/bug49269.phpt new file mode 100644 index 0000000..2de29d8 --- /dev/null +++ b/Zend/tests/bug49269.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #49269 (Ternary operator fails on Iterator object when used inside foreach declaration). +--FILE-- +<?php +class TestObject implements Iterator +{ + public $n = 0; + function valid() + { + return ($this->n < 3); + } + function current() {return $this->n;} + function next() {$this->n++;} + function key() { } + function rewind() {$this->n = 0;} +} + + +$array_object = new TestObject(); + +foreach ((true ? $array_object : $array_object) as $item) echo "$item\n"; +?> +--EXPECT-- +0 +1 +2 diff --git a/Zend/tests/bug49472.phpt b/Zend/tests/bug49472.phpt new file mode 100644 index 0000000..1803d18 --- /dev/null +++ b/Zend/tests/bug49472.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #49472 (Constants defined in Interfaces can be overridden) +--FILE-- +<?php + +interface ia { + const c = 'Sea'; + const y = 2; +} + +class Foo implements ia { +} + +class FooBar extends Foo implements ia { + const x = 1; + const c = 'Ocean'; + + public function show() { + return ia::c; + } +} + +new FooBar; + +?> +--EXPECTF-- +Fatal error: Cannot inherit previously-inherited or override constant c from interface ia in %s on line %d diff --git a/Zend/tests/bug49866.phpt b/Zend/tests/bug49866.phpt new file mode 100644 index 0000000..7fbc0d8 --- /dev/null +++ b/Zend/tests/bug49866.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #49866 (Making reference on string offsets crashes PHP) +--FILE-- +<?php +$a = "string"; +$b = &$a[1]; +$b = "f"; +echo $a; +--EXPECTF-- +Fatal error: Cannot create references to/from string offsets nor overloaded objects in %sbug49866.php on line 3 diff --git a/Zend/tests/bug49893.phpt b/Zend/tests/bug49893.phpt new file mode 100644 index 0000000..b340f7b --- /dev/null +++ b/Zend/tests/bug49893.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #49893 (Crash while creating an instance of Zend_Mail_Storage_Pop3) +--FILE-- +<?php +class A { + function __destruct() { + try { + throw new Exception("2"); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } + } +} +class B { + function __construct() { + $this->a = new A(); + throw new Exception("1"); + } +} +try { + $b = new B(); +} catch(Exception $e) { + echo $e->getMessage() . "\n";; +} +?> +--EXPECT-- +2 +1 diff --git a/Zend/tests/bug49908.phpt b/Zend/tests/bug49908.phpt new file mode 100644 index 0000000..08d6383 --- /dev/null +++ b/Zend/tests/bug49908.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #49908 (throwing exception in __autoload crashes when interface is not defined) +--FILE-- +<?php + +function __autoload($className) { + var_dump($className); + + if ($className == 'Foo') { + class Foo implements Bar {}; + } else { + throw new Exception($className); + } +} + +new Foo; + +?> +--EXPECTF-- +%unicode|string%(3) "Foo" +%unicode|string%(3) "Bar" + +Fatal error: Uncaught exception 'Exception' with message 'Bar' in %s:%d +Stack trace: +#0 %s(7): __autoload('Bar') +#1 %s(13): __autoload('Foo') +#2 {main} + thrown in %s on line %d diff --git a/Zend/tests/bug50005.phpt b/Zend/tests/bug50005.phpt new file mode 100644 index 0000000..bf4fbbd --- /dev/null +++ b/Zend/tests/bug50005.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #50005 (Throwing through Reflection modified Exception object makes segmentation fault) +--FILE-- +<?php + +class a extends exception { + public function __construct() { + $this->file = null; + } +} + +throw new a; + +?> +--EXPECTF-- +Fatal error: Uncaught exception 'a' in :%d +Stack trace: +#0 {main} + thrown in Unknown on line %d diff --git a/Zend/tests/bug50146.phpt b/Zend/tests/bug50146.phpt new file mode 100644 index 0000000..7aa26a6 --- /dev/null +++ b/Zend/tests/bug50146.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #50146 (property_exists: Closure object cannot have properties) +--FILE-- +<?php + +$obj = function(){}; + +var_dump(property_exists($obj,'foo')); + +$ref = new ReflectionObject($obj); +var_dump($ref->hasProperty('b')); + +var_dump(isset($obj->a)); + +?> +--EXPECTF-- +bool(false) +bool(false) + +Catchable fatal error: Closure object cannot have properties in %s on line %d diff --git a/Zend/tests/bug50174.phpt b/Zend/tests/bug50174.phpt new file mode 100644 index 0000000..ac2ad2c --- /dev/null +++ b/Zend/tests/bug50174.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #50174 (Incorrectly matched docComment) +--SKIPIF-- +<?php if (!extension_loaded('reflection') || !extension_loaded('spl')) print "skip SPL and reflection extensions required"; ?> +--FILE-- +<?php + +class TestClass +{ + /** const comment */ + const C = 0; + + function x() {} +} + +$rm = new ReflectionMethod('TestClass', 'x'); +var_dump($rm->getDocComment()); + +class TestClass2 +{ + /** const comment */ + const C = 0; + + public $x; +} + +$rp = new ReflectionProperty('TestClass2', 'x'); +var_dump($rp->getDocComment()); + +?> +--EXPECT-- +bool(false) +bool(false) diff --git a/Zend/tests/bug50255.phpt b/Zend/tests/bug50255.phpt new file mode 100644 index 0000000..9f390af --- /dev/null +++ b/Zend/tests/bug50255.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #50255 (isset() and empty() silently casts array to object) +--FILE-- +<?php + +$arr = array('foo' => 'bar'); + +print "isset\n"; +var_dump(isset($arr->foo)); +var_dump(isset($arr->bar)); +var_dump(isset($arr['foo'])); +var_dump(isset($arr['bar'])); +print "empty\n"; +var_dump(empty($arr->foo)); +var_dump(empty($arr->bar)); +var_dump(empty($arr['foo'])); +var_dump(empty($arr['bar'])); + +?> +--EXPECT-- +isset +bool(false) +bool(false) +bool(true) +bool(false) +empty +bool(true) +bool(true) +bool(false) +bool(true) diff --git a/Zend/tests/bug50261.phpt b/Zend/tests/bug50261.phpt new file mode 100644 index 0000000..271a2c4 --- /dev/null +++ b/Zend/tests/bug50261.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #50261 (Crash When Calling Parent Constructor with call_user_func()) +--FILE-- +<?php + +class testClass { + function testClass($x) { + echo __METHOD__, " (". $x . ")\n"; + } +} + +class testClass2 extends testClass { + function __construct() { + static $x = 0; + + if ($x) { + print "Infinite loop...\n"; + } else { + $x++; + + parent::__construct(1); + testclass::__construct(2); + call_user_func(array('parent', '__construct'), 3); + call_user_func(array('testclass', '__construct'), 4); + call_user_func(array('testclass', 'testclass'), 5); + } + } +} + +new testClass2; + +?> +--EXPECT-- +testClass::testClass (1) +testClass::testClass (2) +testClass::testClass (3) +testClass::testClass (4) +testClass::testClass (5) diff --git a/Zend/tests/bug50383.phpt b/Zend/tests/bug50383.phpt new file mode 100644 index 0000000..2210c4b --- /dev/null +++ b/Zend/tests/bug50383.phpt @@ -0,0 +1,130 @@ +--TEST-- +Bug #50383 (Exceptions thrown in __call / __callStatic do not include file and line in trace) +--FILE-- +<?php + +class myClass { + public static function __callStatic($method, $args) { + throw new Exception("Missing static method '$method'\n"); + } + public function __call($method, $args) { + throw new Exception("Missing method '$method'\n"); + } +} + +function thrower() { + myClass::ThrowException(); +} +function thrower2() { + $x = new myClass; + $x->foo(); +} + +try { + thrower(); +} catch(Exception $e) { + print $e->getMessage(); + print_r($e->getTrace()); +} + +try { + thrower2(); +} catch (Exception $e) { + print $e->getMessage(); + print_r($e->getTrace()); +} + +?> +--EXPECTF-- +Missing static method 'ThrowException' +Array +( + [0] => Array + ( + [file] => %s + [line] => 13 + [function] => __callStatic + [class] => myClass + [type] => :: + [args] => Array + ( + [0] => ThrowException + [1] => Array + ( + ) + + ) + + ) + + [1] => Array + ( + [file] => %s + [line] => 13 + [function] => ThrowException + [class] => myClass + [type] => :: + [args] => Array + ( + ) + + ) + + [2] => Array + ( + [file] => %s + [line] => 21 + [function] => thrower + [args] => Array + ( + ) + + ) + +) +Missing method 'foo' +Array +( + [0] => Array + ( + [file] => %s + [line] => 17 + [function] => __call + [class] => myClass + [type] => -> + [args] => Array + ( + [0] => foo + [1] => Array + ( + ) + + ) + + ) + + [1] => Array + ( + [file] => %s + [line] => 17 + [function] => foo + [class] => myClass + [type] => -> + [args] => Array + ( + ) + + ) + + [2] => Array + ( + [file] => %s + [line] => 28 + [function] => thrower2 + [args] => Array + ( + ) + + ) + +) diff --git a/Zend/tests/bug50394.phpt b/Zend/tests/bug50394.phpt new file mode 100644 index 0000000..e6069d3 --- /dev/null +++ b/Zend/tests/bug50394.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #50394: Reference argument converted to value in __call +--FILE-- +<?php +function inc( &$x ) { $x++; } + +class Proxy { + function __call( $name, $args ) { + echo "$name called!\n"; + call_user_func_array( 'inc', $args ); + } +} + +$arg = 1; +$args = array( &$arg ); +$proxy = new Proxy; +call_user_func_array( array( $proxy, 'bar' ), $args ); +call_user_func_array( array( $proxy, 'bar' ), array(&$arg) ); +var_dump($arg); +--EXPECT-- +bar called! +bar called! +int(3) + diff --git a/Zend/tests/bug50810.phpt b/Zend/tests/bug50810.phpt new file mode 100644 index 0000000..8b4d719 --- /dev/null +++ b/Zend/tests/bug50810.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #50810 (property_exists does not work for private) +--FILE-- +<?php + +class ExampleSuperClass +{ + private $foo; + static protected $bar; + + private function foo() + { + } + + public function propertyFooExists() + { + return property_exists($this, 'foo'); + } + +} + +class ExampleSubClass extends ExampleSuperClass +{ + public function methodExists() + { + return method_exists($this, 'foo'); + } + + public function propertyBarExists() + { + return property_exists($this, 'bar'); + } +} + +$example = new ExampleSubClass(); +var_dump($example->methodExists()); +var_dump(method_exists($example, 'propertyFooExists')); +var_dump($example->propertyFooExists()); +var_dump($example->propertyBarExists()); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/bug50816.phpt b/Zend/tests/bug50816.phpt new file mode 100644 index 0000000..98a8938 --- /dev/null +++ b/Zend/tests/bug50816.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #50816 (Using class constants in array definition fails) +--FILE-- +<?php +define("ONE", 1); +define("TWO", 1); + +class Foo { + const ONE = 1; + const TWO = 1; + + public static $mapWithConst = array(self::ONE => 'one', self::TWO => 'two',); + + public static $mapWithConst1 = array(1 => 'one', self::TWO => 'two',); + public static $mapWithConst2 = array(self::ONE => 'one', 1 => 'two',); + + public static $mapWithoutConst = array(1 => 'one', 1 => 'two',); +} + +$mapWithConst = array(1 => 'one', 1 => 'two',); + +$mapWithoutConst = array(Foo::ONE => 'one', Foo::TWO => 'two',); +$mapWithoutConst0 = array(1 => 'one', 1 => 'two',); +$mapWithoutConst1 = array(ONE => 'one', 1 => 'two',); +$mapWithoutConst2 = array(1 => 'one', TWO => 'two',); +$mapWithoutConst3 = array(ONE => 'one', TWO => 'two',); + +var_dump(Foo::$mapWithConst[1]); +var_dump(Foo::$mapWithConst1[1]); +var_dump(Foo::$mapWithConst2[1]); +var_dump(Foo::$mapWithoutConst[1]); +var_dump($mapWithConst[1]); +var_dump($mapWithoutConst[1]); +var_dump($mapWithoutConst0[1]); +var_dump($mapWithoutConst1[1]); +var_dump($mapWithoutConst2[1]); +var_dump($mapWithoutConst3[1]); +--EXPECT-- +string(3) "two" +string(3) "two" +string(3) "two" +string(3) "two" +string(3) "two" +string(3) "two" +string(3) "two" +string(3) "two" +string(3) "two" +string(3) "two" diff --git a/Zend/tests/bug51176.phpt b/Zend/tests/bug51176.phpt new file mode 100644 index 0000000..1b0e285 --- /dev/null +++ b/Zend/tests/bug51176.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #51176 (Static calling in non-static method behaves like $this->) +--FILE-- +<?php +class Foo +{ + public function start() + { + self::bar(); + static::bar(); + Foo::bar(); + } + + public function __call($n, $a) + { + echo "instance\n"; + } + + public static function __callStatic($n, $a) + { + echo "static\n"; + } +} + +$foo = new Foo(); +$foo->start(); + +?> +--EXPECT-- +instance +instance +instance
\ No newline at end of file diff --git a/Zend/tests/bug51394.phpt b/Zend/tests/bug51394.phpt new file mode 100644 index 0000000..406de13 --- /dev/null +++ b/Zend/tests/bug51394.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #51394 (Error line reported incorrectly if error handler throws an exception) +--INI-- +error_reporting=-1 +--FILE-- +<?php +function eh() +{ + throw new Exception("error!"); + return false; +} + +set_error_handler("eh"); +$a = $empty($b); +--EXPECTF-- +Warning: Uncaught exception 'Exception' with message 'error!' in %sbug51394.php:4 +Stack trace: +#0 %sbug51394.php(9): eh(8, 'Undefined varia...', '%s', 9, Array) +#1 {main} + thrown in %sbug51394.php on line 4 + +Fatal error: Function name must be a string in %sbug51394.php on line 9
\ No newline at end of file diff --git a/Zend/tests/bug51421.phpt b/Zend/tests/bug51421.phpt new file mode 100644 index 0000000..bc1758c --- /dev/null +++ b/Zend/tests/bug51421.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #51421 (Abstract __construct constructor argument list not enforced) +--FILE-- +<?php + +class ExampleClass {} + +abstract class TestInterface { + abstract public function __construct(ExampleClass $var); +} + +class Test extends TestInterface { + public function __construct() {} +} + +?> +--EXPECTF-- +Fatal error: Declaration of Test::__construct() must be compatible with TestInterface::__construct(ExampleClass $var) in %s on line %d diff --git a/Zend/tests/bug51791.phpt b/Zend/tests/bug51791.phpt new file mode 100644 index 0000000..b6ced4b --- /dev/null +++ b/Zend/tests/bug51791.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #51791 (constant() failed to check undefined constant and php interpreter stoped) +--FILE-- +<?php + +class A { + const B = 1; +} +var_dump(constant('A::B1')); + +?> +--EXPECTF-- +Warning: constant(): Couldn't find constant A::B1 in %s on line %d +NULL diff --git a/Zend/tests/bug51822.phpt b/Zend/tests/bug51822.phpt new file mode 100644 index 0000000..cffae7b --- /dev/null +++ b/Zend/tests/bug51822.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #51822 (Segfault with strange __destruct() for static class variables) +--FILE-- +<?php +class DestructableObject +{ + public function __destruct() + { + echo "2\n"; + } +} + +class DestructorCreator +{ + public function __destruct() + { + $this->test = new DestructableObject; + echo "1\n"; + } +} + +class Test +{ + public static $mystatic; +} + +// Uncomment this to avoid segfault +//Test::$mystatic = new DestructorCreator(); + +$x = new Test(); + +if (!isset(Test::$mystatic)) + Test::$mystatic = new DestructorCreator(); + +echo "bla\n"; +?> +--EXPECT-- +bla +1 +2 diff --git a/Zend/tests/bug51827.phpt b/Zend/tests/bug51827.phpt new file mode 100644 index 0000000..0834749 --- /dev/null +++ b/Zend/tests/bug51827.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #51827 (Bad warning when register_shutdown_function called with wrong num of parameters) +--FILE-- +<?php + + +function abc() { + var_dump(1); +} + +register_shutdown_function('timE'); +register_shutdown_function('ABC'); +register_shutdown_function('exploDe'); + +?> +--EXPECTF-- +int(1) + +Warning: explode() expects at least 2 parameters, 0 given in Unknown on line %d diff --git a/Zend/tests/bug52001.phpt b/Zend/tests/bug52001.phpt new file mode 100644 index 0000000..cf55d19 --- /dev/null +++ b/Zend/tests/bug52001.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #52001 (Memory allocation problems after using variable variables) +--FILE-- +<?php +a(0,$$var); + +$temp1=1; +$temp2=2; +var_dump($temp1); + +function a($b,$c) {} +?> +--EXPECTF-- +Notice: Undefined variable: var in %sbug52001.php on line 2 + +Notice: Undefined variable: in %sbug52001.php on line 2 +int(1) diff --git a/Zend/tests/bug52041.phpt b/Zend/tests/bug52041.phpt new file mode 100644 index 0000000..c4b9f97 --- /dev/null +++ b/Zend/tests/bug52041.phpt @@ -0,0 +1,75 @@ +--TEST-- +Bug #52041 (Memory leak when writing on uninitialized variable returned from function) +--FILE-- +<?php +function foo() { + return $x; +} + +foo()->a = 1; +foo()->a->b = 2; +foo()->a++; +foo()->a->b++; +foo()->a += 2; +foo()->a->b += 2; + +foo()[0] = 1; +foo()[0][0] = 2; +foo()[0]++; +foo()[0][0]++; +foo()[0] += 2; +foo()[0][0] += 2; + +var_dump(foo()); +?> +--EXPECTF-- +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Warning: Creating default object from empty value in %sbug52041.php on line 6 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Warning: Creating default object from empty value in %sbug52041.php on line 7 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Warning: Creating default object from empty value in %sbug52041.php on line 8 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Warning: Creating default object from empty value in %sbug52041.php on line 9 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Warning: Creating default object from empty value in %sbug52041.php on line 10 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Warning: Creating default object from empty value in %sbug52041.php on line 11 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Notice: Undefined offset: 0 in %sbug52041.php on line 15 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Notice: Undefined offset: 0 in %sbug52041.php on line 16 + +Notice: Undefined offset: 0 in %sbug52041.php on line 16 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Notice: Undefined offset: 0 in %sbug52041.php on line 17 + +Notice: Undefined variable: x in %sbug52041.php on line 3 + +Notice: Undefined offset: 0 in %sbug52041.php on line 18 + +Notice: Undefined offset: 0 in %sbug52041.php on line 18 + +Notice: Undefined variable: x in %sbug52041.php on line 3 +NULL diff --git a/Zend/tests/bug52051.phpt b/Zend/tests/bug52051.phpt new file mode 100644 index 0000000..e8a4f49 --- /dev/null +++ b/Zend/tests/bug52051.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #52051 (handling of case sensitivity of old-style constructors changed in 5.3+) +--FILE-- +<?php + +class AA { + function AA() { echo "foo\n"; } +} +class bb extends AA {} +class CC extends bb { + function CC() { parent::bb(); } +} +new CC(); + +class A { + function A() { echo "bar\n"; } +} +class B extends A {} +class C extends B { + function C() { parent::B(); } +} +new C(); + +?> +--EXPECT-- +foo +bar diff --git a/Zend/tests/bug52060.phpt b/Zend/tests/bug52060.phpt new file mode 100644 index 0000000..fef603b --- /dev/null +++ b/Zend/tests/bug52060.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #52060 (Memory leak when passing a closure to method_exists()) +--FILE-- +<?php + +$closure = function($a) { echo $a; }; + +var_dump(method_exists($closure, '__invoke')); // true + +?> +--EXPECT-- +bool(true) diff --git a/Zend/tests/bug52160.phpt b/Zend/tests/bug52160.phpt new file mode 100644 index 0000000..c85d2f0 --- /dev/null +++ b/Zend/tests/bug52160.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #52160 (Invalid E_STRICT redefined constructor error) +--FILE-- +<?php + +class bar { + function __construct() { } + static function bar() { + var_dump(1); + } +} + +bar::bar(); + +class foo { + static function foo() { + var_dump(2); + } + function __construct() { } +} + +foo::foo(); + +class baz { + static function baz() { + var_dump(3); + } +} + +?> +--EXPECTF-- +Strict Standards: Redefining already defined constructor for class foo in %s on line %d + +Fatal error: Constructor baz::baz() cannot be static in %s on line %d diff --git a/Zend/tests/bug52193.phpt b/Zend/tests/bug52193.phpt new file mode 100644 index 0000000..7452672 --- /dev/null +++ b/Zend/tests/bug52193.phpt @@ -0,0 +1,78 @@ +--TEST-- +Bug #52193 (converting closure to array yields empty array) +--FILE-- +<?php + +var_dump((array) 1); +var_dump((array) NULL); +var_dump((array) new stdclass); +var_dump($h = (array) function () { return 2; }); +var_dump($h[0]()); + +$i = function () use (&$h) { + return $h; +}; + +var_dump($x = (array)$i); +var_dump($y = $x[0]); +var_dump($y()); + +$items = range(1, 5); +$func = function(){ return 'just a test'; }; + +array_splice($items, 0 , 4, $func); +var_dump($items); + +?> +--EXPECTF-- +array(1) { + [0]=> + int(1) +} +array(0) { +} +array(0) { +} +array(1) { + [0]=> + object(Closure)#%d (0) { + } +} +int(2) +array(1) { + [0]=> + object(Closure)#%d (1) { + ["static"]=> + array(1) { + ["h"]=> + &array(1) { + [0]=> + object(Closure)#%d (0) { + } + } + } + } +} +object(Closure)#%d (1) { + ["static"]=> + array(1) { + ["h"]=> + &array(1) { + [0]=> + object(Closure)#%d (0) { + } + } + } +} +array(1) { + [0]=> + object(Closure)#%d (0) { + } +} +array(2) { + [0]=> + object(Closure)#%d (0) { + } + [1]=> + int(5) +} diff --git a/Zend/tests/bug52237.phpt b/Zend/tests/bug52237.phpt new file mode 100644 index 0000000..0b54787 --- /dev/null +++ b/Zend/tests/bug52237.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #52237 (Crash when passing the reference of the property of a non-object) +--FILE-- +<?php +$data = 'test'; +preg_match('//', '', $data->info); +var_dump($data); +?> +--EXPECTF-- + +Warning: Attempt to modify property of non-object in %sbug52237.php on line 3 +string(4) "test" diff --git a/Zend/tests/bug52361.phpt b/Zend/tests/bug52361.phpt new file mode 100644 index 0000000..3c2dffa --- /dev/null +++ b/Zend/tests/bug52361.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #52361 (Throwing an exception in a destructor causes invalid catching) +--FILE-- +<?php +class aaa { + public function __destruct() { + try { + throw new Exception(__CLASS__); + } catch(Exception $ex) { + echo "1. $ex\n"; + } + } +} +function bbb() { + $a = new aaa(); + throw new Exception(__FUNCTION__); +} +try { + bbb(); + echo "must be skipped !!!"; +} catch(Exception $ex) { + echo "2. $ex\n"; +} +?> +--EXPECTF-- +1. exception 'Exception' with message 'aaa' in %sbug52361.php:5 +Stack trace: +#0 %sbug52361.php(16): aaa->__destruct() +#1 %sbug52361.php(16): bbb() +#2 {main} +2. exception 'Exception' with message 'bbb' in %sbug52361.php:13 +Stack trace: +#0 %sbug52361.php(16): bbb() +#1 {main} + diff --git a/Zend/tests/bug52484.phpt b/Zend/tests/bug52484.phpt new file mode 100644 index 0000000..ccdf858 --- /dev/null +++ b/Zend/tests/bug52484.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #52484 (__set() ignores setting properties with empty names) +--FILE-- +<?php + +class A { + function __unset($prop) { + unset($this->$prop); + } +} + +$a = new A(); +$prop = null; + +unset($a->$prop); + +?> +--EXPECTF-- +Fatal error: Cannot access empty property in %s on line %d diff --git a/Zend/tests/bug52484_2.phpt b/Zend/tests/bug52484_2.phpt new file mode 100644 index 0000000..1639c81 --- /dev/null +++ b/Zend/tests/bug52484_2.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #52484.2 (__set() ignores setting properties with empty names) +--FILE-- +<?php + +class A { + function __set($prop, $val) { + $this->$prop = $val; + } +} + +$a = new A(); +$prop = null; + +$a->$prop = 2; + +?> +--EXPECTF-- +Fatal error: Cannot access empty property in %s on line %d diff --git a/Zend/tests/bug52484_3.phpt b/Zend/tests/bug52484_3.phpt new file mode 100644 index 0000000..20dde3d --- /dev/null +++ b/Zend/tests/bug52484_3.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #52484.3 (__set() ignores setting properties with empty names) +--FILE-- +<?php + +class A { + function __get($prop) { + var_dump($this->$prop); + } +} + +$a = new A(); +$prop = null; + +var_dump($a->$prop); + +?> +--EXPECTF-- +Fatal error: Cannot access empty property in %s on line %d diff --git a/Zend/tests/bug52508.phpt b/Zend/tests/bug52508.phpt new file mode 100644 index 0000000..83292a5 --- /dev/null +++ b/Zend/tests/bug52508.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #52508 (newline problem with parse_ini_file+INI_SCANNER_RAW) +--FILE-- +<?php + +$file = dirname(__FILE__) .'/bug52508.ini'; + +file_put_contents($file, "a = 1"); + +$ini_array = parse_ini_file($file, true, INI_SCANNER_RAW); +var_dump($ini_array); + +unlink($file); + +?> +--EXPECT-- +array(1) { + ["a"]=> + string(1) "1" +} diff --git a/Zend/tests/bug52614.phpt b/Zend/tests/bug52614.phpt new file mode 100644 index 0000000..d220881 --- /dev/null +++ b/Zend/tests/bug52614.phpt @@ -0,0 +1,83 @@ +--TEST-- +Bug #52614 (Memory leak when writing on uninitialized variable returned from method call) +--FILE-- +<?php +class foo { + public $a1; + public $a2 = array(); + public $a3; + public $o1; + public $o2; + + public function f1() { + return $this->a1; + } + + public function f2() { + return $this->a2; + } + + public function f3() { + $this->a3 = array(); + return $this->a3; + } + + public function f4() { + return $this->o1; + } + + public function f5() { + $this->o2 = new stdClass; + return $this->o2; + } + + public function &f6() { + return $this->a1; + } + + public function f7(&$x) { + $x = 2; + } + +} + +$foo = new foo; + +$foo->f1()[0] = 1; +var_dump($foo->a1); + +$foo->f2()[0] = 1; +var_dump($foo->a2); + +$foo->f3()[0] = 1; +var_dump($foo->a3); + +$foo->f4()->a = 1; +var_dump($foo->o1); + +$foo->f5()->a = 1; +var_dump($foo->o2); + +$foo->a1[0] = 1; +$foo->f7($foo->f6()[0]); +var_dump($foo->a1[0]); +$foo->f1()[0]++; +var_dump($foo->a1[0]); +$foo->f6()[0]++; +var_dump($foo->a1[0]); +--EXPECTF-- +NULL +array(0) { +} +array(0) { +} + +Warning: Creating default object from empty value in %sbug52614.php on line 52 +NULL +object(stdClass)#%d (1) { + ["a"]=> + int(1) +} +int(2) +int(2) +int(3) diff --git a/Zend/tests/bug52879.phpt b/Zend/tests/bug52879.phpt new file mode 100644 index 0000000..0193be4 --- /dev/null +++ b/Zend/tests/bug52879.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #52879 (Objects unreferenced in __get, __set, __isset or __unset can be freed too early) +--FILE-- +<?php +class MyClass { + public $myRef; + public function __set($property,$value) { + $this->myRef = $value; + } +} +$myGlobal=new MyClass($myGlobal); +$myGlobal->myRef=&$myGlobal; +$myGlobal->myNonExistentProperty="ok\n"; +echo $myGlobal; +--EXPECT-- +ok diff --git a/Zend/tests/bug52939.phpt b/Zend/tests/bug52939.phpt new file mode 100644 index 0000000..91bd27b --- /dev/null +++ b/Zend/tests/bug52939.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #52939 (zend_call_function_array does not respect ZEND_SEND_PREFER_REF) +--FILE-- +<?php +$ar1 = array("row1" => 2, "row2" => 1); +var_dump(array_multisort($ar1)); +var_dump($ar1); + +$ar1 = array("row1" => 2, "row2" => 1); +$args = array(&$ar1); +var_dump(call_user_func_array("array_multisort", $args)); +var_dump($ar1); + +$ar1 = array("row1" => 2, "row2" => 1); +$args = array($ar1); +var_dump(call_user_func_array("array_multisort", $args)); +var_dump($ar1); +?> +--EXPECT-- +bool(true) +array(2) { + ["row2"]=> + int(1) + ["row1"]=> + int(2) +} +bool(true) +array(2) { + ["row2"]=> + int(1) + ["row1"]=> + int(2) +} +bool(true) +array(2) { + ["row1"]=> + int(2) + ["row2"]=> + int(1) +} diff --git a/Zend/tests/bug52940.phpt b/Zend/tests/bug52940.phpt new file mode 100644 index 0000000..f8d31c0 --- /dev/null +++ b/Zend/tests/bug52940.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #52940 (call_user_func_array still allows call-time pass-by-reference) +--FILE-- +<?php +function foo($a) { + $a++; + var_dump($a); +} +function bar(&$a) { + $a++; + var_dump($a); +} +$a = 1; +call_user_func_array("foo", array(&$a)); +var_dump($a); +call_user_func_array("bar", array(&$a)); +var_dump($a); +?> +--EXPECT-- +int(2) +int(1) +int(2) +int(2) diff --git a/Zend/tests/bug53305.phpt b/Zend/tests/bug53305.phpt new file mode 100644 index 0000000..c922ac6 --- /dev/null +++ b/Zend/tests/bug53305.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #53305 (E_NOTICE when defining a constant starts with __COMPILER_HALT_OFFSET__) +--FILE-- +<?php +error_reporting(E_ALL); + +define('__COMPILER_HALT_OFFSET__1', 1); +define('__COMPILER_HALT_OFFSET__2', 2); +define('__COMPILER_HALT_OFFSET__', 3); +define('__COMPILER_HALT_OFFSET__1'.chr(0), 4); + +var_dump(__COMPILER_HALT_OFFSET__1); +var_dump(constant('__COMPILER_HALT_OFFSET__1'.chr(0))); + +?> +--EXPECTF-- +Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d +int(1) +int(4) diff --git a/Zend/tests/bug53347.phpt b/Zend/tests/bug53347.phpt new file mode 100644 index 0000000..66e4ec2 --- /dev/null +++ b/Zend/tests/bug53347.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #53347 Segfault accessing static method +--FILE-- +<?php class ezcConsoleOutput +{ + protected static $color = array( 'gray' => 30 ); + + public static function isValidFormatCode( $type, $key ) + { + return isset( self::${$type}[$key] ); + } +} + +var_dump( ezcConsoleOutput::isValidFormatCode( 'color', 'gray' ) ); +?> +--EXPECT-- +bool(true) diff --git a/Zend/tests/bug53511.phpt b/Zend/tests/bug53511.phpt new file mode 100644 index 0000000..88f0cbe --- /dev/null +++ b/Zend/tests/bug53511.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #53511 (Exceptions are lost in case an exception is thrown in catch operator) +--FILE-- +<?php +class Foo { + function __destruct() { + throw new Exception("ops 1"); + } +} + +function test() { + $e = new Foo(); + try { + throw new Exception("ops 2"); + } catch (Exception $e) { + echo $e->getMessage()."\n"; + } +} + +test(); +echo "bug\n"; +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'ops 2' in %sbug53511.php:11 +Stack trace: +#0 %sbug53511.php(17): test() +#1 {main} + +Next exception 'Exception' with message 'ops 1' in %sbug53511.php:4 +Stack trace: +#0 %sbug53511.php(12): Foo->__destruct() +#1 %sbug53511.php(17): test() +#2 {main} + thrown in %sbug53511.php on line 4 diff --git a/Zend/tests/bug53629.phpt b/Zend/tests/bug53629.phpt new file mode 100644 index 0000000..4b46b9f --- /dev/null +++ b/Zend/tests/bug53629.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #53629 (memory leak inside highlight_string()) +--FILE-- +<?php + +$str = ' +<?php +class foo { + public $bar = <<<EOT +bar + EOT; +} +?> +'; +$str2 = ' +<?php +var_dump(array(<<<EOD +foobar! +EOD +)); +?> +'; + +highlight_string($str, true); +highlight_string($str2, true); + + +echo "Done\n"; +?> +--EXPECT-- +Done diff --git a/Zend/tests/bug53632.phpt b/Zend/tests/bug53632.phpt new file mode 100644 index 0000000..9a6dade --- /dev/null +++ b/Zend/tests/bug53632.phpt @@ -0,0 +1,10 @@ +--TEST-- +zend_strtod() hangs with 2.2250738585072011e-308 +--FILE-- +<?php +$d = 2.2250738585072011e-308; + +echo "Done\n"; +?> +--EXPECTF-- +Done diff --git a/Zend/tests/bug53727.phpt b/Zend/tests/bug53727.phpt new file mode 100644 index 0000000..22cd523 --- /dev/null +++ b/Zend/tests/bug53727.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #53727 (Inconsistent behavior of is_subclass_of with interfaces) +--FILE-- +<?php +interface MyInterface { + const TEST_CONSTANT = true; +} + +class ParentClass implements MyInterface { } + +class ChildClass extends ParentClass { } + +echo (is_subclass_of('ChildClass', 'MyInterface') ? 'true' : 'false') . "\n"; +echo (defined('ChildClass::TEST_CONSTANT') ? 'true' : 'false') . "\n"; + +echo (is_subclass_of('ParentClass', 'MyInterface') ? 'true' : 'false') . "\n"; +echo (defined('ParentClass::TEST_CONSTANT') ? 'true' : 'false') . "\n"; +--EXPECT-- +true +true +true +true diff --git a/Zend/tests/bug53748.phpt b/Zend/tests/bug53748.phpt new file mode 100644 index 0000000..2f171fe --- /dev/null +++ b/Zend/tests/bug53748.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #53748 (Using traits lead to a segmentation fault) +--FILE-- +<?php + +trait Singleton { + protected static $instances=array(); + abstract protected function __construct($config); + public static function getInstance($config) { + if (!isset(self::$instances[$serialize = serialize($config)])) { + self::$instances[$serialize] = new self($config); + } + return self::$instances[$serialize]; + } +} + +class MyHelloWorld { + use Singleton; + public function __construct($config) + { + var_dump( $config); + } +} + + +$o= myHelloWorld::getInstance(1); +$o= myHelloWorld::getInstance(1); +$o= myHelloWorld::getInstance(2); +$o= myHelloWorld::getInstance(array(1=>2)); +$o= myHelloWorld::getInstance(array(1=>2)); + +?> +--EXPECTF-- +int(1) +int(2) +array(1) { + [1]=> + int(2) +} diff --git a/Zend/tests/bug53958.phpt b/Zend/tests/bug53958.phpt new file mode 100644 index 0000000..96a4115 --- /dev/null +++ b/Zend/tests/bug53958.phpt @@ -0,0 +1,61 @@ +--TEST-- +Bug #53958 (Closures can't 'use' shared variables by value and by reference) +--FILE-- +<?php +// TEST 1 +$a = 1; +$fn1 = function() use ($a) {echo "$a\n"; $a++;}; +$fn2 = function() use ($a) {echo "$a\n"; $a++;}; +$a = 5; +$fn1(); // 1 +$fn2(); // 1 +$fn1(); // 1 +$fn2(); // 1 + +// TEST 2 +$b = 1; +$fn1 = function() use (&$b) {echo "$b\n"; $b++;}; +$fn2 = function() use (&$b) {echo "$b\n"; $b++;}; +$b = 5; +$fn1(); // 5 +$fn2(); // 6 +$fn1(); // 7 +$fn2(); // 8 + +// TEST 3 +$c = 1; +$fn1 = function() use (&$c) {echo "$c\n"; $c++;}; +$fn2 = function() use ($c) {echo "$c\n"; $c++;}; +$c = 5; +$fn1(); // 5 +$fn2(); // 1 +$fn1(); // 6 +$fn2(); // 1 + +// TEST 4 +$d = 1; +$fn1 = function() use ($d) {echo "$d\n"; $d++;}; +$fn2 = function() use (&$d) {echo "$d\n"; $d++;}; +$d = 5; +$fn1(); // 1 +$fn2(); // 5 +$fn1(); // 1 +$fn2(); // 6 +?> +--EXPECT-- +1 +1 +1 +1 +5 +6 +7 +8 +5 +1 +6 +1 +1 +5 +1 +6 diff --git a/Zend/tests/bug53971.phpt b/Zend/tests/bug53971.phpt new file mode 100644 index 0000000..a1e66cc --- /dev/null +++ b/Zend/tests/bug53971.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #53971 (isset() and empty() produce apparently spurious runtime error) +--FILE-- +<?php +$s = ""; +var_dump(isset($s[0][0])); +?> +--EXPECT-- +bool(false) + + diff --git a/Zend/tests/bug54013.phpt b/Zend/tests/bug54013.phpt new file mode 100644 index 0000000..4219eed --- /dev/null +++ b/Zend/tests/bug54013.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #54013 (ReflectionParam for duplicate parameter contains garbage) +--FILE-- +<?php + +class a +{ + function b($aaaaaaaa, $aaaaaaaa) + { + $params = func_get_args(); + } +} + +$c = new a; +$c->b('waa?', 'meukee!'); + +$reflectionClass = new ReflectionClass($c); +$params = $reflectionClass->getMethod('b')->getParameters(); + +var_dump($params[0], $params[1]); + +?> +--EXPECTF-- +object(ReflectionParameter)#%d (1) { + ["name"]=> + string(8) "aaaaaaaa" +} +object(ReflectionParameter)#%d (1) { + ["name"]=> + string(8) "aaaaaaaa" +} diff --git a/Zend/tests/bug54039.phpt b/Zend/tests/bug54039.phpt new file mode 100644 index 0000000..ccdfe94 --- /dev/null +++ b/Zend/tests/bug54039.phpt @@ -0,0 +1,58 @@ +--TEST-- +Bug #54039 (use() of static variables in lambda functions can break staticness) +--FILE-- +<?php +function test_1() { + static $v = 0; + ++$v; + echo "Outer function increments \$v to $v\n"; + $f = function() use($v) { + echo "Inner function reckons \$v is $v\n"; + }; + return $f; +} + +$f = test_1(); $f(); +$f = test_1(); $f(); + +function test_2() { + static $v = 0; + $f = function() use($v) { + echo "Inner function reckons \$v is $v\n"; + }; + ++$v; + echo "Outer function increments \$v to $v\n"; + return $f; +} + +$f = test_2(); $f(); +$f = test_2(); $f(); + +function test_3() { + static $v = ""; + $v .= 'b'; + echo "Outer function catenates 'b' onto \$v to give $v\n"; + $f = function() use($v) { + echo "Inner function reckons \$v is $v\n"; + }; + $v .= 'a'; + echo "Outer function catenates 'a' onto \$v to give $v\n"; + return $f; +} +$f = test_3(); $f(); +$f = test_3(); $f(); +--EXPECT-- +Outer function increments $v to 1 +Inner function reckons $v is 1 +Outer function increments $v to 2 +Inner function reckons $v is 2 +Outer function increments $v to 1 +Inner function reckons $v is 0 +Outer function increments $v to 2 +Inner function reckons $v is 1 +Outer function catenates 'b' onto $v to give b +Outer function catenates 'a' onto $v to give ba +Inner function reckons $v is b +Outer function catenates 'b' onto $v to give bab +Outer function catenates 'a' onto $v to give baba +Inner function reckons $v is bab diff --git a/Zend/tests/bug54262.phpt b/Zend/tests/bug54262.phpt new file mode 100644 index 0000000..17a6ea6 --- /dev/null +++ b/Zend/tests/bug54262.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #54262 (Crash when assigning value to a dimension in a non-array) +--FILE-- +<?php +$a = '0'; +var_dump(isset($a['b'])); +$simpleString = preg_match('//', '', $a->a); +$simpleString["wrong"] = "f"; +echo "ok\n"; +?> +--EXPECTF-- +bool(false) + +Warning: Attempt to modify property of non-object in %sbug54262.php on line 4 + +Warning: Cannot use a scalar value as an array in %sbug54262.php on line 5 +ok diff --git a/Zend/tests/bug54265.phpt b/Zend/tests/bug54265.phpt new file mode 100644 index 0000000..43db028 --- /dev/null +++ b/Zend/tests/bug54265.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #54265 (crash when variable gets reassigned in error handler) +--FILE-- +<?php +function my_errorhandler($errno,$errormsg) { + global $my_var; + $my_var = 0; + echo "EROOR: $errormsg\n"; +} +set_error_handler("my_errorhandler"); +$my_var = str_repeat("A",$my_var[0]->errormsg = "xyz"); +echo "ok\n"; +?> +--EXPECT-- +EROOR: Creating default object from empty value +ok + diff --git a/Zend/tests/bug54268.phpt b/Zend/tests/bug54268.phpt new file mode 100644 index 0000000..b544cd8 --- /dev/null +++ b/Zend/tests/bug54268.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #54268 (Double free when destroy_zend_class fails) +--INI-- +memory_limit=8M +--SKIPIF-- +<?php +$zend_mm_enabled = getenv("USE_ZEND_ALLOC"); +if ($zend_mm_enabled === "0") { + die("skip Zend MM disabled"); +} +?> +--FILE-- +<?php +class DestructableObject +{ + public function __destruct() + { + DestructableObject::__destruct(); + } +} +class DestructorCreator +{ + public function __destruct() + { + $this->test = new DestructableObject; + } +} +class Test +{ + public static $mystatic; +} +$x = new Test(); +Test::$mystatic = new DestructorCreator(); +--EXPECTF-- +Fatal error: Allowed memory size of %s bytes exhausted%s(tried to allocate %s bytes) in %s on line %d diff --git a/Zend/tests/bug54305.phpt b/Zend/tests/bug54305.phpt new file mode 100644 index 0000000..8e85d2b --- /dev/null +++ b/Zend/tests/bug54305.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #54305 (Crash in gc_remove_zval_from_buffer) +--FILE-- +<?php +class TestClass { + public function methodWithArgs($a, $b) { + } +} +abstract class AbstractClass { +} +$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs'); +echo $methodWithArgs++; +?> +--EXPECTF-- +Method [ <user> public method methodWithArgs ] { + @@ %sbug54305.php %d - %d + + - Parameters [2] { + Parameter #0 [ <required> $a ] + Parameter #1 [ <required> $b ] + } +} diff --git a/Zend/tests/bug54358.phpt b/Zend/tests/bug54358.phpt new file mode 100644 index 0000000..faeeeac --- /dev/null +++ b/Zend/tests/bug54358.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #54358 (Closure, use and reference) +--FILE-- +<?php +class asserter { + public function call($function) { + } +} + +$asserter = new asserter(); + +$closure = function() use ($asserter, &$function) { + $asserter->call($function = 'md5'); +}; + +$closure(); + +var_dump($function); + +$closure = function() use ($asserter, $function) { + $asserter->call($function); +}; + +$closure(); + +var_dump($function); + +$closure = function() use ($asserter, $function) { + $asserter->call($function); +}; + +$closure(); + +var_dump($function); +?> +--EXPECT-- +string(3) "md5" +string(3) "md5" +string(3) "md5" diff --git a/Zend/tests/bug54367.phpt b/Zend/tests/bug54367.phpt new file mode 100644 index 0000000..1ca6ad4 --- /dev/null +++ b/Zend/tests/bug54367.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #54367 (Use of closure causes problem in ArrayAccess) +--FILE-- +<?php +class MyObjet implements ArrayAccess +{ + public function offsetSet($offset, $value) { } + public function offsetExists($offset) { } + public function offsetUnset($offset) { } + + public function offsetGet ($offset) + { + return function ($var) use ($offset) { // here is the problem + var_dump($offset, $var); + }; + } +} + +$a = new MyObjet(); +echo $a['p']('foo'); +?> +--EXPECT-- +string(1) "p" +string(3) "foo" diff --git a/Zend/tests/bug54372.phpt b/Zend/tests/bug54372.phpt new file mode 100644 index 0000000..e2e9911 --- /dev/null +++ b/Zend/tests/bug54372.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #54372 (Crash accessing global object itself returned from its __get() handle) +--FILE-- +<?php +class test_class +{ + public function __get($name) + { + return $this; + } + + public function b() + { + echo "ok\n"; + } +} + +global $test3; +$test3 = new test_class(); +$test3->a->b(); +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug54547.phpt b/Zend/tests/bug54547.phpt new file mode 100644 index 0000000..452cbb8 --- /dev/null +++ b/Zend/tests/bug54547.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #54547: wrong equality of string numbers near LONG_MAX with 64-bit longs +--SKIPIF-- +<?php +if (PHP_INT_MAX !== 9223372036854775807) + die("skip for 64-bit long systems only"); +--FILE-- +<?php +var_dump("9223372036854775807" == "9223372036854775808"); +var_dump("-9223372036854775808" == "-9223372036854775809"); +var_dump("0x7fffffffffffffff" == "9223372036854775808"); + +/* not exactly what the bug is about, but closely related problem: */ +var_dump("999223372036854775807"=="999223372036854775808"); +var_dump("899223372036854775807">"00999223372036854775807"); +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/Zend/tests/bug54585.phpt b/Zend/tests/bug54585.phpt new file mode 100644 index 0000000..2ca11f3 --- /dev/null +++ b/Zend/tests/bug54585.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #54585 (track_errors causes segfault) +--INI-- +track_errors=On +--FILE-- +<?php +function testing($source) { + unset($source[$cos]); +} +testing($_GET); +echo "ok\n"; +?> +--EXPECTF-- +Notice: Undefined variable: cos in %sbug54585.php on line 3 +ok diff --git a/Zend/tests/bug54624.phpt b/Zend/tests/bug54624.phpt new file mode 100644 index 0000000..1d0c1ce --- /dev/null +++ b/Zend/tests/bug54624.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #54624 (class_alias and type hint) +--FILE-- +<?php +class A +{ + function foo(A $param) { + } + +} + +class_alias('A', 'AliasA'); + +eval(' + class B extends A + { + function foo(AliasA $param) { + } + + } +'); + +echo "DONE\n"; +?> +--EXPECTF-- +DONE diff --git a/Zend/tests/bug54804.inc b/Zend/tests/bug54804.inc new file mode 100644 index 0000000..74b7a16 --- /dev/null +++ b/Zend/tests/bug54804.inc @@ -0,0 +1,3 @@ +<?php +namespace b\c {} +namespace b\d {} diff --git a/Zend/tests/bug54804.phpt b/Zend/tests/bug54804.phpt new file mode 100644 index 0000000..c68e946 --- /dev/null +++ b/Zend/tests/bug54804.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #54804 (__halt_compiler and imported namespaces) +--FILE-- +<?php +namespace a; +require __DIR__ . '/bug54804.inc'; +echo 'DONE'; +__halt_compiler(); +?> +--EXPECT-- +DONE diff --git a/Zend/tests/bug54910.phpt b/Zend/tests/bug54910.phpt new file mode 100644 index 0000000..8808cd0 --- /dev/null +++ b/Zend/tests/bug54910.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #54910 (Crash when calling call_user_func with unknown function name) +--FILE-- +<?php +class A { + public function __call($method, $args) { + if (stripos($method, 'get') === 0) { + return $this->get(); + } + die("No such method - '$method'\n"); + } + + protected function get() { + $class = get_class($this); + $call = array($class, 'noSuchMethod'); + + if (is_callable($call)) { + call_user_func($call); + } + } +} + +class B extends A {} + +$input = new B(); +echo $input->getEmail(); +--EXPECT-- +No such method - 'noSuchMethod' diff --git a/Zend/tests/bug55007.phpt b/Zend/tests/bug55007.phpt new file mode 100644 index 0000000..12fbf12 --- /dev/null +++ b/Zend/tests/bug55007.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #55007 (compiler fail after previous fail) +--FILE-- +<?php + +function __autoload($classname) { + if ('CompileErrorClass'==$classname) eval('class CompileErrorClass { function foo() { $a[] } }'); + if ('MyErrorHandler'==$classname) eval('class MyErrorHandler { function __construct() { print "My error handler runs.\n"; } }'); +} + +function shutdown() { + new MyErrorHandler(); +} + + +register_shutdown_function('shutdown'); + +new CompileErrorClass(); + +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s(%d) : eval()'d code on line %d +My error handler runs. diff --git a/Zend/tests/bug55086.phpt b/Zend/tests/bug55086.phpt new file mode 100644 index 0000000..9a5c747 --- /dev/null +++ b/Zend/tests/bug55086.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #55086 (Namespace alias does not work inside trait's use block) +--FILE-- +<?php +namespace N1 { + + trait T1 { + public function hello() { return 'hello from t1'; } + } + + trait T2 { + public function hello() { return 'hello from t2'; } + } + +} +namespace N2 { + use N1\T1; + use N1\T2; + class A { + use T1, T2 { + T1::hello insteadof T2; + T1::hello as foo; + } + } + $a = new A; + echo $a->hello(), PHP_EOL; + echo $a->foo(), PHP_EOL; + try { + } catch(namespace \Foo $e) + { + } +} +?> +--EXPECT-- +hello from t1 +hello from t1 diff --git a/Zend/tests/bug55135.phpt b/Zend/tests/bug55135.phpt new file mode 100644 index 0000000..f6d0aaf --- /dev/null +++ b/Zend/tests/bug55135.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #55135 (Array keys are no longer type casted in unset()) +--FILE-- +<?php +// This fails. +$array = array(1 => 2); +$a = "1"; +unset($array[$a]); +print_r($array); + +// Those works. +$array = array(1 => 2); +$a = 1; +unset($array[$a]); +print_r($array); + +$array = array(1 => 2); +unset($array[1]); +print_r($array); + +$array = array(1 => 2); +$a = 1; +unset($array["1"]); +print_r($array); +?> +--EXPECT-- +Array +( +) +Array +( +) +Array +( +) +Array +( +) diff --git a/Zend/tests/bug55137.phpt b/Zend/tests/bug55137.phpt new file mode 100644 index 0000000..4a4e6e6 --- /dev/null +++ b/Zend/tests/bug55137.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #55137 (Changing trait static method visibility) +--FILE-- +<?php + +trait A { + protected static function foo() { echo "abc\n"; } + private static function bar() { echo "def\n"; } +} + + +class B { + use A { + A::foo as public; + A::bar as public baz; + } +} + +B::foo(); +B::baz(); + + +?> +--EXPECT-- +abc +def diff --git a/Zend/tests/bug55156.phpt b/Zend/tests/bug55156.phpt new file mode 100644 index 0000000..6c0ff76 --- /dev/null +++ b/Zend/tests/bug55156.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #55156 (ReflectionClass::getDocComment() returns comment even though the class has none) +--FILE-- +<?php + +/** test */ +namespace foo { + function test() { } + + $x = new \ReflectionFunction('foo\test'); + var_dump($x->getDocComment()); + + /** test1 */ + class bar { } + + /** test2 */ + class foo extends namespace\bar { } + + $x = new \ReflectionClass('foo\bar'); + var_dump($x->getDocComment()); + + $x = new \ReflectionClass('foo\foo'); + var_dump($x->getDocComment()); +} + +?> +--EXPECTF-- +bool(false) +string(12) "/** test1 */" +string(12) "/** test2 */" diff --git a/Zend/tests/bug55247.phpt b/Zend/tests/bug55247.phpt new file mode 100644 index 0000000..6fa893f --- /dev/null +++ b/Zend/tests/bug55247.phpt @@ -0,0 +1,33 @@ +--TEST-- +Request #55247 (Parser problem with static calls using string method name) +--FILE-- +<?php +class Test{ + public static function __callStatic($method, $arguments) + { + echo $method . PHP_EOL; + } + public function __call($method, $arguments) + { + echo $method . PHP_EOL; + } +} + +$method = 'method'; + +$test = new Test(); + +$test->method(); +$test->$method(); +$test->{'method'}(); + +Test::method(); +Test::$method(); +Test::{'method'}(); +--EXPECT-- +method +method +method +method +method +method diff --git a/Zend/tests/bug55305.phpt b/Zend/tests/bug55305.phpt new file mode 100644 index 0000000..7f0749a --- /dev/null +++ b/Zend/tests/bug55305.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #55305 (ref lost: 1st ref instantiated in class def, 2nd ref made w/o instantiating) +--FILE-- +<?php +class Foo { + var $foo = "test"; +} + +$f = new Foo(); +$f->bar =& $f->foo; +var_dump($f->foo); +var_dump($f->bar); +?> +--EXPECT-- +string(4) "test" +string(4) "test" diff --git a/Zend/tests/bug55445.phpt b/Zend/tests/bug55445.phpt new file mode 100644 index 0000000..0f36ac5 --- /dev/null +++ b/Zend/tests/bug55445.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #55445 (Lexer error with short open tags) +--INI-- +short_open_tag=0 +--FILE-- +<?php $u = "chris"; ?><p>Welcome <?= $u ?></p> +--EXPECTF-- +<p>Welcome chris</p> diff --git a/Zend/tests/bug55509.phpt b/Zend/tests/bug55509.phpt new file mode 100644 index 0000000..5268789 --- /dev/null +++ b/Zend/tests/bug55509.phpt @@ -0,0 +1,71 @@ +--TEST--
+Bug #55509 (segfault on x86_64 using more than 2G memory)
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE == 4) {
+ die('skip Not for 32-bits OS');
+}
+
+$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
+if ($zend_mm_enabled === "0") {
+ die("skip Zend MM disabled");
+}
+
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+// check the available memory
+if (PHP_OS == 'Linux') {
+ $lines = file('/proc/meminfo');
+ $infos = array();
+ foreach ($lines as $line) {
+ $tmp = explode(":", $line);
+ $index = strtolower($tmp[0]);
+ $value = (int)ltrim($tmp[1], " ")*1024;
+ $infos[$index] = $value;
+ }
+ $freeMemory = $infos['memfree']+$infos['buffers']+$infos['cached'];
+ if ($freeMemory < 2100*1024*1024) {
+ die('skip Not enough memory.');
+ }
+}
+elseif (PHP_OS == 'FreeBSD') {
+ $lines = explode("\n",`sysctl -a`);
+ $infos = array();
+ foreach ($lines as $line) {
+ if(!$line){
+ continue;
+ }
+ $tmp = explode(":", $line);
+ $index = strtolower($tmp[0]);
+ $value = trim($tmp[1], " ");
+ $infos[$index] = $value;
+ }
+ $freeMemory = ($infos['vm.stats.vm.v_inactive_count']*$infos['hw.pagesize'])
+ +($infos['vm.stats.vm.v_cache_count']*$infos['hw.pagesize'])
+ +($infos['vm.stats.vm.v_free_count']*$infos['hw.pagesize']);
+ if ($freeMemory < 2100*1024*1024) {
+ die('skip Not enough memory.');
+ }
+}
+?>
+--INI--
+memory_limit=2100M
+--FILE--
+<?php
+$a1 = str_repeat("1", 1024 * 1024 * 1024 * 0.5);
+echo "1\n";
+$a2 = str_repeat("2", 1024 * 1024 * 1024 * 0.5);
+echo "2\n";
+$a3 = str_repeat("3", 1024 * 1024 * 1024 * 0.5);
+echo "3\n";
+$a4 = str_repeat("4", 1024 * 1024 * 1024 * 0.5);
+echo "4\n";
+$a5 = str_repeat("5", 1024 * 1024 * 1024 * 0.5);
+echo "5\n";
+?>
+--EXPECTF--
+1
+2
+3
+4
+
+Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %sbug55509.php on line %d
diff --git a/Zend/tests/bug55578.phpt b/Zend/tests/bug55578.phpt new file mode 100644 index 0000000..4a8604a --- /dev/null +++ b/Zend/tests/bug55578.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #55578 (Segfault on implode/concat) +--FILE-- +<?php +$options = array(); + +class Foo { + public function __toString() { + return 'Foo'; + } +} + +function test($options, $queryPart) { + return ''. (0 ? 1 : $queryPart); +} + +var_dump(test($options, new Foo())); +?> +--EXPECT-- +string(3) "Foo" diff --git a/Zend/tests/bug55705.phpt b/Zend/tests/bug55705.phpt new file mode 100644 index 0000000..69220bf --- /dev/null +++ b/Zend/tests/bug55705.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #55705 (Omitting a callable typehinted argument causes a segfault) +--FILE-- +<?php +function f(callable $c) {} +f(); +?> +--EXPECTF-- +Catchable fatal error: Argument 1 passed to f() must be callable, none given, called in %s on line 3 and defined in %s on line %d diff --git a/Zend/tests/bug55825.phpt b/Zend/tests/bug55825.phpt new file mode 100644 index 0000000..23fc933 --- /dev/null +++ b/Zend/tests/bug55825.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #55825 (Missing initial value of static locals in trait methods) +--FILE-- +<?php +trait T1 { + public function inc() { + static $x=1; + echo $x++ . "\n"; + } +} +class C { use T1; } +$c1 = new C; +$c1->inc(); +$c1->inc(); +--EXPECT-- +1 +2 diff --git a/Zend/tests/bug60099.phpt b/Zend/tests/bug60099.phpt new file mode 100644 index 0000000..13e2f54 --- /dev/null +++ b/Zend/tests/bug60099.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #60099 (__halt_compiler() works in braced namespaces) +--FILE-- +<?php +namespace foo { + __halt_compiler(); + +?> +--EXPECTF-- +Fatal error: __HALT_COMPILER() can only be used from the outermost scope in %s on line %d diff --git a/Zend/tests/bug60138.phpt b/Zend/tests/bug60138.phpt new file mode 100644 index 0000000..3bf1fba --- /dev/null +++ b/Zend/tests/bug60138.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #60138 (GC crash with referenced array in RecursiveArrayIterator) +--FILE-- +<?php +$tree = array(array("f")); +$category =& $tree[0]; + +$iterator = new RecursiveIteratorIterator( + new RecursiveArrayIterator($tree), + RecursiveIteratorIterator::SELF_FIRST +); +foreach($iterator as $file); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug60139.phpt b/Zend/tests/bug60139.phpt new file mode 100644 index 0000000..d5926b2 --- /dev/null +++ b/Zend/tests/bug60139.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #60139 (Anonymous functions create cycles not detected by the GC) +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +class Foo { + public $x; + + public function __construct() { + $this->x = function() {}; + } +} + +class Bar { + public $x; + + public function __construct() { + $self = $this; + $this->x = function() use ($self) {}; + } +} + +gc_collect_cycles(); +new Foo; +var_dump(gc_collect_cycles()); +new Bar; +var_dump(gc_collect_cycles()); +?> +--EXPECT-- +int(2) +int(2) diff --git a/Zend/tests/bug60169.phpt b/Zend/tests/bug60169.phpt new file mode 100644 index 0000000..f975741 --- /dev/null +++ b/Zend/tests/bug60169.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #60169 (Conjunction of ternary and list crashes PHP) +--FILE-- +<?php +error_reporting(0); +$arr = array("test"); +list($a,$b) = is_array($arr)? $arr : $arr; +list($c,$d) = is_array($arr)?: NULL; +echo "ok\n"; +--EXPECT-- +ok diff --git a/Zend/tests/bug60350.phpt b/Zend/tests/bug60350.phpt new file mode 100644 index 0000000..3facd54 --- /dev/null +++ b/Zend/tests/bug60350.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #60350 No string escape code for ESC (ascii 27), normally \e +--FILE-- +<?php +$str = "\e"; +if (ord($str) == 27) { + echo "Works"; +} +?> +--EXPECT-- +Works diff --git a/Zend/tests/bug60362.phpt b/Zend/tests/bug60362.phpt new file mode 100644 index 0000000..e8d16ea --- /dev/null +++ b/Zend/tests/bug60362.phpt @@ -0,0 +1,74 @@ +--TEST-- +Bug #60362: non-existent sub-sub keys should not have values +--FILE-- +<?php +$arr = array('exists' => 'foz'); + +if (isset($arr['exists']['non_existent'])) { + echo "sub-key 'non_existent' is set: "; + var_dump($arr['exists']['non_existent']); +} else { + echo "sub-key 'non_existent' is not set.\n"; +} +if (isset($arr['exists'][1])) { + echo "sub-key 1 is set: "; + var_dump($arr['exists'][1]); +} else { + echo "sub-key 1 is not set.\n"; +} + +echo "-------------------\n"; +if (isset($arr['exists']['non_existent']['sub_sub'])) { + echo "sub-key 'sub_sub' is set: "; + var_dump($arr['exists']['non_existent']['sub_sub']); +} else { + echo "sub-sub-key 'sub_sub' is not set.\n"; +} +if (isset($arr['exists'][1][0])) { + echo "sub-sub-key 0 is set: "; + var_dump($arr['exists'][1][0]); +} else { + echo "sub-sub-key 0 is not set.\n"; +} + +echo "-------------------\n"; +if (empty($arr['exists']['non_existent'])) { + echo "sub-key 'non_existent' is empty.\n"; +} else { + echo "sub-key 'non_existent' is not empty: "; + var_dump($arr['exists']['non_existent']); +} +if (empty($arr['exists'][1])) { + echo "sub-key 1 is empty.\n"; +} else { + echo "sub-key 1 is not empty: "; + var_dump($arr['exists'][1]); +} + +echo "-------------------\n"; +if (empty($arr['exists']['non_existent']['sub_sub'])) { + echo "sub-sub-key 'sub_sub' is empty.\n"; +} else { + echo "sub-sub-key 'sub_sub' is not empty: "; + var_dump($arr['exists']['non_existent']['sub_sub']); +} +if (empty($arr['exists'][1][0])) { + echo "sub-sub-key 0 is empty.\n"; +} else { + echo "sub-sub-key 0 is not empty: "; + var_dump($arr['exists'][1][0]); +} +echo "DONE"; +--EXPECT-- +sub-key 'non_existent' is not set. +sub-key 1 is set: string(1) "o" +------------------- +sub-sub-key 'sub_sub' is not set. +sub-sub-key 0 is set: string(1) "o" +------------------- +sub-key 'non_existent' is empty. +sub-key 1 is not empty: string(1) "o" +------------------- +sub-sub-key 'sub_sub' is empty. +sub-sub-key 0 is not empty: string(1) "o" +DONE diff --git a/Zend/tests/bug60444.phpt b/Zend/tests/bug60444.phpt new file mode 100644 index 0000000..38f81bc --- /dev/null +++ b/Zend/tests/bug60444.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #60444 (Segmentation fault with include & class extending) +--FILE-- +<?php +class Foo { + public function __construct() { + eval("class Bar extends Foo {}"); + Some::foo($this); + } +} +class Some { + public static function foo(Foo $foo) { + } +} +new Foo; +echo "done\n"; +--EXPECT-- +done diff --git a/Zend/tests/bug60536_001.phpt b/Zend/tests/bug60536_001.phpt new file mode 100644 index 0000000..9166467 --- /dev/null +++ b/Zend/tests/bug60536_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #60536 (Traits Segfault) +--FILE-- +<?php +trait T { private $x = 0; } +class X { + use T; +} +class Y extends X { + use T; + function x() { + return ++$this->x; + } +} +class Z extends Y { + function z() { + return ++$this->x; + } +} +$a = new Z(); +$a->x(); +echo "DONE"; +?> +--EXPECTF-- +DONE diff --git a/Zend/tests/bug60536_002.phpt b/Zend/tests/bug60536_002.phpt new file mode 100644 index 0000000..0bca983 --- /dev/null +++ b/Zend/tests/bug60536_002.phpt @@ -0,0 +1,40 @@ +--TEST-- +The same rules are applied for properties that are defined in the class hierarchy. Thus, if the properties are compatible, a notice is issued, if not a fatal error occures. (relevant with #60536) +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class Base { + private $hello; +} + +trait THello1 { + private $hello; +} + +echo "PRE-CLASS-GUARD\n"; +class Notice extends Base { + use THello1; + private $hello; +} +echo "POST-CLASS-GUARD\n"; + +// now we do the test for a fatal error + +class TraitsTest { + use THello1; + public $hello; +} + +echo "POST-CLASS-GUARD2\n"; + +$t = new TraitsTest; +$t->hello = "foo"; +?> +--EXPECTF-- +PRE-CLASS-GUARD + +Strict Standards: Notice and THello1 define the same property ($hello) in the composition of Notice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +POST-CLASS-GUARD + +Fatal error: TraitsTest and THello1 define the same property ($hello) in the composition of TraitsTest. However, the definition differs and is considered incompatible. Class was composed in %s on line %d diff --git a/Zend/tests/bug60536_003.phpt b/Zend/tests/bug60536_003.phpt new file mode 100644 index 0000000..d944a0a --- /dev/null +++ b/Zend/tests/bug60536_003.phpt @@ -0,0 +1,46 @@ +--TEST-- +Properties should be initialized correctly (relevant to #60536) +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class BaseWithPropA { + private $hello = 0; +} + +trait AHelloProperty { + private $hello = 0; +} + +class BaseWithTPropB { + use AHelloProperty; +} + +class SubclassA extends BaseWithPropA { + use AHelloProperty; +} + +class SubclassB extends BaseWithTPropB { + use AHelloProperty; +} + +$a = new SubclassA; +var_dump($a); + +$b = new SubclassB; +var_dump($b); + +?> +--EXPECTF-- +object(SubclassA)#%d (2) { + ["hello":"SubclassA":private]=> + int(0) + ["hello":"BaseWithPropA":private]=> + int(0) +} +object(SubclassB)#%d (2) { + ["hello":"SubclassB":private]=> + int(0) + ["hello":"BaseWithTPropB":private]=> + int(0) +} diff --git a/Zend/tests/bug60536_004.phpt b/Zend/tests/bug60536_004.phpt new file mode 100644 index 0000000..4f20836 --- /dev/null +++ b/Zend/tests/bug60536_004.phpt @@ -0,0 +1,37 @@ +--TEST-- +Introducing new private variables of the same name in a subclass is ok, and does not lead to any output. That is consitent with normal inheritance handling. (relevant to #60536) +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class Base { + private $hello; +} + +trait THello1 { + private $hello; +} + +// Now we use the trait, which happens to introduce another private variable +// but they are distinct, and not related to each other, so no warning. +echo "PRE-CLASS-GUARD\n"; +class SameNameInSubClassNoNotice extends Base { + use THello1; +} +echo "POST-CLASS-GUARD\n"; + +// now the same with a class that defines the property itself, +// that should give the expected strict warning. + +class Notice extends Base { + use THello1; + private $hello; +} +echo "POST-CLASS-GUARD2\n"; +?> +--EXPECTF-- +PRE-CLASS-GUARD +POST-CLASS-GUARD + +Strict Standards: Notice and THello1 define the same property ($hello) in the composition of Notice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %sbug60536_004.php on line %d +POST-CLASS-GUARD2 diff --git a/Zend/tests/bug60536_005.phpt b/Zend/tests/bug60536_005.phpt new file mode 100644 index 0000000..378adcc --- /dev/null +++ b/Zend/tests/bug60536_005.phpt @@ -0,0 +1,38 @@ +--TEST-- +Introducing new private variables of the same name in a subclass is ok, and does not lead to any output. That is consitent with normal inheritance handling. (relevant to #60536) +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class Base { + protected $hello; +} + +trait THello1 { + protected $hello; +} + +// Protected and public are handle more strict with a warning then what is +// expected from normal inheritance since they can have easier coliding semantics +echo "PRE-CLASS-GUARD\n"; +class SameNameInSubClassProducesNotice extends Base { + use THello1; +} +echo "POST-CLASS-GUARD\n"; + +// now the same with a class that defines the property itself, too. + +class Notice extends Base { + use THello1; + protected $hello; +} +echo "POST-CLASS-GUARD2\n"; +?> +--EXPECTF-- +PRE-CLASS-GUARD + +Strict Standards: Base and THello1 define the same property ($hello) in the composition of SameNameInSubClassProducesNotice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +POST-CLASS-GUARD + +Strict Standards: Notice and THello1 define the same property ($hello) in the composition of Notice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +POST-CLASS-GUARD2 diff --git a/Zend/tests/bug60569.phpt b/Zend/tests/bug60569.phpt Binary files differnew file mode 100644 index 0000000..56aaa2c --- /dev/null +++ b/Zend/tests/bug60569.phpt diff --git a/Zend/tests/bug60573.phpt b/Zend/tests/bug60573.phpt new file mode 100644 index 0000000..d41a5f3 --- /dev/null +++ b/Zend/tests/bug60573.phpt @@ -0,0 +1,84 @@ +--TEST-- +Bug #60573 (type hinting with "self" keyword causes weird errors) +--FILE-- +<?php +class Foo1 { + +public function setSelf(self $s) { } + +} + +class Bar1 extends Foo1 { + +public function setSelf(parent $s) { } + +} + +class Foo2 { + +public function setSelf(Foo2 $s) { } + +} + +class Bar2 extends Foo2 { + +public function setSelf(parent $s) { } + +} + +class Base { +} + +class Foo3 extends Base{ + +public function setSelf(parent $s) { } + +} + +class Bar3 extends Foo3 { + +public function setSelf(Base $s) { } + +} + +class Foo4 { + +public function setSelf(self $s) { } + +} + +class Bar4 extends Foo4 { + +public function setSelf(self $s) { } + +} + +class Foo5 extends Base { + +public function setSelf(parent $s) { } + +} + +class Bar5 extends Foo5 { + +public function setSelf(parent $s) { } + +} + +abstract class Foo6 extends Base { + +abstract public function setSelf(parent $s); + +} + +class Bar6 extends Foo6 { + +public function setSelf(Foo6 $s) { } + +} +--EXPECTF-- +Strict Standards: Declaration of Bar4::setSelf() should be compatible with Foo4::setSelf(Foo4 $s) in %sbug60573.php on line %d + +Strict Standards: Declaration of Bar5::setSelf() should be compatible with Foo5::setSelf(Base $s) in %sbug60573.php on line %d + +Fatal error: Declaration of Bar6::setSelf() must be compatible with Foo6::setSelf(Base $s) in %sbug60573.php on line %d diff --git a/Zend/tests/bug60611.phpt b/Zend/tests/bug60611.phpt new file mode 100644 index 0000000..abd04b0 --- /dev/null +++ b/Zend/tests/bug60611.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #60611 (Segmentation fault with Cls::{expr}() syntax) +--FILE-- +<?php +class Cls { + function __call($name, $arg) { + } + static function __callStatic($name, $arg) { + } +} + +$cls = new Cls; +$cls->{0}(); +$cls->{1.0}(); +$cls->{true}(); +$cls->{false}(); +$cls->{null}(); + +Cls::{0}(); +Cls::{1.0}(); +Cls::{true}(); +Cls::{false}(); +Cls::{null}(); + +?> +--EXPECTF-- +Fatal error: Method name must be a string in %sbug60611.php on line %d diff --git a/Zend/tests/bug60613.phpt b/Zend/tests/bug60613.phpt new file mode 100644 index 0000000..a9db68d --- /dev/null +++ b/Zend/tests/bug60613.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #60613 (Segmentation fault with $cls->{expr}() syntax) +--FILE-- +<?php +class Cls { + function __call($name, $arg) { + } +} + +$cls = new Cls(); +$cls->{0}(); +$cls->{1.0}(); +$cls->{true}(); +$cls->{false}(); +$cls->{null}(); +echo "ok\n"; +--EXPECTF-- +Fatal error: Method name must be a string in %sbug60613.php on line %d diff --git a/Zend/tests/bug60771.phpt b/Zend/tests/bug60771.phpt new file mode 100644 index 0000000..2cf69f7 --- /dev/null +++ b/Zend/tests/bug60771.phpt @@ -0,0 +1,9 @@ +--TEST--
+test of larger than 8kb text file being parsed by require statement
+--FILE--
+<?php
+ file_put_contents('test.php',str_repeat('passed, ',1024));
+ require('test.php');
+?>
+--EXPECT--
+passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed,
diff --git a/Zend/tests/bug60825.phpt b/Zend/tests/bug60825.phpt new file mode 100644 index 0000000..0aeb8f7 --- /dev/null +++ b/Zend/tests/bug60825.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #60825 (Segfault when running symfony 2 tests) +--DESCRIPTION-- +run this with valgrind +--FILE-- +<?php +class test { + public static $x; + public function __toString() { + self::$x = $this; + return __FILE__; + } +} +$a = new test; +require_once $a; +debug_zval_dump(test::$x); +?> +--EXPECTF-- +string(%d) "%sbug60825.php" refcount(2) diff --git a/Zend/tests/bug60909_1.phpt b/Zend/tests/bug60909_1.phpt new file mode 100644 index 0000000..cfe4289 --- /dev/null +++ b/Zend/tests/bug60909_1.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #60909 (custom error handler throwing Exception + fatal error = no shutdown function). +--FILE-- +<?php +register_shutdown_function(function(){echo("\n\n!!!shutdown!!!\n\n");}); +set_error_handler(function($errno, $errstr, $errfile, $errline){ + echo "error($errstr)"; + throw new Exception("Foo"); +}); + +require 'notfound.php'; +--EXPECTF-- +error(require(notfound.php): failed to open stream: %s) +Warning: Uncaught exception 'Exception' with message 'Foo' in %sbug60909_1.php:5 +Stack trace: +#0 %sbug60909_1.php(8): {closure}(2, 'require(notfoun...', '%s', 8, Array) +#1 %sbug60909_1.php(8): require() +#2 {main} + thrown in %sbug60909_1.php on line 5 + +Fatal error: main(): Failed opening required 'notfound.php' (include_path='%s') in %sbug60909_1.php on line 8 + + +!!!shutdown!!! diff --git a/Zend/tests/bug60909_2.phpt b/Zend/tests/bug60909_2.phpt new file mode 100644 index 0000000..d08d9f9 --- /dev/null +++ b/Zend/tests/bug60909_2.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #60909 (custom error handler throwing Exception + fatal error = no shutdown function). +--FILE-- +<?php +register_shutdown_function(function(){echo("\n\n!!!shutdown!!!\n\n");}); +set_error_handler(function($errno, $errstr, $errfile, $errline){throw new Exception("Foo");}); + +class Bad { + public function __toString() { + throw new Exception('Oops, I cannot do this'); + } +} + +$bad = new Bad(); +echo "$bad"; +--EXPECTF-- +Fatal error: Method Bad::__toString() must not throw an exception in %sbug60909_2.php on line 0 + + +!!!shutdown!!! diff --git a/Zend/tests/bug60978.phpt b/Zend/tests/bug60978.phpt new file mode 100644 index 0000000..5dc6fe3 --- /dev/null +++ b/Zend/tests/bug60978.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #60978 (exit code incorrect) +--FILE-- +<?php +$php = getenv('TEST_PHP_EXECUTABLE'); +exec($php . ' -n -r "exit(2);"', $output, $exit_code); +echo $exit_code; +?> +--EXPECT-- +2 diff --git a/Zend/tests/bug61011.phpt b/Zend/tests/bug61011.phpt new file mode 100644 index 0000000..bce0e33 --- /dev/null +++ b/Zend/tests/bug61011.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #61011 (Crash when an exception is thrown by __autoload accessing a static property) +--FILE-- +<?php +function __autoload($name) { + throw new Exception($name); +} +try { + echo AAA::$a; //zend_fetch_var_address_helper +} catch (Exception $e) { + try { + echo AAA::XXX; //ZEND_FETCH_CONSTANT + } catch (Exception $e) { + try { + echo AAA::foo(); //ZEND_INIT_STATIC_METHOD_CALL + } catch (Exception $e) { + try { + unset(AAA::$a); // ZEND_UNSET_VAR + } catch (Exception $e){ + try { + isset(AAAA::$a); // ZEND_ISSET_ISEMPTY_VAR + } catch (Exception $e) { + try { + $a = array("AAA", "foo"); + $a(); //ZEND_INIT_FCALL_BY_NAME + } catch (Exception $e) { + } + } + } + } + } +} +echo 'okey'; +--EXPECT-- +okey diff --git a/Zend/tests/bug61087.phpt b/Zend/tests/bug61087.phpt new file mode 100644 index 0000000..a0375f2 --- /dev/null +++ b/Zend/tests/bug61087.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #61087 (Memory leak in parse_ini_file when specifying invalid scanner mode) +--FILE-- +<?php +// the used file is actually irrelevant, so just use this file +// even though it's not an .ini +parse_ini_file(__FILE__, false, 100); +?> +--EXPECTF-- +Warning: Invalid scanner mode in %s on line %d diff --git a/Zend/tests/bug61095.phpt b/Zend/tests/bug61095.phpt new file mode 100644 index 0000000..4ca196c --- /dev/null +++ b/Zend/tests/bug61095.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #61095 (Lexing 0x00*+<NUM> incorectly) +--FILE-- +<?php +echo 0x00+2; +echo "\n"; +?> +--EXPECT-- +2 diff --git a/Zend/tests/bug61165.phpt b/Zend/tests/bug61165.phpt new file mode 100644 index 0000000..478fa00 --- /dev/null +++ b/Zend/tests/bug61165.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #61165 (Segfault - strip_tags()) +--FILE-- +<?php + +$handler = NULL; +class T { + public $_this; + + public function __toString() { + global $handler; + $handler = $this; + $this->_this = $this; // <-- uncoment this + return 'A'; + } +} + +$t = new T; +for ($i = 0; $i < 3; $i++) { + strip_tags($t); + strip_tags(new T); +} +var_dump($handler); +--EXPECTF-- +object(T)#%d (1) { + ["_this"]=> + *RECURSION* +} diff --git a/Zend/tests/bug61225.phpt b/Zend/tests/bug61225.phpt new file mode 100644 index 0000000..33d74bd --- /dev/null +++ b/Zend/tests/bug61225.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #61225 (Lexing 0b0*+<NUM> incorectly) +--FILE-- +<?php +echo 0b00+1; +echo "\n"; +?> +--EXPECT-- +1 diff --git a/Zend/tests/bug61273.phpt b/Zend/tests/bug61273.phpt new file mode 100644 index 0000000..aee35c6 --- /dev/null +++ b/Zend/tests/bug61273.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #61273 (call_user_func_array with more than 16333 arguments leaks / crashes) +--FILE-- +<?php +/** + * for 5.3 #define ZEND_VM_STACK_PAGE_SIZE ((64 * 1024) - 64) + * for 5.4 #define ZEND_VM_STACK_PAGE_SIZE ((16 * 1024) - 16) + * we should trick EG(argument_stack) into growing + */ +$args = array_fill(0, 64 * 1024 - 64, 0); +call_user_func_array(function(&$a) {}, $args); +echo strval("okey"); +--EXPECTF-- +Warning: Parameter 1 to {closure}() expected to be a reference, value given in %sbug61273.php on line %d +okey diff --git a/Zend/tests/bug61761.phpt b/Zend/tests/bug61761.phpt new file mode 100644 index 0000000..24c69ae --- /dev/null +++ b/Zend/tests/bug61761.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #61761 ('Overriding' a private static method with a different signature causes crash) +--FILE-- +<?php + +class A +{ + private static function test($a) { } +} + +class B extends A +{ + private static function test($a, $b) { } +} + +?> +==DONE== +--EXPECTF-- +==DONE== diff --git a/Zend/tests/bug61767.phpt b/Zend/tests/bug61767.phpt new file mode 100644 index 0000000..5270872 --- /dev/null +++ b/Zend/tests/bug61767.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #61767 (Shutdown functions not called in certain error situation) +--FILE-- +<?php +set_error_handler(function($code, $msg, $file = null, $line = null) { + echo "Error handler called ($msg)\n"; + throw new \ErrorException($msg, $code, 0, $file, $line); +}); + +register_shutdown_function(function(){ + echo "Shutting down\n"; + print_r(error_get_last()); +}); + +//$undefined = null; // defined variable does not cause problems +$undefined->foo(); +--EXPECTF-- +Error handler called (Undefined variable: undefined) + +Warning: Uncaught exception 'ErrorException' with message 'Undefined variable: undefined' in %sbug61767.php:13 +Stack trace: +#0 %sbug61767.php(13): {closure}(8, 'Undefined varia...', '%s', 13, Array) +#1 {main} + thrown in %sbug61767.php on line 13 + +Fatal error: Call to a member function foo() on a non-object in %sbug61767.php on line 13 +Shutting down +Array +( + [type] => 1 + [message] => Call to a member function foo() on a non-object + [file] => %sbug61767.php + [line] => 13 +) diff --git a/Zend/tests/bug61782.phpt b/Zend/tests/bug61782.phpt new file mode 100644 index 0000000..95bf4e6 --- /dev/null +++ b/Zend/tests/bug61782.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #61782 (__clone/__destruct do not match other methods when checking access controls) +--FILE-- +<?php + abstract class BaseClass { + abstract protected function __clone(); + } + + class MommasBoy extends BaseClass { + protected function __clone() { + echo __METHOD__, "\n"; + } + } + + class LatchkeyKid extends BaseClass { + public function __construct() { + echo 'In ', __CLASS__, ":\n"; + $kid = new MommasBoy(); + $kid = clone $kid; + } + public function __clone() {} + } + + $obj = new LatchkeyKid(); +echo "DONE\n"; +--EXPECT-- +In LatchkeyKid: +MommasBoy::__clone +DONE diff --git a/Zend/tests/bug62005.phpt b/Zend/tests/bug62005.phpt new file mode 100644 index 0000000..c99b287 --- /dev/null +++ b/Zend/tests/bug62005.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #62005 (unexpected behavior when incrementally assigning to a member of a null object) +--FILE-- +<?php +function add_points($player, $points) { + $player->energy += $points; + print_r($player); +} +add_points(NULL, 2); +--EXPECTF-- +Warning: Creating default object from empty value in %sbug62005.php on line %d +stdClass Object +( + [energy] => 2 +) diff --git a/Zend/tests/bug62097.phpt b/Zend/tests/bug62097.phpt new file mode 100644 index 0000000..07e93bf --- /dev/null +++ b/Zend/tests/bug62097.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #62097: fix for bug #54547 is wrong for 32-bit machines +--SKIPIF-- +<?php +if (PHP_INT_MAX !== 2147483647) + die('skip for system with 32-bit wide longs only'); +--FILE-- +<?php +var_dump("02147483647" == "2147483647", + "02147483648" == "2147483648", + "09007199254740991" == "9007199254740991", + "09007199254740992" == "9007199254740992"); +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(false) diff --git a/Zend/tests/bug62358.phpt b/Zend/tests/bug62358.phpt new file mode 100644 index 0000000..35d8b48 --- /dev/null +++ b/Zend/tests/bug62358.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #62358 (Segfault when using traits a lot) +--SKIPIF-- +<?php +if (getenv("USE_ZEND_ALLOC") !== "0") { + die("skip Need Zend MM enabled"); +} +?> +--FILE-- +<?php + +trait T { + public function foo() { + echo "from T"; + } +} + +interface I { + public function foo(); +} + +abstract class A implements I{ + use T; +} + +class B extends A { + public function foo($var) { + } +} +?> +--EXPECTF-- +Strict Standards: Declaration of B::foo() should be compatible with A::foo() in %sbug62358.php on line %d diff --git a/Zend/tests/bug62653.phpt b/Zend/tests/bug62653.phpt new file mode 100644 index 0000000..96299f1 --- /dev/null +++ b/Zend/tests/bug62653.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #62653: unset($array[$float]) causes a crash +--FILE-- +<?php +$array = array("5"=>"bar"); +$foo = "10.0000"; // gettype($foo) = "string" +$foo /= 2; //Makes $foo = 5 but still gettype($foo) = "double" +unset($array[$foo]); +print_r($array); + +$array = array("5"=>"bar"); +$foo = "5"; +unset($array[(float)$foo]); +print_r($array); + +$array = array("5"=>"bar"); +$foo = "10.0000"; +$foo /= 2; //Makes $foo = 5 but still gettype($foo) = "double" +$name = "foo"; +unset($array[$$name]); +print_r($array); + +?> +--EXPECT-- +Array +( +) +Array +( +) +Array +( +) diff --git a/Zend/tests/bug62680.phpt b/Zend/tests/bug62680.phpt new file mode 100644 index 0000000..e2a2366 --- /dev/null +++ b/Zend/tests/bug62680.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #62680 (Function isset() throws fatal error on set array if non-existent key depth >= 3) +--FILE-- +<?php +$array = array(""); +var_dump(isset($array[0]["a"]["b"])); +var_dump(isset($array[0]["a"]["b"]["c"])); +?> +--EXPECT-- +bool(false) +bool(false) diff --git a/Zend/tests/bug62763.phpt b/Zend/tests/bug62763.phpt new file mode 100644 index 0000000..50c27bd --- /dev/null +++ b/Zend/tests/bug62763.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #62763 (register_shutdown_function and extending class) +--FILE-- +<?php +class test1 { + public function __construct() { + register_shutdown_function(array($this, 'shutdown')); + } + public function shutdown() { + exit(__METHOD__); + } +} + +class test2 extends test1 { + public function __destruct() { + exit (__METHOD__); + } +} +new test1; +new test2; +?> +--EXPECT-- +test1::shutdowntest2::__destruct diff --git a/Zend/tests/bug62892.phpt b/Zend/tests/bug62892.phpt new file mode 100644 index 0000000..e6b0e60 --- /dev/null +++ b/Zend/tests/bug62892.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #62892 (ReflectionClass::getTraitAliases crashes on importing trait methods as private) +--FILE-- +<?php + +trait myTrait { + public function run() {} +} + +class myClass { + use myTrait { + MyTrait::run as private; + } +} +$class = new \ReflectionClass('myClass'); +var_dump($class->getTraitAliases()); + +?> +--EXPECTF-- +array(0) { +} diff --git a/Zend/tests/bug62907.phpt b/Zend/tests/bug62907.phpt new file mode 100644 index 0000000..53ab17c --- /dev/null +++ b/Zend/tests/bug62907.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #62907 (Double free when use traits) +--FILE-- +<?php +function __autoload($name) { + if ($name == "B") { + eval ("abstract class B extends A { }"); + } else if ($name == "A") { + eval ("abstract class A { use T { T::__construct as __asconstruct; }}"); + } else if ($name == "T") { + eval ("trait T { public function __construct() { } }"); + } + return TRUE; +} + +class C extends B { + public function __construct() { + } +} +echo "okey"; +--EXPECT-- +okey diff --git a/Zend/tests/bug62956.phpt b/Zend/tests/bug62956.phpt new file mode 100644 index 0000000..c8694d5 --- /dev/null +++ b/Zend/tests/bug62956.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #62956: "incompatible" signatures for private methods should not cause E_STRICT +--FILE-- +<?php +class Base +{ + private function test() + {} +} + +class Extension extends Base +{ + private function test($arg) + {} +} + +?> +==DONE== +--EXPECT-- +==DONE== diff --git a/Zend/tests/bug63055.phpt b/Zend/tests/bug63055.phpt new file mode 100644 index 0000000..711385a --- /dev/null +++ b/Zend/tests/bug63055.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #63055 (Segfault in zend_gc with SF2 testsuite) +--FILE-- +<?php +/* the default gc root size is 10,000 */ +for ($i=0; $i<9998; $i++) { + $array = array(); + $array[0] = &$array; + unset($array); +} + +$matches = array("foo" => "bar"); /* this bucket will trigger the segfault */ +$dummy = array("dummy"); /* used to trigger gc_collect_cycles */ +$dummy[1] = &$dummy; + +$matches[1] = &$matches; +$matches[2] = $dummy; + +str_replace("foo", "bar", "foobar", $matches); +echo "okey"; +?> +--EXPECTF-- +okey diff --git a/Zend/tests/bug63111.phpt b/Zend/tests/bug63111.phpt new file mode 100644 index 0000000..3f19068 --- /dev/null +++ b/Zend/tests/bug63111.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #63111 (is_callable() lies for abstract static method) +--FILE-- +<?php +abstract class Foo { + abstract static function bar(); +} +interface MyInterface { + static function bar(); +} +abstract class Bar { + static function foo() { + echo "ok\n"; + } +} +var_dump(is_callable(array("Foo", "bar"))); +var_dump(is_callable("Foo::bar")); +var_dump(is_callable(array("MyInterface", "bar"))); +var_dump(is_callable("MyInterface::bar")); +var_dump(is_callable(array("Bar", "foo"))); +var_dump(is_callable("Bar::foo")); +Bar::foo(); +Foo::bar(); +?> +--EXPECTF-- +Strict Standards: Static function Foo::bar() should not be abstract in %sbug63111.php on line 3 +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +ok + +Fatal error: Cannot call abstract method Foo::bar() in %sbug63111.php on line 20 + diff --git a/Zend/tests/bug63173.phpt b/Zend/tests/bug63173.phpt new file mode 100644 index 0000000..36ebf20 --- /dev/null +++ b/Zend/tests/bug63173.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #63173: Crash when invoking invalid array callback +--FILE-- +<?php + +// the important part here are the indexes 1 and 2 +$callback = [1 => 0, 2 => 0]; +$callback(); + +?> +--EXPECTF-- +Fatal error: Array callback has to contain indices 0 and 1 in %s on line %d diff --git a/Zend/tests/bug63219.phpt b/Zend/tests/bug63219.phpt new file mode 100644 index 0000000..999be4a --- /dev/null +++ b/Zend/tests/bug63219.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #63219 (Segfault when aliasing trait method when autoloader throws excpetion) +--FILE-- +<?php +trait TFoo { + public function fooMethod(){} +} + +class C { + use TFoo { + Typo::fooMethod as tf; + } +} + +echo "okey"; +?> +--EXPECTF-- +Fatal error: Could not find trait Typo in %sbug63219.php on line %d diff --git a/Zend/tests/bug63305.phpt b/Zend/tests/bug63305.phpt new file mode 100644 index 0000000..4bd3a4d --- /dev/null +++ b/Zend/tests/bug63305.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #63305 (zend_mm_heap corrupted with traits) +--FILE-- +<?php +new Attachment(""); + +function __autoload($class) { + switch ($class) { + case "Attachment": + eval(<<<'PHP' +class Attachment extends File { +} +PHP + ); + break; + case "File": + eval(<<<'PHP' +class File { + use TDatabaseObject { + TDatabaseObject::__construct as private databaseObjectConstruct; + } + public function __construct() { + } +} +PHP + ); + break; + case "TDatabaseObject": + eval(<<<'PHP' +trait TDatabaseObject { + public function __construct() { + } +} +PHP + ); + break; + } + return TRUE; +} +echo "okey"; +?> +--EXPECT-- +okey diff --git a/Zend/tests/bug63336.phpt b/Zend/tests/bug63336.phpt new file mode 100644 index 0000000..d2c3d41 --- /dev/null +++ b/Zend/tests/bug63336.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #63336 (invalid E_NOTICE error occur) +--XFAIL-- +Bug is not fixed yet +--FILE-- +<?php +error_reporting(E_ALL | E_NOTICE ); +define("TEST", "123"); +class Base { + const DUMMY = "XXX"; + public function foo($var=TEST, $more=null) { return true; } + public function bar($more=self::DUMMY) { return true; } +} + +class Child extends Base { + const DUMMY = "DDD"; + public function foo($var=TEST, array $more = array()) { return true; } + public function bar($var, $more=self::DUMMY) { return true; } +} +?> +--EXPECT-- +Strict Standards: Declaration of Child::foo() should be compatible with Base::foo($var = '123', $more = NULL) in %sbug63336.php on line %d + +Strict Standards: Declaration of Child::bar() should be compatible with Base::bar($var, $more = 'XXX') in %sbug63336.php on line %d diff --git a/Zend/tests/bug63462.phpt b/Zend/tests/bug63462.phpt new file mode 100644 index 0000000..e936a6f --- /dev/null +++ b/Zend/tests/bug63462.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test script to verify that magic methods should be called only once when accessing an unset property. +--CREDITS-- +Marco Pivetta <ocramius@gmail.com> +--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 property: Test::$nonExisting in %s on line %d +__get publicProperty + +Notice: Undefined property: Test::$publicProperty in %s on line %d +__get protectedProperty + +Notice: Undefined property: Test::$protectedProperty in %s on line %d +__get privateProperty + +Notice: Undefined property: Test::$privateProperty in %s on line %d +__isset nonExisting +__isset publicProperty +__isset protectedProperty +__isset privateProperty +__set nonExisting +__set publicProperty +__set protectedProperty +__set privateProperty + diff --git a/Zend/tests/bug63468.phpt b/Zend/tests/bug63468.phpt new file mode 100644 index 0000000..00b5a41 --- /dev/null +++ b/Zend/tests/bug63468.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #63468 (wrong called method as callback with inheritance) +--FILE-- +<?php +class Foo +{ + public function run() + { + return call_user_func(array('Bar', 'getValue')); + } + + private static function getValue() + { + return 'Foo'; + } +} + +class Bar extends Foo +{ + public static function getValue() + { + return 'Bar'; + } +} + +$x = new Bar; +var_dump($x->run()); +--EXPECT-- +string(3) "Bar" + diff --git a/Zend/tests/bug63635.phpt b/Zend/tests/bug63635.phpt new file mode 100644 index 0000000..6f6fc6a --- /dev/null +++ b/Zend/tests/bug63635.phpt @@ -0,0 +1,58 @@ +--TEST-- +Bug #63635 (Segfault in gc_collect_cycles) +--FILE-- +<?php +class Node { + public $parent = NULL; + public $childs = array(); + + function __construct(Node $parent=NULL) { + if ($parent) { + $parent->childs[] = $this; + } + $this->childs[] = $this; + } + + function __destruct() { + $this->childs = NULL; + } +} + +define("MAX", 16); + +for ($n = 0; $n < 20; $n++) { + $top = new Node(); + for ($i=0 ; $i<MAX ; $i++) { + $ci = new Node($top); + for ($j=0 ; $j<MAX ; $j++) { + $cj = new Node($ci); + for ($k=0 ; $k<MAX ; $k++) { + $ck = new Node($cj); + } + } + } + echo "$n\n"; +} +echo "ok\n"; +--EXPECT-- +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +ok diff --git a/Zend/tests/bug63762.phpt b/Zend/tests/bug63762.phpt new file mode 100644 index 0000000..8de177d --- /dev/null +++ b/Zend/tests/bug63762.phpt @@ -0,0 +1,53 @@ +--TEST-- +Bug #63762 - Sigsegv when Exception::$trace is changed by user +--FILE-- +<?php +$e = new Exception(); + +$ref = new ReflectionProperty($e, 'trace'); +$ref->setAccessible(TRUE); + +echo "Array of NULL:\n"; +$ref->setValue($e, array(NULL)); + +var_dump($e->getTraceAsString()); + +echo "\nArray of empty array:\n"; +$ref->setValue($e, array(array())); +var_dump($e->getTraceAsString()); + +echo "\nArray of array of NULL values:\n"; +$ref->setValue($e, array(array( + 'file' => NULL, + 'line' => NULL, + 'class' => NULL, + 'type' => NULL, + 'function' => NULL, + 'args' => NULL +))); +var_dump($e->getTraceAsString()); +?> +--EXPECTF-- +Array of NULL: + +Warning: Expected array for frame 0 in %s on line %d +string(9) "#0 {main}" + +Array of empty array: +string(36) "#0 [internal function]: () +#1 {main}" + +Array of array of NULL values: + +Warning: Function name is no string in %s on line %d + +Warning: Value for class is no string in %s on line %d + +Warning: Value for type is no string in %s on line %d + +Warning: Value for function is no string in %s on line %d + +Warning: args element is no array in %s on line %d +string(60) "#0 [unknown function][unknown][unknown][unknown]() +#1 {main}" + diff --git a/Zend/tests/bug63882.phpt b/Zend/tests/bug63882.phpt new file mode 100644 index 0000000..0cc1bab --- /dev/null +++ b/Zend/tests/bug63882.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #63882 (zend_std_compare_objects crash on recursion) +--FILE-- +<?php +class Test { public $x = 5; } + +$testobj1 = new Test; +$testobj2 = new Test; +$testobj1->x = $testobj1; +$testobj2->x = $testobj2; + +var_dump($testobj1 == $testobj2); +?> +--EXPECTF-- +Fatal error: Nesting level too deep - recursive dependency? in %sbug63882.php on line 9 diff --git a/Zend/tests/bug63982.phpt b/Zend/tests/bug63982.phpt new file mode 100644 index 0000000..31294f3 --- /dev/null +++ b/Zend/tests/bug63982.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #63982 (isset() inconsistently produces a fatal error on protected property) +--FILE-- +<?php +class Test { + protected $protectedProperty; +} + +$test = new Test(); + +var_dump(isset($test->protectedProperty)); +var_dump(isset($test->protectedProperty->foo)); +--EXPECTF-- +bool(false) +bool(false) diff --git a/Zend/tests/bug_debug_backtrace.phpt b/Zend/tests/bug_debug_backtrace.phpt new file mode 100644 index 0000000..3e4a0ec --- /dev/null +++ b/Zend/tests/bug_debug_backtrace.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug - crash in debug_backtrace when trace starts in eval +--FILE-- +<?php +function foo() { + bar(); +} + +function bar() { + boo(); +} + +function boo(){ + debug_print_backtrace(); +} + +eval("foo();"); + +echo "Done\n"; +?> +===DONE=== +--EXPECTF-- +#0 boo() called at [%s:%d] +#1 bar() called at [%s:%d] +#2 foo() called at [%s(%d) : eval()'d code:1] +#3 eval() called at [%s:%d] +Done +===DONE=== diff --git a/Zend/tests/call_static.phpt b/Zend/tests/call_static.phpt new file mode 100644 index 0000000..c37bc72 --- /dev/null +++ b/Zend/tests/call_static.phpt @@ -0,0 +1,20 @@ +--TEST-- +__callStatic() Magic method +--FILE-- +<?php +class Test +{ + static function __callStatic($fname, $args) + { + echo $fname, '() called with ', count($args), " arguments\n"; + } +} + +call_user_func("Test::Two", 'A', 'B'); +call_user_func(array("Test", "Three"), NULL, 0, false); +Test::Four(5, 6, 7, 8); + +--EXPECT-- +Two() called with 2 arguments +Three() called with 3 arguments +Four() called with 4 arguments diff --git a/Zend/tests/call_static_002.phpt b/Zend/tests/call_static_002.phpt new file mode 100644 index 0000000..9604bf5 --- /dev/null +++ b/Zend/tests/call_static_002.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing __call and __callstatic with callbacks +--FILE-- +<?php + +class Foo { + public function __call($a, $b) { + print "nonstatic\n"; + var_dump($a); + } + static public function __callStatic($a, $b) { + print "static\n"; + var_dump($a); + } +} + +$a = new Foo; +call_user_func(array($a, 'aAa')); +call_user_func(array('Foo', 'aAa')); + +?> +--EXPECTF-- +nonstatic +string(3) "aAa" +static +string(3) "aAa" diff --git a/Zend/tests/call_static_003.phpt b/Zend/tests/call_static_003.phpt new file mode 100644 index 0000000..566ff0f --- /dev/null +++ b/Zend/tests/call_static_003.phpt @@ -0,0 +1,38 @@ +--TEST-- +Testing method name case +--FILE-- +<?php + +class Foo { + public function __call($a, $b) { + print "nonstatic\n"; + var_dump($a); + } + static public function __callStatic($a, $b) { + print "static\n"; + var_dump($a); + } + public function test() { + $this->fOoBaR(); + self::foOBAr(); + $this::fOOBAr(); + } +} + +$a = new Foo; +$a->test(); +$a::bAr(); +foo::BAZ(); + +?> +--EXPECT-- +nonstatic +string(6) "fOoBaR" +nonstatic +string(6) "foOBAr" +nonstatic +string(6) "fOOBAr" +static +string(3) "bAr" +static +string(3) "BAZ" diff --git a/Zend/tests/call_static_004.phpt b/Zend/tests/call_static_004.phpt new file mode 100644 index 0000000..5af33ef --- /dev/null +++ b/Zend/tests/call_static_004.phpt @@ -0,0 +1,21 @@ +--TEST-- +Invalid method name in dynamic static call +--FILE-- +<?php + +class foo { + static function __callstatic($a, $b) { + var_dump($a); + } +} + +foo::AaA(); + +$a = 1; +foo::$a(); + +?> +--EXPECTF-- +string(3) "AaA" + +Fatal error: Function name must be a string in %s on line %d diff --git a/Zend/tests/call_static_005.phpt b/Zend/tests/call_static_005.phpt new file mode 100644 index 0000000..7259857 --- /dev/null +++ b/Zend/tests/call_static_005.phpt @@ -0,0 +1,17 @@ +--TEST-- +Invalid method name in dynamic static call +--FILE-- +<?php + +class foo { + static function __callstatic($a, $b) { + var_dump($a); + } +} + +$a = 'foo::'; +$a(); + +?> +--EXPECTF-- +Fatal error: Call to undefined function foo::() in %s on line %d diff --git a/Zend/tests/call_static_006.phpt b/Zend/tests/call_static_006.phpt new file mode 100644 index 0000000..e172f4e --- /dev/null +++ b/Zend/tests/call_static_006.phpt @@ -0,0 +1,30 @@ +--TEST-- +Testing __callStatic +--FILE-- +<?php + +class foo { + public function aa() { + print "ok\n"; + } + static function __callstatic($a, $b) { + var_dump($a); + } +} + +foo::aa(); + +$b = 'AA'; +foo::$b(); + +foo::__construct(); + +?> +--EXPECTF-- +Strict Standards: Non-static method foo::aa() should not be called statically in %s on line %d +ok + +Strict Standards: Non-static method foo::aa() should not be called statically in %s on line %d +ok + +Fatal error: Cannot call constructor in %s on line %d diff --git a/Zend/tests/call_static_007.phpt b/Zend/tests/call_static_007.phpt new file mode 100644 index 0000000..419f102 --- /dev/null +++ b/Zend/tests/call_static_007.phpt @@ -0,0 +1,34 @@ +--TEST-- +Testing __call and __callstatic +--FILE-- +<?php + +class a { + public function __call($a, $b) { + print "__call: ". $a ."\n"; + } + static public function __callStatic($a, $b) { + print "__callstatic: ". $a ."\n"; + } + public function baz() { + self::Bar(); + } +} + + +$a = new a; + +$b = 'Test'; +$a::$b(); +$a->$b(); + +$a->baz(); + +a::Foo(); + +?> +--EXPECT-- +__callstatic: Test +__call: Test +__call: Bar +__callstatic: Foo diff --git a/Zend/tests/call_user_func_001.phpt b/Zend/tests/call_user_func_001.phpt new file mode 100644 index 0000000..e9b35f9 --- /dev/null +++ b/Zend/tests/call_user_func_001.phpt @@ -0,0 +1,35 @@ +--TEST-- +Testing call_user_func inside namespace +--FILE-- +<?php + +namespace testing { + function foobar($str) { + var_dump($str); + } + + abstract class bar { + protected function prot($str) { + print "Shouldn't be called!\n"; + } + } + class foo extends bar { + private function priv($str) { + print "Shouldn't be called!\n"; + } + } + + call_user_func(__NAMESPACE__ .'\foobar', 'foobar'); + + $class = __NAMESPACE__ .'\foo'; + call_user_func(array(new $class, 'priv'), 'foobar'); + call_user_func(array(new $class, 'prot'), 'foobar'); +} + +?> +--EXPECTF-- +%string|unicode%(6) "foobar" + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access private method testing\foo::priv() in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access protected method testing\foo::prot() in %s on line %d diff --git a/Zend/tests/call_user_func_002.phpt b/Zend/tests/call_user_func_002.phpt new file mode 100644 index 0000000..e79dd1a --- /dev/null +++ b/Zend/tests/call_user_func_002.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing call_user_func() with autoload and passing invalid params +--FILE-- +<?php + +function __autoload($class) { + var_dump($class); +} + +call_user_func(array('foo', 'bar')); +call_user_func(array('', 'bar')); +call_user_func(array($foo, 'bar')); +call_user_func(array($foo, '')); + +?> +--EXPECTF-- +%unicode|string%(3) "foo" + +Warning: call_user_func() expects parameter 1 to be a valid callback, class 'foo' not found in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, class '' not found in %s on line %d + +Notice: Undefined variable: foo in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in %s on line %d + +Notice: Undefined variable: foo in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in %s on line %d diff --git a/Zend/tests/call_user_func_003.phpt b/Zend/tests/call_user_func_003.phpt new file mode 100644 index 0000000..d516584 --- /dev/null +++ b/Zend/tests/call_user_func_003.phpt @@ -0,0 +1,31 @@ +--TEST-- +Testing call_user_func() with closures +--FILE-- +<?php + +$foo = function() { + static $instance; + + if (is_null($instance)) { + $instance = function () { + return 'OK!'; + }; + } + + return $instance; +}; + +var_dump(call_user_func(array($foo, '__invoke'))->__invoke()); +var_dump(call_user_func(function() use (&$foo) { return $foo; }, '__invoke')); + +?> +--EXPECTF-- +%unicode|string%(3) "OK!" +object(Closure)#%d (1) { + [%u|b%"static"]=> + array(1) { + [%u|b%"instance"]=> + object(Closure)#%d (0) { + } + } +} diff --git a/Zend/tests/call_user_func_004.phpt b/Zend/tests/call_user_func_004.phpt new file mode 100644 index 0000000..4885c4d --- /dev/null +++ b/Zend/tests/call_user_func_004.phpt @@ -0,0 +1,18 @@ +--TEST-- +Calling non-static method with call_user_func() +--FILE-- +<?php + +class foo { + public function teste() { + $this->a = 1; + } +} + +call_user_func(array('foo', 'teste')); + +?> +--EXPECTF-- +Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method foo::teste() should not be called statically in %s on line %d + +Fatal error: Using $this when not in object context in %s on line %d diff --git a/Zend/tests/call_user_func_005.phpt b/Zend/tests/call_user_func_005.phpt new file mode 100644 index 0000000..6c1fa19 --- /dev/null +++ b/Zend/tests/call_user_func_005.phpt @@ -0,0 +1,35 @@ +--TEST-- +Passing Closure as parameter to an non-existent function +--FILE-- +<?php + +class foo { + public static function __callstatic($x, $y) { + var_dump($x,$y); + return 1; + } + + public function teste() { + return foo::x(function &($a=1,$b) { }); + } +} + +var_dump(call_user_func(array('foo', 'teste'))); + +?> +--EXPECTF-- +Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method foo::teste() should not be called statically in %s on line %d +%string|unicode%(1) "x" +array(1) { + [0]=> + object(Closure)#%d (1) { + ["parameter"]=> + array(2) { + ["$a"]=> + string(10) "<required>" + ["$b"]=> + string(10) "<required>" + } + } +} +int(1) diff --git a/Zend/tests/call_with_refs.phpt b/Zend/tests/call_with_refs.phpt new file mode 100644 index 0000000..acad134 --- /dev/null +++ b/Zend/tests/call_with_refs.phpt @@ -0,0 +1,18 @@ +--TEST-- +Check call to non-ref function with call-time refs +--FILE-- +<?php +function my_errorhandler($errno,$errormsg) { + global $my_var; + $my_var=0x12345; + echo $errormsg."\n"; + return true; +} +$oldhandler = set_error_handler("my_errorhandler"); +$my_var = str_repeat("A",64); +$data = call_user_func_array("substr_replace",array(&$my_var, new StdClass(),1)); +echo "OK!"; +--EXPECT-- +Object of class stdClass could not be converted to string +Object of class stdClass to string conversion +OK! diff --git a/Zend/tests/callable_type_hint_001.phpt b/Zend/tests/callable_type_hint_001.phpt new file mode 100644 index 0000000..36643fa --- /dev/null +++ b/Zend/tests/callable_type_hint_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +callable type hint#001 +--FILE-- +<?php + +class bar { + function baz() {} + static function foo() {} +} +function foo(callable $bar) { + var_dump($bar); +} +$closure = function () {}; + +foo("strpos"); +foo("foo"); +foo(array("bar", "baz")); +foo(array("bar", "foo")); +foo($closure); +--EXPECTF-- +string(6) "strpos" +string(3) "foo" + +Strict Standards: Non-static method bar::baz() should not be called statically in %scallable_type_hint_001.php on line %d +array(2) { + [0]=> + string(3) "bar" + [1]=> + string(3) "baz" +} +array(2) { + [0]=> + string(3) "bar" + [1]=> + string(3) "foo" +} +object(Closure)#%d (0) { +} + diff --git a/Zend/tests/callable_type_hint_002.phpt b/Zend/tests/callable_type_hint_002.phpt new file mode 100644 index 0000000..b1b7339 --- /dev/null +++ b/Zend/tests/callable_type_hint_002.phpt @@ -0,0 +1,27 @@ +--TEST-- +callable type hint#002 - Reflection +--FILE-- +<?php + +class bar { + static function foo(callable $arg) {} +} +function foo(callable $bar) { +} +$closure = function (callable $arg) {}; + +$rf = new ReflectionFunction("foo"); +var_dump($rf->getParameters()[0]->isCallable()); + +$rm = new ReflectionMethod("bar", "foo"); +var_dump($rm->getParameters()[0]->isCallable()); + +$rc = new ReflectionFunction($closure); +var_dump($rc->getParameters()[0]->isCallable()); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) + diff --git a/Zend/tests/callable_type_hint_003.phpt b/Zend/tests/callable_type_hint_003.phpt new file mode 100644 index 0000000..83f5090 --- /dev/null +++ b/Zend/tests/callable_type_hint_003.phpt @@ -0,0 +1,21 @@ +--TEST-- +callable type hint#003 +--FILE-- +<?php + +function foo(callable $a, $b, callable $c) { + var_dump($a, $b, $c); +} +function bar(callable $a = null) { + var_dump($a); +} + +foo("strpos", 123, "strpos"); +bar("substr"); +?> +--EXPECT-- +string(6) "strpos" +int(123) +string(6) "strpos" +string(6) "substr" + diff --git a/Zend/tests/cast_to_array.phpt b/Zend/tests/cast_to_array.phpt Binary files differnew file mode 100644 index 0000000..5e35105 --- /dev/null +++ b/Zend/tests/cast_to_array.phpt diff --git a/Zend/tests/cast_to_bool.phpt b/Zend/tests/cast_to_bool.phpt new file mode 100644 index 0000000..75ab09d --- /dev/null +++ b/Zend/tests/cast_to_bool.phpt @@ -0,0 +1,53 @@ +--TEST-- +casting different variables to boolean +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + $tmp = (bool)$var; + var_dump($tmp); +} + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(true) +Done diff --git a/Zend/tests/cast_to_double.phpt b/Zend/tests/cast_to_double.phpt new file mode 100644 index 0000000..a5b9819 --- /dev/null +++ b/Zend/tests/cast_to_double.phpt @@ -0,0 +1,57 @@ +--TEST-- +casting different variables to double +--INI-- +precision=14 +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + $tmp = (double)$var; + var_dump($tmp); +} + +echo "Done\n"; +?> +--EXPECTF-- +float(0) +float(8754456) +float(0) +float(0) +float(9876545) +float(0.1) +float(0) +float(1) +float(0) +float(1) +float(0) +float(%d) + +Notice: Object of class test could not be converted to double in %s on line %d +float(1) +Done diff --git a/Zend/tests/cast_to_int.phpt b/Zend/tests/cast_to_int.phpt new file mode 100644 index 0000000..28c57dd --- /dev/null +++ b/Zend/tests/cast_to_int.phpt @@ -0,0 +1,55 @@ +--TEST-- +casting different variables to integer +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + $tmp = (int)$var; + var_dump($tmp); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(0) +int(8754456) +int(0) +int(0) +int(9876545) +int(0) +int(0) +int(1) +int(0) +int(1) +int(0) +int(%d) + +Notice: Object of class test could not be converted to int in %s on line %d +int(1) +Done diff --git a/Zend/tests/cast_to_object.phpt b/Zend/tests/cast_to_object.phpt Binary files differnew file mode 100644 index 0000000..f8d4878 --- /dev/null +++ b/Zend/tests/cast_to_object.phpt diff --git a/Zend/tests/cast_to_string.phpt b/Zend/tests/cast_to_string.phpt Binary files differnew file mode 100644 index 0000000..f8b57a2 --- /dev/null +++ b/Zend/tests/cast_to_string.phpt diff --git a/Zend/tests/catch.phpt b/Zend/tests/catch.phpt new file mode 100644 index 0000000..0ec5cf7 --- /dev/null +++ b/Zend/tests/catch.phpt @@ -0,0 +1,23 @@ +--TEST-- +catch shouldn't call __autoload +--FILE-- +<?php +function __autoload($name) { + echo("AUTOLOAD '$name'\n"); + eval("class $name {}"); +} + + +try { +} catch (A $e) { +} + +try { + throw new Exception(); +} catch (B $e) { +} catch (Exception $e) { + echo "ok\n"; +} +?> +--EXPECT-- +ok diff --git a/Zend/tests/catch_002.phpt b/Zend/tests/catch_002.phpt new file mode 100644 index 0000000..11d736a --- /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 100644 index 0000000..414d50f --- /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 100644 index 0000000..54920b8 --- /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/class_alias_001.phpt b/Zend/tests/class_alias_001.phpt new file mode 100644 index 0000000..371f08f --- /dev/null +++ b/Zend/tests/class_alias_001.phpt @@ -0,0 +1,30 @@ +--TEST-- +Testing class_alias() +--FILE-- +<?php + +class foo { } + +class_alias('foo', 'bar'); + +$a = new foo; +$b = new bar; + +var_dump($a == $b, $a === $b); +var_dump($a instanceof $b); + +var_dump($a instanceof foo); +var_dump($a instanceof bar); + +var_dump($b instanceof foo); +var_dump($b instanceof bar); + +?> +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/class_alias_002.phpt b/Zend/tests/class_alias_002.phpt new file mode 100644 index 0000000..9601cb2 --- /dev/null +++ b/Zend/tests/class_alias_002.phpt @@ -0,0 +1,12 @@ +--TEST-- +Trying redeclare class with class_alias() +--FILE-- +<?php + +class foo { } + +class_alias('foo', 'FOO'); + +?> +--EXPECTF-- +Warning: Cannot redeclare class FOO in %s on line %d diff --git a/Zend/tests/class_alias_003.phpt b/Zend/tests/class_alias_003.phpt new file mode 100644 index 0000000..57e2fd5 --- /dev/null +++ b/Zend/tests/class_alias_003.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing declaration of alias to 'static' +--FILE-- +<?php + +class bar { +} + +class foo { + public function test() { + class_alias('bar', 'static'); + return new static; + } +} + +$a = new foo; +var_dump($a->test()); + +?> +--EXPECTF-- +object(foo)#%d (0) { +} diff --git a/Zend/tests/class_alias_004.phpt b/Zend/tests/class_alias_004.phpt new file mode 100644 index 0000000..b7dbabd --- /dev/null +++ b/Zend/tests/class_alias_004.phpt @@ -0,0 +1,15 @@ +--TEST-- +Testing creation of alias using an existing interface name +--FILE-- +<?php + +class foo { } + +interface test { } + + +class_alias('foo', 'test'); + +?> +--EXPECTF-- +Warning: Cannot redeclare class test in %s on line %d diff --git a/Zend/tests/class_alias_005.phpt b/Zend/tests/class_alias_005.phpt new file mode 100644 index 0000000..47c825b --- /dev/null +++ b/Zend/tests/class_alias_005.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing static call method using the original class name +--FILE-- +<?php + +class foo { + static public function msg() { + print "hello\n"; + } +} + +interface test { } + + +class_alias('foo', 'baz'); + +class bar extends baz { + public function __construct() { + foo::msg(); + } +} + +new bar; + +?> +--EXPECT-- +hello diff --git a/Zend/tests/class_alias_006.phpt b/Zend/tests/class_alias_006.phpt new file mode 100644 index 0000000..d14ad7c --- /dev/null +++ b/Zend/tests/class_alias_006.phpt @@ -0,0 +1,10 @@ +--TEST-- +Testing creation of alias to an internal class +--FILE-- +<?php + +class_alias('stdclass', 'foo'); + +?> +--EXPECTF-- +Warning: First argument of class_alias() must be a name of user defined class in %s on line %d diff --git a/Zend/tests/class_alias_007.phpt b/Zend/tests/class_alias_007.phpt new file mode 100644 index 0000000..247398e --- /dev/null +++ b/Zend/tests/class_alias_007.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing class_alias() using autoload +--FILE-- +<?php + +function __autoload($a) { + class foo { } +} + +class_alias('foo', 'bar', 1); + +var_dump(new foo, new bar); + +?> +--EXPECTF-- +object(foo)#%d (0) { +} +object(foo)#%d (0) { +} diff --git a/Zend/tests/class_alias_008.phpt b/Zend/tests/class_alias_008.phpt new file mode 100644 index 0000000..8ee8fa0 --- /dev/null +++ b/Zend/tests/class_alias_008.phpt @@ -0,0 +1,16 @@ +--TEST-- +Testing class_alias() with abstract class using an arbitrary class name as alias +--FILE-- +<?php + +abstract class foo { } + +class_alias('foo', "\0"); + +$a = "\0"; + +new $a; + +?> +--EXPECTF-- +Fatal error: Cannot instantiate abstract class foo in %s on line %d diff --git a/Zend/tests/class_alias_009.phpt b/Zend/tests/class_alias_009.phpt new file mode 100644 index 0000000..f17769e --- /dev/null +++ b/Zend/tests/class_alias_009.phpt @@ -0,0 +1,14 @@ +--TEST-- +Testing interface declaration using the original and alias class name +--FILE-- +<?php + +interface a { } + +class_alias('a', 'b'); + +interface c extends a, b { } + +?> +--EXPECTF-- +Fatal error: Class c cannot implement previously implemented interface a in %s on line %d diff --git a/Zend/tests/class_alias_010.phpt b/Zend/tests/class_alias_010.phpt new file mode 100644 index 0000000..38590b6 --- /dev/null +++ b/Zend/tests/class_alias_010.phpt @@ -0,0 +1,14 @@ +--TEST-- +Trying use an existing alias name in class declaration +--FILE-- +<?php + +interface a { } + +class_alias('a', 'b'); + +class b { } + +?> +--EXPECTF-- +Warning: Cannot redeclare class b in %s on line %d diff --git a/Zend/tests/class_alias_011.phpt b/Zend/tests/class_alias_011.phpt new file mode 100644 index 0000000..58ba28a --- /dev/null +++ b/Zend/tests/class_alias_011.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing callback in alias +--FILE-- +<?php + +class foo { + static public function test() { + print "hello\n"; + } + public function test2() { + print "foobar!\n"; + } +} + +class_alias('FOO', 'bar'); + +call_user_func(array('bar', 'test')); + + +$a = new bar; +call_user_func(array($a, 'test2')); + +?> +--EXPECT-- +hello +foobar! diff --git a/Zend/tests/class_alias_012.phpt b/Zend/tests/class_alias_012.phpt new file mode 100644 index 0000000..dd1c9b1 --- /dev/null +++ b/Zend/tests/class_alias_012.phpt @@ -0,0 +1,33 @@ +--TEST-- +Testing dynamic alias name +--FILE-- +<?php + +namespace test\baz; + +class foo { +} + +new foo; + +class_alias(__NAMESPACE__ .'\foo', __NAMESPACE__ .'\T'); + +var_dump(new foo); +var_dump(new T); + +$var = __NAMESPACE__ .'\foo'; +var_dump(new $var); + +$var = __NAMESPACE__ .'\T'; +var_dump(new $var); + +?> +--EXPECTF-- +object(test\baz\foo)#%d (0) { +} +object(test\baz\foo)#%d (0) { +} +object(test\baz\foo)#%d (0) { +} +object(test\baz\foo)#%d (0) { +} diff --git a/Zend/tests/class_alias_013.phpt b/Zend/tests/class_alias_013.phpt new file mode 100644 index 0000000..4991d0f --- /dev/null +++ b/Zend/tests/class_alias_013.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing alias of alias +--FILE-- +<?php + +namespace test\baz; + +class foo { +} + +new foo; + +$alias1 = __NAMESPACE__ .'\T'; +class_alias(__NAMESPACE__ .'\foo', $alias1); + +$alias2 = $alias1 .'\BAR'; +class_alias($alias1, $alias2); + +var_dump(new \test\baz\foo, new \test\baz\T\BAR); + +?> +--EXPECTF-- +object(test\baz\foo)#%d (0) { +} +object(test\baz\foo)#%d (0) { +} diff --git a/Zend/tests/class_alias_014.phpt b/Zend/tests/class_alias_014.phpt new file mode 100644 index 0000000..7c4bdb9 --- /dev/null +++ b/Zend/tests/class_alias_014.phpt @@ -0,0 +1,15 @@ +--TEST-- +Testing creation of alias to class name without namespace prefix +--FILE-- +<?php + +namespace foo; + +class bar { +} + +class_alias('bar', 'baz'); + +?> +--EXPECTF-- +Warning: Class 'bar' not found in %s on line %d diff --git a/Zend/tests/class_alias_015.phpt b/Zend/tests/class_alias_015.phpt new file mode 100644 index 0000000..c79c077 --- /dev/null +++ b/Zend/tests/class_alias_015.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing instantiation using namespace:: prefix +--FILE-- +<?php + +namespace foo; + +class bar { +} + +class_alias('foo\bar', 'foo\baz'); + +var_dump(new namespace\baz); + +?> +--EXPECTF-- +object(foo\bar)#%d (0) { +} diff --git a/Zend/tests/class_alias_016.phpt b/Zend/tests/class_alias_016.phpt new file mode 100644 index 0000000..930f2ee --- /dev/null +++ b/Zend/tests/class_alias_016.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing creation of alias to global scope +--FILE-- +<?php + +namespace foo; + +class bar { +} + +class_alias('foo\bar', 'foo'); + +var_dump(new \foo); +var_dump(new foo); + +?> +--EXPECTF-- +object(foo\bar)#%d (0) { +} + +Fatal error: Class 'foo\foo' not found in %s on line %d diff --git a/Zend/tests/class_alias_017.phpt b/Zend/tests/class_alias_017.phpt new file mode 100644 index 0000000..f4d3626 --- /dev/null +++ b/Zend/tests/class_alias_017.phpt @@ -0,0 +1,33 @@ +--TEST-- +Testing alias with get_called_class() and get_class() +--FILE-- +<?php + +class foo { + public function __construct() { + echo get_called_class(), "\n"; + } + static public function test() { + echo get_class(), "\n"; + } +} + +class_alias('foo', 'bar'); + +new bar; + + +class baz extends bar { +} + +new baz; +baz::test(); + +bar::test(); + +?> +--EXPECTF-- +foo +baz +foo +foo diff --git a/Zend/tests/class_alias_018.phpt b/Zend/tests/class_alias_018.phpt new file mode 100644 index 0000000..4666e76 --- /dev/null +++ b/Zend/tests/class_alias_018.phpt @@ -0,0 +1,37 @@ +--TEST-- +Testing class alias with is_subclass_of() +--FILE-- +<?php + +class foo { +} + +class_alias('foo', 'bar'); + + +class baz extends bar { +} + +var_dump(is_subclass_of(new foo, 'foo')); +var_dump(is_subclass_of(new foo, 'bar')); +var_dump(is_subclass_of(new foo, 'baz')); + +var_dump(is_subclass_of(new bar, 'foo')); +var_dump(is_subclass_of(new bar, 'bar')); +var_dump(is_subclass_of(new bar, 'baz')); + +var_dump(is_subclass_of(new baz, 'foo')); +var_dump(is_subclass_of(new baz, 'bar')); +var_dump(is_subclass_of(new baz, 'baz')); + +?> +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) diff --git a/Zend/tests/class_alias_019.phpt b/Zend/tests/class_alias_019.phpt new file mode 100644 index 0000000..a0dd249 --- /dev/null +++ b/Zend/tests/class_alias_019.phpt @@ -0,0 +1,17 @@ +--TEST-- +Trying to redeclare class name in global scope inside namespace +--FILE-- +<?php + +namespace foo; + + +class foo { +} + +class_alias(__NAMESPACE__ .'\foo', 'foo'); +class_alias('\foo', 'foo'); + +?> +--EXPECTF-- +Warning: Cannot redeclare class foo in %s on line %d diff --git a/Zend/tests/class_alias_020.phpt b/Zend/tests/class_alias_020.phpt new file mode 100644 index 0000000..e2c7d92 --- /dev/null +++ b/Zend/tests/class_alias_020.phpt @@ -0,0 +1,33 @@ +--TEST-- +Testing class alias in multiple namespaces +--FILE-- +<?php + +namespace foo; + + +class foo { +} + +class_alias(__NAMESPACE__ .'\foo', 'foo'); + +namespace foo\bar; + +class foo { +} + +class_alias(__NAMESPACE__ .'\foo', 'bar'); + + +var_dump(new \foo, new \bar); + +var_dump(new \foo\foo, new \foo\bar); + +?> +--EXPECTF-- +object(foo\foo)#1 (0) { +} +object(foo\bar\foo)#2 (0) { +} + +Fatal error: Class 'foo\bar' not found in %s on line %d diff --git a/Zend/tests/class_alias_021.phpt b/Zend/tests/class_alias_021.phpt new file mode 100644 index 0000000..dd90e12 --- /dev/null +++ b/Zend/tests/class_alias_021.phpt @@ -0,0 +1,25 @@ +--TEST-- +Overriding internal class with class alias +--FILE-- +<?php + +namespace foo; + +class bar { } + +class_alias('foo\bar', 'baz'); + +use \baz as stdClass; + +var_dump(new bar); +var_dump(new stdClass); +var_dump(new \baz); + +?> +--EXPECTF-- +object(foo\bar)#%d (0) { +} +object(foo\bar)#%d (0) { +} +object(foo\bar)#%d (0) { +} diff --git a/Zend/tests/class_constants_001.phpt b/Zend/tests/class_constants_001.phpt new file mode 100644 index 0000000..45270f6 --- /dev/null +++ b/Zend/tests/class_constants_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +class constants basic tests +--FILE-- +<?php + +class test { + const val = "string"; + const val2 = 1; +} + +var_dump(test::val); +var_dump(test::val2); + +var_dump(test::val3); + +echo "Done\n"; +?> +--EXPECTF-- +string(6) "string" +int(1) + +Fatal error: Undefined class constant 'val3' in %s on line %d diff --git a/Zend/tests/class_constants_002.phpt b/Zend/tests/class_constants_002.phpt new file mode 100644 index 0000000..9aad808 --- /dev/null +++ b/Zend/tests/class_constants_002.phpt @@ -0,0 +1,31 @@ +--TEST-- +class constants as default function arguments +--FILE-- +<?php + +class test { + const val = 1; +} + +function foo($v = test::val) { + var_dump($v); +} + +function bar($b = NoSuchClass::val) { + var_dump($b); +} + +foo(); +foo(5); + +bar(10); +bar(); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +int(5) +int(10) + +Fatal error: Class 'NoSuchClass' not found in %s on line %d diff --git a/Zend/tests/class_constants_003.phpt b/Zend/tests/class_constants_003.phpt new file mode 100644 index 0000000..c2782ff --- /dev/null +++ b/Zend/tests/class_constants_003.phpt @@ -0,0 +1,33 @@ +--TEST-- +class constants as default function arguments and dynamically loaded classes +--FILE-- +<?php + +$class_data = <<<DATA +<?php +class test { + const val = 1; +} +?> +DATA; + +$filename = dirname(__FILE__)."/cc003.dat"; +file_put_contents($filename, $class_data); + +function foo($v = test::val) { + var_dump($v); +} + +include $filename; + +foo(); +foo(5); + +unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +int(5) +Done diff --git a/Zend/tests/class_constants_004.phpt b/Zend/tests/class_constants_004.phpt new file mode 100644 index 0000000..73a42ed --- /dev/null +++ b/Zend/tests/class_constants_004.phpt @@ -0,0 +1,44 @@ +--TEST-- +Testing constants (normal, namespace, class and interface) +--FILE-- +<?php + +namespace foo; + +define('foo', 3); + +const foo = 1; + +class foo { + const foo = 2; +} + +interface Ifoo { + const foo = 4; +} + +$const = __NAMESPACE__ .'\\foo'; // class +$const2 = __NAMESPACE__ .'\\Ifoo'; // interface + +var_dump( foo, + \foo\foo, + namespace\foo, + \foo\foo::foo, + $const::foo, + \foo, + constant('foo'), + Ifoo::foo, + $const2::foo + ); + +?> +--EXPECT-- +int(1) +int(1) +int(1) +int(2) +int(2) +int(3) +int(3) +int(4) +int(4) diff --git a/Zend/tests/class_exists_001.phpt b/Zend/tests/class_exists_001.phpt new file mode 100644 index 0000000..8af96a4 --- /dev/null +++ b/Zend/tests/class_exists_001.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing class_exists() inside namespace +--FILE-- +<?php + +namespace foo; + +class foo { + +} + +class_alias(__NAMESPACE__ .'\foo', 'bar'); + + +var_dump(class_exists('\bar')); +var_dump(class_exists('bar')); +var_dump(class_exists('foo\bar')); +var_dump(class_exists('foo\foo')); +var_dump(class_exists('foo')); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) diff --git a/Zend/tests/class_exists_002.phpt b/Zend/tests/class_exists_002.phpt new file mode 100644 index 0000000..d326f06 --- /dev/null +++ b/Zend/tests/class_exists_002.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing several valid and invalid parameters +--FILE-- +<?php + +class foo { + +} + +var_dump(class_exists('')); +var_dump(class_exists(NULL)); +var_dump(class_exists('FOO')); +var_dump(class_exists('bar')); +var_dump(class_exists(1)); +var_dump(class_exists(new stdClass)); + +?> +--EXPECTF-- +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) + +Warning: class_exists() expects parameter 1 to be string, object given in %s on line %d +NULL diff --git a/Zend/tests/class_exists_003.phpt b/Zend/tests/class_exists_003.phpt new file mode 100644 index 0000000..cba4675 --- /dev/null +++ b/Zend/tests/class_exists_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +Checking if exists interface, trait, abstract and final class +--FILE-- +<?php + +interface a { } + +abstract class b { } + +final class c { } + +trait d {} + +var_dump(class_exists('a')); +var_dump(class_exists('b')); +var_dump(class_exists('c')); +var_dump(class_exists('d')); + +?> +--EXPECT-- +bool(false) +bool(true) +bool(true) +bool(false) diff --git a/Zend/tests/clone_001.phpt b/Zend/tests/clone_001.phpt new file mode 100644 index 0000000..c8ff8d8 --- /dev/null +++ b/Zend/tests/clone_001.phpt @@ -0,0 +1,10 @@ +--TEST-- +Using clone statement on non-object +--FILE-- +<?php + +$a = clone array(); + +?> +--EXPECTF-- +Fatal error: __clone method called on non-object in %s on line %d diff --git a/Zend/tests/clone_002.phpt b/Zend/tests/clone_002.phpt new file mode 100644 index 0000000..5015642 --- /dev/null +++ b/Zend/tests/clone_002.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing multiple clone statements +--FILE-- +<?php + +$a = clone clone $b = new stdClass; +var_dump($a == $b); + + +$c = clone clone clone $b = new stdClass; +var_dump($a == $b, $b == $c); + +class foo { } + +$d = clone $a = $b = new foo; +var_dump($a == $d, $b == $d, $c == $a); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) diff --git a/Zend/tests/clone_003.phpt b/Zend/tests/clone_003.phpt new file mode 100644 index 0000000..362e346 --- /dev/null +++ b/Zend/tests/clone_003.phpt @@ -0,0 +1,12 @@ +--TEST-- +Using clone statement on undefined variable +--FILE-- +<?php + +$a = clone $b; + +?> +--EXPECTF-- +Notice: Undefined variable: b in %s on line %d + +Fatal error: __clone method called on non-object in %s on line %d diff --git a/Zend/tests/clone_004.phpt b/Zend/tests/clone_004.phpt new file mode 100644 index 0000000..984313c --- /dev/null +++ b/Zend/tests/clone_004.phpt @@ -0,0 +1,20 @@ +--TEST-- +Testing usage of object as array on clone statement +--FILE-- +<?php + +error_reporting(E_ALL|E_STRICT); + +class foo { + public function __get($a) { + return new $this; + } +} + +$c = new foo; + +$a = clone $c->b[1]; + +?> +--EXPECTF-- +Fatal error: Cannot use object of type foo as array in %s on line %d diff --git a/Zend/tests/closure_001.phpt b/Zend/tests/closure_001.phpt new file mode 100644 index 0000000..ebac729 --- /dev/null +++ b/Zend/tests/closure_001.phpt @@ -0,0 +1,30 @@ +--TEST-- +Closure 001: Lambda without lexical variables +--FILE-- +<?php + +$lambda1 = function () { + echo "Hello World!\n"; +}; + +$lambda2 = function ($x) { + echo "Hello $x!\n"; +}; + +var_dump(is_callable($lambda1)); +var_dump(is_callable($lambda2)); +$lambda1(); +$lambda2("Universe"); +call_user_func($lambda1); +call_user_func($lambda2, "Universe"); + +echo "Done\n"; +?> +--EXPECT-- +bool(true) +bool(true) +Hello World! +Hello Universe! +Hello World! +Hello Universe! +Done diff --git a/Zend/tests/closure_002.phpt b/Zend/tests/closure_002.phpt new file mode 100644 index 0000000..023d4ec --- /dev/null +++ b/Zend/tests/closure_002.phpt @@ -0,0 +1,29 @@ +--TEST-- +Closure 002: Lambda with lexical variables (global scope) +--FILE-- +<?php + +$x = 4; + +$lambda1 = function () use ($x) { + echo "$x\n"; +}; + +$lambda2 = function () use (&$x) { + echo "$x\n"; +}; + +$lambda1(); +$lambda2(); +$x++; +$lambda1(); +$lambda2(); + +echo "Done\n"; +?> +--EXPECT-- +4 +4 +4 +5 +Done diff --git a/Zend/tests/closure_003.phpt b/Zend/tests/closure_003.phpt new file mode 100644 index 0000000..6f5cc70 --- /dev/null +++ b/Zend/tests/closure_003.phpt @@ -0,0 +1,33 @@ +--TEST-- +Closure 003: Lambda with lexical variables (local scope) +--FILE-- +<?php + +function run () { + $x = 4; + + $lambda1 = function () use ($x) { + echo "$x\n"; + }; + + $lambda2 = function () use (&$x) { + echo "$x\n"; + }; + + $lambda1(); + $lambda2(); + $x++; + $lambda1(); + $lambda2(); +} + +run(); + +echo "Done\n"; +?> +--EXPECT-- +4 +4 +4 +5 +Done diff --git a/Zend/tests/closure_004.phpt b/Zend/tests/closure_004.phpt new file mode 100644 index 0000000..c1c2efb --- /dev/null +++ b/Zend/tests/closure_004.phpt @@ -0,0 +1,35 @@ +--TEST-- +Closure 004: Lambda with lexical variables (scope lifetime) +--FILE-- +<?php + +function run () { + $x = 4; + + $lambda1 = function () use ($x) { + echo "$x\n"; + }; + + $lambda2 = function () use (&$x) { + echo "$x\n"; + $x++; + }; + + return array($lambda1, $lambda2); +} + +list ($lambda1, $lambda2) = run(); + +$lambda1(); +$lambda2(); +$lambda1(); +$lambda2(); + +echo "Done\n"; +?> +--EXPECT-- +4 +4 +4 +5 +Done diff --git a/Zend/tests/closure_005.phpt b/Zend/tests/closure_005.phpt new file mode 100644 index 0000000..4e32faa --- /dev/null +++ b/Zend/tests/closure_005.phpt @@ -0,0 +1,74 @@ +--TEST-- +Closure 005: Lambda inside class, lifetime of $this +--FILE-- +<?php + +class A { + private $x; + + function __construct($x) { + $this->x = $x; + } + + function __destruct() { + echo "Destroyed\n"; + } + + function getIncer($val) { + return function() use ($val) { + $this->x += $val; + }; + } + + function getPrinter() { + return function() { + echo $this->x."\n"; + }; + } + + function getError() { + return static function() { + echo $this->x."\n"; + }; + } + + function printX() { + echo $this->x."\n"; + } +} + +$a = new A(3); +$incer = $a->getIncer(2); +$printer = $a->getPrinter(); +$error = $a->getError(); + +$a->printX(); +$printer(); +$incer(); +$a->printX(); +$printer(); + +unset($a); + +$incer(); +$printer(); + +unset($incer); +$printer(); + +unset($printer); + +$error(); + +echo "Done\n"; +?> +--EXPECTF-- +3 +3 +5 +5 +7 +7 +Destroyed + +Fatal error: Using $this when not in object context in %sclosure_005.php on line 28 diff --git a/Zend/tests/closure_006.phpt b/Zend/tests/closure_006.phpt new file mode 100644 index 0000000..aa0ec11 --- /dev/null +++ b/Zend/tests/closure_006.phpt @@ -0,0 +1,19 @@ +--TEST-- +Closure 006: Nested lambdas +--FILE-- +<?php + +$getClosure = function ($v) { + return function () use ($v) { + echo "Hello World: $v!\n"; + }; +}; + +$closure = $getClosure (2); +$closure (); + +echo "Done\n"; +?> +--EXPECT-- +Hello World: 2! +Done diff --git a/Zend/tests/closure_007.phpt b/Zend/tests/closure_007.phpt new file mode 100644 index 0000000..89cd06d --- /dev/null +++ b/Zend/tests/closure_007.phpt @@ -0,0 +1,38 @@ +--TEST-- +Closure 007: Nested lambdas in classes +--FILE-- +<?php + +class A { + private $x = 0; + + function getClosureGetter () { + return function () { + return function () { + $this->x++; + }; + }; + } + + function printX () { + echo $this->x."\n"; + } +} + +$a = new A; +$a->printX(); +$getClosure = $a->getClosureGetter(); +$a->printX(); +$closure = $getClosure(); +$a->printX(); +$closure(); +$a->printX(); + +echo "Done\n"; +?> +--EXPECT-- +0 +0 +0 +1 +Done diff --git a/Zend/tests/closure_008.phpt b/Zend/tests/closure_008.phpt new file mode 100644 index 0000000..64c7e65 --- /dev/null +++ b/Zend/tests/closure_008.phpt @@ -0,0 +1,22 @@ +--TEST-- +Closure 008: Use in preg_replace_callback() +--FILE-- +<?php + +function replace_spaces($text) { + $lambda = function ($matches) { + return str_replace(' ', ' ', $matches[1]).' '; + }; + return preg_replace_callback('/( +) /', $lambda, $text); +} + +echo replace_spaces("1 2 3\n"); +echo replace_spaces("1 2 3\n"); +echo replace_spaces("1 2 3\n"); +echo "Done\n"; +?> +--EXPECT-- +1 2 3 +1 2 3 +1 2 3 +Done diff --git a/Zend/tests/closure_009.phpt b/Zend/tests/closure_009.phpt new file mode 100644 index 0000000..5c576d7 --- /dev/null +++ b/Zend/tests/closure_009.phpt @@ -0,0 +1,31 @@ +--TEST-- +Closure 009: Using static vars inside lambda +--FILE-- +<?php +$a = 1; +$x = function ($x) use ($a) { + static $n = 0; + $n++; + $a = $n.':'.$a; + echo $x.':'.$a."\n"; +}; +$y = function ($x) use (&$a) { + static $n = 0; + $n++; + $a = $n.':'.$a; + echo $x.':'.$a."\n"; +}; +$x(1); +$x(2); +$x(3); +$y(4); +$y(5); +$y(6); +?> +--EXPECT-- +1:1:1 +2:2:1 +3:3:1 +4:1:1 +5:2:1:1 +6:3:2:1:1 diff --git a/Zend/tests/closure_010.phpt b/Zend/tests/closure_010.phpt new file mode 100644 index 0000000..d4787f0 --- /dev/null +++ b/Zend/tests/closure_010.phpt @@ -0,0 +1,18 @@ +--TEST-- +Closure 010: Closure calls itself +--FILE-- +<?php +$i = 3; +$lambda = function ($lambda) use (&$i) { + if ($i==0) return; + echo $i--."\n"; + $lambda($lambda); +}; +$lambda($lambda); +echo "$i\n"; +?> +--EXPECT-- +3 +2 +1 +0 diff --git a/Zend/tests/closure_011.phpt b/Zend/tests/closure_011.phpt new file mode 100644 index 0000000..7071364 --- /dev/null +++ b/Zend/tests/closure_011.phpt @@ -0,0 +1,14 @@ +--TEST-- +Closure 011: Lexical copies not static in closure +--FILE-- +<?php +$i = 1; +$lambda = function () use ($i) { + return ++$i; +}; +$lambda(); +echo $lambda()."\n"; +//early prototypes gave 3 here because $i was static in $lambda +?> +--EXPECT-- +2 diff --git a/Zend/tests/closure_012.phpt b/Zend/tests/closure_012.phpt new file mode 100644 index 0000000..7e1b7a2 --- /dev/null +++ b/Zend/tests/closure_012.phpt @@ -0,0 +1,24 @@ +--TEST-- +Closure 012: Undefined lexical variables +--FILE-- +<?php +$lambda = function () use ($i) { + return ++$i; +}; +$lambda(); +$lambda(); +var_dump($i); +$lambda = function () use (&$i) { + return ++$i; +}; +$lambda(); +$lambda(); +var_dump($i); +?> +--EXPECTF-- +Notice: Undefined variable: i in %sclosure_012.php on line 2 + +Notice: Undefined variable: i in %sclosure_012.php on line 7 +NULL +int(2) + diff --git a/Zend/tests/closure_013.phpt b/Zend/tests/closure_013.phpt new file mode 100644 index 0000000..72d2b3f --- /dev/null +++ b/Zend/tests/closure_013.phpt @@ -0,0 +1,25 @@ +--TEST-- +Closure 013: __invoke() on temporary result +--FILE-- +<?php +class Foo { + function __invoke() { + echo "Hello World!\n"; + } +} + +function foo() { + return function() { + echo "Hello World!\n"; + }; +} +$test = new Foo; +$test->__invoke(); +$test = foo(); +$test->__invoke(); +$test = foo()->__invoke(); +?> +--EXPECT-- +Hello World! +Hello World! +Hello World! diff --git a/Zend/tests/closure_014.phpt b/Zend/tests/closure_014.phpt new file mode 100644 index 0000000..9e4819b --- /dev/null +++ b/Zend/tests/closure_014.phpt @@ -0,0 +1,79 @@ +--TEST-- +Closure 014: return by value/reference +--FILE-- +<?php +class C1 { + function __invoke() { + return 0; + } +} +class C2 { + function &__invoke(&$a) { + return $a; + } +} +class C3 { + function __invoke() { + } +} + +$x = new C1(); +var_dump($x()); +var_dump($x->__invoke()); +$x(); +$x->__invoke(); +$x = function() { + return 0; +}; +var_dump($x()); +var_dump($x->__invoke()); +$x(); +$x->__invoke(); + +$x = new C2(); +$a = $b = $c = $d = 1; +$e =& $x($a); +$e = 2; +var_dump($a); +$e =& $x->__invoke($b); +$e = 3; +var_dump($b); +$x($b); +$x->__invoke($b); +$x = function & (&$a) { + return $a; +}; +$e =& $x($c); +$e = 4; +var_dump($c); +$e =& $x->__invoke($d); +$e = 5; +var_dump($d); +$x($d); +$x->__invoke($d); + +$x = new C3(); +var_dump($x()); +var_dump($x->__invoke()); +$x(); +$x->__invoke(); +$x = function() { +}; +var_dump($x()); +var_dump($x->__invoke()); +$x(); +$x->__invoke(); +?> +--EXPECT-- +int(0) +int(0) +int(0) +int(0) +int(2) +int(3) +int(4) +int(5) +NULL +NULL +NULL +NULL diff --git a/Zend/tests/closure_015.phpt b/Zend/tests/closure_015.phpt new file mode 100644 index 0000000..33c732d --- /dev/null +++ b/Zend/tests/closure_015.phpt @@ -0,0 +1,19 @@ +--TEST-- +Closure 015: converting to string/unicode +--FILE-- +<?php +set_error_handler('myErrorHandler', E_RECOVERABLE_ERROR); +function myErrorHandler($errno, $errstr, $errfile, $errline) { + echo "Error: $errstr at $errfile($errline)\n"; + return true; +} +$x = function() { return 1; }; +print (string) $x; +print "\n"; +print $x; +print "\n"; +?> +--EXPECTF-- +Error: Object of class Closure could not be converted to string at %sclosure_015.php(8) + +Error: Object of class Closure could not be converted to string at %sclosure_015.php(10) diff --git a/Zend/tests/closure_016.phpt b/Zend/tests/closure_016.phpt new file mode 100644 index 0000000..ae00365 --- /dev/null +++ b/Zend/tests/closure_016.phpt @@ -0,0 +1,51 @@ +--TEST-- +Closure 016: closures and is_callable() +--FILE-- +<?php +class Foo { + function __invoke() { + echo "Hello World!\n"; + } +} + +function foo() { + return function() { + echo "Hello World!\n"; + }; +} +$test = new Foo; +var_dump(is_callable($test, true, $name)); +echo $name."\n"; +var_dump(is_callable($test, false, $name)); +echo $name."\n"; +var_dump(is_callable(array($test,"__invoke"), true, $name)); +echo $name."\n"; +var_dump(is_callable(array($test,"__invoke"), false, $name)); +echo $name."\n"; +$test = foo(); +var_dump(is_callable($test, true, $name)); +echo $name."\n"; +var_dump(is_callable($test, false, $name)); +echo $name."\n"; +var_dump(is_callable(array($test,"__invoke"), true, $name)); +echo $name."\n"; +var_dump(is_callable(array($test,"__invoke"), false, $name)); +echo $name."\n"; +?> +--EXPECT-- +bool(true) +Foo::__invoke +bool(true) +Foo::__invoke +bool(true) +Foo::__invoke +bool(true) +Foo::__invoke +bool(true) +Closure::__invoke +bool(true) +Closure::__invoke +bool(true) +Closure::__invoke +bool(true) +Closure::__invoke diff --git a/Zend/tests/closure_017.phpt b/Zend/tests/closure_017.phpt new file mode 100644 index 0000000..45a07f9 --- /dev/null +++ b/Zend/tests/closure_017.phpt @@ -0,0 +1,12 @@ +--TEST-- +Closure 017: Trying to destroy an active lambda function +--FILE-- +<?php + +$a = function(&$a) { $a = 1; }; + +$a($a); + +?> +--EXPECTF-- +Fatal error: Cannot destroy active lambda function in %s on line %d diff --git a/Zend/tests/closure_018.phpt b/Zend/tests/closure_018.phpt new file mode 100644 index 0000000..d98c78a --- /dev/null +++ b/Zend/tests/closure_018.phpt @@ -0,0 +1,28 @@ +--TEST-- +Closure 018: Assigning lambda to static var and returning by ref +--FILE-- +<?php + +class foo { + public function test(&$x) { + static $lambda; + $lambda = function &() use (&$x) { + return $x = $x * $x; + }; + return $lambda(); + } +} + +$test = new foo; + +$y = 2; +var_dump($test->test($y)); +var_dump($x = $test->test($y)); +var_dump($y, $x); + +?> +--EXPECT-- +int(4) +int(16) +int(16) +int(16) diff --git a/Zend/tests/closure_019.phpt b/Zend/tests/closure_019.phpt new file mode 100644 index 0000000..0c4c34e --- /dev/null +++ b/Zend/tests/closure_019.phpt @@ -0,0 +1,26 @@ +--TEST-- +Closure 019: Calling lambda using $GLOBALS and global $var +--FILE-- +<?php + +$lambda = function &(&$x) { + return $x = $x * $x; +}; + +function test() { + global $lambda; + + $y = 3; + var_dump($GLOBALS['lambda']($y)); + var_dump($lambda($y)); + var_dump($GLOBALS['lambda'](1)); +} + +test(); + +?> +--EXPECTF-- +int(9) +int(81) + +Fatal error: Cannot pass parameter 1 by reference in %s on line %d diff --git a/Zend/tests/closure_020.phpt b/Zend/tests/closure_020.phpt new file mode 100644 index 0000000..bec2bed --- /dev/null +++ b/Zend/tests/closure_020.phpt @@ -0,0 +1,43 @@ +--TEST-- +Closure 020: Trying to access private property outside class +--FILE-- +<?php + +class foo { + private $test = 3; + + public function x() { + $a = &$this; + $this->a = function() use (&$a) { return $a; }; + var_dump($this->a->__invoke()); + var_dump(is_a($this->a, 'closure')); + var_dump(is_callable($this->a)); + + return $this->a; + } +} + +$foo = new foo; +$y = $foo->x(); +var_dump($y()->test); + +?> +--EXPECTF-- +object(foo)#%d (2) { + ["test":"foo":private]=> + int(3) + ["a"]=> + object(Closure)#%d (2) { + ["static"]=> + array(1) { + ["a"]=> + *RECURSION* + } + ["this"]=> + *RECURSION* + } +} +bool(true) +bool(true) + +Fatal error: Cannot access private property foo::$test in %s on line %d diff --git a/Zend/tests/closure_021.phpt b/Zend/tests/closure_021.phpt new file mode 100644 index 0000000..76be762 --- /dev/null +++ b/Zend/tests/closure_021.phpt @@ -0,0 +1,22 @@ +--TEST-- +Closure 021: Throwing exception inside lambda +--FILE-- +<?php + +$foo = function() { + try { + throw new Exception('test!'); + } catch(Exception $e) { + throw $e; + } +}; + +try { + $foo(); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +?> +--EXPECT-- +string(5) "test!" diff --git a/Zend/tests/closure_022.phpt b/Zend/tests/closure_022.phpt new file mode 100644 index 0000000..8621d2c --- /dev/null +++ b/Zend/tests/closure_022.phpt @@ -0,0 +1,12 @@ +--TEST-- +Closure 022: Closure properties +--FILE-- +<?php +$a = 0; +$foo = function() use ($a) { +}; +$foo->a = 1; +?> +--EXPECTF-- +Catchable fatal error: Closure object cannot have properties in %sclosure_022.php on line 5 + diff --git a/Zend/tests/closure_023.phpt b/Zend/tests/closure_023.phpt new file mode 100644 index 0000000..634fb6d --- /dev/null +++ b/Zend/tests/closure_023.phpt @@ -0,0 +1,14 @@ +--TEST-- +Closure 023: Closure declared in statically called method +--FILE-- +<?php +class foo { + public static function bar() { + $func = function() { echo "Done"; }; + $func(); + } +} +foo::bar(); +--EXPECT-- +Done + diff --git a/Zend/tests/closure_024.phpt b/Zend/tests/closure_024.phpt new file mode 100644 index 0000000..74083f7 --- /dev/null +++ b/Zend/tests/closure_024.phpt @@ -0,0 +1,26 @@ +--TEST-- +Closure 024: Clone the Closure object +--FILE-- +<?php + +$a = 1; +$c = function($add) use(&$a) { return $a+$add; }; + +$cc = clone $c; + +echo $c(10)."\n"; +echo $cc(10)."\n"; + +$a++; + +echo $c(10)."\n"; +echo $cc(10)."\n"; + +echo "Done.\n"; +?> +--EXPECTF-- +11 +11 +12 +12 +Done.
\ No newline at end of file diff --git a/Zend/tests/closure_025.phpt b/Zend/tests/closure_025.phpt new file mode 100644 index 0000000..8ee187e --- /dev/null +++ b/Zend/tests/closure_025.phpt @@ -0,0 +1,12 @@ +--TEST-- +Closure 025: Using closure in create_function() +--FILE-- +<?php + +$a = create_function('$x', 'return function($y) use ($x) { return $x * $y; };'); + +var_dump($a(2)->__invoke(4)); + +?> +--EXPECT-- +int(8) diff --git a/Zend/tests/closure_026.phpt b/Zend/tests/closure_026.phpt new file mode 100644 index 0000000..150cc86 --- /dev/null +++ b/Zend/tests/closure_026.phpt @@ -0,0 +1,54 @@ +--TEST-- +Closure 026: Assigning a closure object to an array in $this +--FILE-- +<?php + +class foo { + public function __construct() { + $a =& $this; + + $a->a[] = function() { + return 1; + }; + + var_dump($this); + + var_dump($this->a[0]()); + } +} + +$x = new foo; + +print "--------------\n"; + +foreach ($x as $b => $c) { + var_dump($b, $c); + var_dump($c[0]()); +} + +?> +--EXPECTF-- +object(foo)#%d (1) { + ["a"]=> + array(1) { + [0]=> + object(Closure)#%d (1) { + ["this"]=> + *RECURSION* + } + } +} +int(1) +-------------- +string(1) "a" +array(1) { + [0]=> + object(Closure)#%d (1) { + ["this"]=> + object(foo)#%d (1) { + ["a"]=> + *RECURSION* + } + } +} +int(1) diff --git a/Zend/tests/closure_027.phpt b/Zend/tests/closure_027.phpt new file mode 100644 index 0000000..f26e114 --- /dev/null +++ b/Zend/tests/closure_027.phpt @@ -0,0 +1,31 @@ +--TEST-- +Closure 027: Testing Closure type-hint +--FILE-- +<?php + +function test(closure $a) { + var_dump($a()); +} + + +test(function() { return new stdclass; }); + +test(function() { }); + +$a = function($x) use ($y) {}; +test($a); + +test(new stdclass); + +?> +--EXPECTF-- +object(stdClass)#%d (0) { +} +NULL + +Notice: Undefined variable: y in %s on line %d + +Warning: Missing argument 1 for {closure}(), called in %s on line %d and defined in %s on line %d +NULL + +Catchable fatal error: Argument 1 passed to test() must be an instance of Closure, instance of stdClass given, called in %s on line %d and defined in %s on line %d diff --git a/Zend/tests/closure_028.phpt b/Zend/tests/closure_028.phpt new file mode 100644 index 0000000..3584075 --- /dev/null +++ b/Zend/tests/closure_028.phpt @@ -0,0 +1,14 @@ +--TEST-- +Closure 028: Trying to use lambda directly in foreach +--FILE-- +<?php + +foreach (function(){ return 1; } as $y) { + var_dump($y); +} + +print "ok\n"; + +?> +--EXPECT-- +ok diff --git a/Zend/tests/closure_029.phpt b/Zend/tests/closure_029.phpt new file mode 100644 index 0000000..8d909c0 --- /dev/null +++ b/Zend/tests/closure_029.phpt @@ -0,0 +1,14 @@ +--TEST-- +Closure 029: Testing lambda with instanceof operator +--FILE-- +<?php + +var_dump(function() { } instanceof closure); +var_dump(function(&$x) { } instanceof closure); +var_dump(@function(&$x) use ($y, $z) { } instanceof closure); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/closure_030.phpt b/Zend/tests/closure_030.phpt new file mode 100644 index 0000000..318d215 --- /dev/null +++ b/Zend/tests/closure_030.phpt @@ -0,0 +1,20 @@ +--TEST-- +Closure 030: Using lambda with variable variables +--FILE-- +<?php + +$b = function() { return func_get_args(); }; +$a = 'b'; +var_dump($$a(1)); +var_dump($$a->__invoke(2)); + +?> +--EXPECT-- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(2) +} diff --git a/Zend/tests/closure_031.phpt b/Zend/tests/closure_031.phpt new file mode 100644 index 0000000..dace4a4 --- /dev/null +++ b/Zend/tests/closure_031.phpt @@ -0,0 +1,16 @@ +--TEST-- +Closure 031: Closure properties with custom error handlers +--FILE-- +<?php +function foo($errno, $errstr, $errfile, $errline) { + echo "Error: $errstr\n"; +} +set_error_handler('foo'); +$foo = function() { +}; +var_dump($foo->a); +?> +--EXPECT-- +Error: Closure object cannot have properties +NULL + diff --git a/Zend/tests/closure_032.phpt b/Zend/tests/closure_032.phpt new file mode 100644 index 0000000..412a923 --- /dev/null +++ b/Zend/tests/closure_032.phpt @@ -0,0 +1,70 @@ +--TEST-- +Closure 032: Testing Closure and debug_backtrace +--FILE-- +<?php + +function test(closure $a) { + $a(23); +} + + +$c = function($param) { print_r(debug_backtrace()); debug_print_backtrace(); }; + +$c(23); +test($c); +?> +--EXPECTF-- +Array +( + [0] => Array + ( + [file] => %s + [line] => %d + [function] => {closure} + [args] => Array + ( + [0] => 23 + ) + + ) + +) +#0 {closure}(23) called at [%s:%d] +Array +( + [0] => Array + ( + [file] => %s + [line] => %d + [function] => {closure} + [args] => Array + ( + [0] => 23 + ) + + ) + + [1] => Array + ( + [file] => %s + [line] => %d + [function] => test + [args] => Array + ( + [0] => Closure Object + ( + [parameter] => Array + ( + [$param] => <required> + ) + + ) + + ) + + ) + +) +#0 {closure}(23) called at [%s:%d] +#1 test(Closure Object ()) called at [%s:%d] + diff --git a/Zend/tests/closure_033.phpt b/Zend/tests/closure_033.phpt new file mode 100644 index 0000000..f651006 --- /dev/null +++ b/Zend/tests/closure_033.phpt @@ -0,0 +1,28 @@ +--TEST-- +Closure 033: Dynamic closure property and private function +--FILE-- +<?php + +class Test { + public $func; + function __construct() { + $this->func = function() { + echo __METHOD__ . "()\n"; + }; + } + private function func() { + echo __METHOD__ . "()\n"; + } +} + +$o = new Test; +$f = $o->func; +$f(); +$o->func(); + +?> +===DONE=== +--EXPECTF-- +Test::{closure}() + +Fatal error: Call to private method Test::func() from context '' in %sclosure_033.php on line %d diff --git a/Zend/tests/closure_034.phpt b/Zend/tests/closure_034.phpt new file mode 100644 index 0000000..8ba276a --- /dev/null +++ b/Zend/tests/closure_034.phpt @@ -0,0 +1,19 @@ +--TEST-- +Closure 033: Recursive var_dump on closures +--FILE-- +<?php + +$a = function () use(&$a) {}; +var_dump($a); + +?> +===DONE=== +--EXPECTF-- +object(Closure)#%d (1) { + ["static"]=> + array(1) { + ["a"]=> + *RECURSION* + } +} +===DONE=== diff --git a/Zend/tests/closure_035.phpt b/Zend/tests/closure_035.phpt new file mode 100644 index 0000000..e39a991 --- /dev/null +++ b/Zend/tests/closure_035.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing recursion detection with Closures +--FILE-- +<?php + +$x = function () use (&$x) { + $h = function () use ($x) { + var_dump($x); + return 1; + }; + return $h(); +}; + +var_dump($x()); + +?> +--EXPECTF-- +object(Closure)#%d (1) { + ["static"]=> + array(1) { + ["x"]=> + *RECURSION* + } +} +int(1) diff --git a/Zend/tests/closure_036.phpt b/Zend/tests/closure_036.phpt new file mode 100644 index 0000000..77d7ce6 --- /dev/null +++ b/Zend/tests/closure_036.phpt @@ -0,0 +1,33 @@ +--TEST-- +Closure 036: Rebinding closures, keep calling scope +--FILE-- +<?php + +class A { + private $x; + + public function __construct($v) { + $this->x = $v; + } + + public function getIncrementor() { + return function() { return ++$this->x; }; + } +} + +$a = new A(0); +$b = new A(10); + +$ca = $a->getIncrementor(); +$cb = $ca->bindTo($b); +$cb2 = Closure::bind($ca, $b); + +var_dump($ca()); +var_dump($cb()); +var_dump($cb2()); + +?> +--EXPECTF-- +int(1) +int(11) +int(12)
\ No newline at end of file diff --git a/Zend/tests/closure_037.phpt b/Zend/tests/closure_037.phpt new file mode 100644 index 0000000..4b24c85 --- /dev/null +++ b/Zend/tests/closure_037.phpt @@ -0,0 +1,47 @@ +--TEST-- +Closure 037: self:: and static:: within closures +--FILE-- +<?php +class A { + private $x = 0; + + function getClosure () { + return function () { + $this->x++; + self::printX(); + self::print42(); + static::print42(); + }; + } + + function printX () { + echo $this->x."\n"; + } + + function print42() { + echo "42\n"; + } +} + +class B extends A { + function print42() { + echo "forty two\n"; + } +} + +$a = new A; +$closure = $a->getClosure(); +$closure(); +$b = new B; +$closure = $b->getClosure(); +$closure(); +?> +Done. +--EXPECTF-- +1 +42 +42 +1 +42 +forty two +Done.
\ No newline at end of file diff --git a/Zend/tests/closure_038.phpt b/Zend/tests/closure_038.phpt new file mode 100644 index 0000000..fef0734 --- /dev/null +++ b/Zend/tests/closure_038.phpt @@ -0,0 +1,58 @@ +--TEST-- +Closure 038: Rebinding closures, change scope, different runtime type +--FILE-- +<?php + +class A { + private $x; + + public function __construct($v) { + $this->x = $v; + } + + public function getIncrementor() { + return function() { return ++$this->x; }; + } +} +class B extends A { + private $x; + public function __construct($v) { + parent::__construct($v); + $this->x = $v*2; + } +} + +$a = new A(0); +$b = new B(10); + +$ca = $a->getIncrementor(); +var_dump($ca()); + +echo "Testing with scope given as object", "\n"; + +$cb = $ca->bindTo($b, $b); +$cb2 = Closure::bind($ca, $b, $b); +var_dump($cb()); +var_dump($cb2()); + +echo "Testing with scope as string", "\n"; + +$cb = $ca->bindTo($b, 'B'); +$cb2 = Closure::bind($ca, $b, 'B'); +var_dump($cb()); +var_dump($cb2()); + +$cb = $ca->bindTo($b, NULL); +var_dump($cb()); + +?> +--EXPECTF-- +int(1) +Testing with scope given as object +int(21) +int(22) +Testing with scope as string +int(23) +int(24) + +Fatal error: Cannot access private property B::$x in %s on line %d diff --git a/Zend/tests/closure_039.phpt b/Zend/tests/closure_039.phpt new file mode 100644 index 0000000..c6a727c --- /dev/null +++ b/Zend/tests/closure_039.phpt @@ -0,0 +1,58 @@ +--TEST-- +Closure 039: Rebinding closures, change scope, same runtime type +--FILE-- +<?php + +class A { + private $x; + + public function __construct($v) { + $this->x = $v; + } + + public function getIncrementor() { + return function() { return ++$this->x; }; + } +} +class B extends A { + private $x; + public function __construct($v) { + parent::__construct($v); + $this->x = $v*2; + } +} + +$a = new B(-5); +$b = new B(10); + +$ca = $a->getIncrementor(); +var_dump($ca()); + +echo "Testing with scope given as object", "\n"; + +$cb = $ca->bindTo($b, $b); +$cb2 = Closure::bind($ca, $b, $b); +var_dump($cb()); +var_dump($cb2()); + +echo "Testing with scope as string", "\n"; + +$cb = $ca->bindTo($b, 'B'); +$cb2 = Closure::bind($ca, $b, 'B'); +var_dump($cb()); +var_dump($cb2()); + +$cb = $ca->bindTo($b, NULL); +var_dump($cb()); + +?> +--EXPECTF-- +int(-4) +Testing with scope given as object +int(21) +int(22) +Testing with scope as string +int(23) +int(24) + +Fatal error: Cannot access private property B::$x in %s on line %d diff --git a/Zend/tests/closure_040.phpt b/Zend/tests/closure_040.phpt new file mode 100644 index 0000000..a1b6cd6 --- /dev/null +++ b/Zend/tests/closure_040.phpt @@ -0,0 +1,45 @@ +--TEST-- +Closure 040: Rebinding closures, bad arguments +--FILE-- +<?php + +class A { + private $x; + private static $xs = 10; + + public function __construct($v) { + $this->x = $v; + } + + public function getIncrementor() { + return function() { return ++$this->x; }; + } + public function getStaticIncrementor() { + return static function() { return ++static::$xs; }; + } +} + +$a = new A(20); + +$ca = $a->getIncrementor(); +$cas = $a->getStaticIncrementor(); + +$ca->bindTo($a, array()); +$ca->bindTo(array(), 'A'); +$ca->bindTo($a, array(), ""); +$ca->bindTo(); +$cas->bindTo($a, 'A'); + +?> +--EXPECTF-- +Notice: Array to string conversion in %s on line %d + +Warning: Class 'Array' not found in %s on line %d + +Warning: Closure::bindTo() expects parameter 1 to be object, array given in %s on line 25 + +Warning: Closure::bindTo() expects at most 2 parameters, 3 given in %s on line %d + +Warning: Closure::bindTo() expects at least 1 parameter, 0 given in %s on line %d + +Warning: Cannot bind an instance to a static closure in %s on line %d diff --git a/Zend/tests/closure_041.phpt b/Zend/tests/closure_041.phpt new file mode 100644 index 0000000..79cf9f3 --- /dev/null +++ b/Zend/tests/closure_041.phpt @@ -0,0 +1,106 @@ +--TEST-- +Closure 041: Rebinding: preservation of previous scope when not given as arg unless impossible +--FILE-- +<?php + +/* It's impossible to preserve the previous scope when doing so would break + * the invariants that, for non-static closures, having a scope is equivalent + * to having a bound instance. */ + +$staticUnscoped = static function () { + echo "scoped to A: "; var_dump(isset(A::$priv)); + echo "bound: ", isset($this)?get_class($this):"no"; +}; + +$nonstaticUnscoped = function () { + echo "scoped to A: "; var_dump(isset(A::$priv)); + echo "bound: ", isset($this)?get_class($this):"no"; +}; + +class A { + private static $priv = 7; + function getClosure() { + return function () { + echo "scoped to A: "; var_dump(isset(A::$priv)); + echo "bound: ", isset($this)?get_class($this):"no"; + }; + } + function getStaticClosure() { + return static function () { + echo "scoped to A: "; var_dump(isset(A::$priv)); + echo "bound: ", isset($this)?get_class($this):"no"; + }; + } +} +class B extends A {} + +$a = new A(); +$staticScoped = $a->getStaticClosure(); +$nonstaticScoped = $a->getClosure(); + +echo "Before binding", "\n"; +$staticUnscoped(); echo "\n"; +$nonstaticUnscoped(); echo "\n"; +$staticScoped(); echo "\n"; +$nonstaticScoped(); echo "\n"; + +echo "After binding, no instance", "\n"; +$d = $staticUnscoped->bindTo(null); $d(); echo "\n"; +$d = $nonstaticUnscoped->bindTo(null); $d(); echo "\n"; +$d = $staticScoped->bindTo(null); $d(); echo "\n"; +$d = $nonstaticScoped->bindTo(null); $d(); echo "\n"; +//$d should have been turned to static +$d->bindTo($d); + +echo "After binding, with same-class instance for the bound ones", "\n"; +$d = $staticUnscoped->bindTo(new A); $d(); echo "\n"; +$d = $nonstaticUnscoped->bindTo(new A); $d(); echo " (should be scoped to dummy class)\n"; +$d = $staticScoped->bindTo(new A); $d(); echo "\n"; +$d = $nonstaticScoped->bindTo(new A); $d(); echo "\n"; + +echo "After binding, with different instance for the bound ones", "\n"; +$d = $nonstaticUnscoped->bindTo(new B); $d(); echo " (should be scoped to dummy class)\n"; +$d = $nonstaticScoped->bindTo(new B); $d(); echo "\n"; + +echo "Done.\n"; + +--EXPECTF-- +Before binding +scoped to A: bool(false) +bound: no +scoped to A: bool(false) +bound: no +scoped to A: bool(true) +bound: no +scoped to A: bool(true) +bound: A +After binding, no instance +scoped to A: bool(false) +bound: no +scoped to A: bool(false) +bound: no +scoped to A: bool(true) +bound: no +scoped to A: bool(true) +bound: no + +Warning: Cannot bind an instance to a static closure in %s on line %d +After binding, with same-class instance for the bound ones + +Warning: Cannot bind an instance to a static closure in %s on line %d +scoped to A: bool(false) +bound: no +scoped to A: bool(false) +bound: A (should be scoped to dummy class) + +Warning: Cannot bind an instance to a static closure in %s on line %d +scoped to A: bool(true) +bound: no +scoped to A: bool(true) +bound: A +After binding, with different instance for the bound ones +scoped to A: bool(false) +bound: B (should be scoped to dummy class) +scoped to A: bool(true) +bound: B +Done.
\ No newline at end of file diff --git a/Zend/tests/closure_042.phpt b/Zend/tests/closure_042.phpt new file mode 100644 index 0000000..8969765 --- /dev/null +++ b/Zend/tests/closure_042.phpt @@ -0,0 +1,29 @@ +--TEST-- +Closure 042: Binding an instance to a non-scoped non-static closures gives it a dummy scope +--SKIPIF-- +<?php if(!extension_loaded("reflection")) print "skip no reflection"; ?> +--FILE-- +<?php + +$c = function() { var_dump($this); }; +$d = $c->bindTo(new stdClass); +$d(); +$rm = new ReflectionFunction($d); +var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure + +//should have the same effect +$d = $c->bindTo(new stdClass, NULL); +$d(); +$rm = new ReflectionFunction($d); +var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure + +echo "Done.\n"; + +--EXPECTF-- +object(stdClass)#%d (0) { +} +string(7) "Closure" +object(stdClass)#%d (0) { +} +string(7) "Closure" +Done. diff --git a/Zend/tests/closure_043.phpt b/Zend/tests/closure_043.phpt new file mode 100644 index 0000000..98c88fd --- /dev/null +++ b/Zend/tests/closure_043.phpt @@ -0,0 +1,86 @@ +--TEST-- +Closure 043: Scope/bounding combination invariants; static closures +--FILE-- +<?php +/* Whether it's scoped or not, a static closure cannot have + * a bound instance. It should also not be automatically converted + * to a non-static instance when attempting to bind one */ + +$staticUnscoped = static function () { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + +class A { + private static $priv = 7; + static function getStaticClosure() { + return static function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + } +} + +$staticScoped = A::getStaticClosure(); + +echo "Before binding", "\n"; +$staticUnscoped(); echo "\n"; +$staticScoped(); echo "\n"; + +echo "After binding, null scope, no instance", "\n"; +$d = $staticUnscoped->bindTo(null, null); $d(); echo "\n"; +$d = $staticScoped->bindTo(null, null); $d(); echo "\n"; + +echo "After binding, null scope, with instance", "\n"; +$d = $staticUnscoped->bindTo(new A, null); $d(); echo "\n"; +$d = $staticScoped->bindTo(new A, null); $d(); echo "\n"; + +echo "After binding, with scope, no instance", "\n"; +$d = $staticUnscoped->bindTo(null, 'A'); $d(); echo "\n"; +$d = $staticScoped->bindTo(null, 'A'); $d(); echo "\n"; + +echo "After binding, with scope, with instance", "\n"; +$d = $staticUnscoped->bindTo(new A, 'A'); $d(); echo "\n"; +$d = $staticScoped->bindTo(new A, 'A'); $d(); echo "\n"; + +echo "Done.\n"; + +--EXPECTF-- +Before binding +bool(false) +bool(false) + +bool(true) +bool(false) + +After binding, null scope, no instance +bool(false) +bool(false) + +bool(false) +bool(false) + +After binding, null scope, with instance + +Warning: Cannot bind an instance to a static closure in %s on line %d +bool(false) +bool(false) + + +Warning: Cannot bind an instance to a static closure in %s on line %d +bool(false) +bool(false) + +After binding, with scope, no instance +bool(true) +bool(false) + +bool(true) +bool(false) + +After binding, with scope, with instance + +Warning: Cannot bind an instance to a static closure in %s on line %d +bool(true) +bool(false) + + +Warning: Cannot bind an instance to a static closure in %s on line %d +bool(true) +bool(false) + +Done. diff --git a/Zend/tests/closure_044.phpt b/Zend/tests/closure_044.phpt new file mode 100644 index 0000000..d2644c0 --- /dev/null +++ b/Zend/tests/closure_044.phpt @@ -0,0 +1,78 @@ +--TEST-- +Closure 044: Scope/bounding combination invariants; non static closures +--FILE-- +<?php +/* A non-static closure has a bound instance if it has a scope + * and does't have an instance if it has no scope */ + +$nonstaticUnscoped = function () { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + +class A { + private static $priv = 7; + function getClosure() { + return function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + } +} + +$a = new A(); +$nonstaticScoped = $a->getClosure(); + +echo "Before binding", "\n"; +$nonstaticUnscoped(); echo "\n"; +$nonstaticScoped(); echo "\n"; + +echo "After binding, null scope, no instance", "\n"; +$d = $nonstaticUnscoped->bindTo(null, null); $d(); echo "\n"; +$d = $nonstaticScoped->bindTo(null, null); $d(); echo "\n"; + +echo "After binding, null scope, with instance", "\n"; +$d = $nonstaticUnscoped->bindTo(new A, null); $d(); echo "\n"; +$d = $nonstaticScoped->bindTo(new A, null); $d(); echo "\n"; + +echo "After binding, with scope, no instance", "\n"; +$d = $nonstaticUnscoped->bindTo(null, 'A'); $d(); echo "\n"; +$d = $nonstaticScoped->bindTo(null, 'A'); $d(); echo "\n"; + +echo "After binding, with scope, with instance", "\n"; +$d = $nonstaticUnscoped->bindTo(new A, 'A'); $d(); echo "\n"; +$d = $nonstaticScoped->bindTo(new A, 'A'); $d(); echo "\n"; + +echo "Done.\n"; + +--EXPECTF-- +Before binding +bool(false) +bool(false) + +bool(true) +bool(true) + +After binding, null scope, no instance +bool(false) +bool(false) + +bool(false) +bool(false) + +After binding, null scope, with instance +bool(false) +bool(true) + +bool(false) +bool(true) + +After binding, with scope, no instance +bool(true) +bool(false) + +bool(true) +bool(false) + +After binding, with scope, with instance +bool(true) +bool(true) + +bool(true) +bool(true) + +Done. diff --git a/Zend/tests/closure_045.phpt b/Zend/tests/closure_045.phpt new file mode 100644 index 0000000..4115691 --- /dev/null +++ b/Zend/tests/closure_045.phpt @@ -0,0 +1,19 @@ +--TEST-- +Closure 045: Closures created in static methods are static, even without the keyword +--FILE-- +<?php + +class A { +static function foo() { + return function () {}; +} +} + +$a = A::foo(); +$a->bindTo(new A); + +echo "Done.\n"; + +--EXPECTF-- +Warning: Cannot bind an instance to a static closure in %s on line %d +Done. diff --git a/Zend/tests/closure_046.phpt b/Zend/tests/closure_046.phpt new file mode 100644 index 0000000..30a9d3e --- /dev/null +++ b/Zend/tests/closure_046.phpt @@ -0,0 +1,70 @@ +--TEST-- +Closure 046: Rebinding: preservation of previous scope when "static" given as scope arg (same as closure #041) +--FILE-- +<?php + +/* It's impossible to preserve the previous scope when doing so would break + * the invariants that, for non-static closures, having a scope is equivalent + * to having a bound instance. */ + +$nonstaticUnscoped = function () { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + +class A { + private static $priv = 7; + function getClosure() { + return function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + } +} +class B extends A {} + +$a = new A(); +$nonstaticScoped = $a->getClosure(); + +echo "Before binding", "\n"; +$nonstaticUnscoped(); echo "\n"; +$nonstaticScoped(); echo "\n"; + +echo "After binding, no instance", "\n"; +$d = $nonstaticUnscoped->bindTo(null, "static"); $d(); echo "\n"; +$d = $nonstaticScoped->bindTo(null, "static"); $d(); echo "\n"; +//$d should have been turned to static +$d->bindTo($d); + +echo "After binding, with same-class instance for the bound one", "\n"; +$d = $nonstaticUnscoped->bindTo(new A, "static"); $d(); echo "\n"; +$d = $nonstaticScoped->bindTo(new A, "static"); $d(); echo "\n"; + +echo "After binding, with different instance for the bound one", "\n"; +$d = $nonstaticScoped->bindTo(new B, "static"); $d(); echo "\n"; + +echo "Done.\n"; + +--EXPECTF-- +Before binding +bool(false) +bool(false) + +bool(true) +bool(true) + +After binding, no instance +bool(false) +bool(false) + +bool(true) +bool(false) + + +Warning: Cannot bind an instance to a static closure in %s on line %d +After binding, with same-class instance for the bound one +bool(false) +bool(true) + +bool(true) +bool(true) + +After binding, with different instance for the bound one +bool(true) +bool(true) + +Done. diff --git a/Zend/tests/compare_001.phpt b/Zend/tests/compare_001.phpt new file mode 100644 index 0000000..1d42c63 --- /dev/null +++ b/Zend/tests/compare_001.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables for equality +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var == $a[$i]) ? " == " : " != "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} == array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} == bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != object(stdClass)#1 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != object(stdClass)#2 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != object(test)#3 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != int(-2147483648) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(11) "-2147483648" +string(0) "" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" == string(0) "" +string(0) "" != int(1) +string(0) "" != float(2.5) +string(0) "" == int(0) +string(0) "" != string(6) "string" +string(0) "" != string(3) "123" +string(0) "" != string(3) "2.5" +string(0) "" == NULL +string(0) "" != bool(true) +string(0) "" == bool(false) +string(0) "" != object(stdClass)#1 (0) {} +string(0) "" != object(stdClass)#2 (0) {} +string(0) "" != object(test)#3 (0) {} +string(0) "" != array(0) {} +string(0) "" != int(-2147483648) +string(0) "" != string(11) "-2147483648" +int(1) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) != string(0) "" +int(1) == int(1) +int(1) != float(2.5) +int(1) != int(0) +int(1) != string(6) "string" +int(1) != string(3) "123" +int(1) != string(3) "2.5" +int(1) != NULL +int(1) == bool(true) +int(1) != bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + == object(stdClass)#1 (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + == object(stdClass)#2 (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + == object(test)#3 (0) {} +int(1) != array(0) {} +int(1) != int(-2147483648) +int(1) != string(11) "-2147483648" +float(2.5) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) != string(0) "" +float(2.5) != int(1) +float(2.5) == float(2.5) +float(2.5) != int(0) +float(2.5) != string(6) "string" +float(2.5) != string(3) "123" +float(2.5) == string(3) "2.5" +float(2.5) != NULL +float(2.5) == bool(true) +float(2.5) != bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + != object(stdClass)#1 (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + != object(stdClass)#2 (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + != object(test)#3 (0) {} +float(2.5) != array(0) {} +float(2.5) != int(-2147483648) +float(2.5) != string(11) "-2147483648" +int(0) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) == string(0) "" +int(0) != int(1) +int(0) != float(2.5) +int(0) == int(0) +int(0) == string(6) "string" +int(0) != string(3) "123" +int(0) != string(3) "2.5" +int(0) == NULL +int(0) != bool(true) +int(0) == bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + != object(stdClass)#1 (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + != object(stdClass)#2 (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + != object(test)#3 (0) {} +int(0) != array(0) {} +int(0) != int(-2147483648) +int(0) != string(11) "-2147483648" +string(6) "string" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" != string(0) "" +string(6) "string" != int(1) +string(6) "string" != float(2.5) +string(6) "string" == int(0) +string(6) "string" == string(6) "string" +string(6) "string" != string(3) "123" +string(6) "string" != string(3) "2.5" +string(6) "string" != NULL +string(6) "string" == bool(true) +string(6) "string" != bool(false) +string(6) "string" != object(stdClass)#1 (0) {} +string(6) "string" != object(stdClass)#2 (0) {} +string(6) "string" != object(test)#3 (0) {} +string(6) "string" != array(0) {} +string(6) "string" != int(-2147483648) +string(6) "string" != string(11) "-2147483648" +string(3) "123" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" != string(0) "" +string(3) "123" != int(1) +string(3) "123" != float(2.5) +string(3) "123" != int(0) +string(3) "123" != string(6) "string" +string(3) "123" == string(3) "123" +string(3) "123" != string(3) "2.5" +string(3) "123" != NULL +string(3) "123" == bool(true) +string(3) "123" != bool(false) +string(3) "123" != object(stdClass)#1 (0) {} +string(3) "123" != object(stdClass)#2 (0) {} +string(3) "123" != object(test)#3 (0) {} +string(3) "123" != array(0) {} +string(3) "123" != int(-2147483648) +string(3) "123" != string(11) "-2147483648" +string(3) "2.5" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" != string(0) "" +string(3) "2.5" != int(1) +string(3) "2.5" == float(2.5) +string(3) "2.5" != int(0) +string(3) "2.5" != string(6) "string" +string(3) "2.5" != string(3) "123" +string(3) "2.5" == string(3) "2.5" +string(3) "2.5" != NULL +string(3) "2.5" == bool(true) +string(3) "2.5" != bool(false) +string(3) "2.5" != object(stdClass)#1 (0) {} +string(3) "2.5" != object(stdClass)#2 (0) {} +string(3) "2.5" != object(test)#3 (0) {} +string(3) "2.5" != array(0) {} +string(3) "2.5" != int(-2147483648) +string(3) "2.5" != string(11) "-2147483648" +NULL != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL == string(0) "" +NULL != int(1) +NULL != float(2.5) +NULL == int(0) +NULL != string(6) "string" +NULL != string(3) "123" +NULL != string(3) "2.5" +NULL == NULL +NULL != bool(true) +NULL == bool(false) +NULL != object(stdClass)#1 (0) {} +NULL != object(stdClass)#2 (0) {} +NULL != object(test)#3 (0) {} +NULL == array(0) {} +NULL != int(-2147483648) +NULL != string(11) "-2147483648" +bool(true) == array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) != string(0) "" +bool(true) == int(1) +bool(true) == float(2.5) +bool(true) != int(0) +bool(true) == string(6) "string" +bool(true) == string(3) "123" +bool(true) == string(3) "2.5" +bool(true) != NULL +bool(true) == bool(true) +bool(true) != bool(false) +bool(true) == object(stdClass)#1 (0) {} +bool(true) == object(stdClass)#2 (0) {} +bool(true) == object(test)#3 (0) {} +bool(true) != array(0) {} +bool(true) == int(-2147483648) +bool(true) == string(11) "-2147483648" +bool(false) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) == string(0) "" +bool(false) != int(1) +bool(false) != float(2.5) +bool(false) == int(0) +bool(false) != string(6) "string" +bool(false) != string(3) "123" +bool(false) != string(3) "2.5" +bool(false) == NULL +bool(false) != bool(true) +bool(false) == bool(false) +bool(false) != object(stdClass)#1 (0) {} +bool(false) != object(stdClass)#2 (0) {} +bool(false) != object(test)#3 (0) {} +bool(false) == array(0) {} +bool(false) != int(-2147483648) +bool(false) != string(11) "-2147483648" +object(stdClass)#1 (0) {} != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#1 (0) {} != string(0) "" +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + == int(1) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + != float(2.5) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + != int(0) +object(stdClass)#1 (0) {} != string(6) "string" +object(stdClass)#1 (0) {} != string(3) "123" +object(stdClass)#1 (0) {} != string(3) "2.5" +object(stdClass)#1 (0) {} != NULL +object(stdClass)#1 (0) {} == bool(true) +object(stdClass)#1 (0) {} != bool(false) +object(stdClass)#1 (0) {} == object(stdClass)#1 (0) {} +object(stdClass)#1 (0) {} == object(stdClass)#2 (0) {} +object(stdClass)#1 (0) {} != object(test)#3 (0) {} +object(stdClass)#1 (0) {} != array(0) {} +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + != int(-2147483648) +object(stdClass)#1 (0) {} != string(11) "-2147483648" +object(stdClass)#2 (0) {} != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#2 (0) {} != string(0) "" +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + == int(1) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + != float(2.5) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + != int(0) +object(stdClass)#2 (0) {} != string(6) "string" +object(stdClass)#2 (0) {} != string(3) "123" +object(stdClass)#2 (0) {} != string(3) "2.5" +object(stdClass)#2 (0) {} != NULL +object(stdClass)#2 (0) {} == bool(true) +object(stdClass)#2 (0) {} != bool(false) +object(stdClass)#2 (0) {} == object(stdClass)#1 (0) {} +object(stdClass)#2 (0) {} == object(stdClass)#2 (0) {} +object(stdClass)#2 (0) {} != object(test)#3 (0) {} +object(stdClass)#2 (0) {} != array(0) {} +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + != int(-2147483648) +object(stdClass)#2 (0) {} != string(11) "-2147483648" +object(test)#3 (0) {} != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#3 (0) {} != string(0) "" +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + == int(1) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + != float(2.5) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + != int(0) +object(test)#3 (0) {} != string(6) "string" +object(test)#3 (0) {} != string(3) "123" +object(test)#3 (0) {} != string(3) "2.5" +object(test)#3 (0) {} != NULL +object(test)#3 (0) {} == bool(true) +object(test)#3 (0) {} != bool(false) +object(test)#3 (0) {} != object(stdClass)#1 (0) {} +object(test)#3 (0) {} != object(stdClass)#2 (0) {} +object(test)#3 (0) {} == object(test)#3 (0) {} +object(test)#3 (0) {} != array(0) {} +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + != int(-2147483648) +object(test)#3 (0) {} != string(11) "-2147483648" +array(0) {} != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} != string(0) "" +array(0) {} != int(1) +array(0) {} != float(2.5) +array(0) {} != int(0) +array(0) {} != string(6) "string" +array(0) {} != string(3) "123" +array(0) {} != string(3) "2.5" +array(0) {} == NULL +array(0) {} != bool(true) +array(0) {} == bool(false) +array(0) {} != object(stdClass)#1 (0) {} +array(0) {} != object(stdClass)#2 (0) {} +array(0) {} != object(test)#3 (0) {} +array(0) {} == array(0) {} +array(0) {} != int(-2147483648) +array(0) {} != string(11) "-2147483648" +int(-2147483648) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-2147483648) != string(0) "" +int(-2147483648) != int(1) +int(-2147483648) != float(2.5) +int(-2147483648) != int(0) +int(-2147483648) != string(6) "string" +int(-2147483648) != string(3) "123" +int(-2147483648) != string(3) "2.5" +int(-2147483648) != NULL +int(-2147483648) == bool(true) +int(-2147483648) != bool(false) +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + != object(stdClass)#1 (0) {} +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + != object(stdClass)#2 (0) {} +int(-2147483648) +Notice: Object of class test could not be converted to int in %s on line %d + != object(test)#3 (0) {} +int(-2147483648) != array(0) {} +int(-2147483648) == int(-2147483648) +int(-2147483648) == string(11) "-2147483648" +string(11) "-2147483648" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(11) "-2147483648" != string(0) "" +string(11) "-2147483648" != int(1) +string(11) "-2147483648" != float(2.5) +string(11) "-2147483648" != int(0) +string(11) "-2147483648" != string(6) "string" +string(11) "-2147483648" != string(3) "123" +string(11) "-2147483648" != string(3) "2.5" +string(11) "-2147483648" != NULL +string(11) "-2147483648" == bool(true) +string(11) "-2147483648" != bool(false) +string(11) "-2147483648" != object(stdClass)#1 (0) {} +string(11) "-2147483648" != object(stdClass)#2 (0) {} +string(11) "-2147483648" != object(test)#3 (0) {} +string(11) "-2147483648" != array(0) {} +string(11) "-2147483648" == int(-2147483648) +string(11) "-2147483648" == string(11) "-2147483648" +Done diff --git a/Zend/tests/compare_001_64bit.phpt b/Zend/tests/compare_001_64bit.phpt new file mode 100644 index 0000000..bc57d0f --- /dev/null +++ b/Zend/tests/compare_001_64bit.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables for equality +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var == $a[$i]) ? " == " : " != "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} == array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} == bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != object(test)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != int(-9223372036854775808) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} != string(20) "-9223372036854775808" +string(0) "" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" == string(0) "" +string(0) "" != int(1) +string(0) "" != float(2.5) +string(0) "" == int(0) +string(0) "" != string(6) "string" +string(0) "" != string(3) "123" +string(0) "" != string(3) "2.5" +string(0) "" == NULL +string(0) "" != bool(true) +string(0) "" == bool(false) +string(0) "" != object(stdClass)#%d (0) {} +string(0) "" != object(stdClass)#%d (0) {} +string(0) "" != object(test)#%d (0) {} +string(0) "" != array(0) {} +string(0) "" != int(-9223372036854775808) +string(0) "" != string(20) "-9223372036854775808" +int(1) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) != string(0) "" +int(1) == int(1) +int(1) != float(2.5) +int(1) != int(0) +int(1) != string(6) "string" +int(1) != string(3) "123" +int(1) != string(3) "2.5" +int(1) != NULL +int(1) == bool(true) +int(1) != bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + == object(stdClass)#%d (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + == object(stdClass)#%d (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + == object(test)#%d (0) {} +int(1) != array(0) {} +int(1) != int(-9223372036854775808) +int(1) != string(20) "-9223372036854775808" +float(2.5) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) != string(0) "" +float(2.5) != int(1) +float(2.5) == float(2.5) +float(2.5) != int(0) +float(2.5) != string(6) "string" +float(2.5) != string(3) "123" +float(2.5) == string(3) "2.5" +float(2.5) != NULL +float(2.5) == bool(true) +float(2.5) != bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + != object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + != object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + != object(test)#%d (0) {} +float(2.5) != array(0) {} +float(2.5) != int(-9223372036854775808) +float(2.5) != string(20) "-9223372036854775808" +int(0) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) == string(0) "" +int(0) != int(1) +int(0) != float(2.5) +int(0) == int(0) +int(0) == string(6) "string" +int(0) != string(3) "123" +int(0) != string(3) "2.5" +int(0) == NULL +int(0) != bool(true) +int(0) == bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + != object(stdClass)#%d (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + != object(stdClass)#%d (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + != object(test)#%d (0) {} +int(0) != array(0) {} +int(0) != int(-9223372036854775808) +int(0) != string(20) "-9223372036854775808" +string(6) "string" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" != string(0) "" +string(6) "string" != int(1) +string(6) "string" != float(2.5) +string(6) "string" == int(0) +string(6) "string" == string(6) "string" +string(6) "string" != string(3) "123" +string(6) "string" != string(3) "2.5" +string(6) "string" != NULL +string(6) "string" == bool(true) +string(6) "string" != bool(false) +string(6) "string" != object(stdClass)#%d (0) {} +string(6) "string" != object(stdClass)#%d (0) {} +string(6) "string" != object(test)#%d (0) {} +string(6) "string" != array(0) {} +string(6) "string" != int(-9223372036854775808) +string(6) "string" != string(20) "-9223372036854775808" +string(3) "123" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" != string(0) "" +string(3) "123" != int(1) +string(3) "123" != float(2.5) +string(3) "123" != int(0) +string(3) "123" != string(6) "string" +string(3) "123" == string(3) "123" +string(3) "123" != string(3) "2.5" +string(3) "123" != NULL +string(3) "123" == bool(true) +string(3) "123" != bool(false) +string(3) "123" != object(stdClass)#%d (0) {} +string(3) "123" != object(stdClass)#%d (0) {} +string(3) "123" != object(test)#%d (0) {} +string(3) "123" != array(0) {} +string(3) "123" != int(-9223372036854775808) +string(3) "123" != string(20) "-9223372036854775808" +string(3) "2.5" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" != string(0) "" +string(3) "2.5" != int(1) +string(3) "2.5" == float(2.5) +string(3) "2.5" != int(0) +string(3) "2.5" != string(6) "string" +string(3) "2.5" != string(3) "123" +string(3) "2.5" == string(3) "2.5" +string(3) "2.5" != NULL +string(3) "2.5" == bool(true) +string(3) "2.5" != bool(false) +string(3) "2.5" != object(stdClass)#%d (0) {} +string(3) "2.5" != object(stdClass)#%d (0) {} +string(3) "2.5" != object(test)#%d (0) {} +string(3) "2.5" != array(0) {} +string(3) "2.5" != int(-9223372036854775808) +string(3) "2.5" != string(20) "-9223372036854775808" +NULL != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL == string(0) "" +NULL != int(1) +NULL != float(2.5) +NULL == int(0) +NULL != string(6) "string" +NULL != string(3) "123" +NULL != string(3) "2.5" +NULL == NULL +NULL != bool(true) +NULL == bool(false) +NULL != object(stdClass)#%d (0) {} +NULL != object(stdClass)#%d (0) {} +NULL != object(test)#%d (0) {} +NULL == array(0) {} +NULL != int(-9223372036854775808) +NULL != string(20) "-9223372036854775808" +bool(true) == array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) != string(0) "" +bool(true) == int(1) +bool(true) == float(2.5) +bool(true) != int(0) +bool(true) == string(6) "string" +bool(true) == string(3) "123" +bool(true) == string(3) "2.5" +bool(true) != NULL +bool(true) == bool(true) +bool(true) != bool(false) +bool(true) == object(stdClass)#%d (0) {} +bool(true) == object(stdClass)#%d (0) {} +bool(true) == object(test)#%d (0) {} +bool(true) != array(0) {} +bool(true) == int(-9223372036854775808) +bool(true) == string(20) "-9223372036854775808" +bool(false) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) == string(0) "" +bool(false) != int(1) +bool(false) != float(2.5) +bool(false) == int(0) +bool(false) != string(6) "string" +bool(false) != string(3) "123" +bool(false) != string(3) "2.5" +bool(false) == NULL +bool(false) != bool(true) +bool(false) == bool(false) +bool(false) != object(stdClass)#%d (0) {} +bool(false) != object(stdClass)#%d (0) {} +bool(false) != object(test)#%d (0) {} +bool(false) == array(0) {} +bool(false) != int(-9223372036854775808) +bool(false) != string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} != string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + == int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + != float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + != int(0) +object(stdClass)#%d (0) {} != string(6) "string" +object(stdClass)#%d (0) {} != string(3) "123" +object(stdClass)#%d (0) {} != string(3) "2.5" +object(stdClass)#%d (0) {} != NULL +object(stdClass)#%d (0) {} == bool(true) +object(stdClass)#%d (0) {} != bool(false) +object(stdClass)#%d (0) {} == object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} == object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} != object(test)#%d (0) {} +object(stdClass)#%d (0) {} != array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + != int(-9223372036854775808) +object(stdClass)#%d (0) {} != string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} != string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + == int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + != float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + != int(0) +object(stdClass)#%d (0) {} != string(6) "string" +object(stdClass)#%d (0) {} != string(3) "123" +object(stdClass)#%d (0) {} != string(3) "2.5" +object(stdClass)#%d (0) {} != NULL +object(stdClass)#%d (0) {} == bool(true) +object(stdClass)#%d (0) {} != bool(false) +object(stdClass)#%d (0) {} == object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} == object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} != object(test)#%d (0) {} +object(stdClass)#%d (0) {} != array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + != int(-9223372036854775808) +object(stdClass)#%d (0) {} != string(20) "-9223372036854775808" +object(test)#%d (0) {} != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#%d (0) {} != string(0) "" +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + == int(1) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + != float(2.5) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + != int(0) +object(test)#%d (0) {} != string(6) "string" +object(test)#%d (0) {} != string(3) "123" +object(test)#%d (0) {} != string(3) "2.5" +object(test)#%d (0) {} != NULL +object(test)#%d (0) {} == bool(true) +object(test)#%d (0) {} != bool(false) +object(test)#%d (0) {} != object(stdClass)#%d (0) {} +object(test)#%d (0) {} != object(stdClass)#%d (0) {} +object(test)#%d (0) {} == object(test)#%d (0) {} +object(test)#%d (0) {} != array(0) {} +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + != int(-9223372036854775808) +object(test)#%d (0) {} != string(20) "-9223372036854775808" +array(0) {} != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} != string(0) "" +array(0) {} != int(1) +array(0) {} != float(2.5) +array(0) {} != int(0) +array(0) {} != string(6) "string" +array(0) {} != string(3) "123" +array(0) {} != string(3) "2.5" +array(0) {} == NULL +array(0) {} != bool(true) +array(0) {} == bool(false) +array(0) {} != object(stdClass)#%d (0) {} +array(0) {} != object(stdClass)#%d (0) {} +array(0) {} != object(test)#%d (0) {} +array(0) {} == array(0) {} +array(0) {} != int(-9223372036854775808) +array(0) {} != string(20) "-9223372036854775808" +int(-9223372036854775808) != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-9223372036854775808) != string(0) "" +int(-9223372036854775808) != int(1) +int(-9223372036854775808) != float(2.5) +int(-9223372036854775808) != int(0) +int(-9223372036854775808) != string(6) "string" +int(-9223372036854775808) != string(3) "123" +int(-9223372036854775808) != string(3) "2.5" +int(-9223372036854775808) != NULL +int(-9223372036854775808) == bool(true) +int(-9223372036854775808) != bool(false) +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + != object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + != object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class test could not be converted to int in %s on line %d + != object(test)#%d (0) {} +int(-9223372036854775808) != array(0) {} +int(-9223372036854775808) == int(-9223372036854775808) +int(-9223372036854775808) == string(20) "-9223372036854775808" +string(20) "-9223372036854775808" != array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(20) "-9223372036854775808" != string(0) "" +string(20) "-9223372036854775808" != int(1) +string(20) "-9223372036854775808" != float(2.5) +string(20) "-9223372036854775808" != int(0) +string(20) "-9223372036854775808" != string(6) "string" +string(20) "-9223372036854775808" != string(3) "123" +string(20) "-9223372036854775808" != string(3) "2.5" +string(20) "-9223372036854775808" != NULL +string(20) "-9223372036854775808" == bool(true) +string(20) "-9223372036854775808" != bool(false) +string(20) "-9223372036854775808" != object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" != object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" != object(test)#%d (0) {} +string(20) "-9223372036854775808" != array(0) {} +string(20) "-9223372036854775808" == int(-9223372036854775808) +string(20) "-9223372036854775808" == string(20) "-9223372036854775808" +Done diff --git a/Zend/tests/compare_002.phpt b/Zend/tests/compare_002.phpt new file mode 100644 index 0000000..5e5009c --- /dev/null +++ b/Zend/tests/compare_002.phpt @@ -0,0 +1,341 @@ +--TEST-- +comparing different variables for identity +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var === $a[$i]) ? " === " : " !== "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} === array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== object(stdClass)#1 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== object(stdClass)#2 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== object(test)#3 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== int(-2147483648) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(11) "-2147483648" +string(0) "" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" === string(0) "" +string(0) "" !== int(1) +string(0) "" !== float(2.5) +string(0) "" !== int(0) +string(0) "" !== string(6) "string" +string(0) "" !== string(3) "123" +string(0) "" !== string(3) "2.5" +string(0) "" !== NULL +string(0) "" !== bool(true) +string(0) "" !== bool(false) +string(0) "" !== object(stdClass)#1 (0) {} +string(0) "" !== object(stdClass)#2 (0) {} +string(0) "" !== object(test)#3 (0) {} +string(0) "" !== array(0) {} +string(0) "" !== int(-2147483648) +string(0) "" !== string(11) "-2147483648" +int(1) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) !== string(0) "" +int(1) === int(1) +int(1) !== float(2.5) +int(1) !== int(0) +int(1) !== string(6) "string" +int(1) !== string(3) "123" +int(1) !== string(3) "2.5" +int(1) !== NULL +int(1) !== bool(true) +int(1) !== bool(false) +int(1) !== object(stdClass)#1 (0) {} +int(1) !== object(stdClass)#2 (0) {} +int(1) !== object(test)#3 (0) {} +int(1) !== array(0) {} +int(1) !== int(-2147483648) +int(1) !== string(11) "-2147483648" +float(2.5) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) !== string(0) "" +float(2.5) !== int(1) +float(2.5) === float(2.5) +float(2.5) !== int(0) +float(2.5) !== string(6) "string" +float(2.5) !== string(3) "123" +float(2.5) !== string(3) "2.5" +float(2.5) !== NULL +float(2.5) !== bool(true) +float(2.5) !== bool(false) +float(2.5) !== object(stdClass)#1 (0) {} +float(2.5) !== object(stdClass)#2 (0) {} +float(2.5) !== object(test)#3 (0) {} +float(2.5) !== array(0) {} +float(2.5) !== int(-2147483648) +float(2.5) !== string(11) "-2147483648" +int(0) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) !== string(0) "" +int(0) !== int(1) +int(0) !== float(2.5) +int(0) === int(0) +int(0) !== string(6) "string" +int(0) !== string(3) "123" +int(0) !== string(3) "2.5" +int(0) !== NULL +int(0) !== bool(true) +int(0) !== bool(false) +int(0) !== object(stdClass)#1 (0) {} +int(0) !== object(stdClass)#2 (0) {} +int(0) !== object(test)#3 (0) {} +int(0) !== array(0) {} +int(0) !== int(-2147483648) +int(0) !== string(11) "-2147483648" +string(6) "string" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" !== string(0) "" +string(6) "string" !== int(1) +string(6) "string" !== float(2.5) +string(6) "string" !== int(0) +string(6) "string" === string(6) "string" +string(6) "string" !== string(3) "123" +string(6) "string" !== string(3) "2.5" +string(6) "string" !== NULL +string(6) "string" !== bool(true) +string(6) "string" !== bool(false) +string(6) "string" !== object(stdClass)#1 (0) {} +string(6) "string" !== object(stdClass)#2 (0) {} +string(6) "string" !== object(test)#3 (0) {} +string(6) "string" !== array(0) {} +string(6) "string" !== int(-2147483648) +string(6) "string" !== string(11) "-2147483648" +string(3) "123" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" !== string(0) "" +string(3) "123" !== int(1) +string(3) "123" !== float(2.5) +string(3) "123" !== int(0) +string(3) "123" !== string(6) "string" +string(3) "123" === string(3) "123" +string(3) "123" !== string(3) "2.5" +string(3) "123" !== NULL +string(3) "123" !== bool(true) +string(3) "123" !== bool(false) +string(3) "123" !== object(stdClass)#1 (0) {} +string(3) "123" !== object(stdClass)#2 (0) {} +string(3) "123" !== object(test)#3 (0) {} +string(3) "123" !== array(0) {} +string(3) "123" !== int(-2147483648) +string(3) "123" !== string(11) "-2147483648" +string(3) "2.5" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" !== string(0) "" +string(3) "2.5" !== int(1) +string(3) "2.5" !== float(2.5) +string(3) "2.5" !== int(0) +string(3) "2.5" !== string(6) "string" +string(3) "2.5" !== string(3) "123" +string(3) "2.5" === string(3) "2.5" +string(3) "2.5" !== NULL +string(3) "2.5" !== bool(true) +string(3) "2.5" !== bool(false) +string(3) "2.5" !== object(stdClass)#1 (0) {} +string(3) "2.5" !== object(stdClass)#2 (0) {} +string(3) "2.5" !== object(test)#3 (0) {} +string(3) "2.5" !== array(0) {} +string(3) "2.5" !== int(-2147483648) +string(3) "2.5" !== string(11) "-2147483648" +NULL !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL !== string(0) "" +NULL !== int(1) +NULL !== float(2.5) +NULL !== int(0) +NULL !== string(6) "string" +NULL !== string(3) "123" +NULL !== string(3) "2.5" +NULL === NULL +NULL !== bool(true) +NULL !== bool(false) +NULL !== object(stdClass)#1 (0) {} +NULL !== object(stdClass)#2 (0) {} +NULL !== object(test)#3 (0) {} +NULL !== array(0) {} +NULL !== int(-2147483648) +NULL !== string(11) "-2147483648" +bool(true) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) !== string(0) "" +bool(true) !== int(1) +bool(true) !== float(2.5) +bool(true) !== int(0) +bool(true) !== string(6) "string" +bool(true) !== string(3) "123" +bool(true) !== string(3) "2.5" +bool(true) !== NULL +bool(true) === bool(true) +bool(true) !== bool(false) +bool(true) !== object(stdClass)#1 (0) {} +bool(true) !== object(stdClass)#2 (0) {} +bool(true) !== object(test)#3 (0) {} +bool(true) !== array(0) {} +bool(true) !== int(-2147483648) +bool(true) !== string(11) "-2147483648" +bool(false) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) !== string(0) "" +bool(false) !== int(1) +bool(false) !== float(2.5) +bool(false) !== int(0) +bool(false) !== string(6) "string" +bool(false) !== string(3) "123" +bool(false) !== string(3) "2.5" +bool(false) !== NULL +bool(false) !== bool(true) +bool(false) === bool(false) +bool(false) !== object(stdClass)#1 (0) {} +bool(false) !== object(stdClass)#2 (0) {} +bool(false) !== object(test)#3 (0) {} +bool(false) !== array(0) {} +bool(false) !== int(-2147483648) +bool(false) !== string(11) "-2147483648" +object(stdClass)#1 (0) {} !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#1 (0) {} !== string(0) "" +object(stdClass)#1 (0) {} !== int(1) +object(stdClass)#1 (0) {} !== float(2.5) +object(stdClass)#1 (0) {} !== int(0) +object(stdClass)#1 (0) {} !== string(6) "string" +object(stdClass)#1 (0) {} !== string(3) "123" +object(stdClass)#1 (0) {} !== string(3) "2.5" +object(stdClass)#1 (0) {} !== NULL +object(stdClass)#1 (0) {} !== bool(true) +object(stdClass)#1 (0) {} !== bool(false) +object(stdClass)#1 (0) {} === object(stdClass)#1 (0) {} +object(stdClass)#1 (0) {} !== object(stdClass)#2 (0) {} +object(stdClass)#1 (0) {} !== object(test)#3 (0) {} +object(stdClass)#1 (0) {} !== array(0) {} +object(stdClass)#1 (0) {} !== int(-2147483648) +object(stdClass)#1 (0) {} !== string(11) "-2147483648" +object(stdClass)#2 (0) {} !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#2 (0) {} !== string(0) "" +object(stdClass)#2 (0) {} !== int(1) +object(stdClass)#2 (0) {} !== float(2.5) +object(stdClass)#2 (0) {} !== int(0) +object(stdClass)#2 (0) {} !== string(6) "string" +object(stdClass)#2 (0) {} !== string(3) "123" +object(stdClass)#2 (0) {} !== string(3) "2.5" +object(stdClass)#2 (0) {} !== NULL +object(stdClass)#2 (0) {} !== bool(true) +object(stdClass)#2 (0) {} !== bool(false) +object(stdClass)#2 (0) {} !== object(stdClass)#1 (0) {} +object(stdClass)#2 (0) {} === object(stdClass)#2 (0) {} +object(stdClass)#2 (0) {} !== object(test)#3 (0) {} +object(stdClass)#2 (0) {} !== array(0) {} +object(stdClass)#2 (0) {} !== int(-2147483648) +object(stdClass)#2 (0) {} !== string(11) "-2147483648" +object(test)#3 (0) {} !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#3 (0) {} !== string(0) "" +object(test)#3 (0) {} !== int(1) +object(test)#3 (0) {} !== float(2.5) +object(test)#3 (0) {} !== int(0) +object(test)#3 (0) {} !== string(6) "string" +object(test)#3 (0) {} !== string(3) "123" +object(test)#3 (0) {} !== string(3) "2.5" +object(test)#3 (0) {} !== NULL +object(test)#3 (0) {} !== bool(true) +object(test)#3 (0) {} !== bool(false) +object(test)#3 (0) {} !== object(stdClass)#1 (0) {} +object(test)#3 (0) {} !== object(stdClass)#2 (0) {} +object(test)#3 (0) {} === object(test)#3 (0) {} +object(test)#3 (0) {} !== array(0) {} +object(test)#3 (0) {} !== int(-2147483648) +object(test)#3 (0) {} !== string(11) "-2147483648" +array(0) {} !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} !== string(0) "" +array(0) {} !== int(1) +array(0) {} !== float(2.5) +array(0) {} !== int(0) +array(0) {} !== string(6) "string" +array(0) {} !== string(3) "123" +array(0) {} !== string(3) "2.5" +array(0) {} !== NULL +array(0) {} !== bool(true) +array(0) {} !== bool(false) +array(0) {} !== object(stdClass)#1 (0) {} +array(0) {} !== object(stdClass)#2 (0) {} +array(0) {} !== object(test)#3 (0) {} +array(0) {} === array(0) {} +array(0) {} !== int(-2147483648) +array(0) {} !== string(11) "-2147483648" +int(-2147483648) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-2147483648) !== string(0) "" +int(-2147483648) !== int(1) +int(-2147483648) !== float(2.5) +int(-2147483648) !== int(0) +int(-2147483648) !== string(6) "string" +int(-2147483648) !== string(3) "123" +int(-2147483648) !== string(3) "2.5" +int(-2147483648) !== NULL +int(-2147483648) !== bool(true) +int(-2147483648) !== bool(false) +int(-2147483648) !== object(stdClass)#1 (0) {} +int(-2147483648) !== object(stdClass)#2 (0) {} +int(-2147483648) !== object(test)#3 (0) {} +int(-2147483648) !== array(0) {} +int(-2147483648) === int(-2147483648) +int(-2147483648) !== string(11) "-2147483648" +string(11) "-2147483648" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(11) "-2147483648" !== string(0) "" +string(11) "-2147483648" !== int(1) +string(11) "-2147483648" !== float(2.5) +string(11) "-2147483648" !== int(0) +string(11) "-2147483648" !== string(6) "string" +string(11) "-2147483648" !== string(3) "123" +string(11) "-2147483648" !== string(3) "2.5" +string(11) "-2147483648" !== NULL +string(11) "-2147483648" !== bool(true) +string(11) "-2147483648" !== bool(false) +string(11) "-2147483648" !== object(stdClass)#1 (0) {} +string(11) "-2147483648" !== object(stdClass)#2 (0) {} +string(11) "-2147483648" !== object(test)#3 (0) {} +string(11) "-2147483648" !== array(0) {} +string(11) "-2147483648" !== int(-2147483648) +string(11) "-2147483648" === string(11) "-2147483648" +Done diff --git a/Zend/tests/compare_002_64bit.phpt b/Zend/tests/compare_002_64bit.phpt new file mode 100644 index 0000000..517e7b9 --- /dev/null +++ b/Zend/tests/compare_002_64bit.phpt @@ -0,0 +1,341 @@ +--TEST-- +comparing different variables for identity +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var === $a[$i]) ? " === " : " !== "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} === array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== object(test)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== int(-9223372036854775808) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} !== string(20) "-9223372036854775808" +string(0) "" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" === string(0) "" +string(0) "" !== int(1) +string(0) "" !== float(2.5) +string(0) "" !== int(0) +string(0) "" !== string(6) "string" +string(0) "" !== string(3) "123" +string(0) "" !== string(3) "2.5" +string(0) "" !== NULL +string(0) "" !== bool(true) +string(0) "" !== bool(false) +string(0) "" !== object(stdClass)#%d (0) {} +string(0) "" !== object(stdClass)#%d (0) {} +string(0) "" !== object(test)#%d (0) {} +string(0) "" !== array(0) {} +string(0) "" !== int(-9223372036854775808) +string(0) "" !== string(20) "-9223372036854775808" +int(1) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) !== string(0) "" +int(1) === int(1) +int(1) !== float(2.5) +int(1) !== int(0) +int(1) !== string(6) "string" +int(1) !== string(3) "123" +int(1) !== string(3) "2.5" +int(1) !== NULL +int(1) !== bool(true) +int(1) !== bool(false) +int(1) !== object(stdClass)#%d (0) {} +int(1) !== object(stdClass)#%d (0) {} +int(1) !== object(test)#%d (0) {} +int(1) !== array(0) {} +int(1) !== int(-9223372036854775808) +int(1) !== string(20) "-9223372036854775808" +float(2.5) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) !== string(0) "" +float(2.5) !== int(1) +float(2.5) === float(2.5) +float(2.5) !== int(0) +float(2.5) !== string(6) "string" +float(2.5) !== string(3) "123" +float(2.5) !== string(3) "2.5" +float(2.5) !== NULL +float(2.5) !== bool(true) +float(2.5) !== bool(false) +float(2.5) !== object(stdClass)#%d (0) {} +float(2.5) !== object(stdClass)#%d (0) {} +float(2.5) !== object(test)#%d (0) {} +float(2.5) !== array(0) {} +float(2.5) !== int(-9223372036854775808) +float(2.5) !== string(20) "-9223372036854775808" +int(0) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) !== string(0) "" +int(0) !== int(1) +int(0) !== float(2.5) +int(0) === int(0) +int(0) !== string(6) "string" +int(0) !== string(3) "123" +int(0) !== string(3) "2.5" +int(0) !== NULL +int(0) !== bool(true) +int(0) !== bool(false) +int(0) !== object(stdClass)#%d (0) {} +int(0) !== object(stdClass)#%d (0) {} +int(0) !== object(test)#%d (0) {} +int(0) !== array(0) {} +int(0) !== int(-9223372036854775808) +int(0) !== string(20) "-9223372036854775808" +string(6) "string" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" !== string(0) "" +string(6) "string" !== int(1) +string(6) "string" !== float(2.5) +string(6) "string" !== int(0) +string(6) "string" === string(6) "string" +string(6) "string" !== string(3) "123" +string(6) "string" !== string(3) "2.5" +string(6) "string" !== NULL +string(6) "string" !== bool(true) +string(6) "string" !== bool(false) +string(6) "string" !== object(stdClass)#%d (0) {} +string(6) "string" !== object(stdClass)#%d (0) {} +string(6) "string" !== object(test)#%d (0) {} +string(6) "string" !== array(0) {} +string(6) "string" !== int(-9223372036854775808) +string(6) "string" !== string(20) "-9223372036854775808" +string(3) "123" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" !== string(0) "" +string(3) "123" !== int(1) +string(3) "123" !== float(2.5) +string(3) "123" !== int(0) +string(3) "123" !== string(6) "string" +string(3) "123" === string(3) "123" +string(3) "123" !== string(3) "2.5" +string(3) "123" !== NULL +string(3) "123" !== bool(true) +string(3) "123" !== bool(false) +string(3) "123" !== object(stdClass)#%d (0) {} +string(3) "123" !== object(stdClass)#%d (0) {} +string(3) "123" !== object(test)#%d (0) {} +string(3) "123" !== array(0) {} +string(3) "123" !== int(-9223372036854775808) +string(3) "123" !== string(20) "-9223372036854775808" +string(3) "2.5" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" !== string(0) "" +string(3) "2.5" !== int(1) +string(3) "2.5" !== float(2.5) +string(3) "2.5" !== int(0) +string(3) "2.5" !== string(6) "string" +string(3) "2.5" !== string(3) "123" +string(3) "2.5" === string(3) "2.5" +string(3) "2.5" !== NULL +string(3) "2.5" !== bool(true) +string(3) "2.5" !== bool(false) +string(3) "2.5" !== object(stdClass)#%d (0) {} +string(3) "2.5" !== object(stdClass)#%d (0) {} +string(3) "2.5" !== object(test)#%d (0) {} +string(3) "2.5" !== array(0) {} +string(3) "2.5" !== int(-9223372036854775808) +string(3) "2.5" !== string(20) "-9223372036854775808" +NULL !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL !== string(0) "" +NULL !== int(1) +NULL !== float(2.5) +NULL !== int(0) +NULL !== string(6) "string" +NULL !== string(3) "123" +NULL !== string(3) "2.5" +NULL === NULL +NULL !== bool(true) +NULL !== bool(false) +NULL !== object(stdClass)#%d (0) {} +NULL !== object(stdClass)#%d (0) {} +NULL !== object(test)#%d (0) {} +NULL !== array(0) {} +NULL !== int(-9223372036854775808) +NULL !== string(20) "-9223372036854775808" +bool(true) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) !== string(0) "" +bool(true) !== int(1) +bool(true) !== float(2.5) +bool(true) !== int(0) +bool(true) !== string(6) "string" +bool(true) !== string(3) "123" +bool(true) !== string(3) "2.5" +bool(true) !== NULL +bool(true) === bool(true) +bool(true) !== bool(false) +bool(true) !== object(stdClass)#%d (0) {} +bool(true) !== object(stdClass)#%d (0) {} +bool(true) !== object(test)#%d (0) {} +bool(true) !== array(0) {} +bool(true) !== int(-9223372036854775808) +bool(true) !== string(20) "-9223372036854775808" +bool(false) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) !== string(0) "" +bool(false) !== int(1) +bool(false) !== float(2.5) +bool(false) !== int(0) +bool(false) !== string(6) "string" +bool(false) !== string(3) "123" +bool(false) !== string(3) "2.5" +bool(false) !== NULL +bool(false) !== bool(true) +bool(false) === bool(false) +bool(false) !== object(stdClass)#%d (0) {} +bool(false) !== object(stdClass)#%d (0) {} +bool(false) !== object(test)#%d (0) {} +bool(false) !== array(0) {} +bool(false) !== int(-9223372036854775808) +bool(false) !== string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} !== string(0) "" +object(stdClass)#%d (0) {} !== int(1) +object(stdClass)#%d (0) {} !== float(2.5) +object(stdClass)#%d (0) {} !== int(0) +object(stdClass)#%d (0) {} !== string(6) "string" +object(stdClass)#%d (0) {} !== string(3) "123" +object(stdClass)#%d (0) {} !== string(3) "2.5" +object(stdClass)#%d (0) {} !== NULL +object(stdClass)#%d (0) {} !== bool(true) +object(stdClass)#%d (0) {} !== bool(false) +object(stdClass)#%d (0) {} === object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} !== object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} !== object(test)#%d (0) {} +object(stdClass)#%d (0) {} !== array(0) {} +object(stdClass)#%d (0) {} !== int(-9223372036854775808) +object(stdClass)#%d (0) {} !== string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} !== string(0) "" +object(stdClass)#%d (0) {} !== int(1) +object(stdClass)#%d (0) {} !== float(2.5) +object(stdClass)#%d (0) {} !== int(0) +object(stdClass)#%d (0) {} !== string(6) "string" +object(stdClass)#%d (0) {} !== string(3) "123" +object(stdClass)#%d (0) {} !== string(3) "2.5" +object(stdClass)#%d (0) {} !== NULL +object(stdClass)#%d (0) {} !== bool(true) +object(stdClass)#%d (0) {} !== bool(false) +object(stdClass)#%d (0) {} !== object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} === object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} !== object(test)#%d (0) {} +object(stdClass)#%d (0) {} !== array(0) {} +object(stdClass)#%d (0) {} !== int(-9223372036854775808) +object(stdClass)#%d (0) {} !== string(20) "-9223372036854775808" +object(test)#%d (0) {} !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#%d (0) {} !== string(0) "" +object(test)#%d (0) {} !== int(1) +object(test)#%d (0) {} !== float(2.5) +object(test)#%d (0) {} !== int(0) +object(test)#%d (0) {} !== string(6) "string" +object(test)#%d (0) {} !== string(3) "123" +object(test)#%d (0) {} !== string(3) "2.5" +object(test)#%d (0) {} !== NULL +object(test)#%d (0) {} !== bool(true) +object(test)#%d (0) {} !== bool(false) +object(test)#%d (0) {} !== object(stdClass)#%d (0) {} +object(test)#%d (0) {} !== object(stdClass)#%d (0) {} +object(test)#%d (0) {} === object(test)#%d (0) {} +object(test)#%d (0) {} !== array(0) {} +object(test)#%d (0) {} !== int(-9223372036854775808) +object(test)#%d (0) {} !== string(20) "-9223372036854775808" +array(0) {} !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} !== string(0) "" +array(0) {} !== int(1) +array(0) {} !== float(2.5) +array(0) {} !== int(0) +array(0) {} !== string(6) "string" +array(0) {} !== string(3) "123" +array(0) {} !== string(3) "2.5" +array(0) {} !== NULL +array(0) {} !== bool(true) +array(0) {} !== bool(false) +array(0) {} !== object(stdClass)#%d (0) {} +array(0) {} !== object(stdClass)#%d (0) {} +array(0) {} !== object(test)#%d (0) {} +array(0) {} === array(0) {} +array(0) {} !== int(-9223372036854775808) +array(0) {} !== string(20) "-9223372036854775808" +int(-9223372036854775808) !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-9223372036854775808) !== string(0) "" +int(-9223372036854775808) !== int(1) +int(-9223372036854775808) !== float(2.5) +int(-9223372036854775808) !== int(0) +int(-9223372036854775808) !== string(6) "string" +int(-9223372036854775808) !== string(3) "123" +int(-9223372036854775808) !== string(3) "2.5" +int(-9223372036854775808) !== NULL +int(-9223372036854775808) !== bool(true) +int(-9223372036854775808) !== bool(false) +int(-9223372036854775808) !== object(stdClass)#%d (0) {} +int(-9223372036854775808) !== object(stdClass)#%d (0) {} +int(-9223372036854775808) !== object(test)#%d (0) {} +int(-9223372036854775808) !== array(0) {} +int(-9223372036854775808) === int(-9223372036854775808) +int(-9223372036854775808) !== string(20) "-9223372036854775808" +string(20) "-9223372036854775808" !== array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(20) "-9223372036854775808" !== string(0) "" +string(20) "-9223372036854775808" !== int(1) +string(20) "-9223372036854775808" !== float(2.5) +string(20) "-9223372036854775808" !== int(0) +string(20) "-9223372036854775808" !== string(6) "string" +string(20) "-9223372036854775808" !== string(3) "123" +string(20) "-9223372036854775808" !== string(3) "2.5" +string(20) "-9223372036854775808" !== NULL +string(20) "-9223372036854775808" !== bool(true) +string(20) "-9223372036854775808" !== bool(false) +string(20) "-9223372036854775808" !== object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" !== object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" !== object(test)#%d (0) {} +string(20) "-9223372036854775808" !== array(0) {} +string(20) "-9223372036854775808" !== int(-9223372036854775808) +string(20) "-9223372036854775808" === string(20) "-9223372036854775808" +Done diff --git a/Zend/tests/compare_003.phpt b/Zend/tests/compare_003.phpt new file mode 100644 index 0000000..9327ee5 --- /dev/null +++ b/Zend/tests/compare_003.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables (greater than) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var > $a[$i]) ? " > " : " <= "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(stdClass)#1 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(stdClass)#2 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(test)#3 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(-2147483648) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(11) "-2147483648" +string(0) "" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" <= string(0) "" +string(0) "" <= int(1) +string(0) "" <= float(2.5) +string(0) "" <= int(0) +string(0) "" <= string(6) "string" +string(0) "" <= string(3) "123" +string(0) "" <= string(3) "2.5" +string(0) "" <= NULL +string(0) "" <= bool(true) +string(0) "" <= bool(false) +string(0) "" <= object(stdClass)#1 (0) {} +string(0) "" <= object(stdClass)#2 (0) {} +string(0) "" <= object(test)#3 (0) {} +string(0) "" <= array(0) {} +string(0) "" > int(-2147483648) +string(0) "" <= string(11) "-2147483648" +int(1) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) > string(0) "" +int(1) <= int(1) +int(1) <= float(2.5) +int(1) > int(0) +int(1) > string(6) "string" +int(1) <= string(3) "123" +int(1) <= string(3) "2.5" +int(1) > NULL +int(1) <= bool(true) +int(1) > bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#1 (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#2 (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#3 (0) {} +int(1) <= array(0) {} +int(1) > int(-2147483648) +int(1) > string(11) "-2147483648" +float(2.5) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) > string(0) "" +float(2.5) > int(1) +float(2.5) <= float(2.5) +float(2.5) > int(0) +float(2.5) > string(6) "string" +float(2.5) <= string(3) "123" +float(2.5) <= string(3) "2.5" +float(2.5) > NULL +float(2.5) <= bool(true) +float(2.5) > bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + > object(stdClass)#1 (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + > object(stdClass)#2 (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + > object(test)#3 (0) {} +float(2.5) <= array(0) {} +float(2.5) > int(-2147483648) +float(2.5) > string(11) "-2147483648" +int(0) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) <= string(0) "" +int(0) <= int(1) +int(0) <= float(2.5) +int(0) <= int(0) +int(0) <= string(6) "string" +int(0) <= string(3) "123" +int(0) <= string(3) "2.5" +int(0) <= NULL +int(0) <= bool(true) +int(0) <= bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#1 (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#2 (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#3 (0) {} +int(0) <= array(0) {} +int(0) > int(-2147483648) +int(0) > string(11) "-2147483648" +string(6) "string" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" > string(0) "" +string(6) "string" <= int(1) +string(6) "string" <= float(2.5) +string(6) "string" <= int(0) +string(6) "string" <= string(6) "string" +string(6) "string" > string(3) "123" +string(6) "string" > string(3) "2.5" +string(6) "string" > NULL +string(6) "string" <= bool(true) +string(6) "string" > bool(false) +string(6) "string" <= object(stdClass)#1 (0) {} +string(6) "string" <= object(stdClass)#2 (0) {} +string(6) "string" <= object(test)#3 (0) {} +string(6) "string" <= array(0) {} +string(6) "string" > int(-2147483648) +string(6) "string" > string(11) "-2147483648" +string(3) "123" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" > string(0) "" +string(3) "123" > int(1) +string(3) "123" > float(2.5) +string(3) "123" > int(0) +string(3) "123" <= string(6) "string" +string(3) "123" <= string(3) "123" +string(3) "123" > string(3) "2.5" +string(3) "123" > NULL +string(3) "123" <= bool(true) +string(3) "123" > bool(false) +string(3) "123" <= object(stdClass)#1 (0) {} +string(3) "123" <= object(stdClass)#2 (0) {} +string(3) "123" <= object(test)#3 (0) {} +string(3) "123" <= array(0) {} +string(3) "123" > int(-2147483648) +string(3) "123" > string(11) "-2147483648" +string(3) "2.5" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" > string(0) "" +string(3) "2.5" > int(1) +string(3) "2.5" <= float(2.5) +string(3) "2.5" > int(0) +string(3) "2.5" <= string(6) "string" +string(3) "2.5" <= string(3) "123" +string(3) "2.5" <= string(3) "2.5" +string(3) "2.5" > NULL +string(3) "2.5" <= bool(true) +string(3) "2.5" > bool(false) +string(3) "2.5" <= object(stdClass)#1 (0) {} +string(3) "2.5" <= object(stdClass)#2 (0) {} +string(3) "2.5" <= object(test)#3 (0) {} +string(3) "2.5" <= array(0) {} +string(3) "2.5" > int(-2147483648) +string(3) "2.5" > string(11) "-2147483648" +NULL <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL <= string(0) "" +NULL <= int(1) +NULL <= float(2.5) +NULL <= int(0) +NULL <= string(6) "string" +NULL <= string(3) "123" +NULL <= string(3) "2.5" +NULL <= NULL +NULL <= bool(true) +NULL <= bool(false) +NULL <= object(stdClass)#1 (0) {} +NULL <= object(stdClass)#2 (0) {} +NULL <= object(test)#3 (0) {} +NULL <= array(0) {} +NULL <= int(-2147483648) +NULL <= string(11) "-2147483648" +bool(true) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) > string(0) "" +bool(true) <= int(1) +bool(true) <= float(2.5) +bool(true) > int(0) +bool(true) <= string(6) "string" +bool(true) <= string(3) "123" +bool(true) <= string(3) "2.5" +bool(true) > NULL +bool(true) <= bool(true) +bool(true) > bool(false) +bool(true) <= object(stdClass)#1 (0) {} +bool(true) <= object(stdClass)#2 (0) {} +bool(true) <= object(test)#3 (0) {} +bool(true) > array(0) {} +bool(true) <= int(-2147483648) +bool(true) <= string(11) "-2147483648" +bool(false) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) <= string(0) "" +bool(false) <= int(1) +bool(false) <= float(2.5) +bool(false) <= int(0) +bool(false) <= string(6) "string" +bool(false) <= string(3) "123" +bool(false) <= string(3) "2.5" +bool(false) <= NULL +bool(false) <= bool(true) +bool(false) <= bool(false) +bool(false) <= object(stdClass)#1 (0) {} +bool(false) <= object(stdClass)#2 (0) {} +bool(false) <= object(test)#3 (0) {} +bool(false) <= array(0) {} +bool(false) <= int(-2147483648) +bool(false) <= string(11) "-2147483648" +object(stdClass)#1 (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#1 (0) {} > string(0) "" +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= int(1) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + <= float(2.5) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(0) +object(stdClass)#1 (0) {} > string(6) "string" +object(stdClass)#1 (0) {} > string(3) "123" +object(stdClass)#1 (0) {} > string(3) "2.5" +object(stdClass)#1 (0) {} > NULL +object(stdClass)#1 (0) {} <= bool(true) +object(stdClass)#1 (0) {} > bool(false) +object(stdClass)#1 (0) {} <= object(stdClass)#1 (0) {} +object(stdClass)#1 (0) {} <= object(stdClass)#2 (0) {} +object(stdClass)#1 (0) {} <= object(test)#3 (0) {} +object(stdClass)#1 (0) {} > array(0) {} +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(-2147483648) +object(stdClass)#1 (0) {} > string(11) "-2147483648" +object(stdClass)#2 (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#2 (0) {} > string(0) "" +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= int(1) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + <= float(2.5) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(0) +object(stdClass)#2 (0) {} > string(6) "string" +object(stdClass)#2 (0) {} > string(3) "123" +object(stdClass)#2 (0) {} > string(3) "2.5" +object(stdClass)#2 (0) {} > NULL +object(stdClass)#2 (0) {} <= bool(true) +object(stdClass)#2 (0) {} > bool(false) +object(stdClass)#2 (0) {} <= object(stdClass)#1 (0) {} +object(stdClass)#2 (0) {} <= object(stdClass)#2 (0) {} +object(stdClass)#2 (0) {} <= object(test)#3 (0) {} +object(stdClass)#2 (0) {} > array(0) {} +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(-2147483648) +object(stdClass)#2 (0) {} > string(11) "-2147483648" +object(test)#3 (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#3 (0) {} > string(0) "" +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + <= int(1) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + <= float(2.5) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + > int(0) +object(test)#3 (0) {} > string(6) "string" +object(test)#3 (0) {} > string(3) "123" +object(test)#3 (0) {} > string(3) "2.5" +object(test)#3 (0) {} > NULL +object(test)#3 (0) {} <= bool(true) +object(test)#3 (0) {} > bool(false) +object(test)#3 (0) {} <= object(stdClass)#1 (0) {} +object(test)#3 (0) {} <= object(stdClass)#2 (0) {} +object(test)#3 (0) {} <= object(test)#3 (0) {} +object(test)#3 (0) {} > array(0) {} +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + > int(-2147483648) +object(test)#3 (0) {} > string(11) "-2147483648" +array(0) {} <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} > string(0) "" +array(0) {} > int(1) +array(0) {} > float(2.5) +array(0) {} > int(0) +array(0) {} > string(6) "string" +array(0) {} > string(3) "123" +array(0) {} > string(3) "2.5" +array(0) {} <= NULL +array(0) {} <= bool(true) +array(0) {} <= bool(false) +array(0) {} <= object(stdClass)#1 (0) {} +array(0) {} <= object(stdClass)#2 (0) {} +array(0) {} <= object(test)#3 (0) {} +array(0) {} <= array(0) {} +array(0) {} > int(-2147483648) +array(0) {} > string(11) "-2147483648" +int(-2147483648) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-2147483648) <= string(0) "" +int(-2147483648) <= int(1) +int(-2147483648) <= float(2.5) +int(-2147483648) <= int(0) +int(-2147483648) <= string(6) "string" +int(-2147483648) <= string(3) "123" +int(-2147483648) <= string(3) "2.5" +int(-2147483648) > NULL +int(-2147483648) <= bool(true) +int(-2147483648) > bool(false) +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#1 (0) {} +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#2 (0) {} +int(-2147483648) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#3 (0) {} +int(-2147483648) <= array(0) {} +int(-2147483648) <= int(-2147483648) +int(-2147483648) <= string(11) "-2147483648" +string(11) "-2147483648" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(11) "-2147483648" > string(0) "" +string(11) "-2147483648" <= int(1) +string(11) "-2147483648" <= float(2.5) +string(11) "-2147483648" <= int(0) +string(11) "-2147483648" <= string(6) "string" +string(11) "-2147483648" <= string(3) "123" +string(11) "-2147483648" <= string(3) "2.5" +string(11) "-2147483648" > NULL +string(11) "-2147483648" <= bool(true) +string(11) "-2147483648" > bool(false) +string(11) "-2147483648" <= object(stdClass)#1 (0) {} +string(11) "-2147483648" <= object(stdClass)#2 (0) {} +string(11) "-2147483648" <= object(test)#3 (0) {} +string(11) "-2147483648" <= array(0) {} +string(11) "-2147483648" <= int(-2147483648) +string(11) "-2147483648" <= string(11) "-2147483648" +Done diff --git a/Zend/tests/compare_003_64bit.phpt b/Zend/tests/compare_003_64bit.phpt new file mode 100644 index 0000000..1f936c6 --- /dev/null +++ b/Zend/tests/compare_003_64bit.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables (greater than) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var > $a[$i]) ? " > " : " <= "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(test)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(-9223372036854775808) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(20) "-9223372036854775808" +string(0) "" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" <= string(0) "" +string(0) "" <= int(1) +string(0) "" <= float(2.5) +string(0) "" <= int(0) +string(0) "" <= string(6) "string" +string(0) "" <= string(3) "123" +string(0) "" <= string(3) "2.5" +string(0) "" <= NULL +string(0) "" <= bool(true) +string(0) "" <= bool(false) +string(0) "" <= object(stdClass)#%d (0) {} +string(0) "" <= object(stdClass)#%d (0) {} +string(0) "" <= object(test)#%d (0) {} +string(0) "" <= array(0) {} +string(0) "" > int(-9223372036854775808) +string(0) "" <= string(20) "-9223372036854775808" +int(1) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) > string(0) "" +int(1) <= int(1) +int(1) <= float(2.5) +int(1) > int(0) +int(1) > string(6) "string" +int(1) <= string(3) "123" +int(1) <= string(3) "2.5" +int(1) > NULL +int(1) <= bool(true) +int(1) > bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#%d (0) {} +int(1) <= array(0) {} +int(1) > int(-9223372036854775808) +int(1) > string(20) "-9223372036854775808" +float(2.5) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) > string(0) "" +float(2.5) > int(1) +float(2.5) <= float(2.5) +float(2.5) > int(0) +float(2.5) > string(6) "string" +float(2.5) <= string(3) "123" +float(2.5) <= string(3) "2.5" +float(2.5) > NULL +float(2.5) <= bool(true) +float(2.5) > bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + > object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + > object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + > object(test)#%d (0) {} +float(2.5) <= array(0) {} +float(2.5) > int(-9223372036854775808) +float(2.5) > string(20) "-9223372036854775808" +int(0) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) <= string(0) "" +int(0) <= int(1) +int(0) <= float(2.5) +int(0) <= int(0) +int(0) <= string(6) "string" +int(0) <= string(3) "123" +int(0) <= string(3) "2.5" +int(0) <= NULL +int(0) <= bool(true) +int(0) <= bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#%d (0) {} +int(0) <= array(0) {} +int(0) > int(-9223372036854775808) +int(0) > string(20) "-9223372036854775808" +string(6) "string" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" > string(0) "" +string(6) "string" <= int(1) +string(6) "string" <= float(2.5) +string(6) "string" <= int(0) +string(6) "string" <= string(6) "string" +string(6) "string" > string(3) "123" +string(6) "string" > string(3) "2.5" +string(6) "string" > NULL +string(6) "string" <= bool(true) +string(6) "string" > bool(false) +string(6) "string" <= object(stdClass)#%d (0) {} +string(6) "string" <= object(stdClass)#%d (0) {} +string(6) "string" <= object(test)#%d (0) {} +string(6) "string" <= array(0) {} +string(6) "string" > int(-9223372036854775808) +string(6) "string" > string(20) "-9223372036854775808" +string(3) "123" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" > string(0) "" +string(3) "123" > int(1) +string(3) "123" > float(2.5) +string(3) "123" > int(0) +string(3) "123" <= string(6) "string" +string(3) "123" <= string(3) "123" +string(3) "123" > string(3) "2.5" +string(3) "123" > NULL +string(3) "123" <= bool(true) +string(3) "123" > bool(false) +string(3) "123" <= object(stdClass)#%d (0) {} +string(3) "123" <= object(stdClass)#%d (0) {} +string(3) "123" <= object(test)#%d (0) {} +string(3) "123" <= array(0) {} +string(3) "123" > int(-9223372036854775808) +string(3) "123" > string(20) "-9223372036854775808" +string(3) "2.5" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" > string(0) "" +string(3) "2.5" > int(1) +string(3) "2.5" <= float(2.5) +string(3) "2.5" > int(0) +string(3) "2.5" <= string(6) "string" +string(3) "2.5" <= string(3) "123" +string(3) "2.5" <= string(3) "2.5" +string(3) "2.5" > NULL +string(3) "2.5" <= bool(true) +string(3) "2.5" > bool(false) +string(3) "2.5" <= object(stdClass)#%d (0) {} +string(3) "2.5" <= object(stdClass)#%d (0) {} +string(3) "2.5" <= object(test)#%d (0) {} +string(3) "2.5" <= array(0) {} +string(3) "2.5" > int(-9223372036854775808) +string(3) "2.5" > string(20) "-9223372036854775808" +NULL <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL <= string(0) "" +NULL <= int(1) +NULL <= float(2.5) +NULL <= int(0) +NULL <= string(6) "string" +NULL <= string(3) "123" +NULL <= string(3) "2.5" +NULL <= NULL +NULL <= bool(true) +NULL <= bool(false) +NULL <= object(stdClass)#%d (0) {} +NULL <= object(stdClass)#%d (0) {} +NULL <= object(test)#%d (0) {} +NULL <= array(0) {} +NULL <= int(-9223372036854775808) +NULL <= string(20) "-9223372036854775808" +bool(true) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) > string(0) "" +bool(true) <= int(1) +bool(true) <= float(2.5) +bool(true) > int(0) +bool(true) <= string(6) "string" +bool(true) <= string(3) "123" +bool(true) <= string(3) "2.5" +bool(true) > NULL +bool(true) <= bool(true) +bool(true) > bool(false) +bool(true) <= object(stdClass)#%d (0) {} +bool(true) <= object(stdClass)#%d (0) {} +bool(true) <= object(test)#%d (0) {} +bool(true) > array(0) {} +bool(true) <= int(-9223372036854775808) +bool(true) <= string(20) "-9223372036854775808" +bool(false) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) <= string(0) "" +bool(false) <= int(1) +bool(false) <= float(2.5) +bool(false) <= int(0) +bool(false) <= string(6) "string" +bool(false) <= string(3) "123" +bool(false) <= string(3) "2.5" +bool(false) <= NULL +bool(false) <= bool(true) +bool(false) <= bool(false) +bool(false) <= object(stdClass)#%d (0) {} +bool(false) <= object(stdClass)#%d (0) {} +bool(false) <= object(test)#%d (0) {} +bool(false) <= array(0) {} +bool(false) <= int(-9223372036854775808) +bool(false) <= string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} > string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + <= float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(0) +object(stdClass)#%d (0) {} > string(6) "string" +object(stdClass)#%d (0) {} > string(3) "123" +object(stdClass)#%d (0) {} > string(3) "2.5" +object(stdClass)#%d (0) {} > NULL +object(stdClass)#%d (0) {} <= bool(true) +object(stdClass)#%d (0) {} > bool(false) +object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} <= object(test)#%d (0) {} +object(stdClass)#%d (0) {} > array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(-9223372036854775808) +object(stdClass)#%d (0) {} > string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} > string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + <= float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(0) +object(stdClass)#%d (0) {} > string(6) "string" +object(stdClass)#%d (0) {} > string(3) "123" +object(stdClass)#%d (0) {} > string(3) "2.5" +object(stdClass)#%d (0) {} > NULL +object(stdClass)#%d (0) {} <= bool(true) +object(stdClass)#%d (0) {} > bool(false) +object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} <= object(test)#%d (0) {} +object(stdClass)#%d (0) {} > array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(-9223372036854775808) +object(stdClass)#%d (0) {} > string(20) "-9223372036854775808" +object(test)#%d (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#%d (0) {} > string(0) "" +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + <= int(1) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + <= float(2.5) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + > int(0) +object(test)#%d (0) {} > string(6) "string" +object(test)#%d (0) {} > string(3) "123" +object(test)#%d (0) {} > string(3) "2.5" +object(test)#%d (0) {} > NULL +object(test)#%d (0) {} <= bool(true) +object(test)#%d (0) {} > bool(false) +object(test)#%d (0) {} <= object(stdClass)#%d (0) {} +object(test)#%d (0) {} <= object(stdClass)#%d (0) {} +object(test)#%d (0) {} <= object(test)#%d (0) {} +object(test)#%d (0) {} > array(0) {} +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + > int(-9223372036854775808) +object(test)#%d (0) {} > string(20) "-9223372036854775808" +array(0) {} <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} > string(0) "" +array(0) {} > int(1) +array(0) {} > float(2.5) +array(0) {} > int(0) +array(0) {} > string(6) "string" +array(0) {} > string(3) "123" +array(0) {} > string(3) "2.5" +array(0) {} <= NULL +array(0) {} <= bool(true) +array(0) {} <= bool(false) +array(0) {} <= object(stdClass)#%d (0) {} +array(0) {} <= object(stdClass)#%d (0) {} +array(0) {} <= object(test)#%d (0) {} +array(0) {} <= array(0) {} +array(0) {} > int(-9223372036854775808) +array(0) {} > string(20) "-9223372036854775808" +int(-9223372036854775808) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-9223372036854775808) <= string(0) "" +int(-9223372036854775808) <= int(1) +int(-9223372036854775808) <= float(2.5) +int(-9223372036854775808) <= int(0) +int(-9223372036854775808) <= string(6) "string" +int(-9223372036854775808) <= string(3) "123" +int(-9223372036854775808) <= string(3) "2.5" +int(-9223372036854775808) > NULL +int(-9223372036854775808) <= bool(true) +int(-9223372036854775808) > bool(false) +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#%d (0) {} +int(-9223372036854775808) <= array(0) {} +int(-9223372036854775808) <= int(-9223372036854775808) +int(-9223372036854775808) <= string(20) "-9223372036854775808" +string(20) "-9223372036854775808" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(20) "-9223372036854775808" > string(0) "" +string(20) "-9223372036854775808" <= int(1) +string(20) "-9223372036854775808" <= float(2.5) +string(20) "-9223372036854775808" <= int(0) +string(20) "-9223372036854775808" <= string(6) "string" +string(20) "-9223372036854775808" <= string(3) "123" +string(20) "-9223372036854775808" <= string(3) "2.5" +string(20) "-9223372036854775808" > NULL +string(20) "-9223372036854775808" <= bool(true) +string(20) "-9223372036854775808" > bool(false) +string(20) "-9223372036854775808" <= object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" <= object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" <= object(test)#%d (0) {} +string(20) "-9223372036854775808" <= array(0) {} +string(20) "-9223372036854775808" <= int(-9223372036854775808) +string(20) "-9223372036854775808" <= string(20) "-9223372036854775808" +Done diff --git a/Zend/tests/compare_004.phpt b/Zend/tests/compare_004.phpt new file mode 100644 index 0000000..69131cd --- /dev/null +++ b/Zend/tests/compare_004.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables (less than) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var < $a[$i]) ? " < " : " >= "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(stdClass)#1 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(stdClass)#2 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(test)#3 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(-2147483648) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(11) "-2147483648" +string(0) "" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" >= string(0) "" +string(0) "" < int(1) +string(0) "" < float(2.5) +string(0) "" >= int(0) +string(0) "" < string(6) "string" +string(0) "" < string(3) "123" +string(0) "" < string(3) "2.5" +string(0) "" >= NULL +string(0) "" < bool(true) +string(0) "" >= bool(false) +string(0) "" < object(stdClass)#1 (0) {} +string(0) "" < object(stdClass)#2 (0) {} +string(0) "" < object(test)#3 (0) {} +string(0) "" < array(0) {} +string(0) "" >= int(-2147483648) +string(0) "" < string(11) "-2147483648" +int(1) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) >= string(0) "" +int(1) >= int(1) +int(1) < float(2.5) +int(1) >= int(0) +int(1) >= string(6) "string" +int(1) < string(3) "123" +int(1) < string(3) "2.5" +int(1) >= NULL +int(1) >= bool(true) +int(1) >= bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= object(stdClass)#1 (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= object(stdClass)#2 (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + >= object(test)#3 (0) {} +int(1) < array(0) {} +int(1) >= int(-2147483648) +int(1) >= string(11) "-2147483648" +float(2.5) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) >= string(0) "" +float(2.5) >= int(1) +float(2.5) >= float(2.5) +float(2.5) >= int(0) +float(2.5) >= string(6) "string" +float(2.5) < string(3) "123" +float(2.5) >= string(3) "2.5" +float(2.5) >= NULL +float(2.5) >= bool(true) +float(2.5) >= bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + >= object(stdClass)#1 (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + >= object(stdClass)#2 (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + >= object(test)#3 (0) {} +float(2.5) < array(0) {} +float(2.5) >= int(-2147483648) +float(2.5) >= string(11) "-2147483648" +int(0) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) >= string(0) "" +int(0) < int(1) +int(0) < float(2.5) +int(0) >= int(0) +int(0) >= string(6) "string" +int(0) < string(3) "123" +int(0) < string(3) "2.5" +int(0) >= NULL +int(0) < bool(true) +int(0) >= bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#1 (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#2 (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + < object(test)#3 (0) {} +int(0) < array(0) {} +int(0) >= int(-2147483648) +int(0) >= string(11) "-2147483648" +string(6) "string" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" >= string(0) "" +string(6) "string" < int(1) +string(6) "string" < float(2.5) +string(6) "string" >= int(0) +string(6) "string" >= string(6) "string" +string(6) "string" >= string(3) "123" +string(6) "string" >= string(3) "2.5" +string(6) "string" >= NULL +string(6) "string" >= bool(true) +string(6) "string" >= bool(false) +string(6) "string" < object(stdClass)#1 (0) {} +string(6) "string" < object(stdClass)#2 (0) {} +string(6) "string" < object(test)#3 (0) {} +string(6) "string" < array(0) {} +string(6) "string" >= int(-2147483648) +string(6) "string" >= string(11) "-2147483648" +string(3) "123" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" >= string(0) "" +string(3) "123" >= int(1) +string(3) "123" >= float(2.5) +string(3) "123" >= int(0) +string(3) "123" < string(6) "string" +string(3) "123" >= string(3) "123" +string(3) "123" >= string(3) "2.5" +string(3) "123" >= NULL +string(3) "123" >= bool(true) +string(3) "123" >= bool(false) +string(3) "123" < object(stdClass)#1 (0) {} +string(3) "123" < object(stdClass)#2 (0) {} +string(3) "123" < object(test)#3 (0) {} +string(3) "123" < array(0) {} +string(3) "123" >= int(-2147483648) +string(3) "123" >= string(11) "-2147483648" +string(3) "2.5" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" >= string(0) "" +string(3) "2.5" >= int(1) +string(3) "2.5" >= float(2.5) +string(3) "2.5" >= int(0) +string(3) "2.5" < string(6) "string" +string(3) "2.5" < string(3) "123" +string(3) "2.5" >= string(3) "2.5" +string(3) "2.5" >= NULL +string(3) "2.5" >= bool(true) +string(3) "2.5" >= bool(false) +string(3) "2.5" < object(stdClass)#1 (0) {} +string(3) "2.5" < object(stdClass)#2 (0) {} +string(3) "2.5" < object(test)#3 (0) {} +string(3) "2.5" < array(0) {} +string(3) "2.5" >= int(-2147483648) +string(3) "2.5" >= string(11) "-2147483648" +NULL < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL >= string(0) "" +NULL < int(1) +NULL < float(2.5) +NULL >= int(0) +NULL < string(6) "string" +NULL < string(3) "123" +NULL < string(3) "2.5" +NULL >= NULL +NULL < bool(true) +NULL >= bool(false) +NULL < object(stdClass)#1 (0) {} +NULL < object(stdClass)#2 (0) {} +NULL < object(test)#3 (0) {} +NULL >= array(0) {} +NULL < int(-2147483648) +NULL < string(11) "-2147483648" +bool(true) >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) >= string(0) "" +bool(true) >= int(1) +bool(true) >= float(2.5) +bool(true) >= int(0) +bool(true) >= string(6) "string" +bool(true) >= string(3) "123" +bool(true) >= string(3) "2.5" +bool(true) >= NULL +bool(true) >= bool(true) +bool(true) >= bool(false) +bool(true) >= object(stdClass)#1 (0) {} +bool(true) >= object(stdClass)#2 (0) {} +bool(true) >= object(test)#3 (0) {} +bool(true) >= array(0) {} +bool(true) >= int(-2147483648) +bool(true) >= string(11) "-2147483648" +bool(false) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) >= string(0) "" +bool(false) < int(1) +bool(false) < float(2.5) +bool(false) >= int(0) +bool(false) < string(6) "string" +bool(false) < string(3) "123" +bool(false) < string(3) "2.5" +bool(false) >= NULL +bool(false) < bool(true) +bool(false) >= bool(false) +bool(false) < object(stdClass)#1 (0) {} +bool(false) < object(stdClass)#2 (0) {} +bool(false) < object(test)#3 (0) {} +bool(false) >= array(0) {} +bool(false) < int(-2147483648) +bool(false) < string(11) "-2147483648" +object(stdClass)#1 (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#1 (0) {} >= string(0) "" +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(1) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + < float(2.5) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(0) +object(stdClass)#1 (0) {} >= string(6) "string" +object(stdClass)#1 (0) {} >= string(3) "123" +object(stdClass)#1 (0) {} >= string(3) "2.5" +object(stdClass)#1 (0) {} >= NULL +object(stdClass)#1 (0) {} >= bool(true) +object(stdClass)#1 (0) {} >= bool(false) +object(stdClass)#1 (0) {} >= object(stdClass)#1 (0) {} +object(stdClass)#1 (0) {} >= object(stdClass)#2 (0) {} +object(stdClass)#1 (0) {} >= object(test)#3 (0) {} +object(stdClass)#1 (0) {} >= array(0) {} +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(-2147483648) +object(stdClass)#1 (0) {} >= string(11) "-2147483648" +object(stdClass)#2 (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#2 (0) {} >= string(0) "" +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(1) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + < float(2.5) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(0) +object(stdClass)#2 (0) {} >= string(6) "string" +object(stdClass)#2 (0) {} >= string(3) "123" +object(stdClass)#2 (0) {} >= string(3) "2.5" +object(stdClass)#2 (0) {} >= NULL +object(stdClass)#2 (0) {} >= bool(true) +object(stdClass)#2 (0) {} >= bool(false) +object(stdClass)#2 (0) {} >= object(stdClass)#1 (0) {} +object(stdClass)#2 (0) {} >= object(stdClass)#2 (0) {} +object(stdClass)#2 (0) {} >= object(test)#3 (0) {} +object(stdClass)#2 (0) {} >= array(0) {} +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(-2147483648) +object(stdClass)#2 (0) {} >= string(11) "-2147483648" +object(test)#3 (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#3 (0) {} >= string(0) "" +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(1) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + < float(2.5) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(0) +object(test)#3 (0) {} >= string(6) "string" +object(test)#3 (0) {} >= string(3) "123" +object(test)#3 (0) {} >= string(3) "2.5" +object(test)#3 (0) {} >= NULL +object(test)#3 (0) {} >= bool(true) +object(test)#3 (0) {} >= bool(false) +object(test)#3 (0) {} >= object(stdClass)#1 (0) {} +object(test)#3 (0) {} >= object(stdClass)#2 (0) {} +object(test)#3 (0) {} >= object(test)#3 (0) {} +object(test)#3 (0) {} >= array(0) {} +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(-2147483648) +object(test)#3 (0) {} >= string(11) "-2147483648" +array(0) {} < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} >= string(0) "" +array(0) {} >= int(1) +array(0) {} >= float(2.5) +array(0) {} >= int(0) +array(0) {} >= string(6) "string" +array(0) {} >= string(3) "123" +array(0) {} >= string(3) "2.5" +array(0) {} >= NULL +array(0) {} < bool(true) +array(0) {} >= bool(false) +array(0) {} < object(stdClass)#1 (0) {} +array(0) {} < object(stdClass)#2 (0) {} +array(0) {} < object(test)#3 (0) {} +array(0) {} >= array(0) {} +array(0) {} >= int(-2147483648) +array(0) {} >= string(11) "-2147483648" +int(-2147483648) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-2147483648) < string(0) "" +int(-2147483648) < int(1) +int(-2147483648) < float(2.5) +int(-2147483648) < int(0) +int(-2147483648) < string(6) "string" +int(-2147483648) < string(3) "123" +int(-2147483648) < string(3) "2.5" +int(-2147483648) >= NULL +int(-2147483648) >= bool(true) +int(-2147483648) >= bool(false) +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#1 (0) {} +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#2 (0) {} +int(-2147483648) +Notice: Object of class test could not be converted to int in %s on line %d + < object(test)#3 (0) {} +int(-2147483648) < array(0) {} +int(-2147483648) >= int(-2147483648) +int(-2147483648) >= string(11) "-2147483648" +string(11) "-2147483648" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(11) "-2147483648" >= string(0) "" +string(11) "-2147483648" < int(1) +string(11) "-2147483648" < float(2.5) +string(11) "-2147483648" < int(0) +string(11) "-2147483648" < string(6) "string" +string(11) "-2147483648" < string(3) "123" +string(11) "-2147483648" < string(3) "2.5" +string(11) "-2147483648" >= NULL +string(11) "-2147483648" >= bool(true) +string(11) "-2147483648" >= bool(false) +string(11) "-2147483648" < object(stdClass)#1 (0) {} +string(11) "-2147483648" < object(stdClass)#2 (0) {} +string(11) "-2147483648" < object(test)#3 (0) {} +string(11) "-2147483648" < array(0) {} +string(11) "-2147483648" >= int(-2147483648) +string(11) "-2147483648" >= string(11) "-2147483648" +Done diff --git a/Zend/tests/compare_004_64bit.phpt b/Zend/tests/compare_004_64bit.phpt new file mode 100644 index 0000000..36bdaa7 --- /dev/null +++ b/Zend/tests/compare_004_64bit.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables (less than) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var < $a[$i]) ? " < " : " >= "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(test)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(-9223372036854775808) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(20) "-9223372036854775808" +string(0) "" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" >= string(0) "" +string(0) "" < int(1) +string(0) "" < float(2.5) +string(0) "" >= int(0) +string(0) "" < string(6) "string" +string(0) "" < string(3) "123" +string(0) "" < string(3) "2.5" +string(0) "" >= NULL +string(0) "" < bool(true) +string(0) "" >= bool(false) +string(0) "" < object(stdClass)#%d (0) {} +string(0) "" < object(stdClass)#%d (0) {} +string(0) "" < object(test)#%d (0) {} +string(0) "" < array(0) {} +string(0) "" >= int(-9223372036854775808) +string(0) "" < string(20) "-9223372036854775808" +int(1) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) >= string(0) "" +int(1) >= int(1) +int(1) < float(2.5) +int(1) >= int(0) +int(1) >= string(6) "string" +int(1) < string(3) "123" +int(1) < string(3) "2.5" +int(1) >= NULL +int(1) >= bool(true) +int(1) >= bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= object(stdClass)#%d (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= object(stdClass)#%d (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + >= object(test)#%d (0) {} +int(1) < array(0) {} +int(1) >= int(-9223372036854775808) +int(1) >= string(20) "-9223372036854775808" +float(2.5) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) >= string(0) "" +float(2.5) >= int(1) +float(2.5) >= float(2.5) +float(2.5) >= int(0) +float(2.5) >= string(6) "string" +float(2.5) < string(3) "123" +float(2.5) >= string(3) "2.5" +float(2.5) >= NULL +float(2.5) >= bool(true) +float(2.5) >= bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + >= object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + >= object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + >= object(test)#%d (0) {} +float(2.5) < array(0) {} +float(2.5) >= int(-9223372036854775808) +float(2.5) >= string(20) "-9223372036854775808" +int(0) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) >= string(0) "" +int(0) < int(1) +int(0) < float(2.5) +int(0) >= int(0) +int(0) >= string(6) "string" +int(0) < string(3) "123" +int(0) < string(3) "2.5" +int(0) >= NULL +int(0) < bool(true) +int(0) >= bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#%d (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#%d (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + < object(test)#%d (0) {} +int(0) < array(0) {} +int(0) >= int(-9223372036854775808) +int(0) >= string(20) "-9223372036854775808" +string(6) "string" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" >= string(0) "" +string(6) "string" < int(1) +string(6) "string" < float(2.5) +string(6) "string" >= int(0) +string(6) "string" >= string(6) "string" +string(6) "string" >= string(3) "123" +string(6) "string" >= string(3) "2.5" +string(6) "string" >= NULL +string(6) "string" >= bool(true) +string(6) "string" >= bool(false) +string(6) "string" < object(stdClass)#%d (0) {} +string(6) "string" < object(stdClass)#%d (0) {} +string(6) "string" < object(test)#%d (0) {} +string(6) "string" < array(0) {} +string(6) "string" >= int(-9223372036854775808) +string(6) "string" >= string(20) "-9223372036854775808" +string(3) "123" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" >= string(0) "" +string(3) "123" >= int(1) +string(3) "123" >= float(2.5) +string(3) "123" >= int(0) +string(3) "123" < string(6) "string" +string(3) "123" >= string(3) "123" +string(3) "123" >= string(3) "2.5" +string(3) "123" >= NULL +string(3) "123" >= bool(true) +string(3) "123" >= bool(false) +string(3) "123" < object(stdClass)#%d (0) {} +string(3) "123" < object(stdClass)#%d (0) {} +string(3) "123" < object(test)#%d (0) {} +string(3) "123" < array(0) {} +string(3) "123" >= int(-9223372036854775808) +string(3) "123" >= string(20) "-9223372036854775808" +string(3) "2.5" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" >= string(0) "" +string(3) "2.5" >= int(1) +string(3) "2.5" >= float(2.5) +string(3) "2.5" >= int(0) +string(3) "2.5" < string(6) "string" +string(3) "2.5" < string(3) "123" +string(3) "2.5" >= string(3) "2.5" +string(3) "2.5" >= NULL +string(3) "2.5" >= bool(true) +string(3) "2.5" >= bool(false) +string(3) "2.5" < object(stdClass)#%d (0) {} +string(3) "2.5" < object(stdClass)#%d (0) {} +string(3) "2.5" < object(test)#%d (0) {} +string(3) "2.5" < array(0) {} +string(3) "2.5" >= int(-9223372036854775808) +string(3) "2.5" >= string(20) "-9223372036854775808" +NULL < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL >= string(0) "" +NULL < int(1) +NULL < float(2.5) +NULL >= int(0) +NULL < string(6) "string" +NULL < string(3) "123" +NULL < string(3) "2.5" +NULL >= NULL +NULL < bool(true) +NULL >= bool(false) +NULL < object(stdClass)#%d (0) {} +NULL < object(stdClass)#%d (0) {} +NULL < object(test)#%d (0) {} +NULL >= array(0) {} +NULL < int(-9223372036854775808) +NULL < string(20) "-9223372036854775808" +bool(true) >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) >= string(0) "" +bool(true) >= int(1) +bool(true) >= float(2.5) +bool(true) >= int(0) +bool(true) >= string(6) "string" +bool(true) >= string(3) "123" +bool(true) >= string(3) "2.5" +bool(true) >= NULL +bool(true) >= bool(true) +bool(true) >= bool(false) +bool(true) >= object(stdClass)#%d (0) {} +bool(true) >= object(stdClass)#%d (0) {} +bool(true) >= object(test)#%d (0) {} +bool(true) >= array(0) {} +bool(true) >= int(-9223372036854775808) +bool(true) >= string(20) "-9223372036854775808" +bool(false) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) >= string(0) "" +bool(false) < int(1) +bool(false) < float(2.5) +bool(false) >= int(0) +bool(false) < string(6) "string" +bool(false) < string(3) "123" +bool(false) < string(3) "2.5" +bool(false) >= NULL +bool(false) < bool(true) +bool(false) >= bool(false) +bool(false) < object(stdClass)#%d (0) {} +bool(false) < object(stdClass)#%d (0) {} +bool(false) < object(test)#%d (0) {} +bool(false) >= array(0) {} +bool(false) < int(-9223372036854775808) +bool(false) < string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} >= string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + < float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(0) +object(stdClass)#%d (0) {} >= string(6) "string" +object(stdClass)#%d (0) {} >= string(3) "123" +object(stdClass)#%d (0) {} >= string(3) "2.5" +object(stdClass)#%d (0) {} >= NULL +object(stdClass)#%d (0) {} >= bool(true) +object(stdClass)#%d (0) {} >= bool(false) +object(stdClass)#%d (0) {} >= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} >= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} >= object(test)#%d (0) {} +object(stdClass)#%d (0) {} >= array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(-9223372036854775808) +object(stdClass)#%d (0) {} >= string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} >= string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + < float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(0) +object(stdClass)#%d (0) {} >= string(6) "string" +object(stdClass)#%d (0) {} >= string(3) "123" +object(stdClass)#%d (0) {} >= string(3) "2.5" +object(stdClass)#%d (0) {} >= NULL +object(stdClass)#%d (0) {} >= bool(true) +object(stdClass)#%d (0) {} >= bool(false) +object(stdClass)#%d (0) {} >= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} >= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} >= object(test)#%d (0) {} +object(stdClass)#%d (0) {} >= array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(-9223372036854775808) +object(stdClass)#%d (0) {} >= string(20) "-9223372036854775808" +object(test)#%d (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#%d (0) {} >= string(0) "" +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(1) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + < float(2.5) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(0) +object(test)#%d (0) {} >= string(6) "string" +object(test)#%d (0) {} >= string(3) "123" +object(test)#%d (0) {} >= string(3) "2.5" +object(test)#%d (0) {} >= NULL +object(test)#%d (0) {} >= bool(true) +object(test)#%d (0) {} >= bool(false) +object(test)#%d (0) {} >= object(stdClass)#%d (0) {} +object(test)#%d (0) {} >= object(stdClass)#%d (0) {} +object(test)#%d (0) {} >= object(test)#%d (0) {} +object(test)#%d (0) {} >= array(0) {} +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(-9223372036854775808) +object(test)#%d (0) {} >= string(20) "-9223372036854775808" +array(0) {} < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} >= string(0) "" +array(0) {} >= int(1) +array(0) {} >= float(2.5) +array(0) {} >= int(0) +array(0) {} >= string(6) "string" +array(0) {} >= string(3) "123" +array(0) {} >= string(3) "2.5" +array(0) {} >= NULL +array(0) {} < bool(true) +array(0) {} >= bool(false) +array(0) {} < object(stdClass)#%d (0) {} +array(0) {} < object(stdClass)#%d (0) {} +array(0) {} < object(test)#%d (0) {} +array(0) {} >= array(0) {} +array(0) {} >= int(-9223372036854775808) +array(0) {} >= string(20) "-9223372036854775808" +int(-9223372036854775808) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-9223372036854775808) < string(0) "" +int(-9223372036854775808) < int(1) +int(-9223372036854775808) < float(2.5) +int(-9223372036854775808) < int(0) +int(-9223372036854775808) < string(6) "string" +int(-9223372036854775808) < string(3) "123" +int(-9223372036854775808) < string(3) "2.5" +int(-9223372036854775808) >= NULL +int(-9223372036854775808) >= bool(true) +int(-9223372036854775808) >= bool(false) +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class test could not be converted to int in %s on line %d + < object(test)#%d (0) {} +int(-9223372036854775808) < array(0) {} +int(-9223372036854775808) >= int(-9223372036854775808) +int(-9223372036854775808) >= string(20) "-9223372036854775808" +string(20) "-9223372036854775808" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(20) "-9223372036854775808" >= string(0) "" +string(20) "-9223372036854775808" < int(1) +string(20) "-9223372036854775808" < float(2.5) +string(20) "-9223372036854775808" < int(0) +string(20) "-9223372036854775808" < string(6) "string" +string(20) "-9223372036854775808" < string(3) "123" +string(20) "-9223372036854775808" < string(3) "2.5" +string(20) "-9223372036854775808" >= NULL +string(20) "-9223372036854775808" >= bool(true) +string(20) "-9223372036854775808" >= bool(false) +string(20) "-9223372036854775808" < object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" < object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" < object(test)#%d (0) {} +string(20) "-9223372036854775808" < array(0) {} +string(20) "-9223372036854775808" >= int(-9223372036854775808) +string(20) "-9223372036854775808" >= string(20) "-9223372036854775808" +Done diff --git a/Zend/tests/compare_005.phpt b/Zend/tests/compare_005.phpt new file mode 100644 index 0000000..4f5cd80 --- /dev/null +++ b/Zend/tests/compare_005.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables (greater or equal than) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var >= $a[$i]) ? " >= " : " < "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(stdClass)#1 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(stdClass)#2 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(test)#3 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(-2147483648) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(11) "-2147483648" +string(0) "" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" >= string(0) "" +string(0) "" < int(1) +string(0) "" < float(2.5) +string(0) "" >= int(0) +string(0) "" < string(6) "string" +string(0) "" < string(3) "123" +string(0) "" < string(3) "2.5" +string(0) "" >= NULL +string(0) "" < bool(true) +string(0) "" >= bool(false) +string(0) "" < object(stdClass)#1 (0) {} +string(0) "" < object(stdClass)#2 (0) {} +string(0) "" < object(test)#3 (0) {} +string(0) "" < array(0) {} +string(0) "" >= int(-2147483648) +string(0) "" < string(11) "-2147483648" +int(1) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) >= string(0) "" +int(1) >= int(1) +int(1) < float(2.5) +int(1) >= int(0) +int(1) >= string(6) "string" +int(1) < string(3) "123" +int(1) < string(3) "2.5" +int(1) >= NULL +int(1) >= bool(true) +int(1) >= bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= object(stdClass)#1 (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= object(stdClass)#2 (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + >= object(test)#3 (0) {} +int(1) < array(0) {} +int(1) >= int(-2147483648) +int(1) >= string(11) "-2147483648" +float(2.5) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) >= string(0) "" +float(2.5) >= int(1) +float(2.5) >= float(2.5) +float(2.5) >= int(0) +float(2.5) >= string(6) "string" +float(2.5) < string(3) "123" +float(2.5) >= string(3) "2.5" +float(2.5) >= NULL +float(2.5) >= bool(true) +float(2.5) >= bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + >= object(stdClass)#1 (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + >= object(stdClass)#2 (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + >= object(test)#3 (0) {} +float(2.5) < array(0) {} +float(2.5) >= int(-2147483648) +float(2.5) >= string(11) "-2147483648" +int(0) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) >= string(0) "" +int(0) < int(1) +int(0) < float(2.5) +int(0) >= int(0) +int(0) >= string(6) "string" +int(0) < string(3) "123" +int(0) < string(3) "2.5" +int(0) >= NULL +int(0) < bool(true) +int(0) >= bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#1 (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#2 (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + < object(test)#3 (0) {} +int(0) < array(0) {} +int(0) >= int(-2147483648) +int(0) >= string(11) "-2147483648" +string(6) "string" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" >= string(0) "" +string(6) "string" < int(1) +string(6) "string" < float(2.5) +string(6) "string" >= int(0) +string(6) "string" >= string(6) "string" +string(6) "string" >= string(3) "123" +string(6) "string" >= string(3) "2.5" +string(6) "string" >= NULL +string(6) "string" >= bool(true) +string(6) "string" >= bool(false) +string(6) "string" < object(stdClass)#1 (0) {} +string(6) "string" < object(stdClass)#2 (0) {} +string(6) "string" < object(test)#3 (0) {} +string(6) "string" < array(0) {} +string(6) "string" >= int(-2147483648) +string(6) "string" >= string(11) "-2147483648" +string(3) "123" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" >= string(0) "" +string(3) "123" >= int(1) +string(3) "123" >= float(2.5) +string(3) "123" >= int(0) +string(3) "123" < string(6) "string" +string(3) "123" >= string(3) "123" +string(3) "123" >= string(3) "2.5" +string(3) "123" >= NULL +string(3) "123" >= bool(true) +string(3) "123" >= bool(false) +string(3) "123" < object(stdClass)#1 (0) {} +string(3) "123" < object(stdClass)#2 (0) {} +string(3) "123" < object(test)#3 (0) {} +string(3) "123" < array(0) {} +string(3) "123" >= int(-2147483648) +string(3) "123" >= string(11) "-2147483648" +string(3) "2.5" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" >= string(0) "" +string(3) "2.5" >= int(1) +string(3) "2.5" >= float(2.5) +string(3) "2.5" >= int(0) +string(3) "2.5" < string(6) "string" +string(3) "2.5" < string(3) "123" +string(3) "2.5" >= string(3) "2.5" +string(3) "2.5" >= NULL +string(3) "2.5" >= bool(true) +string(3) "2.5" >= bool(false) +string(3) "2.5" < object(stdClass)#1 (0) {} +string(3) "2.5" < object(stdClass)#2 (0) {} +string(3) "2.5" < object(test)#3 (0) {} +string(3) "2.5" < array(0) {} +string(3) "2.5" >= int(-2147483648) +string(3) "2.5" >= string(11) "-2147483648" +NULL < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL >= string(0) "" +NULL < int(1) +NULL < float(2.5) +NULL >= int(0) +NULL < string(6) "string" +NULL < string(3) "123" +NULL < string(3) "2.5" +NULL >= NULL +NULL < bool(true) +NULL >= bool(false) +NULL < object(stdClass)#1 (0) {} +NULL < object(stdClass)#2 (0) {} +NULL < object(test)#3 (0) {} +NULL >= array(0) {} +NULL < int(-2147483648) +NULL < string(11) "-2147483648" +bool(true) >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) >= string(0) "" +bool(true) >= int(1) +bool(true) >= float(2.5) +bool(true) >= int(0) +bool(true) >= string(6) "string" +bool(true) >= string(3) "123" +bool(true) >= string(3) "2.5" +bool(true) >= NULL +bool(true) >= bool(true) +bool(true) >= bool(false) +bool(true) >= object(stdClass)#1 (0) {} +bool(true) >= object(stdClass)#2 (0) {} +bool(true) >= object(test)#3 (0) {} +bool(true) >= array(0) {} +bool(true) >= int(-2147483648) +bool(true) >= string(11) "-2147483648" +bool(false) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) >= string(0) "" +bool(false) < int(1) +bool(false) < float(2.5) +bool(false) >= int(0) +bool(false) < string(6) "string" +bool(false) < string(3) "123" +bool(false) < string(3) "2.5" +bool(false) >= NULL +bool(false) < bool(true) +bool(false) >= bool(false) +bool(false) < object(stdClass)#1 (0) {} +bool(false) < object(stdClass)#2 (0) {} +bool(false) < object(test)#3 (0) {} +bool(false) >= array(0) {} +bool(false) < int(-2147483648) +bool(false) < string(11) "-2147483648" +object(stdClass)#1 (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#1 (0) {} >= string(0) "" +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(1) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + < float(2.5) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(0) +object(stdClass)#1 (0) {} >= string(6) "string" +object(stdClass)#1 (0) {} >= string(3) "123" +object(stdClass)#1 (0) {} >= string(3) "2.5" +object(stdClass)#1 (0) {} >= NULL +object(stdClass)#1 (0) {} >= bool(true) +object(stdClass)#1 (0) {} >= bool(false) +object(stdClass)#1 (0) {} >= object(stdClass)#1 (0) {} +object(stdClass)#1 (0) {} >= object(stdClass)#2 (0) {} +object(stdClass)#1 (0) {} < object(test)#3 (0) {} +object(stdClass)#1 (0) {} >= array(0) {} +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(-2147483648) +object(stdClass)#1 (0) {} >= string(11) "-2147483648" +object(stdClass)#2 (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#2 (0) {} >= string(0) "" +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(1) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + < float(2.5) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(0) +object(stdClass)#2 (0) {} >= string(6) "string" +object(stdClass)#2 (0) {} >= string(3) "123" +object(stdClass)#2 (0) {} >= string(3) "2.5" +object(stdClass)#2 (0) {} >= NULL +object(stdClass)#2 (0) {} >= bool(true) +object(stdClass)#2 (0) {} >= bool(false) +object(stdClass)#2 (0) {} >= object(stdClass)#1 (0) {} +object(stdClass)#2 (0) {} >= object(stdClass)#2 (0) {} +object(stdClass)#2 (0) {} < object(test)#3 (0) {} +object(stdClass)#2 (0) {} >= array(0) {} +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(-2147483648) +object(stdClass)#2 (0) {} >= string(11) "-2147483648" +object(test)#3 (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#3 (0) {} >= string(0) "" +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(1) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + < float(2.5) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(0) +object(test)#3 (0) {} >= string(6) "string" +object(test)#3 (0) {} >= string(3) "123" +object(test)#3 (0) {} >= string(3) "2.5" +object(test)#3 (0) {} >= NULL +object(test)#3 (0) {} >= bool(true) +object(test)#3 (0) {} >= bool(false) +object(test)#3 (0) {} < object(stdClass)#1 (0) {} +object(test)#3 (0) {} < object(stdClass)#2 (0) {} +object(test)#3 (0) {} >= object(test)#3 (0) {} +object(test)#3 (0) {} >= array(0) {} +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(-2147483648) +object(test)#3 (0) {} >= string(11) "-2147483648" +array(0) {} < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} >= string(0) "" +array(0) {} >= int(1) +array(0) {} >= float(2.5) +array(0) {} >= int(0) +array(0) {} >= string(6) "string" +array(0) {} >= string(3) "123" +array(0) {} >= string(3) "2.5" +array(0) {} >= NULL +array(0) {} < bool(true) +array(0) {} >= bool(false) +array(0) {} < object(stdClass)#1 (0) {} +array(0) {} < object(stdClass)#2 (0) {} +array(0) {} < object(test)#3 (0) {} +array(0) {} >= array(0) {} +array(0) {} >= int(-2147483648) +array(0) {} >= string(11) "-2147483648" +int(-2147483648) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-2147483648) < string(0) "" +int(-2147483648) < int(1) +int(-2147483648) < float(2.5) +int(-2147483648) < int(0) +int(-2147483648) < string(6) "string" +int(-2147483648) < string(3) "123" +int(-2147483648) < string(3) "2.5" +int(-2147483648) >= NULL +int(-2147483648) >= bool(true) +int(-2147483648) >= bool(false) +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#1 (0) {} +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#2 (0) {} +int(-2147483648) +Notice: Object of class test could not be converted to int in %s on line %d + < object(test)#3 (0) {} +int(-2147483648) < array(0) {} +int(-2147483648) >= int(-2147483648) +int(-2147483648) >= string(11) "-2147483648" +string(11) "-2147483648" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(11) "-2147483648" >= string(0) "" +string(11) "-2147483648" < int(1) +string(11) "-2147483648" < float(2.5) +string(11) "-2147483648" < int(0) +string(11) "-2147483648" < string(6) "string" +string(11) "-2147483648" < string(3) "123" +string(11) "-2147483648" < string(3) "2.5" +string(11) "-2147483648" >= NULL +string(11) "-2147483648" >= bool(true) +string(11) "-2147483648" >= bool(false) +string(11) "-2147483648" < object(stdClass)#1 (0) {} +string(11) "-2147483648" < object(stdClass)#2 (0) {} +string(11) "-2147483648" < object(test)#3 (0) {} +string(11) "-2147483648" < array(0) {} +string(11) "-2147483648" >= int(-2147483648) +string(11) "-2147483648" >= string(11) "-2147483648" +Done diff --git a/Zend/tests/compare_005_64bit.phpt b/Zend/tests/compare_005_64bit.phpt new file mode 100644 index 0000000..69492b3 --- /dev/null +++ b/Zend/tests/compare_005_64bit.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables (greater or equal than) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var >= $a[$i]) ? " >= " : " < "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} < object(test)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= int(-9223372036854775808) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} >= string(20) "-9223372036854775808" +string(0) "" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" >= string(0) "" +string(0) "" < int(1) +string(0) "" < float(2.5) +string(0) "" >= int(0) +string(0) "" < string(6) "string" +string(0) "" < string(3) "123" +string(0) "" < string(3) "2.5" +string(0) "" >= NULL +string(0) "" < bool(true) +string(0) "" >= bool(false) +string(0) "" < object(stdClass)#%d (0) {} +string(0) "" < object(stdClass)#%d (0) {} +string(0) "" < object(test)#%d (0) {} +string(0) "" < array(0) {} +string(0) "" >= int(-9223372036854775808) +string(0) "" < string(20) "-9223372036854775808" +int(1) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) >= string(0) "" +int(1) >= int(1) +int(1) < float(2.5) +int(1) >= int(0) +int(1) >= string(6) "string" +int(1) < string(3) "123" +int(1) < string(3) "2.5" +int(1) >= NULL +int(1) >= bool(true) +int(1) >= bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= object(stdClass)#%d (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= object(stdClass)#%d (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + >= object(test)#%d (0) {} +int(1) < array(0) {} +int(1) >= int(-9223372036854775808) +int(1) >= string(20) "-9223372036854775808" +float(2.5) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) >= string(0) "" +float(2.5) >= int(1) +float(2.5) >= float(2.5) +float(2.5) >= int(0) +float(2.5) >= string(6) "string" +float(2.5) < string(3) "123" +float(2.5) >= string(3) "2.5" +float(2.5) >= NULL +float(2.5) >= bool(true) +float(2.5) >= bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + >= object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + >= object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + >= object(test)#%d (0) {} +float(2.5) < array(0) {} +float(2.5) >= int(-9223372036854775808) +float(2.5) >= string(20) "-9223372036854775808" +int(0) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) >= string(0) "" +int(0) < int(1) +int(0) < float(2.5) +int(0) >= int(0) +int(0) >= string(6) "string" +int(0) < string(3) "123" +int(0) < string(3) "2.5" +int(0) >= NULL +int(0) < bool(true) +int(0) >= bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#%d (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#%d (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + < object(test)#%d (0) {} +int(0) < array(0) {} +int(0) >= int(-9223372036854775808) +int(0) >= string(20) "-9223372036854775808" +string(6) "string" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" >= string(0) "" +string(6) "string" < int(1) +string(6) "string" < float(2.5) +string(6) "string" >= int(0) +string(6) "string" >= string(6) "string" +string(6) "string" >= string(3) "123" +string(6) "string" >= string(3) "2.5" +string(6) "string" >= NULL +string(6) "string" >= bool(true) +string(6) "string" >= bool(false) +string(6) "string" < object(stdClass)#%d (0) {} +string(6) "string" < object(stdClass)#%d (0) {} +string(6) "string" < object(test)#%d (0) {} +string(6) "string" < array(0) {} +string(6) "string" >= int(-9223372036854775808) +string(6) "string" >= string(20) "-9223372036854775808" +string(3) "123" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" >= string(0) "" +string(3) "123" >= int(1) +string(3) "123" >= float(2.5) +string(3) "123" >= int(0) +string(3) "123" < string(6) "string" +string(3) "123" >= string(3) "123" +string(3) "123" >= string(3) "2.5" +string(3) "123" >= NULL +string(3) "123" >= bool(true) +string(3) "123" >= bool(false) +string(3) "123" < object(stdClass)#%d (0) {} +string(3) "123" < object(stdClass)#%d (0) {} +string(3) "123" < object(test)#%d (0) {} +string(3) "123" < array(0) {} +string(3) "123" >= int(-9223372036854775808) +string(3) "123" >= string(20) "-9223372036854775808" +string(3) "2.5" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" >= string(0) "" +string(3) "2.5" >= int(1) +string(3) "2.5" >= float(2.5) +string(3) "2.5" >= int(0) +string(3) "2.5" < string(6) "string" +string(3) "2.5" < string(3) "123" +string(3) "2.5" >= string(3) "2.5" +string(3) "2.5" >= NULL +string(3) "2.5" >= bool(true) +string(3) "2.5" >= bool(false) +string(3) "2.5" < object(stdClass)#%d (0) {} +string(3) "2.5" < object(stdClass)#%d (0) {} +string(3) "2.5" < object(test)#%d (0) {} +string(3) "2.5" < array(0) {} +string(3) "2.5" >= int(-9223372036854775808) +string(3) "2.5" >= string(20) "-9223372036854775808" +NULL < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL >= string(0) "" +NULL < int(1) +NULL < float(2.5) +NULL >= int(0) +NULL < string(6) "string" +NULL < string(3) "123" +NULL < string(3) "2.5" +NULL >= NULL +NULL < bool(true) +NULL >= bool(false) +NULL < object(stdClass)#%d (0) {} +NULL < object(stdClass)#%d (0) {} +NULL < object(test)#%d (0) {} +NULL >= array(0) {} +NULL < int(-9223372036854775808) +NULL < string(20) "-9223372036854775808" +bool(true) >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) >= string(0) "" +bool(true) >= int(1) +bool(true) >= float(2.5) +bool(true) >= int(0) +bool(true) >= string(6) "string" +bool(true) >= string(3) "123" +bool(true) >= string(3) "2.5" +bool(true) >= NULL +bool(true) >= bool(true) +bool(true) >= bool(false) +bool(true) >= object(stdClass)#%d (0) {} +bool(true) >= object(stdClass)#%d (0) {} +bool(true) >= object(test)#%d (0) {} +bool(true) >= array(0) {} +bool(true) >= int(-9223372036854775808) +bool(true) >= string(20) "-9223372036854775808" +bool(false) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) >= string(0) "" +bool(false) < int(1) +bool(false) < float(2.5) +bool(false) >= int(0) +bool(false) < string(6) "string" +bool(false) < string(3) "123" +bool(false) < string(3) "2.5" +bool(false) >= NULL +bool(false) < bool(true) +bool(false) >= bool(false) +bool(false) < object(stdClass)#%d (0) {} +bool(false) < object(stdClass)#%d (0) {} +bool(false) < object(test)#%d (0) {} +bool(false) >= array(0) {} +bool(false) < int(-9223372036854775808) +bool(false) < string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} >= string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + < float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(0) +object(stdClass)#%d (0) {} >= string(6) "string" +object(stdClass)#%d (0) {} >= string(3) "123" +object(stdClass)#%d (0) {} >= string(3) "2.5" +object(stdClass)#%d (0) {} >= NULL +object(stdClass)#%d (0) {} >= bool(true) +object(stdClass)#%d (0) {} >= bool(false) +object(stdClass)#%d (0) {} >= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} >= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} < object(test)#%d (0) {} +object(stdClass)#%d (0) {} >= array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(-9223372036854775808) +object(stdClass)#%d (0) {} >= string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} >= string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + < float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(0) +object(stdClass)#%d (0) {} >= string(6) "string" +object(stdClass)#%d (0) {} >= string(3) "123" +object(stdClass)#%d (0) {} >= string(3) "2.5" +object(stdClass)#%d (0) {} >= NULL +object(stdClass)#%d (0) {} >= bool(true) +object(stdClass)#%d (0) {} >= bool(false) +object(stdClass)#%d (0) {} >= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} >= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} < object(test)#%d (0) {} +object(stdClass)#%d (0) {} >= array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + >= int(-9223372036854775808) +object(stdClass)#%d (0) {} >= string(20) "-9223372036854775808" +object(test)#%d (0) {} >= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#%d (0) {} >= string(0) "" +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(1) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + < float(2.5) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(0) +object(test)#%d (0) {} >= string(6) "string" +object(test)#%d (0) {} >= string(3) "123" +object(test)#%d (0) {} >= string(3) "2.5" +object(test)#%d (0) {} >= NULL +object(test)#%d (0) {} >= bool(true) +object(test)#%d (0) {} >= bool(false) +object(test)#%d (0) {} < object(stdClass)#%d (0) {} +object(test)#%d (0) {} < object(stdClass)#%d (0) {} +object(test)#%d (0) {} >= object(test)#%d (0) {} +object(test)#%d (0) {} >= array(0) {} +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + >= int(-9223372036854775808) +object(test)#%d (0) {} >= string(20) "-9223372036854775808" +array(0) {} < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} >= string(0) "" +array(0) {} >= int(1) +array(0) {} >= float(2.5) +array(0) {} >= int(0) +array(0) {} >= string(6) "string" +array(0) {} >= string(3) "123" +array(0) {} >= string(3) "2.5" +array(0) {} >= NULL +array(0) {} < bool(true) +array(0) {} >= bool(false) +array(0) {} < object(stdClass)#%d (0) {} +array(0) {} < object(stdClass)#%d (0) {} +array(0) {} < object(test)#%d (0) {} +array(0) {} >= array(0) {} +array(0) {} >= int(-9223372036854775808) +array(0) {} >= string(20) "-9223372036854775808" +int(-9223372036854775808) < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-9223372036854775808) < string(0) "" +int(-9223372036854775808) < int(1) +int(-9223372036854775808) < float(2.5) +int(-9223372036854775808) < int(0) +int(-9223372036854775808) < string(6) "string" +int(-9223372036854775808) < string(3) "123" +int(-9223372036854775808) < string(3) "2.5" +int(-9223372036854775808) >= NULL +int(-9223372036854775808) >= bool(true) +int(-9223372036854775808) >= bool(false) +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + < object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class test could not be converted to int in %s on line %d + < object(test)#%d (0) {} +int(-9223372036854775808) < array(0) {} +int(-9223372036854775808) >= int(-9223372036854775808) +int(-9223372036854775808) >= string(20) "-9223372036854775808" +string(20) "-9223372036854775808" < array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(20) "-9223372036854775808" >= string(0) "" +string(20) "-9223372036854775808" < int(1) +string(20) "-9223372036854775808" < float(2.5) +string(20) "-9223372036854775808" < int(0) +string(20) "-9223372036854775808" < string(6) "string" +string(20) "-9223372036854775808" < string(3) "123" +string(20) "-9223372036854775808" < string(3) "2.5" +string(20) "-9223372036854775808" >= NULL +string(20) "-9223372036854775808" >= bool(true) +string(20) "-9223372036854775808" >= bool(false) +string(20) "-9223372036854775808" < object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" < object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" < object(test)#%d (0) {} +string(20) "-9223372036854775808" < array(0) {} +string(20) "-9223372036854775808" >= int(-9223372036854775808) +string(20) "-9223372036854775808" >= string(20) "-9223372036854775808" +Done diff --git a/Zend/tests/compare_006.phpt b/Zend/tests/compare_006.phpt new file mode 100644 index 0000000..743983b --- /dev/null +++ b/Zend/tests/compare_006.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables (smaller or equal than) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var <= $a[$i]) ? " <= " : " > "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(stdClass)#1 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(stdClass)#2 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(test)#3 (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(-2147483648) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(11) "-2147483648" +string(0) "" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" <= string(0) "" +string(0) "" <= int(1) +string(0) "" <= float(2.5) +string(0) "" <= int(0) +string(0) "" <= string(6) "string" +string(0) "" <= string(3) "123" +string(0) "" <= string(3) "2.5" +string(0) "" <= NULL +string(0) "" <= bool(true) +string(0) "" <= bool(false) +string(0) "" <= object(stdClass)#1 (0) {} +string(0) "" <= object(stdClass)#2 (0) {} +string(0) "" <= object(test)#3 (0) {} +string(0) "" <= array(0) {} +string(0) "" > int(-2147483648) +string(0) "" <= string(11) "-2147483648" +int(1) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) > string(0) "" +int(1) <= int(1) +int(1) <= float(2.5) +int(1) > int(0) +int(1) > string(6) "string" +int(1) <= string(3) "123" +int(1) <= string(3) "2.5" +int(1) > NULL +int(1) <= bool(true) +int(1) > bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#1 (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#2 (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#3 (0) {} +int(1) <= array(0) {} +int(1) > int(-2147483648) +int(1) > string(11) "-2147483648" +float(2.5) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) > string(0) "" +float(2.5) > int(1) +float(2.5) <= float(2.5) +float(2.5) > int(0) +float(2.5) > string(6) "string" +float(2.5) <= string(3) "123" +float(2.5) <= string(3) "2.5" +float(2.5) > NULL +float(2.5) <= bool(true) +float(2.5) > bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + > object(stdClass)#1 (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + > object(stdClass)#2 (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + > object(test)#3 (0) {} +float(2.5) <= array(0) {} +float(2.5) > int(-2147483648) +float(2.5) > string(11) "-2147483648" +int(0) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) <= string(0) "" +int(0) <= int(1) +int(0) <= float(2.5) +int(0) <= int(0) +int(0) <= string(6) "string" +int(0) <= string(3) "123" +int(0) <= string(3) "2.5" +int(0) <= NULL +int(0) <= bool(true) +int(0) <= bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#1 (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#2 (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#3 (0) {} +int(0) <= array(0) {} +int(0) > int(-2147483648) +int(0) > string(11) "-2147483648" +string(6) "string" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" > string(0) "" +string(6) "string" <= int(1) +string(6) "string" <= float(2.5) +string(6) "string" <= int(0) +string(6) "string" <= string(6) "string" +string(6) "string" > string(3) "123" +string(6) "string" > string(3) "2.5" +string(6) "string" > NULL +string(6) "string" <= bool(true) +string(6) "string" > bool(false) +string(6) "string" <= object(stdClass)#1 (0) {} +string(6) "string" <= object(stdClass)#2 (0) {} +string(6) "string" <= object(test)#3 (0) {} +string(6) "string" <= array(0) {} +string(6) "string" > int(-2147483648) +string(6) "string" > string(11) "-2147483648" +string(3) "123" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" > string(0) "" +string(3) "123" > int(1) +string(3) "123" > float(2.5) +string(3) "123" > int(0) +string(3) "123" <= string(6) "string" +string(3) "123" <= string(3) "123" +string(3) "123" > string(3) "2.5" +string(3) "123" > NULL +string(3) "123" <= bool(true) +string(3) "123" > bool(false) +string(3) "123" <= object(stdClass)#1 (0) {} +string(3) "123" <= object(stdClass)#2 (0) {} +string(3) "123" <= object(test)#3 (0) {} +string(3) "123" <= array(0) {} +string(3) "123" > int(-2147483648) +string(3) "123" > string(11) "-2147483648" +string(3) "2.5" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" > string(0) "" +string(3) "2.5" > int(1) +string(3) "2.5" <= float(2.5) +string(3) "2.5" > int(0) +string(3) "2.5" <= string(6) "string" +string(3) "2.5" <= string(3) "123" +string(3) "2.5" <= string(3) "2.5" +string(3) "2.5" > NULL +string(3) "2.5" <= bool(true) +string(3) "2.5" > bool(false) +string(3) "2.5" <= object(stdClass)#1 (0) {} +string(3) "2.5" <= object(stdClass)#2 (0) {} +string(3) "2.5" <= object(test)#3 (0) {} +string(3) "2.5" <= array(0) {} +string(3) "2.5" > int(-2147483648) +string(3) "2.5" > string(11) "-2147483648" +NULL <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL <= string(0) "" +NULL <= int(1) +NULL <= float(2.5) +NULL <= int(0) +NULL <= string(6) "string" +NULL <= string(3) "123" +NULL <= string(3) "2.5" +NULL <= NULL +NULL <= bool(true) +NULL <= bool(false) +NULL <= object(stdClass)#1 (0) {} +NULL <= object(stdClass)#2 (0) {} +NULL <= object(test)#3 (0) {} +NULL <= array(0) {} +NULL <= int(-2147483648) +NULL <= string(11) "-2147483648" +bool(true) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) > string(0) "" +bool(true) <= int(1) +bool(true) <= float(2.5) +bool(true) > int(0) +bool(true) <= string(6) "string" +bool(true) <= string(3) "123" +bool(true) <= string(3) "2.5" +bool(true) > NULL +bool(true) <= bool(true) +bool(true) > bool(false) +bool(true) <= object(stdClass)#1 (0) {} +bool(true) <= object(stdClass)#2 (0) {} +bool(true) <= object(test)#3 (0) {} +bool(true) > array(0) {} +bool(true) <= int(-2147483648) +bool(true) <= string(11) "-2147483648" +bool(false) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) <= string(0) "" +bool(false) <= int(1) +bool(false) <= float(2.5) +bool(false) <= int(0) +bool(false) <= string(6) "string" +bool(false) <= string(3) "123" +bool(false) <= string(3) "2.5" +bool(false) <= NULL +bool(false) <= bool(true) +bool(false) <= bool(false) +bool(false) <= object(stdClass)#1 (0) {} +bool(false) <= object(stdClass)#2 (0) {} +bool(false) <= object(test)#3 (0) {} +bool(false) <= array(0) {} +bool(false) <= int(-2147483648) +bool(false) <= string(11) "-2147483648" +object(stdClass)#1 (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#1 (0) {} > string(0) "" +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= int(1) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + <= float(2.5) +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(0) +object(stdClass)#1 (0) {} > string(6) "string" +object(stdClass)#1 (0) {} > string(3) "123" +object(stdClass)#1 (0) {} > string(3) "2.5" +object(stdClass)#1 (0) {} > NULL +object(stdClass)#1 (0) {} <= bool(true) +object(stdClass)#1 (0) {} > bool(false) +object(stdClass)#1 (0) {} <= object(stdClass)#1 (0) {} +object(stdClass)#1 (0) {} <= object(stdClass)#2 (0) {} +object(stdClass)#1 (0) {} > object(test)#3 (0) {} +object(stdClass)#1 (0) {} > array(0) {} +object(stdClass)#1 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(-2147483648) +object(stdClass)#1 (0) {} > string(11) "-2147483648" +object(stdClass)#2 (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#2 (0) {} > string(0) "" +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= int(1) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + <= float(2.5) +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(0) +object(stdClass)#2 (0) {} > string(6) "string" +object(stdClass)#2 (0) {} > string(3) "123" +object(stdClass)#2 (0) {} > string(3) "2.5" +object(stdClass)#2 (0) {} > NULL +object(stdClass)#2 (0) {} <= bool(true) +object(stdClass)#2 (0) {} > bool(false) +object(stdClass)#2 (0) {} <= object(stdClass)#1 (0) {} +object(stdClass)#2 (0) {} <= object(stdClass)#2 (0) {} +object(stdClass)#2 (0) {} > object(test)#3 (0) {} +object(stdClass)#2 (0) {} > array(0) {} +object(stdClass)#2 (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(-2147483648) +object(stdClass)#2 (0) {} > string(11) "-2147483648" +object(test)#3 (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#3 (0) {} > string(0) "" +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + <= int(1) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + <= float(2.5) +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + > int(0) +object(test)#3 (0) {} > string(6) "string" +object(test)#3 (0) {} > string(3) "123" +object(test)#3 (0) {} > string(3) "2.5" +object(test)#3 (0) {} > NULL +object(test)#3 (0) {} <= bool(true) +object(test)#3 (0) {} > bool(false) +object(test)#3 (0) {} > object(stdClass)#1 (0) {} +object(test)#3 (0) {} > object(stdClass)#2 (0) {} +object(test)#3 (0) {} <= object(test)#3 (0) {} +object(test)#3 (0) {} > array(0) {} +object(test)#3 (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + > int(-2147483648) +object(test)#3 (0) {} > string(11) "-2147483648" +array(0) {} <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} > string(0) "" +array(0) {} > int(1) +array(0) {} > float(2.5) +array(0) {} > int(0) +array(0) {} > string(6) "string" +array(0) {} > string(3) "123" +array(0) {} > string(3) "2.5" +array(0) {} <= NULL +array(0) {} <= bool(true) +array(0) {} <= bool(false) +array(0) {} <= object(stdClass)#1 (0) {} +array(0) {} <= object(stdClass)#2 (0) {} +array(0) {} <= object(test)#3 (0) {} +array(0) {} <= array(0) {} +array(0) {} > int(-2147483648) +array(0) {} > string(11) "-2147483648" +int(-2147483648) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-2147483648) <= string(0) "" +int(-2147483648) <= int(1) +int(-2147483648) <= float(2.5) +int(-2147483648) <= int(0) +int(-2147483648) <= string(6) "string" +int(-2147483648) <= string(3) "123" +int(-2147483648) <= string(3) "2.5" +int(-2147483648) > NULL +int(-2147483648) <= bool(true) +int(-2147483648) > bool(false) +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#1 (0) {} +int(-2147483648) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#2 (0) {} +int(-2147483648) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#3 (0) {} +int(-2147483648) <= array(0) {} +int(-2147483648) <= int(-2147483648) +int(-2147483648) <= string(11) "-2147483648" +string(11) "-2147483648" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(11) "-2147483648" > string(0) "" +string(11) "-2147483648" <= int(1) +string(11) "-2147483648" <= float(2.5) +string(11) "-2147483648" <= int(0) +string(11) "-2147483648" <= string(6) "string" +string(11) "-2147483648" <= string(3) "123" +string(11) "-2147483648" <= string(3) "2.5" +string(11) "-2147483648" > NULL +string(11) "-2147483648" <= bool(true) +string(11) "-2147483648" > bool(false) +string(11) "-2147483648" <= object(stdClass)#1 (0) {} +string(11) "-2147483648" <= object(stdClass)#2 (0) {} +string(11) "-2147483648" <= object(test)#3 (0) {} +string(11) "-2147483648" <= array(0) {} +string(11) "-2147483648" <= int(-2147483648) +string(11) "-2147483648" <= string(11) "-2147483648" +Done diff --git a/Zend/tests/compare_006_64bit.phpt b/Zend/tests/compare_006_64bit.phpt new file mode 100644 index 0000000..56aad8d --- /dev/null +++ b/Zend/tests/compare_006_64bit.phpt @@ -0,0 +1,389 @@ +--TEST-- +comparing different variables (smaller or equal than) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +class test { +} + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +$var_cnt = count($a); + +function my_dump($var) { + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); +} + +foreach($a as $var) { + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var <= $a[$i]) ? " <= " : " > "; + my_dump($a[$i]); + echo "\n"; + } +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(0) "" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(1) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > float(2.5) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(0) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(6) "string" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(3) "123" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(3) "2.5" +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > NULL +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= bool(true) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > bool(false) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(stdClass)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} <= object(test)#%d (0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > array(0) {} +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > int(-9223372036854775808) +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} > string(20) "-9223372036854775808" +string(0) "" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(0) "" <= string(0) "" +string(0) "" <= int(1) +string(0) "" <= float(2.5) +string(0) "" <= int(0) +string(0) "" <= string(6) "string" +string(0) "" <= string(3) "123" +string(0) "" <= string(3) "2.5" +string(0) "" <= NULL +string(0) "" <= bool(true) +string(0) "" <= bool(false) +string(0) "" <= object(stdClass)#%d (0) {} +string(0) "" <= object(stdClass)#%d (0) {} +string(0) "" <= object(test)#%d (0) {} +string(0) "" <= array(0) {} +string(0) "" > int(-9223372036854775808) +string(0) "" <= string(20) "-9223372036854775808" +int(1) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(1) > string(0) "" +int(1) <= int(1) +int(1) <= float(2.5) +int(1) > int(0) +int(1) > string(6) "string" +int(1) <= string(3) "123" +int(1) <= string(3) "2.5" +int(1) > NULL +int(1) <= bool(true) +int(1) > bool(false) +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(1) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(1) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#%d (0) {} +int(1) <= array(0) {} +int(1) > int(-9223372036854775808) +int(1) > string(20) "-9223372036854775808" +float(2.5) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +float(2.5) > string(0) "" +float(2.5) > int(1) +float(2.5) <= float(2.5) +float(2.5) > int(0) +float(2.5) > string(6) "string" +float(2.5) <= string(3) "123" +float(2.5) <= string(3) "2.5" +float(2.5) > NULL +float(2.5) <= bool(true) +float(2.5) > bool(false) +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + > object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class stdClass could not be converted to double in %s on line %d + > object(stdClass)#%d (0) {} +float(2.5) +Notice: Object of class test could not be converted to double in %s on line %d + > object(test)#%d (0) {} +float(2.5) <= array(0) {} +float(2.5) > int(-9223372036854775808) +float(2.5) > string(20) "-9223372036854775808" +int(0) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(0) <= string(0) "" +int(0) <= int(1) +int(0) <= float(2.5) +int(0) <= int(0) +int(0) <= string(6) "string" +int(0) <= string(3) "123" +int(0) <= string(3) "2.5" +int(0) <= NULL +int(0) <= bool(true) +int(0) <= bool(false) +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(0) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(0) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#%d (0) {} +int(0) <= array(0) {} +int(0) > int(-9223372036854775808) +int(0) > string(20) "-9223372036854775808" +string(6) "string" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(6) "string" > string(0) "" +string(6) "string" <= int(1) +string(6) "string" <= float(2.5) +string(6) "string" <= int(0) +string(6) "string" <= string(6) "string" +string(6) "string" > string(3) "123" +string(6) "string" > string(3) "2.5" +string(6) "string" > NULL +string(6) "string" <= bool(true) +string(6) "string" > bool(false) +string(6) "string" <= object(stdClass)#%d (0) {} +string(6) "string" <= object(stdClass)#%d (0) {} +string(6) "string" <= object(test)#%d (0) {} +string(6) "string" <= array(0) {} +string(6) "string" > int(-9223372036854775808) +string(6) "string" > string(20) "-9223372036854775808" +string(3) "123" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "123" > string(0) "" +string(3) "123" > int(1) +string(3) "123" > float(2.5) +string(3) "123" > int(0) +string(3) "123" <= string(6) "string" +string(3) "123" <= string(3) "123" +string(3) "123" > string(3) "2.5" +string(3) "123" > NULL +string(3) "123" <= bool(true) +string(3) "123" > bool(false) +string(3) "123" <= object(stdClass)#%d (0) {} +string(3) "123" <= object(stdClass)#%d (0) {} +string(3) "123" <= object(test)#%d (0) {} +string(3) "123" <= array(0) {} +string(3) "123" > int(-9223372036854775808) +string(3) "123" > string(20) "-9223372036854775808" +string(3) "2.5" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(3) "2.5" > string(0) "" +string(3) "2.5" > int(1) +string(3) "2.5" <= float(2.5) +string(3) "2.5" > int(0) +string(3) "2.5" <= string(6) "string" +string(3) "2.5" <= string(3) "123" +string(3) "2.5" <= string(3) "2.5" +string(3) "2.5" > NULL +string(3) "2.5" <= bool(true) +string(3) "2.5" > bool(false) +string(3) "2.5" <= object(stdClass)#%d (0) {} +string(3) "2.5" <= object(stdClass)#%d (0) {} +string(3) "2.5" <= object(test)#%d (0) {} +string(3) "2.5" <= array(0) {} +string(3) "2.5" > int(-9223372036854775808) +string(3) "2.5" > string(20) "-9223372036854775808" +NULL <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +NULL <= string(0) "" +NULL <= int(1) +NULL <= float(2.5) +NULL <= int(0) +NULL <= string(6) "string" +NULL <= string(3) "123" +NULL <= string(3) "2.5" +NULL <= NULL +NULL <= bool(true) +NULL <= bool(false) +NULL <= object(stdClass)#%d (0) {} +NULL <= object(stdClass)#%d (0) {} +NULL <= object(test)#%d (0) {} +NULL <= array(0) {} +NULL <= int(-9223372036854775808) +NULL <= string(20) "-9223372036854775808" +bool(true) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(true) > string(0) "" +bool(true) <= int(1) +bool(true) <= float(2.5) +bool(true) > int(0) +bool(true) <= string(6) "string" +bool(true) <= string(3) "123" +bool(true) <= string(3) "2.5" +bool(true) > NULL +bool(true) <= bool(true) +bool(true) > bool(false) +bool(true) <= object(stdClass)#%d (0) {} +bool(true) <= object(stdClass)#%d (0) {} +bool(true) <= object(test)#%d (0) {} +bool(true) > array(0) {} +bool(true) <= int(-9223372036854775808) +bool(true) <= string(20) "-9223372036854775808" +bool(false) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +bool(false) <= string(0) "" +bool(false) <= int(1) +bool(false) <= float(2.5) +bool(false) <= int(0) +bool(false) <= string(6) "string" +bool(false) <= string(3) "123" +bool(false) <= string(3) "2.5" +bool(false) <= NULL +bool(false) <= bool(true) +bool(false) <= bool(false) +bool(false) <= object(stdClass)#%d (0) {} +bool(false) <= object(stdClass)#%d (0) {} +bool(false) <= object(test)#%d (0) {} +bool(false) <= array(0) {} +bool(false) <= int(-9223372036854775808) +bool(false) <= string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} > string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + <= float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(0) +object(stdClass)#%d (0) {} > string(6) "string" +object(stdClass)#%d (0) {} > string(3) "123" +object(stdClass)#%d (0) {} > string(3) "2.5" +object(stdClass)#%d (0) {} > NULL +object(stdClass)#%d (0) {} <= bool(true) +object(stdClass)#%d (0) {} > bool(false) +object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} > object(test)#%d (0) {} +object(stdClass)#%d (0) {} > array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(-9223372036854775808) +object(stdClass)#%d (0) {} > string(20) "-9223372036854775808" +object(stdClass)#%d (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(stdClass)#%d (0) {} > string(0) "" +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= int(1) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to double in %s on line %d + <= float(2.5) +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(0) +object(stdClass)#%d (0) {} > string(6) "string" +object(stdClass)#%d (0) {} > string(3) "123" +object(stdClass)#%d (0) {} > string(3) "2.5" +object(stdClass)#%d (0) {} > NULL +object(stdClass)#%d (0) {} <= bool(true) +object(stdClass)#%d (0) {} > bool(false) +object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {} +object(stdClass)#%d (0) {} > object(test)#%d (0) {} +object(stdClass)#%d (0) {} > array(0) {} +object(stdClass)#%d (0) {} +Notice: Object of class stdClass could not be converted to int in %s on line %d + > int(-9223372036854775808) +object(stdClass)#%d (0) {} > string(20) "-9223372036854775808" +object(test)#%d (0) {} > array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +object(test)#%d (0) {} > string(0) "" +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + <= int(1) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to double in %s on line %d + <= float(2.5) +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + > int(0) +object(test)#%d (0) {} > string(6) "string" +object(test)#%d (0) {} > string(3) "123" +object(test)#%d (0) {} > string(3) "2.5" +object(test)#%d (0) {} > NULL +object(test)#%d (0) {} <= bool(true) +object(test)#%d (0) {} > bool(false) +object(test)#%d (0) {} > object(stdClass)#%d (0) {} +object(test)#%d (0) {} > object(stdClass)#%d (0) {} +object(test)#%d (0) {} <= object(test)#%d (0) {} +object(test)#%d (0) {} > array(0) {} +object(test)#%d (0) {} +Notice: Object of class test could not be converted to int in %s on line %d + > int(-9223372036854775808) +object(test)#%d (0) {} > string(20) "-9223372036854775808" +array(0) {} <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +array(0) {} > string(0) "" +array(0) {} > int(1) +array(0) {} > float(2.5) +array(0) {} > int(0) +array(0) {} > string(6) "string" +array(0) {} > string(3) "123" +array(0) {} > string(3) "2.5" +array(0) {} <= NULL +array(0) {} <= bool(true) +array(0) {} <= bool(false) +array(0) {} <= object(stdClass)#%d (0) {} +array(0) {} <= object(stdClass)#%d (0) {} +array(0) {} <= object(test)#%d (0) {} +array(0) {} <= array(0) {} +array(0) {} > int(-9223372036854775808) +array(0) {} > string(20) "-9223372036854775808" +int(-9223372036854775808) <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +int(-9223372036854775808) <= string(0) "" +int(-9223372036854775808) <= int(1) +int(-9223372036854775808) <= float(2.5) +int(-9223372036854775808) <= int(0) +int(-9223372036854775808) <= string(6) "string" +int(-9223372036854775808) <= string(3) "123" +int(-9223372036854775808) <= string(3) "2.5" +int(-9223372036854775808) > NULL +int(-9223372036854775808) <= bool(true) +int(-9223372036854775808) > bool(false) +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class stdClass could not be converted to int in %s on line %d + <= object(stdClass)#%d (0) {} +int(-9223372036854775808) +Notice: Object of class test could not be converted to int in %s on line %d + <= object(test)#%d (0) {} +int(-9223372036854775808) <= array(0) {} +int(-9223372036854775808) <= int(-9223372036854775808) +int(-9223372036854775808) <= string(20) "-9223372036854775808" +string(20) "-9223372036854775808" <= array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3)} +string(20) "-9223372036854775808" > string(0) "" +string(20) "-9223372036854775808" <= int(1) +string(20) "-9223372036854775808" <= float(2.5) +string(20) "-9223372036854775808" <= int(0) +string(20) "-9223372036854775808" <= string(6) "string" +string(20) "-9223372036854775808" <= string(3) "123" +string(20) "-9223372036854775808" <= string(3) "2.5" +string(20) "-9223372036854775808" > NULL +string(20) "-9223372036854775808" <= bool(true) +string(20) "-9223372036854775808" > bool(false) +string(20) "-9223372036854775808" <= object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" <= object(stdClass)#%d (0) {} +string(20) "-9223372036854775808" <= object(test)#%d (0) {} +string(20) "-9223372036854775808" <= array(0) {} +string(20) "-9223372036854775808" <= int(-9223372036854775808) +string(20) "-9223372036854775808" <= string(20) "-9223372036854775808" +Done diff --git a/Zend/tests/concat_001.phpt b/Zend/tests/concat_001.phpt new file mode 100644 index 0000000..1307c28 --- /dev/null +++ b/Zend/tests/concat_001.phpt @@ -0,0 +1,98 @@ +--TEST-- +concat different types +--INI-- +precision=14 +--FILE-- +<?php + +class test { + function __toString() { + return "this is test object"; + } +} + +$a = array(1,2,3); +$o = new test; +$s = "some string"; +$i = 222; +$d = 2323.444; + +var_dump($a.$o); +var_dump($a.$s); +var_dump($a.$i); +var_dump($a.$d); +var_dump($a.$a); + +var_dump($o.$a); +var_dump($o.$s); +var_dump($o.$i); +var_dump($o.$d); +var_dump($o.$o); + +var_dump($s.$o); +var_dump($s.$a); +var_dump($s.$i); +var_dump($s.$d); +var_dump($s.$s); + +var_dump($i.$a); +var_dump($i.$o); +var_dump($i.$s); +var_dump($i.$d); +var_dump($i.$i); + +var_dump($d.$a); +var_dump($d.$o); +var_dump($d.$s); +var_dump($d.$i); +var_dump($d.$d); + +echo "Done\n"; +?> +--EXPECTF-- + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(24) "Arraythis is test object" + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(16) "Arraysome string" + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(8) "Array222" + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(13) "Array2323.444" + +Notice: Array to string conversion in %sconcat_001.php on line %d + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(10) "ArrayArray" + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(24) "this is test objectArray" +string(30) "this is test objectsome string" +string(22) "this is test object222" +string(27) "this is test object2323.444" +string(38) "this is test objectthis is test object" +string(30) "some stringthis is test object" + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(16) "some stringArray" +string(14) "some string222" +string(19) "some string2323.444" +string(22) "some stringsome string" + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(8) "222Array" +string(22) "222this is test object" +string(14) "222some string" +string(11) "2222323.444" +string(6) "222222" + +Notice: Array to string conversion in %sconcat_001.php on line %d +string(13) "2323.444Array" +string(27) "2323.444this is test object" +string(19) "2323.444some string" +string(11) "2323.444222" +string(16) "2323.4442323.444" +Done diff --git a/Zend/tests/constants/dir-constant-eval.phpt b/Zend/tests/constants/dir-constant-eval.phpt new file mode 100644 index 0000000..8fe619d --- /dev/null +++ b/Zend/tests/constants/dir-constant-eval.phpt @@ -0,0 +1,8 @@ +--TEST-- +__DIR__ constant used with eval() +--FILE-- +<?php +eval('echo __DIR__ . "\n";'); +?> +--EXPECTF-- +%stests%sconstants diff --git a/Zend/tests/constants/dir-constant-includes.phpt b/Zend/tests/constants/dir-constant-includes.phpt new file mode 100644 index 0000000..8ea6529 --- /dev/null +++ b/Zend/tests/constants/dir-constant-includes.phpt @@ -0,0 +1,22 @@ +--TEST-- +__DIR__ constant test with includes +--FILE-- +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; +include 'fixtures/folder1/fixture.php'; +include 'fixtures/folder2/fixture.php'; +include 'fixtures/folder3/fixture.php'; +include 'fixtures/folder4/fixture.php'; +?> +--EXPECTF-- +%stests%sconstants +%stests%sconstants +%stests%sconstants%sfixtures%sfolder1 +%stests%sconstants%sfixtures%sfolder1 +%stests%sconstants%sfixtures%sfolder2 +%stests%sconstants%sfixtures%sfolder2 +%stests%sconstants%sfixtures%sfolder3 +%stests%sconstants%sfixtures%sfolder3 +%stests%sconstants%sfixtures%sfolder4 +%stests%sconstants%sfixtures%sfolder4 diff --git a/Zend/tests/constants/dir-constant-nested_includes.phpt b/Zend/tests/constants/dir-constant-nested_includes.phpt new file mode 100644 index 0000000..18bdfa8 --- /dev/null +++ b/Zend/tests/constants/dir-constant-nested_includes.phpt @@ -0,0 +1,70 @@ +--TEST-- +__DIR__ constant test with nested includes +--FILE-- +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; +include 'fixtures/folder1/fixture.php'; +include 'fixtures/folder1/subfolder1/fixture.php'; +include 'fixtures/folder1/subfolder2/fixture.php'; +include 'fixtures/folder1/subfolder3/fixture.php'; +include 'fixtures/folder1/subfolder4/fixture.php'; +include 'fixtures/folder2/fixture.php'; +include 'fixtures/folder2/subfolder1/fixture.php'; +include 'fixtures/folder2/subfolder2/fixture.php'; +include 'fixtures/folder2/subfolder3/fixture.php'; +include 'fixtures/folder2/subfolder4/fixture.php'; +include 'fixtures/folder3/fixture.php'; +include 'fixtures/folder3/subfolder1/fixture.php'; +include 'fixtures/folder3/subfolder2/fixture.php'; +include 'fixtures/folder3/subfolder3/fixture.php'; +include 'fixtures/folder3/subfolder4/fixture.php'; +include 'fixtures/folder4/fixture.php'; +include 'fixtures/folder4/subfolder1/fixture.php'; +include 'fixtures/folder4/subfolder2/fixture.php'; +include 'fixtures/folder4/subfolder3/fixture.php'; +include 'fixtures/folder4/subfolder4/fixture.php'; +?> +--EXPECTF-- +%stests%sconstants +%stests%sconstants +%stests%sconstants%sfixtures%sfolder1 +%stests%sconstants%sfixtures%sfolder1 +%stests%sconstants%sfixtures%sfolder1%ssubfolder1 +%stests%sconstants%sfixtures%sfolder1%ssubfolder1 +%stests%sconstants%sfixtures%sfolder1%ssubfolder2 +%stests%sconstants%sfixtures%sfolder1%ssubfolder2 +%stests%sconstants%sfixtures%sfolder1%ssubfolder3 +%stests%sconstants%sfixtures%sfolder1%ssubfolder3 +%stests%sconstants%sfixtures%sfolder1%ssubfolder4 +%stests%sconstants%sfixtures%sfolder1%ssubfolder4 +%stests%sconstants%sfixtures%sfolder2 +%stests%sconstants%sfixtures%sfolder2 +%stests%sconstants%sfixtures%sfolder2%ssubfolder1 +%stests%sconstants%sfixtures%sfolder2%ssubfolder1 +%stests%sconstants%sfixtures%sfolder2%ssubfolder2 +%stests%sconstants%sfixtures%sfolder2%ssubfolder2 +%stests%sconstants%sfixtures%sfolder2%ssubfolder3 +%stests%sconstants%sfixtures%sfolder2%ssubfolder3 +%stests%sconstants%sfixtures%sfolder2%ssubfolder4 +%stests%sconstants%sfixtures%sfolder2%ssubfolder4 +%stests%sconstants%sfixtures%sfolder3 +%stests%sconstants%sfixtures%sfolder3 +%stests%sconstants%sfixtures%sfolder3%ssubfolder1 +%stests%sconstants%sfixtures%sfolder3%ssubfolder1 +%stests%sconstants%sfixtures%sfolder3%ssubfolder2 +%stests%sconstants%sfixtures%sfolder3%ssubfolder2 +%stests%sconstants%sfixtures%sfolder3%ssubfolder3 +%stests%sconstants%sfixtures%sfolder3%ssubfolder3 +%stests%sconstants%sfixtures%sfolder3%ssubfolder4 +%stests%sconstants%sfixtures%sfolder3%ssubfolder4 +%stests%sconstants%sfixtures%sfolder4 +%stests%sconstants%sfixtures%sfolder4 +%stests%sconstants%sfixtures%sfolder4%ssubfolder1 +%stests%sconstants%sfixtures%sfolder4%ssubfolder1 +%stests%sconstants%sfixtures%sfolder4%ssubfolder2 +%stests%sconstants%sfixtures%sfolder4%ssubfolder2 +%stests%sconstants%sfixtures%sfolder4%ssubfolder3 +%stests%sconstants%sfixtures%sfolder4%ssubfolder3 +%stests%sconstants%sfixtures%sfolder4%ssubfolder4 +%stests%sconstants%sfixtures%sfolder4%ssubfolder4 diff --git a/Zend/tests/constants/dir-constant-normal.phpt b/Zend/tests/constants/dir-constant-normal.phpt new file mode 100644 index 0000000..1a573a2 --- /dev/null +++ b/Zend/tests/constants/dir-constant-normal.phpt @@ -0,0 +1,10 @@ +--TEST-- +Standard behaviour of __DIR__ +--FILE-- +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; +?> +--EXPECTF-- +%stests%sconstants +%stests%sconstants diff --git a/Zend/tests/constants/fixtures/folder1/fixture.php b/Zend/tests/constants/fixtures/folder1/fixture.php new file mode 100755 index 0000000..3406c99 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder1/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; + echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder1/subfolder1/fixture.php b/Zend/tests/constants/fixtures/folder1/subfolder1/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder1/subfolder1/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder1/subfolder2/fixture.php b/Zend/tests/constants/fixtures/folder1/subfolder2/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder1/subfolder2/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder1/subfolder3/fixture.php b/Zend/tests/constants/fixtures/folder1/subfolder3/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder1/subfolder3/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder1/subfolder4/fixture.php b/Zend/tests/constants/fixtures/folder1/subfolder4/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder1/subfolder4/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder2/fixture.php b/Zend/tests/constants/fixtures/folder2/fixture.php new file mode 100755 index 0000000..3406c99 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder2/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; + echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder2/subfolder1/fixture.php b/Zend/tests/constants/fixtures/folder2/subfolder1/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder2/subfolder1/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder2/subfolder2/fixture.php b/Zend/tests/constants/fixtures/folder2/subfolder2/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder2/subfolder2/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder2/subfolder3/fixture.php b/Zend/tests/constants/fixtures/folder2/subfolder3/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder2/subfolder3/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder2/subfolder4/fixture.php b/Zend/tests/constants/fixtures/folder2/subfolder4/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder2/subfolder4/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder3/fixture.php b/Zend/tests/constants/fixtures/folder3/fixture.php new file mode 100755 index 0000000..3406c99 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder3/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; + echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder3/subfolder1/fixture.php b/Zend/tests/constants/fixtures/folder3/subfolder1/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder3/subfolder1/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder3/subfolder2/fixture.php b/Zend/tests/constants/fixtures/folder3/subfolder2/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder3/subfolder2/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder3/subfolder3/fixture.php b/Zend/tests/constants/fixtures/folder3/subfolder3/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder3/subfolder3/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder3/subfolder4/fixture.php b/Zend/tests/constants/fixtures/folder3/subfolder4/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder3/subfolder4/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder4/fixture.php b/Zend/tests/constants/fixtures/folder4/fixture.php new file mode 100755 index 0000000..3406c99 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder4/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; + echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder4/subfolder1/fixture.php b/Zend/tests/constants/fixtures/folder4/subfolder1/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder4/subfolder1/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder4/subfolder2/fixture.php b/Zend/tests/constants/fixtures/folder4/subfolder2/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder4/subfolder2/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder4/subfolder3/fixture.php b/Zend/tests/constants/fixtures/folder4/subfolder3/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder4/subfolder3/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants/fixtures/folder4/subfolder4/fixture.php b/Zend/tests/constants/fixtures/folder4/subfolder4/fixture.php new file mode 100755 index 0000000..86e6859 --- /dev/null +++ b/Zend/tests/constants/fixtures/folder4/subfolder4/fixture.php @@ -0,0 +1,3 @@ +<?php +echo __DIR__ . "\n"; +echo dirname(__FILE__) . "\n"; diff --git a/Zend/tests/constants_001.phpt b/Zend/tests/constants_001.phpt new file mode 100644 index 0000000..8419eb6 --- /dev/null +++ b/Zend/tests/constants_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +Defining and using constants +--FILE-- +<?php + +define('foo', 2); +define('1', 2); +define(1, 2); +define('', 1); +define('1foo', 3); + +var_dump(constant('foo')); +var_dump(constant('1')); +var_dump(constant(1)); +var_dump(constant('')); +var_dump(constant('1foo')); + +?> +--EXPECTF-- +Notice: Constant 1 already defined in %s on line %d +int(2) +int(2) +int(2) +int(1) +int(3) diff --git a/Zend/tests/constants_002.phpt b/Zend/tests/constants_002.phpt new file mode 100644 index 0000000..5acca98 --- /dev/null +++ b/Zend/tests/constants_002.phpt @@ -0,0 +1,18 @@ +--TEST-- +Defining constants with non-scalar values +--FILE-- +<?php + +define('foo', new stdClass); +var_dump(foo); + +define('foo', fopen(__FILE__, 'r')); +var_dump(foo); + +?> +--EXPECTF-- +Warning: Constants may only evaluate to scalar values in %s on line %d + +Notice: Use of undefined constant foo - assumed 'foo' in %s on line %d +string(%d) "foo" +resource(%d) of type (stream) diff --git a/Zend/tests/constants_003.phpt b/Zend/tests/constants_003.phpt new file mode 100644 index 0000000..205f95f --- /dev/null +++ b/Zend/tests/constants_003.phpt @@ -0,0 +1,21 @@ +--TEST-- +Using namespace constants and constants of global scope +--FILE-- +<?php + +namespace foo; + +const foo = 1; + +define('foo', 2); + +var_dump(foo, namespace\foo, \foo\foo, \foo, constant('foo'), constant('foo\foo')); + +?> +--EXPECT-- +int(1) +int(1) +int(1) +int(2) +int(2) +int(1) diff --git a/Zend/tests/constants_004.phpt b/Zend/tests/constants_004.phpt new file mode 100644 index 0000000..69369aa --- /dev/null +++ b/Zend/tests/constants_004.phpt @@ -0,0 +1,13 @@ +--TEST-- +Trying to redeclare constant inside namespace +--FILE-- +<?php + +namespace foo; + +const foo = 1; +const foo = 2; + +?> +--EXPECTF-- +Notice: Constant foo\foo already defined in %s on line %d diff --git a/Zend/tests/constants_005.phpt b/Zend/tests/constants_005.phpt new file mode 100644 index 0000000..d2a205b --- /dev/null +++ b/Zend/tests/constants_005.phpt @@ -0,0 +1,12 @@ +--TEST-- +Persistent case insensitive and user defined constants +--FILE-- +<?php +var_dump(ZEND_THREAD_safe); +define("ZEND_THREAD_safe", 123); +var_dump(ZEND_THREAD_safe); +?> +--EXPECTF-- +Notice: Use of undefined constant ZEND_THREAD_safe - assumed 'ZEND_THREAD_safe' in %s on line %d +string(16) "ZEND_THREAD_safe" +int(123) diff --git a/Zend/tests/constants_006.phpt b/Zend/tests/constants_006.phpt new file mode 100644 index 0000000..6458a07 --- /dev/null +++ b/Zend/tests/constants_006.phpt @@ -0,0 +1,32 @@ +--TEST-- +Magic constants lowercased +--FILE-- +<?php + +namespace test; + +var_dump(__dir__); +var_dump(__file__); +var_dump(__line__); + +class foo { + public function __construct() { + var_dump(__method__); + var_dump(__class__); + var_dump(__function__); + } +} + +new foo; + +var_dump(__namespace__); + +?> +--EXPECTF-- +string(%d) "%s" +string(%d) "%s" +int(%d) +string(21) "test\foo::__construct" +string(8) "test\foo" +string(11) "__construct" +string(4) "test" diff --git a/Zend/tests/constants_007.phpt b/Zend/tests/constants_007.phpt new file mode 100644 index 0000000..7d9f3fe --- /dev/null +++ b/Zend/tests/constants_007.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing const names +--FILE-- +<?php + +const a = 'a'; +const A = 'b'; + + +class a { + const a = 'c'; + const A = 'd'; +} + +var_dump(a, A, a::a, a::A); + +?> +--EXPECT-- +string(1) "a" +string(1) "b" +string(1) "c" +string(1) "d" diff --git a/Zend/tests/constants_008.phpt b/Zend/tests/constants_008.phpt new file mode 100644 index 0000000..226e147 --- /dev/null +++ b/Zend/tests/constants_008.phpt @@ -0,0 +1,17 @@ +--TEST-- +Defining constant twice with two different forms +--FILE-- +<?php + +define('a', 2); +const a = 1; + + +if (defined('a')) { + print a; +} + +?> +--EXPECTF-- +Notice: Constant a already defined in %s on line %d +2 diff --git a/Zend/tests/constants_009.phpt b/Zend/tests/constants_009.phpt new file mode 100644 index 0000000..ea986dd --- /dev/null +++ b/Zend/tests/constants_009.phpt @@ -0,0 +1,25 @@ +--TEST-- +Accessing constants inside namespace +--FILE-- +<?php + +namespace foo\x; + +const x = 2; + +class x { + const x = 1; +} + + +var_dump(namespace\x, +x::x, +namespace\x::x); +var_dump(defined('foo\x\x')); + +?> +--EXPECT-- +int(2) +int(1) +int(1) +bool(true) diff --git a/Zend/tests/constructor_args.phpt b/Zend/tests/constructor_args.phpt new file mode 100644 index 0000000..8056874 --- /dev/null +++ b/Zend/tests/constructor_args.phpt @@ -0,0 +1,20 @@ +--TEST-- +Different numbers of arguments in __construct() +--FILE-- +<?php +interface foobar { + function __construct(); +} +abstract class bar implements foobar { + public function __construct($x = 1) { + } +} +final class foo extends bar implements foobar { + public function __construct($x = 1, $y = 2) { + } +} +new foo; +print "ok!"; +?> +--EXPECT-- +ok! diff --git a/Zend/tests/debug_backtrace_limit.phpt b/Zend/tests/debug_backtrace_limit.phpt new file mode 100644 index 0000000..985c2cc --- /dev/null +++ b/Zend/tests/debug_backtrace_limit.phpt @@ -0,0 +1,133 @@ +--TEST-- +debug_backtrace limit +--FILE-- +<?php +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + print_r(debug_backtrace(0, 1)); + print_r(debug_backtrace(0, 2)); + print_r(debug_backtrace(0, 0)); + print_r(debug_backtrace(0, 4)); +} + +a(); +?> +--EXPECTF-- +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 7 + [function] => c + [args] => Array + ( + ) + + ) + +) +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 7 + [function] => c + [args] => Array + ( + ) + + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 3 + [function] => b + [args] => Array + ( + ) + + ) + +) +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 7 + [function] => c + [args] => Array + ( + ) + + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 3 + [function] => b + [args] => Array + ( + ) + + ) + + [2] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 17 + [function] => a + [args] => Array + ( + ) + + ) + +) +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 7 + [function] => c + [args] => Array + ( + ) + + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 3 + [function] => b + [args] => Array + ( + ) + + ) + + [2] => Array + ( + [file] => %sdebug_backtrace_limit.php + [line] => 17 + [function] => a + [args] => Array + ( + ) + + ) + +) diff --git a/Zend/tests/debug_backtrace_options.phpt b/Zend/tests/debug_backtrace_options.phpt new file mode 100644 index 0000000..1b2d7e5 --- /dev/null +++ b/Zend/tests/debug_backtrace_options.phpt @@ -0,0 +1,397 @@ +--TEST-- +debug_backtrace options +--FILE-- +<?php + +function backtrace_print($opt = null) +{ + if(is_null($opt)) { + print_r(debug_backtrace()); + } else { + print_r(debug_backtrace($opt)); + } +} + +function doit($a, $b, $how) +{ + echo "==default\n"; + $how(); + echo "==true\n"; + $how(true); + echo "==false\n"; + $how(false); + echo "==DEBUG_BACKTRACE_PROVIDE_OBJECT\n"; + $how(DEBUG_BACKTRACE_PROVIDE_OBJECT); + echo "==DEBUG_BACKTRACE_IGNORE_ARGS\n"; + $how(DEBUG_BACKTRACE_IGNORE_ARGS); + echo "==both\n"; + $how(DEBUG_BACKTRACE_PROVIDE_OBJECT|DEBUG_BACKTRACE_IGNORE_ARGS); +} + +class foo { + protected function doCall($dowhat, $how) + { + $dowhat('a','b', $how); + } + static function statCall($dowhat, $how) + { + $obj = new self(); + $obj->doCall($dowhat, $how); + } +} +foo::statCall("doit", "debug_print_backtrace"); +foo::statCall("doit", "backtrace_print"); + +?> +--EXPECTF-- +==default +#0 doit(a, b, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +#1 foo->doCall(doit, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +#2 foo::statCall(doit, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +==true +#0 doit(a, b, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +#1 foo->doCall(doit, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +#2 foo::statCall(doit, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +==false +#0 doit(a, b, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +#1 foo->doCall(doit, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +#2 foo::statCall(doit, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +==DEBUG_BACKTRACE_PROVIDE_OBJECT +#0 doit(a, b, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +#1 foo->doCall(doit, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +#2 foo::statCall(doit, debug_print_backtrace) called at [%sdebug_backtrace_options.php:%d] +==DEBUG_BACKTRACE_IGNORE_ARGS +#0 doit() called at [%sdebug_backtrace_options.php:%d] +#1 foo->doCall() called at [%sdebug_backtrace_options.php:%d] +#2 foo::statCall() called at [%sdebug_backtrace_options.php:%d] +==both +#0 doit() called at [%sdebug_backtrace_options.php:%d] +#1 foo->doCall() called at [%sdebug_backtrace_options.php:%d] +#2 foo::statCall() called at [%sdebug_backtrace_options.php:%d] +==default +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => backtrace_print + [args] => Array + ( + ) + + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doit + [args] => Array + ( + [0] => a + [1] => b + [2] => backtrace_print + ) + + ) + + [2] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doCall + [class] => foo + [object] => foo Object + ( + ) + + [type] => -> + [args] => Array + ( + [0] => doit + [1] => backtrace_print + ) + + ) + + [3] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => statCall + [class] => foo + [type] => :: + [args] => Array + ( + [0] => doit + [1] => backtrace_print + ) + + ) + +) +==true +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => 17 + [function] => backtrace_print + [args] => Array + ( + [0] => 1 + ) + + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doit + [args] => Array + ( + [0] => a + [1] => b + [2] => backtrace_print + ) + + ) + + [2] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doCall + [class] => foo + [object] => foo Object + ( + ) + + [type] => -> + [args] => Array + ( + [0] => doit + [1] => backtrace_print + ) + + ) + + [3] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => statCall + [class] => foo + [type] => :: + [args] => Array + ( + [0] => doit + [1] => backtrace_print + ) + + ) + +) +==false +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => 19 + [function] => backtrace_print + [args] => Array + ( + [0] => + ) + + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doit + [args] => Array + ( + [0] => a + [1] => b + [2] => backtrace_print + ) + + ) + + [2] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doCall + [class] => foo + [type] => -> + [args] => Array + ( + [0] => doit + [1] => backtrace_print + ) + + ) + + [3] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => statCall + [class] => foo + [type] => :: + [args] => Array + ( + [0] => doit + [1] => backtrace_print + ) + + ) + +) +==DEBUG_BACKTRACE_PROVIDE_OBJECT +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => 21 + [function] => backtrace_print + [args] => Array + ( + [0] => 1 + ) + + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doit + [args] => Array + ( + [0] => a + [1] => b + [2] => backtrace_print + ) + + ) + + [2] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doCall + [class] => foo + [object] => foo Object + ( + ) + + [type] => -> + [args] => Array + ( + [0] => doit + [1] => backtrace_print + ) + + ) + + [3] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => statCall + [class] => foo + [type] => :: + [args] => Array + ( + [0] => doit + [1] => backtrace_print + ) + + ) + +) +==DEBUG_BACKTRACE_IGNORE_ARGS +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => 23 + [function] => backtrace_print + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doit + ) + + [2] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doCall + [class] => foo + [type] => -> + ) + + [3] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => statCall + [class] => foo + [type] => :: + ) + +) +==both +Array +( + [0] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => 25 + [function] => backtrace_print + ) + + [1] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doit + ) + + [2] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => doCall + [class] => foo + [object] => foo Object + ( + ) + + [type] => -> + ) + + [3] => Array + ( + [file] => %sdebug_backtrace_options.php + [line] => %d + [function] => statCall + [class] => foo + [type] => :: + ) + +) diff --git a/Zend/tests/debug_print_backtrace_limit.phpt b/Zend/tests/debug_print_backtrace_limit.phpt new file mode 100644 index 0000000..5100387 --- /dev/null +++ b/Zend/tests/debug_print_backtrace_limit.phpt @@ -0,0 +1,31 @@ +--TEST-- +debug_print_backtrace limit +--FILE-- +<?php +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + debug_print_backtrace(0, 1); + debug_print_backtrace(0, 2); + debug_print_backtrace(0, 0); + debug_print_backtrace(0, 4); +} + +a(); +?> +--EXPECTF-- +#0 c() called at [%sdebug_print_backtrace_limit.php:7] +#0 c() called at [%sdebug_print_backtrace_limit.php:7] +#1 b() called at [%sdebug_print_backtrace_limit.php:3] +#0 c() called at [%sdebug_print_backtrace_limit.php:7] +#1 b() called at [%sdebug_print_backtrace_limit.php:3] +#2 a() called at [%sdebug_print_backtrace_limit.php:17] +#0 c() called at [%sdebug_print_backtrace_limit.php:7] +#1 b() called at [%sdebug_print_backtrace_limit.php:3] +#2 a() called at [%sdebug_print_backtrace_limit.php:17] diff --git a/Zend/tests/declare_001.phpt b/Zend/tests/declare_001.phpt new file mode 100644 index 0000000..21d7978 --- /dev/null +++ b/Zend/tests/declare_001.phpt @@ -0,0 +1,30 @@ +--TEST-- +Testing declare statement with several type values +--SKIPIF-- +<?php +if (!extension_loaded("mbstring")) { + die("skip Requires ext/mbstring"); +} +?> +--INI-- +zend.multibyte=1 +--FILE-- +<?php + +declare(encoding = 1); +declare(encoding = 112313123213131232100); +declare(encoding = NULL); +declare(encoding = 'utf-8'); +declare(encoding = M_PI); + +print 'DONE'; + +?> +--EXPECTF-- +Warning: Unsupported encoding [1] in %sdeclare_001.php on line %d + +Warning: Unsupported encoding [1.1231312321313E+20] in %sdeclare_001.php on line %d + +Warning: Unsupported encoding [] in %sdeclare_001.php on line %d + +Fatal error: Cannot use constants as encoding in %sdeclare_001.php on line %d diff --git a/Zend/tests/declare_002.phpt b/Zend/tests/declare_002.phpt new file mode 100644 index 0000000..1984455 --- /dev/null +++ b/Zend/tests/declare_002.phpt @@ -0,0 +1,31 @@ +--TEST-- +Testing declare statement with several type values +--SKIPIF-- +<?php +if (!ini_get("zend.multibyte")) { + die("skip Requires zend.multibyte=1"); +} +if (!extension_loaded("mbstring")) { + die("skip Requires ext/mbstring"); +} +?> +--FILE-- +<?php + +declare(encoding = 1); +declare(encoding = 1123131232131312321); +declare(encoding = NULL); +declare(encoding = 'utf-8'); +declare(encoding = M_PI); + +print 'DONE'; + +?> +--EXPECTF-- +Warning: Unsupported encoding [%d] in %sdeclare_002.php on line 3 + +Warning: Unsupported encoding [%f] in %sdeclare_002.php on line 4 + +Warning: Unsupported encoding [] in %sdeclare_002.php on line 5 + +Fatal error: Cannot use constants as encoding in %sdeclare_002.php on line 7 diff --git a/Zend/tests/declare_003.phpt b/Zend/tests/declare_003.phpt new file mode 100644 index 0000000..2980f75 --- /dev/null +++ b/Zend/tests/declare_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing declare statement with several type values +--INI-- +precision=15 +zend.multibyte=1 +--FILE-- +<?php + +declare(encoding = 1); +declare(encoding = 11111111111111); +declare(encoding = NULL); +declare(encoding = M_PI); + +print 'DONE'; + +?> +--EXPECTF-- +Warning: Unsupported encoding [1] in %sdeclare_003.php on line %d + +Warning: Unsupported encoding [11111111111111] in %sdeclare_003.php on line %d + +Warning: Unsupported encoding [] in %sdeclare_003.php on line %d + +Fatal error: Cannot use constants as encoding in %sdeclare_003.php on line %d diff --git a/Zend/tests/declare_004.phpt b/Zend/tests/declare_004.phpt new file mode 100644 index 0000000..a2ba51a --- /dev/null +++ b/Zend/tests/declare_004.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing declare statement with several type values +--SKIPIF-- +<?php +if (!ini_get("zend.multibyte")) { + die("skip Requires zend.multibyte=1"); +} +?> +--FILE-- +<?php + +declare(encoding = 1); +declare(encoding = 1123131232131312321); +declare(encoding = NULL); +declare(encoding = M_PI); + +print 'DONE'; + +?> +--EXPECTF-- +Warning: Unsupported encoding [%d] in %sdeclare_004.php on line 3 + +Warning: Unsupported encoding [%f] in %sdeclare_004.php on line 4 + +Warning: Unsupported encoding [] in %sdeclare_004.php on line 5 + +Fatal error: Cannot use constants as encoding in %sdeclare_004.php on line 6 diff --git a/Zend/tests/decrement_001.phpt b/Zend/tests/decrement_001.phpt new file mode 100644 index 0000000..6ade8ad --- /dev/null +++ b/Zend/tests/decrement_001.phpt @@ -0,0 +1,60 @@ +--TEST-- +decrementing different variables +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--INI-- +precision=14 +--FILE-- +<?php + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +foreach ($a as $var) { + $var--; + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +int(-1) +int(0) +float(1.5) +int(-1) +string(6) "string" +int(122) +float(1.5) +NULL +bool(true) +bool(false) +object(stdClass)#%d (0) { +} +array(0) { +} +float(-2147483649) +float(-2147483649) +Done diff --git a/Zend/tests/decrement_001_64bit.phpt b/Zend/tests/decrement_001_64bit.phpt new file mode 100644 index 0000000..7ad24b7 --- /dev/null +++ b/Zend/tests/decrement_001_64bit.phpt @@ -0,0 +1,60 @@ +--TEST-- +decrementing different variables +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--INI-- +precision=14 +--FILE-- +<?php + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), +); + +foreach ($a as $var) { + $var--; + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +int(-1) +int(0) +float(1.5) +int(-1) +string(6) "string" +int(122) +float(1.5) +NULL +bool(true) +bool(false) +object(stdClass)#%d (0) { +} +array(0) { +} +float(-9.2233720368548E+18) +float(-9.2233720368548E+18) +Done diff --git a/Zend/tests/dereference_001.phpt b/Zend/tests/dereference_001.phpt new file mode 100644 index 0000000..e09ad29 --- /dev/null +++ b/Zend/tests/dereference_001.phpt @@ -0,0 +1,51 @@ +--TEST-- +Testing array dereference +--FILE-- +<?php +error_reporting(E_ALL); + +function a() { + return array(1,array(5)); +} +var_dump(a()[1][0]); // int(5) + +function b() { + return array(); +} +var_dump(b()[0]); // Notice: Undefined offset: 0 + +class foo { + public $y = 1; + + public function test() { + return array(array(array('foobar'))); + } +} + +function c() { + return array(new foo); +} +var_dump(c()[0]->y); // int(1) + +function d() { + $obj = new foo; + return $obj->test(); +} +var_dump(d()[0][0][0][3]); // string(1) "b" + +function e() { + $y = 'bar'; + $x = array('a' => 'foo', 'b' => $y); + return $x; +} +var_dump(e()['b']); // string(3) "bar" + +?> +--EXPECTF-- +int(5) + +Notice: Undefined offset: 0 in %s on line %d +NULL +int(1) +string(1) "b" +string(3) "bar" diff --git a/Zend/tests/dereference_002.phpt b/Zend/tests/dereference_002.phpt new file mode 100644 index 0000000..022ff37 --- /dev/null +++ b/Zend/tests/dereference_002.phpt @@ -0,0 +1,79 @@ +--TEST-- +Testing array dereference on method calls +--FILE-- +<?php + +error_reporting(E_ALL); + +class foo { + public function bar() { + $x = array(); + $x[] = 3; + $x[] = array(1, 5); + $x[] = new foo; + return $x; + } +} + +$foo = new foo; + +var_dump($x = $foo->bar()[1]); +var_dump($foo->bar()[1][1]); +var_dump($x[0]); +var_dump($x = $foo->bar()[2]); +var_dump($x->bar()); +var_dump($x->bar()[0]); + +$x = array(); +$x[] = new foo; +var_dump($x[0]->bar()[2]); +var_dump($foo->bar()[2]->bar()[1]); +var_dump($foo->bar()[2]->bar()[2]->bar()[1][0]); +var_dump($foo->bar()[2]->bar()[2]->bar()[1][0][1]); +var_dump($foo->bar()[2]->bar()[2]->bar()[4]); +var_dump($foo->bar()[3]->bar()); + +?> +--EXPECTF-- +array(2) { + [0]=> + int(1) + [1]=> + int(5) +} +int(5) +int(1) +object(foo)#2 (0) { +} +array(3) { + [0]=> + int(3) + [1]=> + array(2) { + [0]=> + int(1) + [1]=> + int(5) + } + [2]=> + object(foo)#3 (0) { + } +} +int(3) +object(foo)#3 (0) { +} +array(2) { + [0]=> + int(1) + [1]=> + int(5) +} +int(1) +NULL + +Notice: Undefined offset: 4 in %s on line %d +NULL + +Notice: Undefined offset: 3 in %s on line %d + +Fatal error: Call to a member function bar() on a non-object in %s on line %d diff --git a/Zend/tests/dereference_003.phpt b/Zend/tests/dereference_003.phpt new file mode 100644 index 0000000..3a54875 --- /dev/null +++ b/Zend/tests/dereference_003.phpt @@ -0,0 +1,46 @@ +--TEST-- +Testing array dereference on method calls +--FILE-- +<?php + +error_reporting(E_ALL); + +class foo { + public $x = 2; + public function a() { + $x = array(); + $x[] = new foo; + return $x; + } + public function b() { + return array(1.2, array(new self)); + } + public function c() { + $a = array(); + $b = &$a; + $b[] = true; + return $a; + } + public function d() { + return $this->b(); + } +} + +$foo = new foo; + +var_dump($foo->a()[0]->x); +var_dump($foo->a()[0]); +var_dump($foo->b()[1][0]->a()[0]->x); +var_dump($foo->c()[0]); +var_dump($foo->d()[0]); + +?> +--EXPECTF-- +int(2) +object(foo)#%d (1) { + ["x"]=> + int(2) +} +int(2) +bool(true) +float(1.2) diff --git a/Zend/tests/dereference_004.phpt b/Zend/tests/dereference_004.phpt new file mode 100644 index 0000000..a77cf03 --- /dev/null +++ b/Zend/tests/dereference_004.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing array dereference on __invoke() result +--FILE-- +<?php + +error_reporting(E_ALL); + +class foo { + public $x = array(); + public function __construct() { + $h = array(); + $h[] = new stdclass; + $this->x = $h; + } + public function __invoke() { + return $this->x; + } +} + + +$fo = new foo; +var_dump($fo()[0]); + +?> +--EXPECTF-- +object(stdClass)#%d (0) { +} diff --git a/Zend/tests/dereference_005.phpt b/Zend/tests/dereference_005.phpt new file mode 100644 index 0000000..cca8757 --- /dev/null +++ b/Zend/tests/dereference_005.phpt @@ -0,0 +1,38 @@ +--TEST-- +Testing array dereference on object that implements ArrayAccess +--FILE-- +<?php + +error_reporting(E_ALL); + +class obj implements arrayaccess { + private $container = array(); + public function __construct() { + $this->container = array( + "one" => 1, + "two" => 2, + "three" => 3, + ); + } + public function offsetSet($offset, $value) { + $this->container[$offset] = $value; + } + public function offsetExists($offset) { + return isset($this->container[$offset]); + } + public function offsetUnset($offset) { + unset($this->container[$offset]); + } + public function offsetGet($offset) { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } +} + +function x() { + return new obj; +} +var_dump(x()['two']); + +?> +--EXPECT-- +int(2) diff --git a/Zend/tests/dereference_006.phpt b/Zend/tests/dereference_006.phpt new file mode 100644 index 0000000..61a0735 --- /dev/null +++ b/Zend/tests/dereference_006.phpt @@ -0,0 +1,30 @@ +--TEST-- +Testing array dereference and references +--FILE-- +<?php + +error_reporting(E_ALL); + +function &foo(&$foo) { + return $foo; +} + +$a = array(1); +foo($a)[0] = 2; +var_dump($a); + +foo($a)[] = 3; +var_dump($a); + +?> +--EXPECT-- +array(1) { + [0]=> + int(2) +} +array(2) { + [0]=> + int(2) + [1]=> + int(3) +} diff --git a/Zend/tests/dereference_007.phpt b/Zend/tests/dereference_007.phpt new file mode 100644 index 0000000..2f7d66f --- /dev/null +++ b/Zend/tests/dereference_007.phpt @@ -0,0 +1,37 @@ +--TEST-- +Trying to write on method return +--FILE-- +<?php + +error_reporting(E_ALL); + +class foo { + public $x = array(); + + public function b() { + return $this->x; + } + + public function c() { + return $x; + } + + static public function d() { + + } +} + +$foo = new foo; + +$foo->b()[0] = 1; + +$foo->c()[100] = 2; + +foo::d()[] = 3; + +print "ok\n"; + +?> +--EXPECTF-- +Notice: Undefined variable: x in %s on line %d +ok diff --git a/Zend/tests/dereference_008.phpt b/Zend/tests/dereference_008.phpt new file mode 100644 index 0000000..01c828f --- /dev/null +++ b/Zend/tests/dereference_008.phpt @@ -0,0 +1,33 @@ +--TEST-- +Testing array dereference with dynamic method name and references +--FILE-- +<?php + +error_reporting(E_ALL); + +class foo { + public $x = array(1); + + public function &b() { + return $this->x; + } +} + +$foo = new foo; + +$a = 'b'; +var_dump($foo->$a()[0]); + +$h = &$foo->$a(); +$h[] = 2; +var_dump($foo->$a()); + +?> +--EXPECT-- +int(1) +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} diff --git a/Zend/tests/dereference_009.phpt b/Zend/tests/dereference_009.phpt new file mode 100644 index 0000000..e579c44 --- /dev/null +++ b/Zend/tests/dereference_009.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing array dereference with references +--FILE-- +<?php + +error_reporting(E_ALL); + +$a = array(); + +function &a() { + return $GLOBALS['a']; +} + +var_dump($h =& a()); +$h[] = 1; +var_dump(a()[0]); + +$h[] = array($h); +var_dump(a()[1][0][0]); + +?> +--EXPECT-- +array(0) { +} +int(1) +int(1) diff --git a/Zend/tests/dereference_010.phpt b/Zend/tests/dereference_010.phpt new file mode 100644 index 0000000..6acda77 --- /dev/null +++ b/Zend/tests/dereference_010.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing dereference in non-array values +--FILE-- +<?php + +error_reporting(E_ALL); + +function a() { + return 1; +} + +$a = 1; +var_dump($a[1]); +var_dump(a()[1]); + +function b() { + return new stdClass; +} + +var_dump(b()[1]); + +?> +--EXPECTF-- +NULL +NULL + +Fatal error: Cannot use object of type stdClass as array in %s on line %d diff --git a/Zend/tests/dereference_011.phpt b/Zend/tests/dereference_011.phpt new file mode 100644 index 0000000..17dc8b3 --- /dev/null +++ b/Zend/tests/dereference_011.phpt @@ -0,0 +1,45 @@ +--TEST-- +Testing array dereference with chaining +--FILE-- +<?php + +error_reporting(E_ALL); + +class foo { + public $arr; + + public function &a() { + return $this->arr; + } +} + +$foo = new foo; + +$h = &$foo->a(); +$h[] = 1; +$h[] = $foo; +var_dump($foo->a()[1]->arr[1]->a()[1]->arr[1]->arr[0]); +var_dump($foo->a()[1]); +var_dump($foo->a()[1]->arr[1]); + +?> +--EXPECTF-- +int(1) +object(foo)#%d (1) { + ["arr"]=> + &array(2) { + [0]=> + int(1) + [1]=> + *RECURSION* + } +} +object(foo)#%d (1) { + ["arr"]=> + &array(2) { + [0]=> + int(1) + [1]=> + *RECURSION* + } +} diff --git a/Zend/tests/dereference_012.phpt b/Zend/tests/dereference_012.phpt new file mode 100644 index 0000000..f3ba774 --- /dev/null +++ b/Zend/tests/dereference_012.phpt @@ -0,0 +1,56 @@ +--TEST-- +Testing array dereferencing on return of a method with and without reference +--FILE-- +<?php + +class foo { + static $x = array(); + + public function &a() { + self::$x = array(1, 2, 3); + return self::$x; + } + + public function b() { + $x = array(1); + $x[] = 2; + return $x; + } +} + +$foo = new foo; + +// Changing the static variable +$foo->a()[0] = 2; +var_dump($foo::$x); + +$foo->b()[] = new stdClass; + +$h = $foo->b(); +var_dump($h); + +$h[0] = 3; +var_dump($h); + +?> +--EXPECT-- +array(3) { + [0]=> + int(2) + [1]=> + int(2) + [2]=> + int(3) +} +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(2) { + [0]=> + int(3) + [1]=> + int(2) +} diff --git a/Zend/tests/dereference_013.phpt b/Zend/tests/dereference_013.phpt new file mode 100644 index 0000000..cfd89e7 --- /dev/null +++ b/Zend/tests/dereference_013.phpt @@ -0,0 +1,38 @@ +--TEST-- +Testing array dereferencing on array returned from __call method +--FILE-- +<?php + +error_reporting(E_ALL); + +class foo { + public $x = array(2); + + public function __call($x, $y) { + if (count($this->x) == 1) { + $this->x[] = $y[0]; + } + return $this->x; + } +} + +$foo = new foo; + +$x = array(1); + +$foo->b($x)[1] = 3; + +var_dump($foo->b()[0]); +var_dump($foo->b()[1]); +var_dump($foo->b()[2]); + +?> +--EXPECTF-- +int(2) +array(1) { + [0]=> + int(1) +} + +Notice: Undefined offset: %d in %s on line %d +NULL diff --git a/Zend/tests/dereference_014.phpt b/Zend/tests/dereference_014.phpt new file mode 100644 index 0000000..62dffd3 --- /dev/null +++ b/Zend/tests/dereference_014.phpt @@ -0,0 +1,34 @@ +--TEST-- +Trying to create an object from dereferencing uninitialized variable +--FILE-- +<?php + +error_reporting(E_ALL); + +class foo { + public $x; + static public $y; + + public function a() { + return $this->x; + } + + static public function b() { + return self::$y; + } +} + +$foo = new foo; +$h = $foo->a()[0]->a; +var_dump($h); + +$h = foo::b()[1]->b; +var_dump($h); + +?> +--EXPECTF-- +Notice: Trying to get property of non-object in %s on line %d +NULL + +Notice: Trying to get property of non-object in %s on line %d +NULL diff --git a/Zend/tests/div_001.phpt b/Zend/tests/div_001.phpt new file mode 100644 index 0000000..5fa264a --- /dev/null +++ b/Zend/tests/div_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +dividing doubles +--INI-- +precision=14 +--FILE-- +<?php + +$d1 = 1.1; +$d2 = 434234.234; + +$c = $d2 / $d1; +var_dump($c); + +$d1 = 1.1; +$d2 = "434234.234"; + +$c = $d2 / $d1; +var_dump($c); + +$d1 = "1.1"; +$d2 = "434234.234"; + +$c = $d2 / $d1; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +float(394758.39454545) +float(394758.39454545) +float(394758.39454545) +Done diff --git a/Zend/tests/div_002.phpt b/Zend/tests/div_002.phpt new file mode 100644 index 0000000..6ade1d9 --- /dev/null +++ b/Zend/tests/div_002.phpt @@ -0,0 +1,15 @@ +--TEST-- +dividing arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a / $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/double_to_string.phpt b/Zend/tests/double_to_string.phpt new file mode 100644 index 0000000..2948b0b --- /dev/null +++ b/Zend/tests/double_to_string.phpt @@ -0,0 +1,52 @@ +--TEST-- +double to string conversion tests +--INI-- +precision=14 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 290000000000000000, + 290000000000000, + 29000000000000, + 29000000000000.123123, + 29000000000000.7123123, + 29000.7123123, + 239234242.7123123, + 0.12345678901234567890, + 10000000000000, + 100000000000000, + 1000000000000000001, + 100000000000001, + 10000000000, + 999999999999999, + 9999999999999999, + (float)0 + ); + +foreach ($doubles as $d) { + var_dump((string)$d); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(7) "2.9E+17" +string(7) "2.9E+14" +string(%d) "2%s" +string(%d) "2%s" +string(%d) "29%d" +string(13) "29000.7123123" +string(15) "239234242.71231" +string(16) "0.12345678901235" +string(14) "10000000000000" +string(7) "1.0E+14" +string(7) "1.0E+18" +string(7) "1.0E+14" +string(11) "10000000000" +string(7) "1.0E+15" +string(7) "1.0E+16" +string(1) "0" +Done diff --git a/Zend/tests/double_to_string_64bit.phpt b/Zend/tests/double_to_string_64bit.phpt new file mode 100644 index 0000000..5ecb1a6 --- /dev/null +++ b/Zend/tests/double_to_string_64bit.phpt @@ -0,0 +1,58 @@ +--TEST-- +double to string conversion tests (64bit) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--INI-- +precision=14 +--FILE-- +<?php + +$doubles = array( + 29000000000000000000000000000000000000, + 290000000000000000, + 290000000000000, + 29000000000000, + 29000000000000.123123, + 29000000000000.7123123, + 29000.7123123, + 239234242.7123123, + 0.12345678901234567890, + 10000000000000000000000000000000000000000000000, + 1000000000000000000000000000000000, + 100000000000000001, + 1000006000000000011, + 100000000000001, + 10000000000, + 999999999999999999, + 9999999999999999999, + 9999999999999999999999999999999999999, + (float)0 + ); + +foreach ($doubles as $d) { + var_dump((string)$d); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(7) "2.9E+37" +string(18) "290000000000000000" +string(15) "290000000000000" +string(14) "29000000000000" +string(14) "29000000000000" +string(14) "29000000000001" +string(13) "29000.7123123" +string(15) "239234242.71231" +string(16) "0.12345678901235" +string(7) "1.0E+46" +string(7) "1.0E+33" +string(18) "100000000000000001" +string(19) "1000006000000000011" +string(15) "100000000000001" +string(11) "10000000000" +string(18) "999999999999999999" +string(7) "1.0E+19" +string(7) "1.0E+37" +string(1) "0" +Done diff --git a/Zend/tests/dtor_scope.phpt b/Zend/tests/dtor_scope.phpt new file mode 100644 index 0000000..ab991cf --- /dev/null +++ b/Zend/tests/dtor_scope.phpt @@ -0,0 +1,34 @@ +--TEST-- +Scoping in destructor call +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> +--FILE-- +<?php + class T + { + private $var = array(); + + public function add($a) + { + array_push($this->var, $a); + } + + public function __destruct() + { + print_r($this->var); + } + } + + class TT extends T + { + } + $t = new TT(); + $t->add("Hello"); + $t->add("World"); +?> +--EXPECT-- +Array +( + [0] => Hello + [1] => World +) diff --git a/Zend/tests/dynamic_call_001.phpt b/Zend/tests/dynamic_call_001.phpt new file mode 100644 index 0000000..94e4203 --- /dev/null +++ b/Zend/tests/dynamic_call_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing dynamic call to constructor (old-style) +--FILE-- +<?php + +class foo { + public function foo() { + } +} + +$a = 'foo'; + +$a::$a(); + +?> +--EXPECTF-- +Fatal error: Non-static method foo::foo() cannot be called statically in %s on line %d diff --git a/Zend/tests/dynamic_call_002.phpt b/Zend/tests/dynamic_call_002.phpt new file mode 100644 index 0000000..dcb1529 --- /dev/null +++ b/Zend/tests/dynamic_call_002.phpt @@ -0,0 +1,12 @@ +--TEST-- +Testing dynamic call with invalid value for method name +--FILE-- +<?php + +$a = new stdClass; + +$a::$a(); + +?> +--EXPECTF-- +Fatal error: Function name must be a string in %s on line %d diff --git a/Zend/tests/dynamic_call_003.phpt b/Zend/tests/dynamic_call_003.phpt new file mode 100644 index 0000000..15b830e --- /dev/null +++ b/Zend/tests/dynamic_call_003.phpt @@ -0,0 +1,13 @@ +--TEST-- +Testing dynamic call with invalid method name +--FILE-- +<?php + +$a = new stdClass; +$b = 1; + +$a::$b(); + +?> +--EXPECTF-- +Fatal error: Function name must be a string in %s on line %d diff --git a/Zend/tests/dynamic_call_004.phpt b/Zend/tests/dynamic_call_004.phpt new file mode 100644 index 0000000..6e83303 --- /dev/null +++ b/Zend/tests/dynamic_call_004.phpt @@ -0,0 +1,12 @@ +--TEST-- +Testing dynamic call with undefined variables +--FILE-- +<?php + +$a::$b(); + +?> +--EXPECTF-- +Notice: Undefined variable: a in %s on line %d + +Fatal error: Class name must be a valid object or a string in %s on line %d diff --git a/Zend/tests/each_001.phpt b/Zend/tests/each_001.phpt new file mode 100644 index 0000000..06ab52a --- /dev/null +++ b/Zend/tests/each_001.phpt @@ -0,0 +1,10 @@ +--TEST-- +Testing each() with an undefined variable +--FILE-- +<?php + +each($foo); + +?> +--EXPECTF-- +Warning: Variable passed to each() is not an array or object in %s on line %d diff --git a/Zend/tests/each_002.phpt b/Zend/tests/each_002.phpt new file mode 100644 index 0000000..f47ded4 --- /dev/null +++ b/Zend/tests/each_002.phpt @@ -0,0 +1,30 @@ +--TEST-- +Testing each() with array and object +--FILE-- +<?php + +$foo = each(new stdClass); +var_dump($foo); + +var_dump(each(new stdClass)); + +$a = array(new stdClass); +var_dump(each($a)); + + +?> +--EXPECTF-- +bool(false) +bool(false) +array(4) { + [1]=> + object(stdClass)#1 (0) { + } + ["value"]=> + object(stdClass)#1 (0) { + } + [0]=> + int(0) + ["key"]=> + int(0) +} diff --git a/Zend/tests/each_003.phpt b/Zend/tests/each_003.phpt new file mode 100644 index 0000000..2361d6a --- /dev/null +++ b/Zend/tests/each_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing each() with recursion +--FILE-- +<?php + +$a = array(array()); +$a[] =& $a; + +var_dump(each($a[1])); + +?> +--EXPECTF-- +array(4) { + [1]=> + array(0) { + } + ["value"]=> + array(0) { + } + [0]=> + int(0) + ["key"]=> + int(0) +} diff --git a/Zend/tests/empty_str_offset.phpt b/Zend/tests/empty_str_offset.phpt new file mode 100644 index 0000000..486c052 --- /dev/null +++ b/Zend/tests/empty_str_offset.phpt @@ -0,0 +1,89 @@ +--TEST-- +Testing empty() with string offsets +--FILE-- +<?php + +print "- empty ---\n"; + +$str = "test0123"; + +var_dump(empty($str[-1])); +var_dump(empty($str[0])); +var_dump(empty($str[1])); +var_dump(empty($str[4])); // 0 +var_dump(empty($str[5])); // 1 +var_dump(empty($str[8])); +var_dump(empty($str[10000])); +// non-numeric offsets +print "- string ---\n"; +var_dump(empty($str['-1'])); +var_dump(empty($str['0'])); +var_dump(empty($str['1'])); +var_dump(empty($str['4'])); // 0 +var_dump(empty($str['1.5'])); +var_dump(empty($str['good'])); +var_dump(empty($str['3 and a half'])); +print "- bool ---\n"; +var_dump(empty($str[true])); +var_dump(empty($str[false])); +var_dump(empty($str[false][true])); +print "- null ---\n"; +var_dump(empty($str[null])); +print "- double ---\n"; +var_dump(empty($str[-1.1])); +var_dump(empty($str[-0.8])); +var_dump(empty($str[-0.1])); +var_dump(empty($str[0.2])); +var_dump(empty($str[0.9])); +var_dump(empty($str[M_PI])); +var_dump(empty($str[100.5001])); +print "- array ---\n"; +var_dump(empty($str[array()])); +var_dump(empty($str[array(1,2,3)])); +print "- object ---\n"; +var_dump(empty($str[new stdClass()])); +print "- resource ---\n"; +$f = fopen(__FILE__, 'r'); +var_dump(empty($str[$f])); +print "done\n"; + +?> +--EXPECTF-- +- empty --- +bool(true) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) +bool(true) +- string --- +bool(true) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +- bool --- +bool(false) +bool(false) +bool(true) +- null --- +bool(false) +- double --- +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +- array --- +bool(true) +bool(true) +- object --- +bool(true) +- resource --- +bool(true) +done diff --git a/Zend/tests/errmsg_001.phpt b/Zend/tests/errmsg_001.phpt new file mode 100644 index 0000000..b85e032 --- /dev/null +++ b/Zend/tests/errmsg_001.phpt @@ -0,0 +1,16 @@ +--TEST-- +errmsg: Non-abstract method must contain body +--FILE-- +<?php + +abstract class test { +} + +class Impl extends Test { + function Foo(); +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Non-abstract method Impl::Foo() must contain body in %s on line %d diff --git a/Zend/tests/errmsg_002.phpt b/Zend/tests/errmsg_002.phpt new file mode 100644 index 0000000..b7330c9 --- /dev/null +++ b/Zend/tests/errmsg_002.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: function cannot be declared private +--FILE-- +<?php + +abstract class test { + abstract private function foo() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Abstract function test::foo() cannot be declared private in %s on line %d diff --git a/Zend/tests/errmsg_003.phpt b/Zend/tests/errmsg_003.phpt new file mode 100644 index 0000000..64e4587 --- /dev/null +++ b/Zend/tests/errmsg_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +errmsg: cannot reassign $this (by ref) +--FILE-- +<?php + +class test { + function foo() { + $a = new test; + $this = &$a; + } +} + +$t = new test; +$t->foo(); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot re-assign $this in %s on line %d diff --git a/Zend/tests/errmsg_004.phpt b/Zend/tests/errmsg_004.phpt new file mode 100644 index 0000000..e6d22d6 --- /dev/null +++ b/Zend/tests/errmsg_004.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: can't use function return value in write context +--FILE-- +<?php + +function foo() { + return "blah"; +} + +foo() = 1; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Can't use function return value in write context in %s on line %d diff --git a/Zend/tests/errmsg_005.phpt b/Zend/tests/errmsg_005.phpt new file mode 100644 index 0000000..31c924c --- /dev/null +++ b/Zend/tests/errmsg_005.phpt @@ -0,0 +1,18 @@ +--TEST-- +errmsg: can't use method return value in write context +--FILE-- +<?php + +class test { + function foo() { + return "blah"; + } +} + +$t = new test; +$t->foo() = 1; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Can't use method return value in write context in %s on line %d diff --git a/Zend/tests/errmsg_006.phpt b/Zend/tests/errmsg_006.phpt new file mode 100644 index 0000000..976093d --- /dev/null +++ b/Zend/tests/errmsg_006.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: can't use [] for reading +--FILE-- +<?php + +$a = array(); +$b = $a[]; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s on line %d diff --git a/Zend/tests/errmsg_007.phpt b/Zend/tests/errmsg_007.phpt new file mode 100644 index 0000000..1ac2966 --- /dev/null +++ b/Zend/tests/errmsg_007.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: can't use [] for reading - 2 +--FILE-- +<?php + +$a = array(); +isset($a[]); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s on line %d diff --git a/Zend/tests/errmsg_008.phpt b/Zend/tests/errmsg_008.phpt new file mode 100644 index 0000000..e900603 --- /dev/null +++ b/Zend/tests/errmsg_008.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: can't use [] for unsetting +--FILE-- +<?php + +$a = array(); +unset($a[]); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for unsetting in %s on line %d diff --git a/Zend/tests/errmsg_009.phpt b/Zend/tests/errmsg_009.phpt new file mode 100644 index 0000000..4834fa3 --- /dev/null +++ b/Zend/tests/errmsg_009.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: multiple access type modifiers are not allowed (properties) +--FILE-- +<?php + +class test { + public private $var; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple access type modifiers are not allowed in %s on line %d diff --git a/Zend/tests/errmsg_010.phpt b/Zend/tests/errmsg_010.phpt new file mode 100644 index 0000000..ae2572f --- /dev/null +++ b/Zend/tests/errmsg_010.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: multiple access type modifiers are not allowed (methods) +--FILE-- +<?php + +class test { + private protected function foo() {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple access type modifiers are not allowed in %s on line %d diff --git a/Zend/tests/errmsg_011.phpt b/Zend/tests/errmsg_011.phpt new file mode 100644 index 0000000..9cfde0f --- /dev/null +++ b/Zend/tests/errmsg_011.phpt @@ -0,0 +1,16 @@ +--TEST-- +errmsg: cannot redeclare (method) +--FILE-- +<?php + +class test { + + function foo() {} + function foo() {} + +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot redeclare test::foo() in %s on line %d diff --git a/Zend/tests/errmsg_012.phpt b/Zend/tests/errmsg_012.phpt new file mode 100644 index 0000000..183785b --- /dev/null +++ b/Zend/tests/errmsg_012.phpt @@ -0,0 +1,11 @@ +--TEST-- +errmsg: __autoload() must take exactly 1 argument +--FILE-- +<?php + +function __autoload($a, $b) {} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: __autoload() must take exactly 1 argument in %s on line %d diff --git a/Zend/tests/errmsg_013.phpt b/Zend/tests/errmsg_013.phpt new file mode 100644 index 0000000..d1f248e --- /dev/null +++ b/Zend/tests/errmsg_013.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: default value for parameters with array type hint can only be an array or NULL +--FILE-- +<?php + +class test { + function foo(array $a = "s") { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Default value for parameters with array type hint can only be an array or NULL in %s on line %d diff --git a/Zend/tests/errmsg_014.phpt b/Zend/tests/errmsg_014.phpt new file mode 100644 index 0000000..77e12b0 --- /dev/null +++ b/Zend/tests/errmsg_014.phpt @@ -0,0 +1,17 @@ +--TEST-- +errmsg: cannot call __clone() method on objects +--FILE-- +<?php + +class test { + function __clone() { + } +} + +$t = new test; +$t->__clone(); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot call __clone() method on objects - use 'clone $obj' instead in %s on line %d diff --git a/Zend/tests/errmsg_015.phpt b/Zend/tests/errmsg_015.phpt new file mode 100644 index 0000000..8e626e5 --- /dev/null +++ b/Zend/tests/errmsg_015.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: __clone() cannot accept any arguments +--FILE-- +<?php + +class test { + function __clone($var) { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__clone() cannot accept any arguments in %s on line %d diff --git a/Zend/tests/errmsg_016.phpt b/Zend/tests/errmsg_016.phpt new file mode 100644 index 0000000..ccda07b --- /dev/null +++ b/Zend/tests/errmsg_016.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: __isset() must take exactly 1 argument +--FILE-- +<?php + +class test { + function __isset() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__isset() must take exactly 1 argument in %s on line %d diff --git a/Zend/tests/errmsg_017.phpt b/Zend/tests/errmsg_017.phpt new file mode 100644 index 0000000..df2b665 --- /dev/null +++ b/Zend/tests/errmsg_017.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: __unset() must take exactly 1 argument +--FILE-- +<?php + +class test { + function __unset() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__unset() must take exactly 1 argument in %s on line %d diff --git a/Zend/tests/errmsg_018.phpt b/Zend/tests/errmsg_018.phpt new file mode 100644 index 0000000..fb05cb1 --- /dev/null +++ b/Zend/tests/errmsg_018.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: static abstract function +--FILE-- +<?php + +class test { + static abstract function foo (); +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Static function test::foo() should not be abstract in %s on line %d + +Fatal error: Class test contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (test::foo) in %s on line %d diff --git a/Zend/tests/errmsg_019.phpt b/Zend/tests/errmsg_019.phpt new file mode 100644 index 0000000..2b45650 --- /dev/null +++ b/Zend/tests/errmsg_019.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: __destruct() cannot take arguments +--FILE-- +<?php + +class test { + function __destruct($var) { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Destructor test::__destruct() cannot take arguments in %s on line %d diff --git a/Zend/tests/errmsg_020.phpt b/Zend/tests/errmsg_020.phpt new file mode 100644 index 0000000..8199d5d --- /dev/null +++ b/Zend/tests/errmsg_020.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: disabled function +--INI-- +disable_functions=phpinfo +--FILE-- +<?php + +phpinfo(); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: phpinfo() has been disabled for security reasons in %s on line %d +Done diff --git a/Zend/tests/errmsg_021.phpt b/Zend/tests/errmsg_021.phpt new file mode 100644 index 0000000..4e62f85 --- /dev/null +++ b/Zend/tests/errmsg_021.phpt @@ -0,0 +1,17 @@ +--TEST-- +errmsg: disabled class +--INI-- +disable_classes=stdclass +--FILE-- +<?php + +class test extends stdclass { +} + +$t = new test; + +echo "Done\n"; +?> +--EXPECTF-- +Warning: test() has been disabled for security reasons in %s on line %d +Done diff --git a/Zend/tests/errmsg_022.phpt b/Zend/tests/errmsg_022.phpt new file mode 100644 index 0000000..ea7b082 --- /dev/null +++ b/Zend/tests/errmsg_022.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: only variables can be passed by reference +--FILE-- +<?php + +function foo (&$var) { +} + +foo(1); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Only variables can be passed by reference in %s on line %d diff --git a/Zend/tests/errmsg_023.phpt b/Zend/tests/errmsg_023.phpt new file mode 100644 index 0000000..9fd7804 --- /dev/null +++ b/Zend/tests/errmsg_023.phpt @@ -0,0 +1,17 @@ +--TEST-- +errmsg: access level must be the same or weaker +--FILE-- +<?php + +class test1 { + protected $var; +} + +class test extends test1 { + private $var; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Access level to test::$var must be protected (as in class test1) or weaker in %s on line %d diff --git a/Zend/tests/errmsg_024.phpt b/Zend/tests/errmsg_024.phpt new file mode 100644 index 0000000..011e6fd --- /dev/null +++ b/Zend/tests/errmsg_024.phpt @@ -0,0 +1,17 @@ +--TEST-- +No more errmsg: can now change initial value of property +--FILE-- +<?php + +class test1 { + static protected $var = 1; +} + +class test extends test1 { + static $var = 10; +} + +echo "Done\n"; +?> +--EXPECTF-- +Done diff --git a/Zend/tests/errmsg_025.phpt b/Zend/tests/errmsg_025.phpt new file mode 100644 index 0000000..014b409 --- /dev/null +++ b/Zend/tests/errmsg_025.phpt @@ -0,0 +1,20 @@ +--TEST-- +errmsg: cannot inherit previously inherited constant +--FILE-- +<?php + +interface test1 { + const FOO = 10; +} + +interface test2 { + const FOO = 10; +} + +class test implements test1, test2 { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot inherit previously-inherited or override constant FOO from interface test2 in %s on line %d diff --git a/Zend/tests/errmsg_026.phpt b/Zend/tests/errmsg_026.phpt new file mode 100644 index 0000000..1954122 --- /dev/null +++ b/Zend/tests/errmsg_026.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot redeclare class +--FILE-- +<?php + +class stdclass { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot redeclare class stdclass in %s on line %d diff --git a/Zend/tests/errmsg_027.phpt b/Zend/tests/errmsg_027.phpt new file mode 100644 index 0000000..f4fec61 --- /dev/null +++ b/Zend/tests/errmsg_027.phpt @@ -0,0 +1,16 @@ +--TEST-- +errmsg: class declarations may not be nested +--FILE-- +<?php + +class test { + function foo() { + class test2 { + } + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Class declarations may not be nested in %s on line %d diff --git a/Zend/tests/errmsg_028.phpt b/Zend/tests/errmsg_028.phpt new file mode 100644 index 0000000..3331cb3 --- /dev/null +++ b/Zend/tests/errmsg_028.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'self' as class name +--FILE-- +<?php + +class self { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'self' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_029.phpt b/Zend/tests/errmsg_029.phpt new file mode 100644 index 0000000..73b85ce --- /dev/null +++ b/Zend/tests/errmsg_029.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'parent' as class name +--FILE-- +<?php + +class parent { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'parent' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_030.phpt b/Zend/tests/errmsg_030.phpt new file mode 100644 index 0000000..ab6ccbd --- /dev/null +++ b/Zend/tests/errmsg_030.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'self' as parent class name +--FILE-- +<?php + +class test extends self { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'self' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_031.phpt b/Zend/tests/errmsg_031.phpt new file mode 100644 index 0000000..6e35648 --- /dev/null +++ b/Zend/tests/errmsg_031.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'parent' as parent class name +--FILE-- +<?php + +class test extends parent { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'parent' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_032.phpt b/Zend/tests/errmsg_032.phpt new file mode 100644 index 0000000..6e34604 --- /dev/null +++ b/Zend/tests/errmsg_032.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: __construct() cannot be static +--FILE-- +<?php + +class test { + + static function __construct() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Constructor test::__construct() cannot be static in %s on line %d diff --git a/Zend/tests/errmsg_033.phpt b/Zend/tests/errmsg_033.phpt new file mode 100644 index 0000000..9693890 --- /dev/null +++ b/Zend/tests/errmsg_033.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: __destruct() cannot be static +--FILE-- +<?php + +class test { + + static function __destruct() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Destructor test::__destruct() cannot be static in %s on line %d diff --git a/Zend/tests/errmsg_034.phpt b/Zend/tests/errmsg_034.phpt new file mode 100644 index 0000000..1494fe5 --- /dev/null +++ b/Zend/tests/errmsg_034.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: __clone() cannot be static +--FILE-- +<?php + +class test { + + static function __clone() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Clone method test::__clone() cannot be static in %s on line %d diff --git a/Zend/tests/errmsg_035.phpt b/Zend/tests/errmsg_035.phpt new file mode 100644 index 0000000..76cbe3d --- /dev/null +++ b/Zend/tests/errmsg_035.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'self' as interface name +--FILE-- +<?php + +class test implements self { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'self' as interface name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_036.phpt b/Zend/tests/errmsg_036.phpt new file mode 100644 index 0000000..d1f4274 --- /dev/null +++ b/Zend/tests/errmsg_036.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'parent' as interface name +--FILE-- +<?php + +class test implements parent { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'parent' as interface name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_037.phpt b/Zend/tests/errmsg_037.phpt new file mode 100644 index 0000000..6b98bb3 --- /dev/null +++ b/Zend/tests/errmsg_037.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: properties cannot be abstract +--FILE-- +<?php + +class test { + abstract $var = 1; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Properties cannot be declared abstract in %s on line %d diff --git a/Zend/tests/errmsg_038.phpt b/Zend/tests/errmsg_038.phpt new file mode 100644 index 0000000..2927e94 --- /dev/null +++ b/Zend/tests/errmsg_038.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: properties cannot be final +--FILE-- +<?php + +class test { + final $var = 1; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot declare property test::$var final, the final modifier is allowed only for methods and classes in %s on line %d diff --git a/Zend/tests/errmsg_039.phpt b/Zend/tests/errmsg_039.phpt new file mode 100644 index 0000000..0000811 --- /dev/null +++ b/Zend/tests/errmsg_039.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: cannot redeclare property +--FILE-- +<?php + +class test { + var $var; + var $var; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot redeclare test::$var in %s on line %d diff --git a/Zend/tests/errmsg_040.phpt b/Zend/tests/errmsg_040.phpt new file mode 100644 index 0000000..f3d0afc --- /dev/null +++ b/Zend/tests/errmsg_040.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: arrays are not allowed in class constants +--FILE-- +<?php + +class test { + const TEST = array(1,2,3); +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Arrays are not allowed in class constants in %s on line %d diff --git a/Zend/tests/errmsg_041.phpt b/Zend/tests/errmsg_041.phpt new file mode 100644 index 0000000..bfcafd2 --- /dev/null +++ b/Zend/tests/errmsg_041.phpt @@ -0,0 +1,11 @@ +--TEST-- +errmsg: instanceof expects an object instance, constant given +--FILE-- +<?php + +var_dump("abc" instanceof stdclass); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: instanceof expects an object instance, constant given in %s on line %d diff --git a/Zend/tests/errmsg_042.phpt b/Zend/tests/errmsg_042.phpt new file mode 100644 index 0000000..3b4ea7c --- /dev/null +++ b/Zend/tests/errmsg_042.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: key element cannot be a reference +--FILE-- +<?php + +$a = array(1,2,3); +foreach ($a as &$k=>$v) { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Key element cannot be a reference in %s on line %d diff --git a/Zend/tests/errmsg_043.phpt b/Zend/tests/errmsg_043.phpt new file mode 100644 index 0000000..3de8bc2 --- /dev/null +++ b/Zend/tests/errmsg_043.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot create references to temp array +--FILE-- +<?php + +foreach (array(1,2,3) as $k=>&$v) { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot create references to elements of a temporary array expression in %s on line %d diff --git a/Zend/tests/errmsg_044.phpt b/Zend/tests/errmsg_044.phpt new file mode 100644 index 0000000..e908845 --- /dev/null +++ b/Zend/tests/errmsg_044.phpt @@ -0,0 +1,11 @@ +--TEST-- +Trying use object of type stdClass as array +--FILE-- +<?php + +$a[0] = new stdclass; +$a[0][0] = new stdclass; + +?> +--EXPECTF-- +Fatal error: Cannot use object of type stdClass as array in %s on line %d diff --git a/Zend/tests/error_reporting01.phpt b/Zend/tests/error_reporting01.phpt new file mode 100644 index 0000000..5153d41 --- /dev/null +++ b/Zend/tests/error_reporting01.phpt @@ -0,0 +1,26 @@ +--TEST-- +testing @ and error_reporting - 1 +--FILE-- +<?php + +error_reporting(E_ALL); + +function foo($arg) { +} + +function bar() { + throw new Exception("test"); +} + +try { + @foo(@bar()); +} catch (Exception $e) { +} + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECT-- +int(32767) +Done diff --git a/Zend/tests/error_reporting02.phpt b/Zend/tests/error_reporting02.phpt new file mode 100644 index 0000000..f478663 --- /dev/null +++ b/Zend/tests/error_reporting02.phpt @@ -0,0 +1,27 @@ +--TEST-- +testing @ and error_reporting - 2 +--FILE-- +<?php + +error_reporting(E_ALL); + +function foo($arg) { +} + +function bar() { + error_reporting(E_ALL|E_STRICT); + throw new Exception("test"); +} + +try { + @foo(@bar()); +} catch (Exception $e) { +} + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECT-- +int(32767) +Done diff --git a/Zend/tests/error_reporting03.phpt b/Zend/tests/error_reporting03.phpt new file mode 100644 index 0000000..3c6595c --- /dev/null +++ b/Zend/tests/error_reporting03.phpt @@ -0,0 +1,35 @@ +--TEST-- +testing @ and error_reporting - 3 +--FILE-- +<?php + +error_reporting(E_ALL); + +function foo($arg) { + echo @$nonex_foo; +} + +function bar() { + echo @$nonex_bar; + throw new Exception("test"); +} + +function foo1() { + echo $undef1; + error_reporting(E_ALL|E_STRICT); + echo $undef2; +} + +try { + @foo(@bar(@foo1())); +} catch (Exception $e) { +} + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Undefined variable: undef2 in %s on line %d +int(32767) +Done diff --git a/Zend/tests/error_reporting04.phpt b/Zend/tests/error_reporting04.phpt new file mode 100644 index 0000000..295a3a4 --- /dev/null +++ b/Zend/tests/error_reporting04.phpt @@ -0,0 +1,23 @@ +--TEST-- +testing @ and error_reporting - 4 +--FILE-- +<?php + +error_reporting(E_ALL); + +function foo() { + echo $undef; + error_reporting(E_ALL|E_STRICT); +} + + +foo(@$var); + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Undefined variable: undef in %s on line %d +int(32767) +Done diff --git a/Zend/tests/error_reporting05.phpt b/Zend/tests/error_reporting05.phpt new file mode 100644 index 0000000..fe5374c --- /dev/null +++ b/Zend/tests/error_reporting05.phpt @@ -0,0 +1,34 @@ +--TEST-- +testing @ and error_reporting - 5 +--FILE-- +<?php + +error_reporting(E_ALL); + +class test { + function __get($name) { + return $undef_name; + } + function __set($name, $value) { + return $undef_value; + } +} + +$test = new test; + +$test->abc = 123; +echo $test->bcd; + +@$test->qwe = 123; +echo @$test->wer; + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Undefined variable: undef_value in %s on line %d + +Notice: Undefined variable: undef_name in %s on line %d +int(32767) +Done diff --git a/Zend/tests/error_reporting06.phpt b/Zend/tests/error_reporting06.phpt new file mode 100644 index 0000000..285a623 --- /dev/null +++ b/Zend/tests/error_reporting06.phpt @@ -0,0 +1,30 @@ +--TEST-- +testing @ and error_reporting - 6 +--FILE-- +<?php + +error_reporting(E_ALL); + +function foo1($arg) { +} + +function foo2($arg) { +} + +function foo3($arg) { + echo $undef3; + throw new Exception("test"); +} + +try { + @foo1(@foo2(@foo3())); +} catch (Exception $e) { +} + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +int(32767) +Done diff --git a/Zend/tests/error_reporting07.phpt b/Zend/tests/error_reporting07.phpt new file mode 100644 index 0000000..c63efae --- /dev/null +++ b/Zend/tests/error_reporting07.phpt @@ -0,0 +1,30 @@ +--TEST-- +testing @ and error_reporting - 7 +--FILE-- +<?php + +error_reporting(E_ALL); + +function foo1($arg) { +} + +function foo2($arg) { +} + +function foo3($arg) { + echo $undef3; + throw new Exception("test"); +} + +try { + @error_reporting(@foo1(@foo2(@foo3()))); +} catch (Exception $e) { +} + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +int(32767) +Done diff --git a/Zend/tests/error_reporting08.phpt b/Zend/tests/error_reporting08.phpt new file mode 100644 index 0000000..edf3292 --- /dev/null +++ b/Zend/tests/error_reporting08.phpt @@ -0,0 +1,32 @@ +--TEST-- +testing @ and error_reporting - 8 +--FILE-- +<?php + +error_reporting(E_ALL); + +function foo1($arg) { +} + +function foo2($arg) { +} + +function foo3($arg) { + error_reporting(E_ALL|E_STRICT); + echo $undef3; + throw new Exception("test"); +} + +try { + @foo1(@foo2(@foo3())); +} catch (Exception $e) { +} + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Undefined variable: undef3 in %s on line %d +int(32767) +Done diff --git a/Zend/tests/error_reporting09.phpt b/Zend/tests/error_reporting09.phpt new file mode 100644 index 0000000..8d4e7e1 --- /dev/null +++ b/Zend/tests/error_reporting09.phpt @@ -0,0 +1,31 @@ +--TEST-- +testing @ and error_reporting - 9 +--FILE-- +<?php + +error_reporting(E_ALL); + +function bar() { + echo @$blah; + echo $undef2; +} + +function foo() { + echo @$undef; + error_reporting(E_ALL|E_STRICT); + echo $blah; + return bar(); +} + +@foo(); + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Undefined variable: blah in %s on line %d + +Notice: Undefined variable: undef2 in %s on line %d +int(32767) +Done diff --git a/Zend/tests/error_reporting10.phpt b/Zend/tests/error_reporting10.phpt new file mode 100644 index 0000000..12b1db5 --- /dev/null +++ b/Zend/tests/error_reporting10.phpt @@ -0,0 +1,35 @@ +--TEST-- +testing @ and error_reporting - 10 +--FILE-- +<?php + +error_reporting(E_ALL); + +function make_exception() +{ + @$blah; + str_replace(); + error_reporting(0); + throw new Exception(); +} + +try { + @make_exception(); +} catch (Exception $e) {} + +var_dump(error_reporting()); + +error_reporting(E_ALL&~E_NOTICE); + +try { + @make_exception(); +} catch (Exception $e) {} + +var_dump(error_reporting()); + +echo "Done\n"; +?> +--EXPECTF-- +int(32767) +int(32759) +Done diff --git a/Zend/tests/exception_001.phpt b/Zend/tests/exception_001.phpt new file mode 100644 index 0000000..ab74a92 --- /dev/null +++ b/Zend/tests/exception_001.phpt @@ -0,0 +1,38 @@ +--TEST-- +Testing nested exceptions +--FILE-- +<?php + +try { + try { + try { + try { + throw new Exception(NULL); + } catch (Exception $e) { + var_dump($e->getMessage()); + throw $e; + } + } catch (Exception $e) { + var_dump($e->getMessage()); + throw $e; + } + } catch (Exception $e) { + var_dump($e->getMessage()); + throw $e; + } +} catch (Exception $e) { + var_dump($e->getMessage()); + throw $e; +} + +?> +--EXPECTF-- +string(0) "" +string(0) "" +string(0) "" +string(0) "" + +Fatal error: Uncaught exception 'Exception' in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d diff --git a/Zend/tests/exception_002.phpt b/Zend/tests/exception_002.phpt new file mode 100644 index 0000000..25f0c61 --- /dev/null +++ b/Zend/tests/exception_002.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing exception and GOTO +--FILE-- +<?php + +goto foo; + +try { + print 1; + + foo: + print 2; +} catch (Exception $e) { + +} + +?> +--EXPECT-- +2 diff --git a/Zend/tests/exception_003.phpt b/Zend/tests/exception_003.phpt new file mode 100644 index 0000000..e060aac --- /dev/null +++ b/Zend/tests/exception_003.phpt @@ -0,0 +1,14 @@ +--TEST-- +Throwing exception in global scope +--FILE-- +<?php + +throw new Exception(1); + +?> +--EXPECTF-- + +Fatal error: Uncaught exception 'Exception' with message '1' in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d diff --git a/Zend/tests/exception_004.phpt b/Zend/tests/exception_004.phpt new file mode 100644 index 0000000..77d947f --- /dev/null +++ b/Zend/tests/exception_004.phpt @@ -0,0 +1,18 @@ +--TEST-- +Throwing exception using a class that isn't derived from the Exception base class +--FILE-- +<?php + +error_reporting(E_ALL|E_STRICT); + +class Foo { } + +try { + throw new Foo(); +} catch (Foo $e) { + var_dump($e); +} + +?> +--EXPECTF-- +Fatal error: Exceptions must be valid objects derived from the Exception base class in %s on line %d diff --git a/Zend/tests/exception_005.phpt b/Zend/tests/exception_005.phpt new file mode 100644 index 0000000..45a9269 --- /dev/null +++ b/Zend/tests/exception_005.phpt @@ -0,0 +1,12 @@ +--TEST-- +Trying to throw exception of an interface +--FILE-- +<?php + +interface a { } + +throw new a(); + +?> +--EXPECTF-- +Fatal error: Cannot instantiate interface a in %s on line %d diff --git a/Zend/tests/exception_006.phpt b/Zend/tests/exception_006.phpt new file mode 100644 index 0000000..5c981fc --- /dev/null +++ b/Zend/tests/exception_006.phpt @@ -0,0 +1,10 @@ +--TEST-- +Trying to throw a non-object +--FILE-- +<?php + +throw 1; + +?> +--EXPECTF-- +Fatal error: Can only throw objects in %s on line %d diff --git a/Zend/tests/exception_007.phpt b/Zend/tests/exception_007.phpt new file mode 100644 index 0000000..953e765 --- /dev/null +++ b/Zend/tests/exception_007.phpt @@ -0,0 +1,36 @@ +--TEST-- +Setting previous exception +--FILE-- +<?php + +try { + try { + throw new Exception("First", 1, new Exception("Another", 0, NULL)); + } + catch (Exception $e) { + throw new Exception("Second", 2, $e); + } +} +catch (Exception $e) { + throw new Exception("Third", 3, $e); +} + +?> +===DONE=== +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'Another' in %sexception_007.php:%d +Stack trace: +#0 {main} + +Next exception 'Exception' with message 'First' in %sexception_007.php:%d +Stack trace: +#0 {main} + +Next exception 'Exception' with message 'Second' in %sexception_007.php:%d +Stack trace: +#0 {main} + +Next exception 'Exception' with message 'Third' in %sexception_007.php:%d +Stack trace: +#0 {main} + thrown in %sexception_007.php on line %d diff --git a/Zend/tests/exception_008.phpt b/Zend/tests/exception_008.phpt new file mode 100644 index 0000000..0d40541 --- /dev/null +++ b/Zend/tests/exception_008.phpt @@ -0,0 +1,36 @@ +--TEST-- +Exception in __destruct while exception is pending +--FILE-- +<?php + +class TestFirst +{ + function __destruct() { + throw new Exception("First"); + } +} + +class TestSecond +{ + function __destruct() { + throw new Exception("Second"); + } +} + +$ar = array(new TestFirst, new TestSecond); + +unset($ar); + +?> +===DONE=== +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'First' in %sexception_008.php:%d +Stack trace: +#0 %sexception_008.php(%d): TestFirst->__destruct() +#1 {main} + +Next exception 'Exception' with message 'Second' in %sexception_008.php:%d +Stack trace: +#0 %sexception_008.php(%d): TestSecond->__destruct() +#1 {main} + thrown in %sexception_008.php on line %d diff --git a/Zend/tests/exception_009.phpt b/Zend/tests/exception_009.phpt new file mode 100644 index 0000000..b22b3aa --- /dev/null +++ b/Zend/tests/exception_009.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing exception properties +--FILE-- +<?php + +class my_file +{ + public function __toString() + { + return "somebuildfilename" ; + } +} + +class my_exception extends exception +{ + public function __construct() + { + $this->message = new stdclass ; + $this->file = new my_file ; + $this->line = "12" ; + } +} + +throw new my_exception; + +?> +--EXPECT-- +Catchable fatal error: Object of class stdClass could not be converted to string in Unknown on line 0 diff --git a/Zend/tests/exception_010.phpt b/Zend/tests/exception_010.phpt new file mode 100644 index 0000000..6bff8c6 --- /dev/null +++ b/Zend/tests/exception_010.phpt @@ -0,0 +1,30 @@ +--TEST-- +Testing Exception's methods +--FILE-- +<?php + +$x = new Exception; +$x->gettraceasstring(1); +$x->gettraceasstring(); +$x->__tostring(1); +$x->gettrace(1); +$x->getline(1); +$x->getfile(1); +$x->getmessage(1); +$x->getcode(1); + +?> +--EXPECTF-- +Warning: Exception::getTraceAsString() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: Exception::__toString() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: Exception::getTrace() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: Exception::getLine() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: Exception::getFile() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: Exception::getMessage() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: Exception::getCode() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/Zend/tests/exception_handler_001.phpt b/Zend/tests/exception_handler_001.phpt new file mode 100644 index 0000000..8f6572e --- /dev/null +++ b/Zend/tests/exception_handler_001.phpt @@ -0,0 +1,20 @@ +--TEST-- +exception handler tests - 1 +--FILE-- +<?php + +set_exception_handler("foo"); + +function foo($e) { + var_dump(get_class($e)." thrown!"); +} + +class test extends Exception { +} + +throw new test(); + +echo "Done\n"; +?> +--EXPECTF-- +string(12) "test thrown!" diff --git a/Zend/tests/exception_handler_002.phpt b/Zend/tests/exception_handler_002.phpt new file mode 100644 index 0000000..7dfbb38 --- /dev/null +++ b/Zend/tests/exception_handler_002.phpt @@ -0,0 +1,27 @@ +--TEST-- +exception handler tests - 2 +--FILE-- +<?php + +set_exception_handler("foo"); + +function foo($e) { + var_dump(get_class($e)." thrown!"); + throw new Exception(); +} + +class test extends Exception { +} + +throw new test(); + +echo "Done\n"; +?> +--EXPECTF-- +string(12) "test thrown!" + +Fatal error: Uncaught exception 'Exception' in %sexception_handler_002.php:7 +Stack trace: +#0 [internal function]: foo(Object(test)) +#1 {main} + thrown in %sexception_handler_002.php on line %d diff --git a/Zend/tests/exception_handler_003.phpt b/Zend/tests/exception_handler_003.phpt new file mode 100644 index 0000000..137a6ca --- /dev/null +++ b/Zend/tests/exception_handler_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +exception handler tests - 3 +--FILE-- +<?php + +class test { + + function foo () { + set_exception_handler(array($this, "bar")); + } + + function bar($e) { + var_dump(get_class($e)." thrown!"); + } +} + +$a = new test; +$a->foo(); +throw new Exception(); + +echo "Done\n"; +?> +--EXPECTF-- +string(17) "Exception thrown!" diff --git a/Zend/tests/exception_handler_004.phpt b/Zend/tests/exception_handler_004.phpt new file mode 100644 index 0000000..bf581bb --- /dev/null +++ b/Zend/tests/exception_handler_004.phpt @@ -0,0 +1,21 @@ +--TEST-- +exception handler tests - 4 +--FILE-- +<?php + +set_exception_handler("fo"); +set_exception_handler(array("", "")); +set_exception_handler(); +set_exception_handler("foo", "bar"); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: set_exception_handler() expects the argument (fo) to be a valid callback in %s on line %d + +Warning: set_exception_handler() expects the argument (::) to be a valid callback in %s on line %d + +Warning: set_exception_handler() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: set_exception_handler() expects exactly 1 parameter, 2 given in %s on line %d +Done diff --git a/Zend/tests/exception_handler_005.phpt b/Zend/tests/exception_handler_005.phpt new file mode 100644 index 0000000..cc99bc6 --- /dev/null +++ b/Zend/tests/exception_handler_005.phpt @@ -0,0 +1,23 @@ +--TEST-- +exception handler tests - 5 +--FILE-- +<?php + +set_exception_handler("foo"); +set_exception_handler("foo1"); + +function foo($e) { + var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); +} + +function foo1($e) { + var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); +} + + +throw new excEption(); + +echo "Done\n"; +?> +--EXPECTF-- +string(25) "foo1(): Exception thrown!" diff --git a/Zend/tests/exception_handler_006.phpt b/Zend/tests/exception_handler_006.phpt new file mode 100644 index 0000000..05a5d92 --- /dev/null +++ b/Zend/tests/exception_handler_006.phpt @@ -0,0 +1,25 @@ +--TEST-- +exception handler tests - 6 +--FILE-- +<?php + +set_exception_handler("foo"); +set_exception_handler("foo1"); + +restore_exception_handler(); + +function foo($e) { + var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); +} + +function foo1($e) { + var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); +} + + +throw new excEption(); + +echo "Done\n"; +?> +--EXPECTF-- +string(24) "foo(): Exception thrown!" diff --git a/Zend/tests/float_prec_001.phpt b/Zend/tests/float_prec_001.phpt new file mode 100644 index 0000000..ffddab4 --- /dev/null +++ b/Zend/tests/float_prec_001.phpt @@ -0,0 +1,10 @@ +--TEST-- +Double precision is used for floating point calculations +--FILE-- +<?php +var_dump (0.002877 == 2877.0 / 1000000.0); +var_dump (substr (sprintf ("%.35f", 0.002877), 0, 10)); +?> +--EXPECT-- +bool(true) +string(10) "0.00287699" diff --git a/Zend/tests/foreach.phpt b/Zend/tests/foreach.phpt new file mode 100644 index 0000000..041a763 --- /dev/null +++ b/Zend/tests/foreach.phpt @@ -0,0 +1,25 @@ +--TEST-- +foreach() by-ref bug +--FILE-- +<?php +$foo = array(1,2,3,4); +foreach($foo as $key => &$val) { + if($val == 3) { + $foo[$key] = 0; + } else { + $val++; + } +} +var_dump($foo); +?> +--EXPECT-- +array(4) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(0) + [3]=> + &int(5) +} diff --git a/Zend/tests/foreach_002.phpt b/Zend/tests/foreach_002.phpt new file mode 100644 index 0000000..5523424 --- /dev/null +++ b/Zend/tests/foreach_002.phpt @@ -0,0 +1,20 @@ +--TEST-- +Creating recursive array on foreach using same variable +--FILE-- +<?php + +error_reporting(E_ALL); + +foreach (($a = array('a' => array('a' => &$a))) as $a) { + var_dump($a); +} + +?> +--EXPECT-- +array(1) { + ["a"]=> + &array(1) { + ["a"]=> + *RECURSION* + } +} diff --git a/Zend/tests/foreach_undefined.phpt b/Zend/tests/foreach_undefined.phpt new file mode 100644 index 0000000..101d983 --- /dev/null +++ b/Zend/tests/foreach_undefined.phpt @@ -0,0 +1,14 @@ +--TEST-- +foreach() & undefined var +--FILE-- +<?php + +foreach($a as $val); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Undefined variable: a in %s on line %d + +Warning: Invalid argument supplied for foreach() in %s on line %d +Done diff --git a/Zend/tests/foreach_unset_globals.phpt b/Zend/tests/foreach_unset_globals.phpt new file mode 100644 index 0000000..188c70a --- /dev/null +++ b/Zend/tests/foreach_unset_globals.phpt @@ -0,0 +1,21 @@ +--TEST-- +traverse an array and use its keys to unset GLOBALS +--FILE-- +<?php + +$arr = array("a" => 1, "b" => 2); +foreach ($arr as $key => $val) { + unset($GLOBALS[$key]); +} + +var_dump($arr); +echo "Done\n"; +?> +--EXPECTF-- +array(2) { + ["a"]=> + int(1) + ["b"]=> + int(2) +} +Done diff --git a/Zend/tests/fr47160.phpt b/Zend/tests/fr47160.phpt new file mode 100644 index 0000000..809e1f1 --- /dev/null +++ b/Zend/tests/fr47160.phpt @@ -0,0 +1,150 @@ +--TEST-- +Calling method from array +--FILE-- +<?php + +class Hello { + public function world($x) { + echo "Hello, $x\n"; return $this; + } +} + +class Hello2 { + static public function world($x) { + echo "Hello, $x\n"; + } +} + +class Magic { + public function __call($f, $a) { + printf("%s called (%s)!\n", __METHOD__, $f); + } +} + +class Magic2 { + public static function __callStatic($f, $a) { + printf("%s called (%s)!\n", __METHOD__, $f); + } +} + +class Magic3 { + public static function __callStatic($f, $a) { + printf("%s called (%s)!\n", __METHOD__, $f); + } + public function __call($f, $a) { + printf("%s called (%s)!\n", __METHOD__, $f); + } +} + +$f = array('Hello','world'); +var_dump($f('you')); +var_dump(call_user_func($f, 'you')); + +printf("-----\n"); + +$h= new Hello; +$f = array($h,'world'); +var_dump($f('again')); +var_dump(call_user_func($f, 'again')); + +printf("-----\n"); + +function bar() { + return array(new Hello,'world'); +} +$f = bar(); +var_dump($f('there')); +var_dump(call_user_func($f, 'there')); + +printf("-----\n"); + +$x = function ($c,$v) { return array($c, $v); }; + +$c = new Hello; +$m = 'world'; +$f = $x($c, $m); +var_dump($f('devs')); +var_dump(call_user_func($f, 'devs')); + +printf("-----\n"); + +$f = array(new Magic, 'foo'); +$f(); +call_user_func($f); + +printf("-----\n"); + +$f = array('Magic2', 'foo'); +$f(); +call_user_func($f); + + +printf("-----\n"); + +$f = array('Magic3', 'foo'); +$f(); +call_user_func($f); + +printf("-----\n"); + +$f = array(new Magic3, 'foo'); +$f(); +call_user_func($f); + +printf("-----\n"); + +$f = array(new Hello2, 'world'); +var_dump($f('you')); +var_dump(call_user_func($f, 'you')); + +?> +--EXPECTF-- +Strict Standards: Non-static method Hello::world() should not be called statically in %s on line %d +Hello, you + +Notice: Undefined variable: this in %s on line %d +NULL + +Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method Hello::world() should not be called statically in %s on line %d +Hello, you + +Notice: Undefined variable: this in %s on line %d +NULL +----- +Hello, again +object(Hello)#1 (0) { +} +Hello, again +object(Hello)#1 (0) { +} +----- +Hello, there +object(Hello)#2 (0) { +} +Hello, there +object(Hello)#2 (0) { +} +----- +Hello, devs +object(Hello)#4 (0) { +} +Hello, devs +object(Hello)#4 (0) { +} +----- +Magic::__call called (foo)! +Magic::__call called (foo)! +----- +Magic2::__callStatic called (foo)! +Magic2::__callStatic called (foo)! +----- +Magic3::__callStatic called (foo)! +Magic3::__callStatic called (foo)! +----- +Magic3::__call called (foo)! +Magic3::__call called (foo)! +----- +Hello, you +NULL +Hello, you +NULL diff --git a/Zend/tests/function_arguments_001.phpt b/Zend/tests/function_arguments_001.phpt new file mode 100644 index 0000000..8e3d34d --- /dev/null +++ b/Zend/tests/function_arguments_001.phpt @@ -0,0 +1,9 @@ +--TEST-- +Argument parsing error #001 +--FILE-- +<?php +function foo($arg1 string) {} +?> +--EXPECTF-- +Parse error: %s error, %s)%s in %sfunction_arguments_001.php on line %d + diff --git a/Zend/tests/function_arguments_002.phpt b/Zend/tests/function_arguments_002.phpt new file mode 100644 index 0000000..1b5b7bd --- /dev/null +++ b/Zend/tests/function_arguments_002.phpt @@ -0,0 +1,9 @@ +--TEST-- +Argument parsing error #002 +--FILE-- +<?php +function foo($arg1/) {} +?> +--EXPECTF-- +Parse error: %s error, %s)%s in %sfunction_arguments_002.php on line %d + diff --git a/Zend/tests/function_exists_basic.phpt b/Zend/tests/function_exists_basic.phpt new file mode 100644 index 0000000..469e3d8 --- /dev/null +++ b/Zend/tests/function_exists_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +function_exists function : basic functionality +--FILE-- +<?php +/* + * proto bool function_exists(string function_name) + * Function is implemented in Zend/zend_builtin_functions.c +*/ + +echo "*** Testing function_exists() : basic functionality ***\n"; + +echo "Internal function: "; +var_dump(function_exists('function_exists')); + +echo "User defined function: "; +function f() {} +var_dump(function_exists('f')); + +echo "Case sensitivity: "; +var_dump(function_exists('F')); + +echo "Non existent function: "; +var_dump(function_exists('g')); + +echo "Method: "; +Class C { + static function f() {} +} +var_dump(function_exists('C::f')); +?> +===Done=== +--EXPECT-- +*** Testing function_exists() : basic functionality *** +Internal function: bool(true) +User defined function: bool(true) +Case sensitivity: bool(true) +Non existent function: bool(false) +Method: bool(false) +===Done=== diff --git a/Zend/tests/function_exists_error.phpt b/Zend/tests/function_exists_error.phpt new file mode 100644 index 0000000..cbc3908 --- /dev/null +++ b/Zend/tests/function_exists_error.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function_exists() function : error conditions +--FILE-- +<?php +/* + * proto bool function_exists(string function_name) + * Function is implemented in Zend/zend_builtin_functions.c +*/ + +echo "*** Testing function_exists() : error conditions ***\n"; + +$arg_0 = "ABC"; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(function_exists($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(function_exists()); + +?> +===Done=== +--EXPECTF-- +*** Testing function_exists() : error conditions *** + +Too many arguments + +Warning: function_exists() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Too few arguments + +Warning: function_exists() expects exactly 1 parameter, 0 given in %s on line %d +NULL +===Done=== + diff --git a/Zend/tests/function_exists_variation1.phpt b/Zend/tests/function_exists_variation1.phpt new file mode 100644 index 0000000..16b05fc --- /dev/null +++ b/Zend/tests/function_exists_variation1.phpt @@ -0,0 +1,138 @@ +--TEST-- +Test function_exists() function : usage variations - test values for $str argument +--FILE-- +<?php + +/* + * proto bool function_exists(string function_name) + * Function is implemented in Zend/zend_builtin_functions.c +*/ + +echo "*** Testing function_exists() function: with unexpected inputs for 'str' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $str +$inputs = array ( + + // integer values + 0, + 1, + 255, + 256, + PHP_INT_MAX, + -PHP_INT_MAX, + + // float values + 10.5, + -20.5, + 10.1234567e10, + + // array values + array(), + array(0), + array(1, 2), + + // boolean values + true, + false, + TRUE, + FALSE, + + // null values + NULL, + null, + + // objects + new sample(), + + // resource + $file_handle, + + // undefined variable + @$undefined_var, + + // unset variable + @$unset_var +); + +// loop through with each element of the $inputs array to test function_exists() function +$count = 1; +foreach($inputs as $input) { + echo "-- Iteration $count --\n"; + var_dump( function_exists($input) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===Done=== +--EXPECTF-- +*** Testing function_exists() function: with unexpected inputs for 'str' argument *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- + +Warning: function_exists() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: function_exists() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: function_exists() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- + +Warning: function_exists() expects parameter 1 to be string, resource given in %s on line %d +NULL +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +===Done=== +
\ No newline at end of file diff --git a/Zend/tests/gc_001.phpt b/Zend/tests/gc_001.phpt new file mode 100644 index 0000000..0523c73 --- /dev/null +++ b/Zend/tests/gc_001.phpt @@ -0,0 +1,12 @@ +--TEST-- +GC 001: gc_enable()/gc_diable()/gc_enabled() +--FILE-- +<?php +gc_disable(); +var_dump(gc_enabled()); +gc_enable(); +var_dump(gc_enabled()); +?> +--EXPECT-- +bool(false) +bool(true) diff --git a/Zend/tests/gc_002.phpt b/Zend/tests/gc_002.phpt new file mode 100644 index 0000000..439520c --- /dev/null +++ b/Zend/tests/gc_002.phpt @@ -0,0 +1,16 @@ +--TEST-- +GC 002: gc_enable()/gc_diable() and ini_get() +--FILE-- +<?php +gc_disable(); +var_dump(gc_enabled()); +echo ini_get('zend.enable_gc') . "\n"; +gc_enable(); +var_dump(gc_enabled()); +echo ini_get('zend.enable_gc') . "\n"; +?> +--EXPECT-- +bool(false) +0 +bool(true) +1 diff --git a/Zend/tests/gc_003.phpt b/Zend/tests/gc_003.phpt new file mode 100644 index 0000000..c2df57b --- /dev/null +++ b/Zend/tests/gc_003.phpt @@ -0,0 +1,16 @@ +--TEST-- +GC 003: gc_enabled() and ini_set() +--FILE-- +<?php +ini_set('zend.enable_gc','0'); +var_dump(gc_enabled()); +echo ini_get('zend.enable_gc') . "\n"; +ini_set('zend.enable_gc','1'); +var_dump(gc_enabled()); +echo ini_get('zend.enable_gc') . "\n"; +?> +--EXPECT-- +bool(false) +0 +bool(true) +1 diff --git a/Zend/tests/gc_004.phpt b/Zend/tests/gc_004.phpt new file mode 100644 index 0000000..1b6f70a --- /dev/null +++ b/Zend/tests/gc_004.phpt @@ -0,0 +1,23 @@ +--TEST-- +GC 004: Simple array cycle +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(); +$a[] =& $a; +var_dump($a); +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +array(1) { + [0]=> + &array(1) { + [0]=> + *RECURSION* + } +} +int(1) +ok diff --git a/Zend/tests/gc_005.phpt b/Zend/tests/gc_005.phpt new file mode 100644 index 0000000..71fb890 --- /dev/null +++ b/Zend/tests/gc_005.phpt @@ -0,0 +1,20 @@ +--TEST-- +GC 005: Simple object cycle +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = new stdClass(); +$a->a = $a; +var_dump($a); +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECTF-- +object(stdClass)#%d (1) { + ["a"]=> + *RECURSION* +} +int(1) +ok diff --git a/Zend/tests/gc_006.phpt b/Zend/tests/gc_006.phpt new file mode 100644 index 0000000..c633d03 --- /dev/null +++ b/Zend/tests/gc_006.phpt @@ -0,0 +1,24 @@ +--TEST-- +GC 006: Simple array-object cycle +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = new stdClass(); +$a->a = array(); +$a->a[0] =& $a; +var_dump($a); +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECTF-- +object(stdClass)#%d (1) { + ["a"]=> + array(1) { + [0]=> + *RECURSION* + } +} +int(2) +ok diff --git a/Zend/tests/gc_007.phpt b/Zend/tests/gc_007.phpt new file mode 100644 index 0000000..8601ea4 --- /dev/null +++ b/Zend/tests/gc_007.phpt @@ -0,0 +1,25 @@ +--TEST-- +GC 007: Unreferensed array cycle +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(array()); +$a[0][0] =& $a[0]; +var_dump($a[0]); +var_dump(gc_collect_cycles()); +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +array(1) { + [0]=> + &array(1) { + [0]=> + *RECURSION* + } +} +int(0) +int(1) +ok diff --git a/Zend/tests/gc_008.phpt b/Zend/tests/gc_008.phpt new file mode 100644 index 0000000..289d581 --- /dev/null +++ b/Zend/tests/gc_008.phpt @@ -0,0 +1,23 @@ +--TEST-- +GC 008: Unreferensed object cycle +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = new stdClass(); +$a->a = new stdClass(); +$a->a->a = $a->a; +var_dump($a->a); +var_dump(gc_collect_cycles()); +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECTF-- +object(stdClass)#%d (1) { + ["a"]=> + *RECURSION* +} +int(0) +int(1) +ok diff --git a/Zend/tests/gc_009.phpt b/Zend/tests/gc_009.phpt new file mode 100644 index 0000000..263d31f --- /dev/null +++ b/Zend/tests/gc_009.phpt @@ -0,0 +1,27 @@ +--TEST-- +GC 009: Unreferensed array-object cycle +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(); +$a[0] = new stdClass(); +$a[0]->a = array(); +$a[0]->a[0] =& $a[0]; +var_dump($a[0]); +var_dump(gc_collect_cycles()); +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECTF-- +object(stdClass)#%d (1) { + ["a"]=> + array(1) { + [0]=> + *RECURSION* + } +} +int(0) +int(2) +ok diff --git a/Zend/tests/gc_010.phpt b/Zend/tests/gc_010.phpt new file mode 100644 index 0000000..af2dda3 --- /dev/null +++ b/Zend/tests/gc_010.phpt @@ -0,0 +1,24 @@ +--TEST-- +GC 010: Cycle with reference to $GLOBALS +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(); +$a[] =& $a; +var_dump($a); +$a[] =& $GLOBALS; +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +array(1) { + [0]=> + &array(1) { + [0]=> + *RECURSION* + } +} +int(1) +ok diff --git a/Zend/tests/gc_011.phpt b/Zend/tests/gc_011.phpt new file mode 100644 index 0000000..9c4cc2c --- /dev/null +++ b/Zend/tests/gc_011.phpt @@ -0,0 +1,27 @@ +--TEST-- +GC 011: GC and destructors +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +class Foo { + public $a; + function __destruct() { + echo __FUNCTION__,"\n"; + } +} +$a = new Foo(); +$a->a = $a; +var_dump($a); +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECTF-- +object(Foo)#%d (1) { + ["a"]=> + *RECURSION* +} +__destruct +int(1) +ok diff --git a/Zend/tests/gc_012.phpt b/Zend/tests/gc_012.phpt new file mode 100644 index 0000000..f6c8538 --- /dev/null +++ b/Zend/tests/gc_012.phpt @@ -0,0 +1,19 @@ +--TEST-- +GC 012: collection of many loops at once +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a=array(); +for ($i=0; $i < 1000; $i++) { + $a[$i] = array(array()); + $a[$i][0] = & $a[$i]; +} +var_dump(gc_collect_cycles()); +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n"; +--EXPECT-- +int(0) +int(1000) +ok diff --git a/Zend/tests/gc_013.phpt b/Zend/tests/gc_013.phpt new file mode 100644 index 0000000..9209ca2 --- /dev/null +++ b/Zend/tests/gc_013.phpt @@ -0,0 +1,18 @@ +--TEST-- +GC 013: Too many cycles in one array +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(); +for ($i = 0; $i < 10001; $i++) { + $a[$i] =& $a; +} +$a[] = "xxx"; +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n"; +?> +--EXPECT-- +int(2) +ok diff --git a/Zend/tests/gc_014.phpt b/Zend/tests/gc_014.phpt new file mode 100644 index 0000000..9f43fc8 --- /dev/null +++ b/Zend/tests/gc_014.phpt @@ -0,0 +1,20 @@ +--TEST-- +GC 014: Too many cycles in one object +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = new stdClass(); +for ($i = 0; $i < 10001; $i++) { + $b =& $a; + $a->{"a".$i} = $a; +} +unset($b); +$a->b = "xxx"; +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n"; +?> +--EXPECT-- +int(10002) +ok diff --git a/Zend/tests/gc_015.phpt b/Zend/tests/gc_015.phpt new file mode 100644 index 0000000..df85836 --- /dev/null +++ b/Zend/tests/gc_015.phpt @@ -0,0 +1,20 @@ +--TEST-- +GC 015: Object as root of cycle +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = new stdClass(); +$c =& $a; +$b = $a; +$a->a = $a; +$a->b = "xxx"; +unset($c); +unset($a); +unset($b); +var_dump(gc_collect_cycles()); +echo "ok\n"; +?> +--EXPECT-- +int(2) +ok diff --git a/Zend/tests/gc_016.phpt b/Zend/tests/gc_016.phpt new file mode 100644 index 0000000..f1e14da --- /dev/null +++ b/Zend/tests/gc_016.phpt @@ -0,0 +1,26 @@ +--TEST-- +GC 016: nested GC calls +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +class Foo { + public $a; + function __destruct() { + echo "-> "; + $a = array(); + $a[] =& $a; + unset($a); + var_dump(gc_collect_cycles()); + } +} +$a = new Foo(); +$a->a = $a; +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +-> int(1) +int(1) +ok diff --git a/Zend/tests/gc_017.phpt b/Zend/tests/gc_017.phpt new file mode 100644 index 0000000..50be610 --- /dev/null +++ b/Zend/tests/gc_017.phpt @@ -0,0 +1,43 @@ +--TEST-- +GC 017: GC and destructors with unset +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +class Node { + public $name; + public $children; + public $parent; + function __construct($name) { + $this->name = $name; + $this->children = array(); + $this->parent = null; + } + function insert($node) { + $node->parent = $this; + $this->children[] = $node; + } + function __destruct() { + var_dump($this->name); + unset($this->name); + unset($this->children); + unset($this->parent); + } +} +$a = new Node('A'); +$b = new Node('B'); +$c = new Node('C'); +$a->insert($b); +$a->insert($c); +unset($a); +unset($b); +unset($c); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECTF-- +string(1) "%s" +string(1) "%s" +string(1) "%s" +int(10) +ok diff --git a/Zend/tests/gc_018.phpt b/Zend/tests/gc_018.phpt new file mode 100644 index 0000000..ef797ae --- /dev/null +++ b/Zend/tests/gc_018.phpt @@ -0,0 +1,15 @@ +--TEST-- +GC 018: GC detach with assign +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(array()); +$a[0][0] =& $a[0]; +$a = 1; +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +int(1) +ok diff --git a/Zend/tests/gc_019.phpt b/Zend/tests/gc_019.phpt new file mode 100644 index 0000000..17d0f73 --- /dev/null +++ b/Zend/tests/gc_019.phpt @@ -0,0 +1,16 @@ +--TEST-- +GC 019: GC detach with assign by reference +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(array()); +$a[0][0] =& $a[0]; +$b = 1; +$a =& $b; +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +int(1) +ok diff --git a/Zend/tests/gc_020.phpt b/Zend/tests/gc_020.phpt new file mode 100644 index 0000000..8f22e1b --- /dev/null +++ b/Zend/tests/gc_020.phpt @@ -0,0 +1,17 @@ +--TEST-- +GC 020: GC detach reference with assign +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(); +$a[0] =& $a; +$a[1] = array(); +$a[1][0] =& $a[1]; +$a = 1; +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +int(1) +ok diff --git a/Zend/tests/gc_021.phpt b/Zend/tests/gc_021.phpt new file mode 100644 index 0000000..3db702a --- /dev/null +++ b/Zend/tests/gc_021.phpt @@ -0,0 +1,18 @@ +--TEST-- +GC 021: GC detach reference with assign by reference +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(); +$a[0] =& $a; +$a[1] = array(); +$a[1][0] =& $a[1]; +$b = 1; +$a =& $b; +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +int(2) +ok diff --git a/Zend/tests/gc_022.phpt b/Zend/tests/gc_022.phpt new file mode 100644 index 0000000..cb9e50a --- /dev/null +++ b/Zend/tests/gc_022.phpt @@ -0,0 +1,16 @@ +--TEST-- +GC 022: GC detach reference in executor's PZVAL_UNLOCK() +--INI-- +error_reporting=0 +zend.enable_gc=1 +--FILE-- +<?php +$a = array(array()); +$a[0][0] =& $a[0]; +$s = array(1) + unserialize(serialize($a[0])); +var_dump(gc_collect_cycles()); +echo "ok\n" +?> +--EXPECT-- +int(1) +ok diff --git a/Zend/tests/gc_023.phpt b/Zend/tests/gc_023.phpt new file mode 100644 index 0000000..6d6e1e6 --- /dev/null +++ b/Zend/tests/gc_023.phpt @@ -0,0 +1,29 @@ +--TEST-- +GC 023: Root buffer overflow (automatic collection) +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a=array(); +for ($i=0; $i < 9999; $i++) { + $a[$i] = array(array()); + $a[$i][0] = & $a[$i]; +} +var_dump(gc_collect_cycles()); +unset($a); +var_dump(gc_collect_cycles()); +$a=array(); +for ($i=0; $i < 10001; $i++) { + $a[$i] = array(array()); + $a[$i][0] = & $a[$i]; +} +var_dump(gc_collect_cycles()); +unset($a); // 10000 zvals collected automatic +var_dump(gc_collect_cycles()); +echo "ok\n"; +--EXPECT-- +int(0) +int(9999) +int(0) +int(1) +ok diff --git a/Zend/tests/gc_024.phpt b/Zend/tests/gc_024.phpt new file mode 100644 index 0000000..9a2ceb8 --- /dev/null +++ b/Zend/tests/gc_024.phpt @@ -0,0 +1,17 @@ +--TEST-- +GC 024: GC and objects with non-standard handlers +--INI-- +zend.enable_gc=1 +--SKIPIF-- +<?php if (!extension_loaded("spl")) print "skip SPL extension required"; ?> +--FILE-- +<?php +$a = new ArrayObject(); +$a[0] = $a; +unset($a); +var_dump(gc_collect_cycles()); +echo "ok\n"; +?> +--EXPECT-- +int(1) +ok diff --git a/Zend/tests/gc_025.phpt b/Zend/tests/gc_025.phpt new file mode 100644 index 0000000..f838ed3 --- /dev/null +++ b/Zend/tests/gc_025.phpt @@ -0,0 +1,13 @@ +--TEST-- +GC 025: Automatic GC on request shutdown +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +$a = array(array()); +$a[0][0] =& $a[0]; +unset($a); +echo "ok\n" +?> +--EXPECT-- +ok diff --git a/Zend/tests/gc_026.phpt b/Zend/tests/gc_026.phpt new file mode 100644 index 0000000..330c4fa --- /dev/null +++ b/Zend/tests/gc_026.phpt @@ -0,0 +1,14 @@ +--TEST-- +GC 026: Automatic GC on request shutdown (GC enabled at run-time) +--INI-- +zend.enable_gc=0 +--FILE-- +<?php +gc_enable(); +$a = array(array()); +$a[0][0] =& $a[0]; +unset($a); +echo "ok\n" +?> +--EXPECT-- +ok diff --git a/Zend/tests/gc_027.phpt b/Zend/tests/gc_027.phpt new file mode 100644 index 0000000..d499cc3 --- /dev/null +++ b/Zend/tests/gc_027.phpt @@ -0,0 +1,14 @@ +--TEST-- +GC 027: GC and properties of internal classes +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +try { + throw new Exception(); +} catch (Exception $e) { + gc_collect_cycles(); +} +echo "ok\n"; +--EXPECT-- +ok diff --git a/Zend/tests/gc_028.phpt b/Zend/tests/gc_028.phpt new file mode 100644 index 0000000..8dc70fc --- /dev/null +++ b/Zend/tests/gc_028.phpt @@ -0,0 +1,33 @@ +--TEST-- +GC 028: GC and destructors +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +class Foo { + public $bar; + function __destruct() { + if ($this->bar !== null) { + unset($this->bar); + } + } +} +class Bar { + public $foo; + function __destruct() { + if ($this->foo !== null) { + unset($this->foo); + } + } + +} +$foo = new Foo(); +$bar = new Bar(); +$foo->bar = $bar; +$bar->foo = $foo; +unset($foo); +unset($bar); +var_dump(gc_collect_cycles()); +?> +--EXPECT-- +int(2) diff --git a/Zend/tests/gc_029.phpt b/Zend/tests/gc_029.phpt new file mode 100644 index 0000000..edd2317 --- /dev/null +++ b/Zend/tests/gc_029.phpt @@ -0,0 +1,37 @@ +--TEST-- +GC 029: GC and destructors +--SKIPIF-- +<?php if (PHP_ZTS) { print "skip only for no-zts build"; } +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +class Foo { + public $bar; + public $x = array(1,2,3); + function __destruct() { + if ($this->bar !== null) { + $this->x = null; + unset($this->bar); + } + } +} +class Bar { + public $foo; + function __destruct() { + if ($this->foo !== null) { + unset($this->foo); + } + } + +} +$foo = new Foo(); +$bar = new Bar(); +$foo->bar = $bar; +$bar->foo = $foo; +unset($foo); +unset($bar); +var_dump(gc_collect_cycles()); +?> +--EXPECT-- +int(2) diff --git a/Zend/tests/gc_029_zts.phpt b/Zend/tests/gc_029_zts.phpt new file mode 100644 index 0000000..fc77e1f --- /dev/null +++ b/Zend/tests/gc_029_zts.phpt @@ -0,0 +1,37 @@ +--TEST-- +GC 029: GC and destructors +--SKIPIF-- +<?php if (!PHP_ZTS) { print "skip only for zts build"; } +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +class Foo { + public $bar; + public $x = array(1,2,3); + function __destruct() { + if ($this->bar !== null) { + $this->x = null; + unset($this->bar); + } + } +} +class Bar { + public $foo; + function __destruct() { + if ($this->foo !== null) { + unset($this->foo); + } + } + +} +$foo = new Foo(); +$bar = new Bar(); +$foo->bar = $bar; +$bar->foo = $foo; +unset($foo); +unset($bar); +var_dump(gc_collect_cycles()); +?> +--EXPECT-- +int(3) diff --git a/Zend/tests/gc_030.phpt b/Zend/tests/gc_030.phpt new file mode 100644 index 0000000..ef044e0 --- /dev/null +++ b/Zend/tests/gc_030.phpt @@ -0,0 +1,33 @@ +--TEST-- +GC 030: GC and exceptions in destructors +--INI-- +zend.enable_gc=1 +--FILE-- +<?php +class foo { + public $foo; + + public function __destruct() { + throw new Exception("foobar"); + } +} + +$f1 = new foo; +$f2 = new foo; +$f1->foo = $f2; +$f2->foo = $f1; +unset($f1, $f2); +gc_collect_cycles(); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'foobar' in %sgc_030.php:%d +Stack trace: +#0 [internal function]: foo->__destruct() +#1 %sgc_030.php(%d): gc_collect_cycles() +#2 {main} + +Next exception 'Exception' with message 'foobar' in %sgc_030.php:%d +Stack trace: +#0 %sgc_030.php(%d): foo->__destruct() +#1 {main} + thrown in %sgc_030.php on line %d diff --git a/Zend/tests/gc_031.phpt b/Zend/tests/gc_031.phpt new file mode 100644 index 0000000..58c4b15 --- /dev/null +++ b/Zend/tests/gc_031.phpt @@ -0,0 +1,11 @@ +--TEST-- +GC 031: gc_collect_roots() with GC turned off. +--INI-- +zend.enable_gc=0 +--FILE-- +<?php +gc_collect_cycles(); +echo "DONE\n"; +?> +--EXPECTF-- +DONE diff --git a/Zend/tests/gc_032.phpt b/Zend/tests/gc_032.phpt new file mode 100644 index 0000000..615b008 --- /dev/null +++ b/Zend/tests/gc_032.phpt @@ -0,0 +1,40 @@ +--TEST-- +GC 032: Crash in GC because of invalid reference counting +--FILE-- +<?php +$a = array(); +$b =& $a; +$a[0] = $a; +debug_zval_dump($a); +$a = array(array()); +$b =& $a; +$a[0][0] = $a; +debug_zval_dump($a); +?> +--EXPECT-- +array(1) refcount(1){ + [0]=> + array(1) refcount(3){ + [0]=> + array(1) refcount(3){ + [0]=> + *RECURSION* + } + } +} +array(1) refcount(1){ + [0]=> + array(1) refcount(3){ + [0]=> + array(1) refcount(1){ + [0]=> + array(1) refcount(3){ + [0]=> + array(1) refcount(1){ + [0]=> + *RECURSION* + } + } + } + } +} diff --git a/Zend/tests/get_called_class_001.phpt b/Zend/tests/get_called_class_001.phpt new file mode 100644 index 0000000..7012ae8 --- /dev/null +++ b/Zend/tests/get_called_class_001.phpt @@ -0,0 +1,11 @@ +--TEST-- +Calling get_called_class() outside a class +--FILE-- +<?php + +var_dump(get_called_class()); + +?> +--EXPECTF-- +Warning: get_called_class() called from outside a class in %s on line %d +bool(false) diff --git a/Zend/tests/get_class_methods_001.phpt b/Zend/tests/get_class_methods_001.phpt new file mode 100644 index 0000000..277ea2c --- /dev/null +++ b/Zend/tests/get_class_methods_001.phpt @@ -0,0 +1,55 @@ +--TEST-- +get_class_methods(): Testing scope +--FILE-- +<?php + +abstract class A { + public function a() { } + private function b() { } + protected function c() { } +} + +class B extends A { + private function bb() { } + + static public function test() { + var_dump(get_class_methods('A')); + var_dump(get_class_methods('B')); + } +} + + +var_dump(get_class_methods('A')); +var_dump(get_class_methods('B')); + + +B::test(); + +?> +--EXPECT-- +array(1) { + [0]=> + string(1) "a" +} +array(2) { + [0]=> + string(4) "test" + [1]=> + string(1) "a" +} +array(2) { + [0]=> + string(1) "a" + [1]=> + string(1) "c" +} +array(4) { + [0]=> + string(2) "bb" + [1]=> + string(4) "test" + [2]=> + string(1) "a" + [3]=> + string(1) "c" +} diff --git a/Zend/tests/get_class_methods_002.phpt b/Zend/tests/get_class_methods_002.phpt new file mode 100644 index 0000000..27da6e8 --- /dev/null +++ b/Zend/tests/get_class_methods_002.phpt @@ -0,0 +1,43 @@ +--TEST-- +get_class_methods(): Testing with interface +--FILE-- +<?php + +interface A { + function a(); + function b(); +} + +class B implements A { + public function a() { } + public function b() { } + + public function __construct() { + var_dump(get_class_methods('A')); + var_dump(get_class_methods('B')); + } + + public function __destruct() { } +} + +new B; + +?> +--EXPECTF-- +Strict Standards: Redefining already defined constructor for class B in %s on line %d +array(2) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" +} +array(4) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(11) "__construct" + [3]=> + string(10) "__destruct" +} diff --git a/Zend/tests/get_class_methods_003.phpt b/Zend/tests/get_class_methods_003.phpt new file mode 100644 index 0000000..bbb7586 --- /dev/null +++ b/Zend/tests/get_class_methods_003.phpt @@ -0,0 +1,78 @@ +--TEST-- +get_class_methods(): Testing scope +--FILE-- +<?php + +interface A { + function aa(); + function bb(); + static function cc(); +} + +class C { + public function a() { } + protected function b() { } + private function c() { } + + static public function static_a() { } + static protected function static_b() { } + static private function static_c() { } +} + +class B extends C implements A { + public function aa() { } + public function bb() { } + + static function cc() { } + + public function __construct() { + var_dump(get_class_methods('A')); + var_dump(get_class_methods('B')); + var_dump(get_class_methods('C')); + } + + public function __destruct() { } +} + +new B; + +?> +--EXPECT-- +array(3) { + [0]=> + string(2) "aa" + [1]=> + string(2) "bb" + [2]=> + string(2) "cc" +} +array(9) { + [0]=> + string(2) "aa" + [1]=> + string(2) "bb" + [2]=> + string(2) "cc" + [3]=> + string(11) "__construct" + [4]=> + string(10) "__destruct" + [5]=> + string(1) "a" + [6]=> + string(1) "b" + [7]=> + string(8) "static_a" + [8]=> + string(8) "static_b" +} +array(4) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(8) "static_a" + [3]=> + string(8) "static_b" +} diff --git a/Zend/tests/get_class_vars_001.phpt b/Zend/tests/get_class_vars_001.phpt new file mode 100644 index 0000000..ada0be6 --- /dev/null +++ b/Zend/tests/get_class_vars_001.phpt @@ -0,0 +1,33 @@ +--TEST-- +get_class_vars(): Simple test +--FILE-- +<?php + +class A { + public $a = 1; + private $b = 2; + private $c = 3; +} + +class B extends A { + static public $aa = 4; + static private $bb = 5; + static protected $cc = 6; +} + + +var_dump(get_class_vars('A')); +var_dump(get_class_vars('B')); + +?> +--EXPECT-- +array(1) { + ["a"]=> + int(1) +} +array(2) { + ["a"]=> + int(1) + ["aa"]=> + int(4) +} diff --git a/Zend/tests/get_class_vars_002.phpt b/Zend/tests/get_class_vars_002.phpt new file mode 100644 index 0000000..721ebe6 --- /dev/null +++ b/Zend/tests/get_class_vars_002.phpt @@ -0,0 +1,49 @@ +--TEST-- +get_class_vars(): Testing the scope +--FILE-- +<?php + +class A { + public $a = 1; + private $b = 2; + private $c = 3; +} + +class B extends A { + static public $aa = 4; + static private $bb = 5; + static protected $cc = 6; +} + +class C extends B { + public function __construct() { + var_dump(get_class_vars('A')); + var_dump(get_class_vars('B')); + + var_dump($this->a, $this->b, $this->c); + } +} + +new C; + +?> +--EXPECTF-- +array(1) { + ["a"]=> + int(1) +} +array(3) { + ["a"]=> + int(1) + ["aa"]=> + int(4) + ["cc"]=> + int(6) +} + +Notice: Undefined property: C::$b in %s on line %d + +Notice: Undefined property: C::$c in %s on line %d +int(1) +NULL +NULL diff --git a/Zend/tests/get_class_vars_003.phpt b/Zend/tests/get_class_vars_003.phpt new file mode 100644 index 0000000..d2c82bb --- /dev/null +++ b/Zend/tests/get_class_vars_003.phpt @@ -0,0 +1,49 @@ +--TEST-- +get_class_vars(): Testing the scope +--FILE-- +<?php + +class A { + public $a = 1; + private $b = 2; + private $c = 3; +} + +class B extends A { + static public $aa = 4; + static private $bb = 5; + static protected $cc = 6; + + protected function __construct() { + var_dump(get_class_vars('C')); + } +} + +class C extends B { + public $aaa = 7; + private $bbb = 8; + protected $ccc = 9; + + public function __construct() { + parent::__construct(); + } +} + +new C; + +?> +--EXPECT-- +array(6) { + ["aaa"]=> + int(7) + ["ccc"]=> + int(9) + ["a"]=> + int(1) + ["aa"]=> + int(4) + ["bb"]=> + int(5) + ["cc"]=> + int(6) +} diff --git a/Zend/tests/get_class_vars_004.phpt b/Zend/tests/get_class_vars_004.phpt new file mode 100644 index 0000000..26cd461 --- /dev/null +++ b/Zend/tests/get_class_vars_004.phpt @@ -0,0 +1,67 @@ +--TEST-- +get_class_vars(): Testing the scope +--FILE-- +<?php + +class A { + public $a = 1; + static public $A = 2; + + private $b = 3; + static private $B = 4; + + protected $c = 5; + static protected $C = 6; + + public function __construct() { + var_dump(get_class_vars('A')); + } + + static public function test() { + var_dump(get_class_vars('A')); + } +} + +var_dump(get_class_vars('A')); + +new A; + +var_dump(A::test()); + +?> +--EXPECT-- +array(2) { + ["a"]=> + int(1) + ["A"]=> + int(2) +} +array(6) { + ["a"]=> + int(1) + ["b"]=> + int(3) + ["c"]=> + int(5) + ["A"]=> + int(2) + ["B"]=> + int(4) + ["C"]=> + int(6) +} +array(6) { + ["a"]=> + int(1) + ["b"]=> + int(3) + ["c"]=> + int(5) + ["A"]=> + int(2) + ["B"]=> + int(4) + ["C"]=> + int(6) +} +NULL diff --git a/Zend/tests/get_class_vars_005.phpt b/Zend/tests/get_class_vars_005.phpt new file mode 100644 index 0000000..51f5490 --- /dev/null +++ b/Zend/tests/get_class_vars_005.phpt @@ -0,0 +1,39 @@ +--TEST-- +get_class_vars(): Testing visibility +--FILE-- +<?php + +class A { + protected $a = 1; + private $b = 2; +} + +class B extends A { + private $c = 3; + public function __construct() { + var_dump(get_class_vars('A')); + var_dump(get_class_vars('B')); + } +} + +var_dump(get_class_vars('A')); +var_dump(get_class_vars('B')); + +new B; + +?> +--EXPECT-- +array(0) { +} +array(0) { +} +array(1) { + ["a"]=> + int(1) +} +array(2) { + ["c"]=> + int(3) + ["a"]=> + int(1) +} diff --git a/Zend/tests/get_class_vars_006.phpt b/Zend/tests/get_class_vars_006.phpt new file mode 100644 index 0000000..d1c2844 --- /dev/null +++ b/Zend/tests/get_class_vars_006.phpt @@ -0,0 +1,50 @@ +--TEST-- +get_class_vars(): Testing visibility +--FILE-- +<?php + +class A { + protected $a = 1; +} + +class B extends A { } + +class C extends B { } + +var_dump(get_class_vars('A')); +var_dump(get_class_vars('B')); +var_dump(get_class_vars('C')); + +print "---\n"; + +class D extends B { + public function __construct() { + var_dump(get_class_vars('A')); + var_dump(get_class_vars('B')); + var_dump(get_class_vars('C')); + } +} + +new D; + +?> +--EXPECT-- +array(0) { +} +array(0) { +} +array(0) { +} +--- +array(1) { + ["a"]=> + int(1) +} +array(1) { + ["a"]=> + int(1) +} +array(1) { + ["a"]=> + int(1) +} diff --git a/Zend/tests/get_class_vars_007.phpt b/Zend/tests/get_class_vars_007.phpt new file mode 100644 index 0000000..6aea0e2 --- /dev/null +++ b/Zend/tests/get_class_vars_007.phpt @@ -0,0 +1,41 @@ +--TEST-- +get_class_vars(): Testing with static properties +--FILE-- +<?php + +class A { + static public $a, $aa; + static private $b, $bb; + static protected $c, $cc; + + static public function test() { + var_dump(get_class_vars(__CLASS__)); + } +} + +var_dump(get_class_vars('A')); +var_dump(A::test()); + +?> +--EXPECT-- +array(2) { + ["a"]=> + NULL + ["aa"]=> + NULL +} +array(6) { + ["a"]=> + NULL + ["aa"]=> + NULL + ["b"]=> + NULL + ["bb"]=> + NULL + ["c"]=> + NULL + ["cc"]=> + NULL +} +NULL diff --git a/Zend/tests/get_defined_functions_basic.phpt b/Zend/tests/get_defined_functions_basic.phpt new file mode 100644 index 0000000..a849e32 --- /dev/null +++ b/Zend/tests/get_defined_functions_basic.phpt @@ -0,0 +1,59 @@ +--TEST-- +get_defined_functions() function : basic functionality +--FILE-- +<?php + +/* Prototype : array get_defined_functions ( void ) + * Description: Gets an array of all defined functions. + * Source code: Zend/zend_builtin_functions.c +*/ + +echo "*** Testing get_defined_functions() : basic functionality ***\n"; + +function foo() {} + +// mixed case function +function HelloWorld() {} + +Class C { + function f1() {} + static function f2() {} +} + +$func = get_defined_functions(); + +if (!is_array($func)) { + echo "TEST FAILED: return type not an array\n"; +} + + +if (!is_array($func["internal"])) { + echo "TEST FAILED: no element in result array with key 'internal'\n"; +} + +$internal = $func["internal"]; + +//check for a few core functions +if (!in_array("cos", $internal) || !in_array("strlen", $internal)) { + echo "TEST FAILED: missing elements from 'internal' array\n"; + var_dump($internal); +} + +if (!is_array($func["user"])) { + echo "TEST FAILED: no element in result array with key 'user'\n"; +} + +$user = $func["user"]; +if (count($user) == 2 && in_array("foo", $user) && in_array("helloworld", $user)) { + echo "TEST PASSED\n"; +} else { + echo "TEST FAILED: missing elements from 'user' array\n"; + var_dump($user); +} + +?> +===Done=== +--EXPECT-- +*** Testing get_defined_functions() : basic functionality *** +TEST PASSED +===Done=== diff --git a/Zend/tests/get_defined_functions_error.phpt b/Zend/tests/get_defined_functions_error.phpt new file mode 100644 index 0000000..fcb01e0 --- /dev/null +++ b/Zend/tests/get_defined_functions_error.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test get_defined_functions() function : error conditions +--FILE-- +<?php + +/* Prototype : array get_defined_functions ( void ) + * Description: Gets an array of all defined functions. + * Source code: Zend/zend_builtin_functions.c +*/ + + +echo "*** Testing get_defined_functions() : error conditions ***\n"; + + +echo "\n-- Testing get_defined_functions() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( get_defined_functions($extra_arg) ); + +?> +===Done=== +--EXPECTF-- +*** Testing get_defined_functions() : error conditions *** + +-- Testing get_defined_functions() function with more than expected no. of arguments -- + +Warning: get_defined_functions() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +===Done=== diff --git a/Zend/tests/get_defined_vars.phpt b/Zend/tests/get_defined_vars.phpt new file mode 100644 index 0000000..81aa97a --- /dev/null +++ b/Zend/tests/get_defined_vars.phpt @@ -0,0 +1,128 @@ +--TEST-- +Testing get_defined_vars() Function +--FILE-- +<?php +/* Prototype: array get_defined_vars(void); + * Description: Returns a multidimentional array of all defined variables. + */ + +/* Various variables definitions used for testing of the function */ + +$number = 22.33; //number +$string = "sample string"; //string +$array1 = array(1, 1, 2, 3, 5, 8); //simple array +$assoc_array = array( 'a'=>97, 'c'=>99, 'A'=>65, 'C'=>67, 1=>"string1" ); //associative array +$boolean = TRUE; //boolean + +/* Checking for Class and Objects */ +class sample { +var $number = 233; +var $string = "string2"; +public function func() { +$local_var = 2; +var_dump( get_defined_vars() ); +} +} +$sample_obj = new sample; //object declaration + +function func() { +$string33 = 22; +var_dump( get_defined_vars() ); +} + +$arr = get_defined_vars(); + +/* Displaying various variable through the array captured by the get_defined_vars function call */ +echo "\n*** Displaying various variables through the array captured by the get_defined_vars function call ***\n"; +var_dump( $arr["argc"] ); +var_dump( $arr["number"] ); +var_dump( $arr["string"] ); +var_dump( $arr["array1"] ); +var_dump( $arr["assoc_array"] ); +var_dump( $arr["boolean"] ); +var_dump( $arr["sample_obj"] ); + + +echo "\n*** Checking for output when get_defined_vars called in local function ***\n"; +func(); + + +echo "\n*** Checking for output when get_defined_vars called in function of a class ***\n"; +$sample_obj->func(); + +echo "\n*** Checking for output when get_defined_vars called in nested functions ***\n"; +function func1(){ +$func1_var = 2; +var_dump( get_defined_vars() ); +function func2(){ +$func2_var = 3; +var_dump( get_defined_vars() ); +} +func2(); +} +func1(); + +echo "\nDone"; +?> +--EXPECTF-- +*** Displaying various variables through the array captured by the get_defined_vars function call *** +int(1) +float(22.33) +string(13) "sample string" +array(6) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(5) + [5]=> + int(8) +} +array(5) { + ["a"]=> + int(97) + ["c"]=> + int(99) + ["A"]=> + int(65) + ["C"]=> + int(67) + [1]=> + string(7) "string1" +} +bool(true) +object(sample)#1 (2) { + ["number"]=> + int(233) + ["string"]=> + string(7) "string2" +} + +*** Checking for output when get_defined_vars called in local function *** +array(1) { + ["string33"]=> + int(22) +} + +*** Checking for output when get_defined_vars called in function of a class *** +array(1) { + ["local_var"]=> + int(2) +} + +*** Checking for output when get_defined_vars called in nested functions *** +array(1) { + ["func1_var"]=> + int(2) +} +array(1) { + ["func2_var"]=> + int(3) +} + +Done diff --git a/Zend/tests/get_parent_class_001.phpt b/Zend/tests/get_parent_class_001.phpt new file mode 100644 index 0000000..dfef5e0 --- /dev/null +++ b/Zend/tests/get_parent_class_001.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing get_parent_class() +--FILE-- +<?php + +interface ITest { + function foo(); +} + +abstract class bar implements ITest { + public function foo() { + var_dump(get_parent_class()); + } +} + +class foo extends bar { + public function __construct() { + var_dump(get_parent_class()); + } +} + +$a = new foo; +$a->foo(); + +?> +--EXPECT-- +string(3) "bar" +bool(false) diff --git a/Zend/tests/get_required_files.phpt b/Zend/tests/get_required_files.phpt new file mode 100644 index 0000000..c2ba368 --- /dev/null +++ b/Zend/tests/get_required_files.phpt @@ -0,0 +1,16 @@ +--TEST-- +Check if get_required_files works +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +$files = get_required_files(); +var_dump($files); +?> +--EXPECTF-- +array(1) { + [0]=> + %string|unicode%(%d)%s +} diff --git a/Zend/tests/globals.inc b/Zend/tests/globals.inc new file mode 100644 index 0000000..976237c --- /dev/null +++ b/Zend/tests/globals.inc @@ -0,0 +1,15 @@ +<?php + +var_dump(isset($_SERVER)); +var_dump(empty($_SERVER)); +var_dump(gettype($_SERVER)); +var_dump(count($_SERVER)); + +var_dump($_SERVER['PHP_SELF']); +unset($_SERVER['PHP_SELF']); +var_dump($_SERVER['PHP_SELF']); + +unset($_SERVER); +var_dump($_SERVER); + +?> diff --git a/Zend/tests/globals_001.phpt b/Zend/tests/globals_001.phpt new file mode 100644 index 0000000..8efa71d --- /dev/null +++ b/Zend/tests/globals_001.phpt @@ -0,0 +1,34 @@ +--TEST-- +globals in global scope +--INI-- +variables_order="egpcs" +--FILE-- +<?php + +var_dump(isset($_SERVER)); +var_dump(empty($_SERVER)); +var_dump(gettype($_SERVER)); +var_dump(count($_SERVER)); + +var_dump($_SERVER['PHP_SELF']); +unset($_SERVER['PHP_SELF']); +var_dump($_SERVER['PHP_SELF']); + +unset($_SERVER); +var_dump($_SERVER); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +string(5) "array" +int(%d) +string(%d) "%s" + +Notice: Undefined index: PHP_SELF in %s on line %d +NULL + +Notice: Undefined variable: _SERVER in %s on line %d +NULL +Done diff --git a/Zend/tests/globals_002.phpt b/Zend/tests/globals_002.phpt new file mode 100644 index 0000000..e5d518a --- /dev/null +++ b/Zend/tests/globals_002.phpt @@ -0,0 +1,37 @@ +--TEST-- +globals in local scope +--INI-- +variables_order="egpcs" +--FILE-- +<?php +function test() { + var_dump(isset($_SERVER)); + var_dump(empty($_SERVER)); + var_dump(gettype($_SERVER)); + var_dump(count($_SERVER)); + + var_dump($_SERVER['PHP_SELF']); + unset($_SERVER['PHP_SELF']); + var_dump($_SERVER['PHP_SELF']); + + unset($_SERVER); + var_dump($_SERVER); +} + +test(); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +string(5) "array" +int(%d) +string(%d) "%s" + +Notice: Undefined index: PHP_SELF in %s on line %d +NULL + +Notice: Undefined variable: _SERVER in %s on line %d +NULL +Done diff --git a/Zend/tests/globals_003.phpt b/Zend/tests/globals_003.phpt new file mode 100644 index 0000000..6de7c53 --- /dev/null +++ b/Zend/tests/globals_003.phpt @@ -0,0 +1,43 @@ +--TEST-- +globals in local scope - 2 +--INI-- +variables_order="egpcs" +--FILE-- +<?php + +class test { + + static function bar() { + + var_dump(isset($_SERVER)); + var_dump(empty($_SERVER)); + var_dump(gettype($_SERVER)); + var_dump(count($_SERVER)); + + var_dump($_SERVER['PHP_SELF']); + unset($_SERVER['PHP_SELF']); + var_dump($_SERVER['PHP_SELF']); + + unset($_SERVER); + var_dump($_SERVER); + + } +} + +test::bar(); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +string(5) "array" +int(%d) +string(%d) "%s" + +Notice: Undefined index: PHP_SELF in %s on line %d +NULL + +Notice: Undefined variable: _SERVER in %s on line %d +NULL +Done diff --git a/Zend/tests/globals_004.phpt b/Zend/tests/globals_004.phpt new file mode 100644 index 0000000..07dfc78 --- /dev/null +++ b/Zend/tests/globals_004.phpt @@ -0,0 +1,28 @@ +--TEST-- +globals in local scope - 3 +--INI-- +variables_order="egpcs" +--FILE-- +<?php + +function test() { + include dirname(__FILE__)."/globals.inc"; +} + +test(); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +string(5) "array" +int(%d) +string(%d) "%s" + +Notice: Undefined index: PHP_SELF in %s on line %d +NULL + +Notice: Undefined variable: _SERVER in %s on line %d +NULL +Done diff --git a/Zend/tests/halt01.phpt b/Zend/tests/halt01.phpt new file mode 100644 index 0000000..3af80d0 --- /dev/null +++ b/Zend/tests/halt01.phpt @@ -0,0 +1,12 @@ +--TEST-- +__HALT_COMPILER() basic test +--FILE-- +<?php + +print "yo!\n"; + +__HALT_COMPILER(); + +none of this should be displayed! +--EXPECT-- +yo! diff --git a/Zend/tests/halt02.phpt b/Zend/tests/halt02.phpt new file mode 100644 index 0000000..caaa474 --- /dev/null +++ b/Zend/tests/halt02.phpt @@ -0,0 +1,13 @@ +--TEST-- +__HALT_COMPILER() basic test +--FILE-- +<?php + +$fp = fopen(__FILE__, "r"); +fseek($fp, __COMPILER_HALT_OFFSET__+1); +print fread($fp, 1000); + +__HALT_COMPILER(); +Overlay information... +--EXPECT-- +Overlay information... diff --git a/Zend/tests/halt03.phpt b/Zend/tests/halt03.phpt new file mode 100644 index 0000000..6e0931b --- /dev/null +++ b/Zend/tests/halt03.phpt @@ -0,0 +1,10 @@ +--TEST-- +__HALT_COMPILER() basic test +--FILE-- +<?php + +if (true) { + __HALT_COMPILER(); +} +--EXPECTF-- +Fatal error: __HALT_COMPILER() can only be used from the outermost scope in %shalt03.php on line %d diff --git a/Zend/tests/halt_compiler1.phpt b/Zend/tests/halt_compiler1.phpt new file mode 100644 index 0000000..4987b29 --- /dev/null +++ b/Zend/tests/halt_compiler1.phpt @@ -0,0 +1,8 @@ +--TEST-- +__HALT_COMPILER(); +--FILE-- +<?php echo 'test'; var_dump(__COMPILER_HALT_OFFSET__); __HALT_COMPILER(); +?> +===DONE=== +--EXPECT-- +testint(73)
\ No newline at end of file diff --git a/Zend/tests/halt_compiler2.phpt b/Zend/tests/halt_compiler2.phpt new file mode 100644 index 0000000..0ced214 --- /dev/null +++ b/Zend/tests/halt_compiler2.phpt @@ -0,0 +1,23 @@ +--TEST-- +__HALT_COMPILER(); 2 files +--FILE-- +<?php +$text = "<?php echo 'test'; var_dump(__COMPILER_HALT_OFFSET__); __HALT_COMPILER(); ?> +hi there"; +file_put_contents(dirname(__FILE__) . '/test1.php', $text); +$text = "<?php echo 'test2'; var_dump(__COMPILER_HALT_OFFSET__); __HALT_COMPILER(); ?> +hi there 2"; +file_put_contents(dirname(__FILE__) . '/test2.php', $text); +include dirname(__FILE__) . '/test1.php'; +include dirname(__FILE__) . '/test2.php'; +?> +==DONE== +--CLEAN-- +<?php +unlink(dirname(__FILE__) . '/test1.php'); +unlink(dirname(__FILE__) . '/test2.php'); +?> +--EXPECT-- +testint(73) +test2int(74) +==DONE==
\ No newline at end of file diff --git a/Zend/tests/halt_compiler3.phpt b/Zend/tests/halt_compiler3.phpt new file mode 100644 index 0000000..6ee16f7 --- /dev/null +++ b/Zend/tests/halt_compiler3.phpt @@ -0,0 +1,10 @@ +--TEST-- +__HALT_COMPILER(); bad define() of __COMPILER_HALT_OFFSET__ 1 +--FILE-- +<?php +define ('__COMPILER_HALT_OFFSET__', 1); +?> +==DONE== +--EXPECTF-- +Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d +==DONE==
\ No newline at end of file diff --git a/Zend/tests/halt_compiler4.phpt b/Zend/tests/halt_compiler4.phpt new file mode 100644 index 0000000..43e532c --- /dev/null +++ b/Zend/tests/halt_compiler4.phpt @@ -0,0 +1,10 @@ +--TEST-- +__HALT_COMPILER(); bad define() of __COMPILER_HALT_OFFSET__ 2 +--FILE-- +<?php +define ('__COMPILER_HALT_OFFSET__', 1); +__HALT_COMPILER(); +?> +==DONE== +--EXPECTF-- +Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/heredoc_001.phpt b/Zend/tests/heredoc_001.phpt new file mode 100644 index 0000000..d42b3df --- /dev/null +++ b/Zend/tests/heredoc_001.phpt @@ -0,0 +1,23 @@ +--TEST-- +basic heredoc syntax +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<ENDOFHEREDOC +This is a heredoc test. + +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +This is another heredoc test. + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is a heredoc test. +This is another heredoc test. diff --git a/Zend/tests/heredoc_002.phpt b/Zend/tests/heredoc_002.phpt new file mode 100644 index 0000000..481ada9 --- /dev/null +++ b/Zend/tests/heredoc_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +basic binary heredoc syntax +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print b<<<ENDOFHEREDOC +This is a heredoc test. + +ENDOFHEREDOC; + +$x = b<<<ENDOFHEREDOC +This is another heredoc test. + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is a heredoc test. +This is another heredoc test. diff --git a/Zend/tests/heredoc_003.phpt b/Zend/tests/heredoc_003.phpt new file mode 100644 index 0000000..fb34f51 --- /dev/null +++ b/Zend/tests/heredoc_003.phpt @@ -0,0 +1,23 @@ +--TEST-- +simple variable replacement test (heredoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<ENDOFHEREDOC +This is heredoc test #$a. + +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +This is heredoc test #$b. + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is heredoc test #1. +This is heredoc test #2. diff --git a/Zend/tests/heredoc_004.phpt b/Zend/tests/heredoc_004.phpt new file mode 100644 index 0000000..29334b8 --- /dev/null +++ b/Zend/tests/heredoc_004.phpt @@ -0,0 +1,23 @@ +--TEST-- +braces variable replacement test (heredoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<ENDOFHEREDOC +This is heredoc test #{$a}. + +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +This is heredoc test #{$b}. + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is heredoc test #1. +This is heredoc test #2. diff --git a/Zend/tests/heredoc_005.phpt b/Zend/tests/heredoc_005.phpt new file mode 100644 index 0000000..01a046f --- /dev/null +++ b/Zend/tests/heredoc_005.phpt @@ -0,0 +1,22 @@ +--TEST-- +unbraced complex variable replacement test (heredoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<ENDOFHEREDOC +This is heredoc test #s $a, $b, $c['c'], and $d->d. + +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +This is heredoc test #s $a, $b, $c['c'], and $d->d. + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECTF-- +Parse error: %s in %sheredoc_005.php on line 6 diff --git a/Zend/tests/heredoc_006.phpt b/Zend/tests/heredoc_006.phpt new file mode 100644 index 0000000..d40ae1e --- /dev/null +++ b/Zend/tests/heredoc_006.phpt @@ -0,0 +1,23 @@ +--TEST-- +braced complex variable replacement test (heredoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<ENDOFHEREDOC +This is heredoc test #s {$a}, {$b}, {$c['c']}, and {$d->d}. + +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +This is heredoc test #s {$a}, {$b}, {$c['c']}, and {$d->d}. + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is heredoc test #s 1, 2, 3, and 4. +This is heredoc test #s 1, 2, 3, and 4. diff --git a/Zend/tests/heredoc_007.phpt b/Zend/tests/heredoc_007.phpt new file mode 100644 index 0000000..b823b55 --- /dev/null +++ b/Zend/tests/heredoc_007.phpt @@ -0,0 +1,23 @@ +--TEST-- +braced and unbraced complex variable replacement test (heredoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<ENDOFHEREDOC +This is heredoc test #s $a, {$b}, {$c['c']}, and {$d->d}. + +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +This is heredoc test #s $a, {$b}, {$c['c']}, and {$d->d}. + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is heredoc test #s 1, 2, 3, and 4. +This is heredoc test #s 1, 2, 3, and 4. diff --git a/Zend/tests/heredoc_008.phpt b/Zend/tests/heredoc_008.phpt new file mode 100644 index 0000000..8feda03 --- /dev/null +++ b/Zend/tests/heredoc_008.phpt @@ -0,0 +1,17 @@ +--TEST-- +empty doc test (heredoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<ENDOFHEREDOC +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECT-- diff --git a/Zend/tests/heredoc_009.phpt b/Zend/tests/heredoc_009.phpt new file mode 100644 index 0000000..38f5d28 --- /dev/null +++ b/Zend/tests/heredoc_009.phpt @@ -0,0 +1,42 @@ +--TEST-- +Torture the T_END_HEREDOC rules (heredoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<ENDOFHEREDOC +ENDOFHEREDOC ; + ENDOFHEREDOC; +ENDOFHEREDOC + ENDOFHEREDOC +$ENDOFHEREDOC; + +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +ENDOFHEREDOC ; + ENDOFHEREDOC; +ENDOFHEREDOC + ENDOFHEREDOC +$ENDOFHEREDOC; + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECTF-- +Notice: Undefined variable: ENDOFHEREDOC in %s on line %d +ENDOFHEREDOC ; + ENDOFHEREDOC; +ENDOFHEREDOC + ENDOFHEREDOC +; + +Notice: Undefined variable: ENDOFHEREDOC in %s on line %d +ENDOFHEREDOC ; + ENDOFHEREDOC; +ENDOFHEREDOC + ENDOFHEREDOC +; diff --git a/Zend/tests/heredoc_010.phpt b/Zend/tests/heredoc_010.phpt new file mode 100644 index 0000000..5aa0433 --- /dev/null +++ b/Zend/tests/heredoc_010.phpt @@ -0,0 +1,32 @@ +--TEST-- +Torture the T_END_HEREDOC rules with variable expansions (heredoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; +$fooledYou = ''; + +print <<<ENDOFHEREDOC +{$fooledYou}ENDOFHEREDOC{$fooledYou} +ENDOFHEREDOC{$fooledYou} +{$fooledYou}ENDOFHEREDOC + +ENDOFHEREDOC; + +$x = <<<ENDOFHEREDOC +{$fooledYou}ENDOFHEREDOC{$fooledYou} +ENDOFHEREDOC{$fooledYou} +{$fooledYou}ENDOFHEREDOC + +ENDOFHEREDOC; + +print "{$x}"; + +?> +--EXPECT-- +ENDOFHEREDOC +ENDOFHEREDOC +ENDOFHEREDOC +ENDOFHEREDOC +ENDOFHEREDOC +ENDOFHEREDOC diff --git a/Zend/tests/heredoc_011.phpt b/Zend/tests/heredoc_011.phpt new file mode 100644 index 0000000..d3b152a --- /dev/null +++ b/Zend/tests/heredoc_011.phpt @@ -0,0 +1,20 @@ +--TEST-- +STATIC heredocs CAN be used as static scalars. +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +class e { + + const E = <<<THISMUSTNOTERROR +If you DON'T see this, something's wrong. +THISMUSTNOTERROR; + +}; + +print e::E . "\n"; + +?> +--EXPECT-- +If you DON'T see this, something's wrong. diff --git a/Zend/tests/heredoc_012.phpt b/Zend/tests/heredoc_012.phpt new file mode 100644 index 0000000..73f7483 --- /dev/null +++ b/Zend/tests/heredoc_012.phpt @@ -0,0 +1,12 @@ +--TEST-- +Heredoc with double quotes +--FILE-- +<?php +$test = "foo"; +$var = <<<"MYLABEL" +test: $test +MYLABEL; +echo $var; +?> +--EXPECT-- +test: foo diff --git a/Zend/tests/heredoc_013.phpt b/Zend/tests/heredoc_013.phpt new file mode 100644 index 0000000..1ffcf73 --- /dev/null +++ b/Zend/tests/heredoc_013.phpt @@ -0,0 +1,12 @@ +--TEST-- +Heredoc with double quotes and wrong prefix +--FILE-- +<?php +$test = "foo"; +$var = prefix<<<"MYLABEL" +test: $test +MYLABEL; +echo $var; +?> +--EXPECTF-- +Parse error: %s in %sheredoc_013.php on line %d diff --git a/Zend/tests/heredoc_014.phpt b/Zend/tests/heredoc_014.phpt new file mode 100644 index 0000000..8999aa3 --- /dev/null +++ b/Zend/tests/heredoc_014.phpt @@ -0,0 +1,12 @@ +--TEST-- +Heredoc with double quotes syntax but missing second quote +--FILE-- +<?php +$test = "foo"; +$var = <<<"MYLABEL +test: $test +MYLABEL; +echo $var; +?> +--EXPECTF-- +Parse error: %s in %sheredoc_014.php on line %d diff --git a/Zend/tests/heredoc_015.phpt b/Zend/tests/heredoc_015.phpt new file mode 100644 index 0000000..21658cf --- /dev/null +++ b/Zend/tests/heredoc_015.phpt @@ -0,0 +1,41 @@ +--TEST-- +Testing heredoc with escape sequences +--FILE-- +<?php + +$test = <<<TEST +TEST; + +var_dump(strlen($test) == 0); + +$test = <<<TEST +\ +TEST; + +var_dump(strlen($test) == 1); + +$test = <<<TEST +\0 +TEST; + +var_dump(strlen($test) == 1); + +$test = <<<TEST +\n +TEST; + +var_dump(strlen($test) == 1); + +$test = <<<TEST +\\' +TEST; + +var_dump(strlen($test) == 2); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/heredoc_016.phpt b/Zend/tests/heredoc_016.phpt new file mode 100644 index 0000000..de00036 --- /dev/null +++ b/Zend/tests/heredoc_016.phpt @@ -0,0 +1,42 @@ +--TEST-- +Testing heredoc (double quotes) with escape sequences +--FILE-- +<?php + +$test = <<<"TEST" +TEST; + +var_dump(strlen($test) == 0); + +$test = <<<"TEST" +\ +TEST; + +var_dump(strlen($test) == 1); + +$test = <<<"TEST" +\0 +TEST; + +var_dump(strlen($test) == 1); + +$test = <<<"TEST" +\n +TEST; + +var_dump(strlen($test) == 1); + +$test = <<<"TEST" +\\' +TEST; + +var_dump(strlen($test) == 2); + + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/heredoc_017.phpt b/Zend/tests/heredoc_017.phpt new file mode 100644 index 0000000..e0ffddf --- /dev/null +++ b/Zend/tests/heredoc_017.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testinh heredoc syntax +--FILE-- +<?php + +$a = <<<A + A; +; + A; +\; +A; + +var_dump(strlen($a) == 12); + +?> +--EXPECT-- +bool(true) diff --git a/Zend/tests/heredoc_018.phpt b/Zend/tests/heredoc_018.phpt new file mode 100644 index 0000000..c10e9c1 --- /dev/null +++ b/Zend/tests/heredoc_018.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing heredoc with tabs before identifier +--FILE-- +<?php + +$heredoc = <<< A + +foo + + A; +A; + +var_dump(strlen($heredoc) == 9); + +?> +--EXPECT-- +bool(true) diff --git a/Zend/tests/hex_overflow_32bit.phpt b/Zend/tests/hex_overflow_32bit.phpt new file mode 100644 index 0000000..0f192f3 --- /dev/null +++ b/Zend/tests/hex_overflow_32bit.phpt @@ -0,0 +1,29 @@ +--TEST-- +testing integer overflow (32bit) +--INI-- +precision=14 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 0x1736123FFFAAA, + 0XFFFFFFFFFFFFFFFFFF, + 0xAAAAAAAAAAAAAAEEEEEEEEEBBB, + 0x66666666666666666777777, + ); + +foreach ($doubles as $d) { + $l = $d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECTF-- +float(4.0833602971%dE+14) +float(4.7223664828%dE+21) +float(1.3521606402%dE+31) +float(1.9807040628%dE+27) +Done diff --git a/Zend/tests/increment_001.phpt b/Zend/tests/increment_001.phpt new file mode 100644 index 0000000..3638474 --- /dev/null +++ b/Zend/tests/increment_001.phpt @@ -0,0 +1,60 @@ +--TEST-- +incrementing different variables +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--INI-- +precision=14 +--FILE-- +<?php + +$a = array( + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + array(), + PHP_INT_MAX, + (string)PHP_INT_MAX +); + +foreach ($a as $var) { + $var++; + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +string(1) "1" +int(2) +float(3.5) +int(1) +string(6) "strinh" +int(124) +float(3.5) +int(1) +bool(true) +bool(false) +object(stdClass)#%d (0) { +} +array(0) { +} +float(2147483648) +float(2147483648) +Done diff --git a/Zend/tests/indexing_001.phpt b/Zend/tests/indexing_001.phpt new file mode 100644 index 0000000..0e466ab --- /dev/null +++ b/Zend/tests/indexing_001.phpt @@ -0,0 +1,214 @@ +--TEST-- +Indexing - various special cases. +--FILE-- +<?php +echo "*** Indexing - Testing value assignment with key ***\n"; +$array=array(1); +$testvalues=array(null, 0, 1, true, false,'',' ',0.1,array()); + +foreach ($testvalues as $testvalue) { + $testvalue['foo']=$array; + var_dump ($testvalue); +} +echo "\n*** Indexing - Testing reference assignment with key ***\n"; + +$testvalues=array(null, 0, 1, true, false,'',0.1,array()); + +foreach ($testvalues as $testvalue) { + $testvalue['foo']=&$array; + var_dump ($testvalue); +} +echo "*** Indexing - Testing value assignment no key ***\n"; +$array=array(1); +$testvalues=array(null, 0, 1, true, false,'',0.1,array()); + +foreach ($testvalues as $testvalue) { + $testvalue[]=$array; + var_dump ($testvalue); +} +echo "\n*** Indexing - Testing reference assignment no key ***\n"; + +$testvalues=array(null, 0, 1, true, false,'',0.1,array()); + +foreach ($testvalues as $testvalue) { + $testvalue[]=&$array; + var_dump ($testvalue); +} + + +echo "\nDone"; +?> +--EXPECTF-- +*** Indexing - Testing value assignment with key *** +array(1) { + ["foo"]=> + array(1) { + [0]=> + int(1) + } +} + +Warning: Cannot use a scalar value as an array in %s on line %d +int(0) + +Warning: Cannot use a scalar value as an array in %s on line %d +int(1) + +Warning: Cannot use a scalar value as an array in %s on line %d +bool(true) +array(1) { + ["foo"]=> + array(1) { + [0]=> + int(1) + } +} +array(1) { + ["foo"]=> + array(1) { + [0]=> + int(1) + } +} + +Warning: Illegal string offset 'foo' in %s on line %d + +Notice: Array to string conversion in %s on line %d +string(1) "A" + +Warning: Cannot use a scalar value as an array in %s on line %d +float(0.1) +array(1) { + ["foo"]=> + array(1) { + [0]=> + int(1) + } +} + +*** Indexing - Testing reference assignment with key *** +array(1) { + ["foo"]=> + &array(1) { + [0]=> + int(1) + } +} + +Warning: Cannot use a scalar value as an array in %s on line %d +int(0) + +Warning: Cannot use a scalar value as an array in %s on line %d +int(1) + +Warning: Cannot use a scalar value as an array in %s on line %d +bool(true) +array(1) { + ["foo"]=> + &array(1) { + [0]=> + int(1) + } +} +array(1) { + ["foo"]=> + &array(1) { + [0]=> + int(1) + } +} + +Warning: Cannot use a scalar value as an array in %s on line %d +float(0.1) +array(1) { + ["foo"]=> + &array(1) { + [0]=> + int(1) + } +} +*** Indexing - Testing value assignment no key *** +array(1) { + [0]=> + array(1) { + [0]=> + int(1) + } +} + +Warning: Cannot use a scalar value as an array in %s on line %d +int(0) + +Warning: Cannot use a scalar value as an array in %s on line %d +int(1) + +Warning: Cannot use a scalar value as an array in %s on line %d +bool(true) +array(1) { + [0]=> + array(1) { + [0]=> + int(1) + } +} +array(1) { + [0]=> + array(1) { + [0]=> + int(1) + } +} + +Warning: Cannot use a scalar value as an array in %s on line %d +float(0.1) +array(1) { + [0]=> + array(1) { + [0]=> + int(1) + } +} + +*** Indexing - Testing reference assignment no key *** +array(1) { + [0]=> + &array(1) { + [0]=> + int(1) + } +} + +Warning: Cannot use a scalar value as an array in %s on line %d +int(0) + +Warning: Cannot use a scalar value as an array in %s on line %d +int(1) + +Warning: Cannot use a scalar value as an array in %s on line %d +bool(true) +array(1) { + [0]=> + &array(1) { + [0]=> + int(1) + } +} +array(1) { + [0]=> + &array(1) { + [0]=> + int(1) + } +} + +Warning: Cannot use a scalar value as an array in %s on line %d +float(0.1) +array(1) { + [0]=> + &array(1) { + [0]=> + int(1) + } +} + +Done
\ No newline at end of file diff --git a/Zend/tests/indirect_call_array_001.phpt b/Zend/tests/indirect_call_array_001.phpt new file mode 100644 index 0000000..56675b8 --- /dev/null +++ b/Zend/tests/indirect_call_array_001.phpt @@ -0,0 +1,11 @@ +--TEST-- +Indirect method call by array - Invalid class name +--FILE-- +<?php + +$arr = array('a', 'b'); +$arr(); + +?> +--EXPECTF-- +Fatal error: Class 'a' not found in %s on line %d diff --git a/Zend/tests/indirect_call_array_002.phpt b/Zend/tests/indirect_call_array_002.phpt new file mode 100644 index 0000000..013fa55 --- /dev/null +++ b/Zend/tests/indirect_call_array_002.phpt @@ -0,0 +1,11 @@ +--TEST-- +Indirect method call by array - Invalid method name +--FILE-- +<?php + +$arr = array('stdclass', 'b'); +$arr(); + +?> +--EXPECTF-- +Fatal error: Call to undefined method stdClass::b() in %s on line %d diff --git a/Zend/tests/indirect_call_array_003.phpt b/Zend/tests/indirect_call_array_003.phpt new file mode 100644 index 0000000..498c580 --- /dev/null +++ b/Zend/tests/indirect_call_array_003.phpt @@ -0,0 +1,38 @@ +--TEST-- +Indirect method call by array - Calling __call() and __callStatic() +--FILE-- +<?php + +class foo { + public function __call($a, $b) { + printf("From %s:\n", __METHOD__); + var_dump($a); + var_dump($this); + } + static public function __callStatic($a, $b) { + printf("From %s:\n", __METHOD__); + var_dump($a); + var_dump($this); + } +} + +$arr = array('foo', 'abc'); +$arr(); + +$foo = new foo; +$arr = array($foo, 'abc'); +$arr(); + + +?> +--EXPECTF-- +From foo::__callStatic: +string(3) "abc" + +Notice: Undefined variable: this in %s on line %d +NULL +From foo::__call: +string(3) "abc" +object(foo)#%d (0) { +} + diff --git a/Zend/tests/indirect_call_array_004.phpt b/Zend/tests/indirect_call_array_004.phpt new file mode 100644 index 0000000..350f720 --- /dev/null +++ b/Zend/tests/indirect_call_array_004.phpt @@ -0,0 +1,71 @@ +--TEST-- +Indirect method call by array - Testing exception and method magics +--FILE-- +<?php + +class foo { + static public function abc() { + throw new Exception('foo'); + } + public function __call($a, $b) { + printf("From %s:\n", __METHOD__); + throw new Exception($a); + } + static public function __callStatic($a, $b) { + printf("From %s:\n", __METHOD__); + throw new Exception($a); + } +} + + +$arr = array('foo', 'abc'); + +try { + $arr(); +} +catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +$arr = array('foo', '123'); + +try { + $arr(); +} +catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + + +echo "------\n"; + +$foo = new foo; +$arr = array($foo, 'abc'); + +try { + $arr(); +} +catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + + +$foo = new foo; +$arr = array($foo, '123'); + +try { + $arr(); +} +catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECTF-- +foo +From foo::__callStatic: +123 +------ +foo +From foo::__call: +123 diff --git a/Zend/tests/indirect_method_call_001.phpt b/Zend/tests/indirect_method_call_001.phpt new file mode 100644 index 0000000..7018eaa --- /dev/null +++ b/Zend/tests/indirect_method_call_001.phpt @@ -0,0 +1,20 @@ +--TEST-- +Testing indirect method call and exceptions +--FILE-- +<?php + +class foo { + public function __construct() { + throw new Exception('foobar'); + } +} + +try { + $X = (new foo)->Inexistent(3); +} catch (Exception $e) { + var_dump($e->getMessage()); // foobar +} + +?> +--EXPECT-- +string(6) "foobar" diff --git a/Zend/tests/indirect_method_call_002.phpt b/Zend/tests/indirect_method_call_002.phpt new file mode 100644 index 0000000..1589533 --- /dev/null +++ b/Zend/tests/indirect_method_call_002.phpt @@ -0,0 +1,32 @@ +--TEST-- +Indirect method call with chaining +--FILE-- +<?php + +class foo { + public $x = 'testing'; + + public function bar() { + return "foo"; + } + public function baz() { + return new self; + } + static function xyz() { + } +} + +var_dump((new foo())->bar()); // string(3) "foo" +var_dump((new foo())->baz()->x); // string(7) "testing" +var_dump((new foo())->baz()->baz()->bar()); // string(3) "foo" +var_dump((new foo())->xyz()); // NULL +(new foo())->www(); + +?> +--EXPECTF-- +string(3) "foo" +string(7) "testing" +string(3) "foo" +NULL + +Fatal error: Call to undefined method foo::www() in %s on line %d diff --git a/Zend/tests/indirect_method_call_003.phpt b/Zend/tests/indirect_method_call_003.phpt new file mode 100644 index 0000000..3df4954 --- /dev/null +++ b/Zend/tests/indirect_method_call_003.phpt @@ -0,0 +1,23 @@ +--TEST-- +Testing indirect method call +--FILE-- +<?php + +class foo { + public $x = 1; + + public function getX() { + return $this->x; + } + public function setX($val) { + $this->x = $val; + return $this; + } +} + +$X = (new foo)->setX(10)->getX(); +var_dump($X); // int(10) + +?> +--EXPECT-- +int(10) diff --git a/Zend/tests/indirect_method_call_004.phpt b/Zend/tests/indirect_method_call_004.phpt new file mode 100644 index 0000000..689600d --- /dev/null +++ b/Zend/tests/indirect_method_call_004.phpt @@ -0,0 +1,26 @@ +--TEST-- +Indirect method call and cloning +--FILE-- +<?php + + +class bar { + public $z; + + public function __construct() { + $this->z = new stdclass; + } + public function getZ() { + return $this->z; + } +} + +var_dump(clone (new bar)->z); +var_dump(clone (new bar)->getZ()); + +?> +--EXPECTF-- +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} diff --git a/Zend/tests/indirect_method_call_005.phpt b/Zend/tests/indirect_method_call_005.phpt new file mode 100644 index 0000000..4f4b363 --- /dev/null +++ b/Zend/tests/indirect_method_call_005.phpt @@ -0,0 +1,16 @@ +--TEST-- +Testing array dereferencing from instance with ArrayObject +--FILE-- +<?php + +class foo extends ArrayObject { + public function __construct($arr) { + parent::__construct($arr); + } +} + +var_dump( (new foo( array(1, array(4, 5), 3) ))[1][0] ); // int(4) + +?> +--EXPECT-- +int(4) diff --git a/Zend/tests/indirect_property_access.phpt b/Zend/tests/indirect_property_access.phpt new file mode 100644 index 0000000..3645687 --- /dev/null +++ b/Zend/tests/indirect_property_access.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing indirect property access +--FILE-- +<?php + +class foo { + public $x = 1; +} + +class bar { + public $y = 'foo'; +} + +$x = 'bar'; + +$bar = new bar; + +var_dump((new bar)->y); // foo +var_dump((new $x)->y); // foo +var_dump((new $bar->y)->x); // 1 + +?> +--EXPECT-- +string(3) "foo" +string(3) "foo" +int(1) diff --git a/Zend/tests/indirect_reference_this.phpt b/Zend/tests/indirect_reference_this.phpt new file mode 100644 index 0000000..c344bd0 --- /dev/null +++ b/Zend/tests/indirect_reference_this.phpt @@ -0,0 +1,13 @@ +--TEST-- +Indirect referenced $this +--FILE-- +<?php +class X { + function f($x){var_dump($$x);} +} +$x = new X; +$x->f("this"); +?> +--EXPECTF-- +object(X)#%d (0) { +} diff --git a/Zend/tests/instanceof.phpt b/Zend/tests/instanceof.phpt new file mode 100644 index 0000000..8bcbede --- /dev/null +++ b/Zend/tests/instanceof.phpt @@ -0,0 +1,18 @@ +--TEST-- +instanceof shouldn't call __autoload +--FILE-- +<?php +function __autoload($name) { + echo("AUTOLOAD '$name'\n"); + eval("class $name {}"); +} + +class A { +} +$a = new A; +var_dump($a instanceof B); +var_dump($a instanceof A); +?> +--EXPECT-- +bool(false) +bool(true) diff --git a/Zend/tests/instanceof_001.phpt b/Zend/tests/instanceof_001.phpt new file mode 100644 index 0000000..b88e174 --- /dev/null +++ b/Zend/tests/instanceof_001.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing instanceof operator with several operators +--FILE-- +<?php + +$a = new stdClass; +var_dump($a instanceof stdClass); + +var_dump(new stdCLass instanceof stdClass); + +$b = create_function('', 'return new stdClass;'); +var_dump($b() instanceof stdClass); + +$c = array(new stdClass); +var_dump($c[0] instanceof stdClass); + +var_dump(@$inexistent instanceof stdClass); + +var_dump("$a" instanceof stdClass); + +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) + +Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d diff --git a/Zend/tests/instanceof_002.phpt b/Zend/tests/instanceof_002.phpt new file mode 100644 index 0000000..d3f4a35 --- /dev/null +++ b/Zend/tests/instanceof_002.phpt @@ -0,0 +1,33 @@ +--TEST-- +Testing instanceof operator with class and interface inheriteds +--FILE-- +<?php + +interface ITest { +} + +interface IFoo extends ITest { +} + +class foo extends stdClass implements ITest { +} + +var_dump(new foo instanceof stdClass); +var_dump(new foo instanceof ITest); +var_dump(new foo instanceof IFoo); + +class bar extends foo implements IFoo { +} + +var_dump(new bar instanceof stdClass); +var_dump(new bar instanceof ITest); +var_dump(new bar instanceof IFoo); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/int_overflow_32bit.phpt b/Zend/tests/int_overflow_32bit.phpt new file mode 100644 index 0000000..d9b5649 --- /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 0000000..7c54125 --- /dev/null +++ b/Zend/tests/int_overflow_64bit.phpt @@ -0,0 +1,33 @@ +--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( + PHP_INT_MAX, + PHP_INT_MAX + 1, + PHP_INT_MAX + 1000, + PHP_INT_MAX * 2 + 4, + -PHP_INT_MAX -1, + -PHP_INT_MAX -2, + -PHP_INT_MAX -1000, + ); + +foreach ($doubles as $d) { + $l = (int)$d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECT-- +int(9223372036854775807) +int(-9223372036854775808) +int(-9223372036854775808) +int(0) +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 0000000..79a949a --- /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"; +?> +--EXPECT-- +int(-2147483648) +int(2147483647) +int(2147483638) +int(2147483548) +int(2147482648) +Done diff --git a/Zend/tests/int_underflow_64bit.phpt b/Zend/tests/int_underflow_64bit.phpt new file mode 100644 index 0000000..48a43a3 --- /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/inter_007.phpt b/Zend/tests/inter_007.phpt new file mode 100644 index 0000000..13b1888 --- /dev/null +++ b/Zend/tests/inter_007.phpt @@ -0,0 +1,20 @@ +--TEST-- +Trying inherit abstract function twice +--FILE-- +<?php + +interface d { + static function B(); +} + +interface c { + function b(); +} + +class_alias('c', 'w'); + +interface a extends d, w { } + +?> +--EXPECTF-- +Fatal error: Cannot make non static method c::B() static in class d in %s on line %d diff --git a/Zend/tests/inter_01.phpt b/Zend/tests/inter_01.phpt new file mode 100644 index 0000000..c73397c --- /dev/null +++ b/Zend/tests/inter_01.phpt @@ -0,0 +1,18 @@ +--TEST-- +Inherited constant from interface +--FILE-- +<?php +interface foo { + const foo = 'foobar'; + public function bar($x = foo); +} + +class foobar implements foo { + const foo = 'bar'; + public function bar($x = foo::foo) { + var_dump($x); + } +} +?> +--EXPECTF-- +Fatal error: Cannot inherit previously-inherited or override constant foo from interface foo in %s on line %d diff --git a/Zend/tests/inter_02.phpt b/Zend/tests/inter_02.phpt new file mode 100644 index 0000000..34e8baa --- /dev/null +++ b/Zend/tests/inter_02.phpt @@ -0,0 +1,21 @@ +--TEST-- +Namespace constant as value default +--FILE-- +<?php + +namespace foo; + +error_reporting(E_ALL); + +interface foo { + const foo = 2; +} + +function foo($x = \foo\foo::foo) { + var_dump($x); +} + +foo(); +?> +--EXPECT-- +int(2) diff --git a/Zend/tests/inter_03.phpt b/Zend/tests/inter_03.phpt new file mode 100644 index 0000000..c91f4aa --- /dev/null +++ b/Zend/tests/inter_03.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing interface constants with inheritance +--FILE-- +<?php + +interface a { + const b = 2; +} + +interface b extends a { + const c = self::b; +} + +var_dump(b::c, a::b); + +?> +--EXPECT-- +int(2) +int(2) diff --git a/Zend/tests/inter_04.phpt b/Zend/tests/inter_04.phpt new file mode 100644 index 0000000..ea0bd84 --- /dev/null +++ b/Zend/tests/inter_04.phpt @@ -0,0 +1,21 @@ +--TEST-- +Trying declare interface with repeated name of inherited method +--FILE-- +<?php + +interface a { + function b(); +} + +interface b { + function b(); +} + +interface c extends a, b { +} + +echo "done!\n"; + +?> +--EXPECTF-- +done! diff --git a/Zend/tests/inter_05.phpt b/Zend/tests/inter_05.phpt new file mode 100644 index 0000000..7d5d13e --- /dev/null +++ b/Zend/tests/inter_05.phpt @@ -0,0 +1,10 @@ +--TEST-- +Trying to inherit a class in an interface +--FILE-- +<?php + +interface a extends Exception { } + +?> +--EXPECTF-- +Fatal error: a cannot implement Exception - it is not an interface in %s on line %d diff --git a/Zend/tests/inter_06.phpt b/Zend/tests/inter_06.phpt new file mode 100644 index 0000000..1987c24 --- /dev/null +++ b/Zend/tests/inter_06.phpt @@ -0,0 +1,10 @@ +--TEST-- +Trying use name of an internal class as interface name +--FILE-- +<?php + +interface stdClass { } + +?> +--EXPECTF-- +Fatal error: Cannot redeclare class stdClass in %s on line %d diff --git a/Zend/tests/interface_exists_001.phpt b/Zend/tests/interface_exists_001.phpt new file mode 100644 index 0000000..ab20dd2 --- /dev/null +++ b/Zend/tests/interface_exists_001.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing interface_exists() +--FILE-- +<?php + +interface foo { +} + +var_dump(interface_exists('foo')); +var_dump(interface_exists(1)); +var_dump(interface_exists(NULL)); +var_dump(interface_exists(new stdClass)); + +?> +--EXPECTF-- +bool(true) +bool(false) +bool(false) + +Warning: interface_exists() expects parameter 1 to be string, object given in %s on line %d +NULL diff --git a/Zend/tests/interface_exists_002.phpt b/Zend/tests/interface_exists_002.phpt new file mode 100644 index 0000000..be78784 --- /dev/null +++ b/Zend/tests/interface_exists_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +Testing interface_exists() inside a namespace +--FILE-- +<?php + +namespace foo; + +interface IFoo { } + +interface ITest extends IFoo { } + +interface IBar extends IFoo { } + + +var_dump(interface_exists('IFoo')); +var_dump(interface_exists('foo\\IFoo')); +var_dump(interface_exists('FOO\\ITEST')); + +?> +--EXPECT-- +bool(false) +bool(true) +bool(true) diff --git a/Zend/tests/is_a.phpt b/Zend/tests/is_a.phpt new file mode 100644 index 0000000..0a01eb7 --- /dev/null +++ b/Zend/tests/is_a.phpt @@ -0,0 +1,43 @@ +--TEST-- +is_a() and is_subclass_of() shouldn't call __autoload +--INI-- +error_reporting=14335 +--FILE-- +<?php +function __autoload($name) { + echo("AUTOLOAD '$name'\n"); + eval("class $name {}"); +} + +class BASE { +} + +interface INT { +} + +class A extends BASE implements INT { +} + +$a = new A; +var_dump(is_a($a, "B1")); +var_dump(is_a($a, "A")); +var_dump(is_a($a, "BASE")); +var_dump(is_a($a, "INT")); +var_dump(is_subclass_of($a, "B2")); +var_dump(is_subclass_of($a, "A")); +var_dump(is_subclass_of($a, "BASE")); +var_dump(is_subclass_of($a, "INT")); + +var_dump(is_subclass_of("X1", "X2")); +?> +--EXPECT-- +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(true) +bool(true) +AUTOLOAD 'X1' +bool(false) diff --git a/Zend/tests/isset_001.phpt b/Zend/tests/isset_001.phpt new file mode 100644 index 0000000..340b237 --- /dev/null +++ b/Zend/tests/isset_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +Testing isset and unset with variable variables +--FILE-- +<?php + +print "- isset ---\n"; + +$var_name = 'unexisting'; + +if (isset($$var_name)) { + print "error\n"; +} + +$test = 'var_name'; + +if (isset($$$test)) { + print "error\n"; +} + +print "- unset ---\n"; + +unset($$var_name); + +unset($$$test); + +print "done\n"; + +?> +--EXPECT-- +- isset --- +- unset --- +done diff --git a/Zend/tests/isset_002.phpt b/Zend/tests/isset_002.phpt new file mode 100644 index 0000000..8dd3acc --- /dev/null +++ b/Zend/tests/isset_002.phpt @@ -0,0 +1,10 @@ +--TEST-- +Testing isset with several undefined variables as argument +--FILE-- +<?php + +var_dump(isset($a, ${$b}, $$c, $$$$d, $e[$f->g]->d)); + +?> +--EXPECT-- +bool(false) diff --git a/Zend/tests/isset_003.phpt b/Zend/tests/isset_003.phpt new file mode 100644 index 0000000..4db42a9 --- /dev/null +++ b/Zend/tests/isset_003.phpt @@ -0,0 +1,40 @@ +--TEST-- +Testing isset accessing undefined array itens and properties +--FILE-- +<?php + +$a = 'foo'; +$b =& $a; + +var_dump(isset($b)); + +var_dump(isset($a[0], $b[1])); + +var_dump(isset($a[0]->a)); + +var_dump(isset($c[0][1][2]->a->b->c->d)); + +var_dump(isset(${$a}->{$b->$c[$d]})); + +var_dump(isset($GLOBALS)); + +var_dump(isset($GLOBALS[1])); + +var_dump(isset($GLOBALS[1]->$GLOBALS)); + +?> +--EXPECTF-- +bool(true) +bool(true) +bool(false) +bool(false) + +Notice: Undefined variable: c in %s on line %d + +Notice: Undefined variable: d in %s on line %d + +Notice: Trying to get property of non-object in %s on line %d +bool(false) +bool(true) +bool(false) +bool(false) diff --git a/Zend/tests/isset_003_2_4.phpt b/Zend/tests/isset_003_2_4.phpt new file mode 100644 index 0000000..c05f3e2 --- /dev/null +++ b/Zend/tests/isset_003_2_4.phpt @@ -0,0 +1,42 @@ +--TEST-- +Testing isset accessing undefined array itens and properties +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.4.0', '<')) die('skip ZendEngine 2.4 needed'); ?> +--FILE-- +<?php + +$a = 'foo'; +$b =& $a; + +var_dump(isset($b)); + +var_dump(isset($a[0], $b[1])); + +var_dump(isset($a[0]->a)); + +var_dump(isset($c[0][1][2]->a->b->c->d)); + +var_dump(isset(${$a}->{$b->$c[$d]})); + +var_dump(isset($GLOBALS)); + +var_dump(isset($GLOBALS[1])); + +var_dump(isset($GLOBALS[1]->$GLOBALS)); + +?> +--EXPECTF-- +bool(true) +bool(true) +bool(false) +bool(false) + +Notice: Undefined variable: c in %s on line %d + +Notice: Undefined variable: d in %s on line %d + +Notice: Trying to get property of non-object in %s on line %d +bool(false) +bool(true) +bool(false) +bool(false) diff --git a/Zend/tests/isset_str_offset.phpt b/Zend/tests/isset_str_offset.phpt new file mode 100644 index 0000000..7a9164a --- /dev/null +++ b/Zend/tests/isset_str_offset.phpt @@ -0,0 +1,89 @@ +--TEST-- +Testing isset with string offsets +--FILE-- +<?php + +print "- isset ---\n"; + +$str = "test0123"; + +var_dump(isset($str[-1])); +var_dump(isset($str[0])); +var_dump(isset($str[1])); +var_dump(isset($str[4])); // 0 +var_dump(isset($str[5])); // 1 +var_dump(isset($str[8])); +var_dump(isset($str[10000])); +// non-numeric offsets +print "- string ---\n"; +var_dump(isset($str['-1'])); +var_dump(isset($str['0'])); +var_dump(isset($str['1'])); +var_dump(isset($str['4'])); // 0 +var_dump(isset($str['1.5'])); +var_dump(isset($str['good'])); +var_dump(isset($str['3 and a half'])); +print "- bool ---\n"; +var_dump(isset($str[true])); +var_dump(isset($str[false])); +var_dump(isset($str[false][true])); +print "- null ---\n"; +var_dump(isset($str[null])); +print "- double ---\n"; +var_dump(isset($str[-1.1])); +var_dump(isset($str[-0.8])); +var_dump(isset($str[-0.1])); +var_dump(isset($str[0.2])); +var_dump(isset($str[0.9])); +var_dump(isset($str[M_PI])); +var_dump(isset($str[100.5001])); +print "- array ---\n"; +var_dump(isset($str[array()])); +var_dump(isset($str[array(1,2,3)])); +print "- object ---\n"; +var_dump(isset($str[new stdClass()])); +print "- resource ---\n"; +$f = fopen(__FILE__, 'r'); +var_dump(isset($str[$f])); +print "done\n"; + +?> +--EXPECTF-- +- isset --- +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +- string --- +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +- bool --- +bool(true) +bool(true) +bool(false) +- null --- +bool(true) +- double --- +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +- array --- +bool(false) +bool(false) +- object --- +bool(false) +- resource --- +bool(false) +done diff --git a/Zend/tests/jump01.phpt b/Zend/tests/jump01.phpt new file mode 100644 index 0000000..87dba88 --- /dev/null +++ b/Zend/tests/jump01.phpt @@ -0,0 +1,14 @@ +--TEST-- +jump 01: goto backward +--FILE-- +<?php +$n = 1; +L1: +echo "$n: ok\n"; +$n++; +if ($n <= 3) goto L1; +?> +--EXPECT-- +1: ok +2: ok +3: ok diff --git a/Zend/tests/jump02.phpt b/Zend/tests/jump02.phpt new file mode 100644 index 0000000..ff83bc4 --- /dev/null +++ b/Zend/tests/jump02.phpt @@ -0,0 +1,16 @@ +--TEST-- +jump 02: goto forward +--FILE-- +<?php +$n = 1; +L1: +if ($n > 3) goto L2; +echo "$n: ok\n"; +$n++; +goto L1; +L2: +?> +--EXPECT-- +1: ok +2: ok +3: ok diff --git a/Zend/tests/jump03.phpt b/Zend/tests/jump03.phpt new file mode 100644 index 0000000..2399f30 --- /dev/null +++ b/Zend/tests/jump03.phpt @@ -0,0 +1,18 @@ +--TEST-- +jump 03: goto inside control structures +--FILE-- +<?php +do { + if (1) { + echo "1: ok\n"; + goto L1; + } else { + echo "bug\n"; +L1: + echo "2: ok\n"; + } +} while (0); +?> +--EXPECT-- +1: ok +2: ok diff --git a/Zend/tests/jump04.phpt b/Zend/tests/jump04.phpt new file mode 100644 index 0000000..2bbf1f5 --- /dev/null +++ b/Zend/tests/jump04.phpt @@ -0,0 +1,24 @@ +--TEST-- +jump 04: goto from loop (backward) +--FILE-- +<?php +$s = "X"; +echo "1: ok\n"; +L1: if ($s != "X") { + echo "4: ok\n"; +} else { + echo "2: ok\n"; + while ($s != "XXX") { + echo "3: ok\n"; + $s .= "X"; + goto L1; + echo "bug\n"; + } + echo "bug\n"; +} +?> +--EXPECT-- +1: ok +2: ok +3: ok +4: ok diff --git a/Zend/tests/jump05.phpt b/Zend/tests/jump05.phpt new file mode 100644 index 0000000..2e5e50c --- /dev/null +++ b/Zend/tests/jump05.phpt @@ -0,0 +1,26 @@ +--TEST-- +jump 05: goto from loop (forward) +--FILE-- +<?php +$ar = array("1","2","3"); +foreach ($ar as $val) { + switch ($val) { + case "1": + echo "1: ok\n"; + break; + case "2": + echo "2: ok\n"; + goto L1; + case "3": + echo "bug\n"; + break; + } +} +echo "bug\n"; +L1: +echo "3: ok\n"; +?> +--EXPECT-- +1: ok +2: ok +3: ok diff --git a/Zend/tests/jump06.phpt b/Zend/tests/jump06.phpt new file mode 100644 index 0000000..ef01b0e --- /dev/null +++ b/Zend/tests/jump06.phpt @@ -0,0 +1,8 @@ +--TEST-- +jump 06: goto to undefined label +--FILE-- +<?php +goto L1; +?> +--EXPECTF-- +Fatal error: 'goto' to undefined label 'L1' in %sjump06.php on line 2 diff --git a/Zend/tests/jump07.phpt b/Zend/tests/jump07.phpt new file mode 100644 index 0000000..c0cb112 --- /dev/null +++ b/Zend/tests/jump07.phpt @@ -0,0 +1,11 @@ +--TEST-- +jump 07: goto into loop (backward) +--FILE-- +<?php +while (0) { + L1: echo "bug\n"; +} +goto L1; +?> +--EXPECTF-- +Fatal error: 'goto' into loop or switch statement is disallowed in %sjump07.php on line 5 diff --git a/Zend/tests/jump08.phpt b/Zend/tests/jump08.phpt new file mode 100644 index 0000000..25a211c --- /dev/null +++ b/Zend/tests/jump08.phpt @@ -0,0 +1,11 @@ +--TEST-- +jump 08: goto into loop (forward) +--FILE-- +<?php +goto L1; +while (0) { + L1: echo "bug\n"; +} +?> +--EXPECTF-- +Fatal error: 'goto' into loop or switch statement is disallowed in %sjump08.php on line 2 diff --git a/Zend/tests/jump09.phpt b/Zend/tests/jump09.phpt new file mode 100644 index 0000000..52a14b7 --- /dev/null +++ b/Zend/tests/jump09.phpt @@ -0,0 +1,13 @@ +--TEST-- +jump 09: goto into switch (backward) +--FILE-- +<?php +switch (0) { + case 1: + L1: echo "bug\n"; + break; +} +goto L1; +?> +--EXPECTF-- +Fatal error: 'goto' into loop or switch statement is disallowed in %sjump09.php on line 7 diff --git a/Zend/tests/jump10.phpt b/Zend/tests/jump10.phpt new file mode 100644 index 0000000..67206a2 --- /dev/null +++ b/Zend/tests/jump10.phpt @@ -0,0 +1,13 @@ +--TEST-- +jump 10: goto into switch (forward) +--FILE-- +<?php +goto L1; +switch (0) { + case 1: + L1: echo "bug\n"; + break; +} +?> +--EXPECTF-- +Fatal error: 'goto' into loop or switch statement is disallowed in %sjump10.php on line 2 diff --git a/Zend/tests/jump11.phpt b/Zend/tests/jump11.phpt new file mode 100644 index 0000000..bd1107c --- /dev/null +++ b/Zend/tests/jump11.phpt @@ -0,0 +1,26 @@ +--TEST-- +jump 08: goto inside switch in constructor +--FILE-- +<?php +class foobar { + public function __construct() { + switch (1) { + default: + goto b; + a: + print "ok!\n"; + break; + b: + print "ok!\n"; + goto a; + } + print "ok!\n"; + } +} + +new foobar; +?> +--EXPECT-- +ok! +ok! +ok! diff --git a/Zend/tests/jump12.phpt b/Zend/tests/jump12.phpt new file mode 100644 index 0000000..10bebc2 --- /dev/null +++ b/Zend/tests/jump12.phpt @@ -0,0 +1,19 @@ +--TEST-- +jump 09: goto in declare statement +--FILE-- +<?php +a: print "ok!\n"; +goto c; +declare (ticks=1) { + b: + print "ok!\n"; + exit; +} +c: + print "ok!\n"; + goto b; +?> +--EXPECTF-- +ok! +ok! +ok! diff --git a/Zend/tests/jump13.phpt b/Zend/tests/jump13.phpt new file mode 100644 index 0000000..2d57f4a --- /dev/null +++ b/Zend/tests/jump13.phpt @@ -0,0 +1,25 @@ +--TEST-- +jump 10: goto with try blocks +--FILE-- +<?php +goto a; +e: return; +try { + a: print 1; + goto b; + try { + b: print 2; + goto c; + } + catch(Exception $e) { + c: print 3; + goto d; + } +} +catch(Exception $e) { + d: print 4; + goto e; +} +?> +--EXPECT-- +1234 diff --git a/Zend/tests/jump14.phpt b/Zend/tests/jump14.phpt new file mode 100644 index 0000000..2cc6391 --- /dev/null +++ b/Zend/tests/jump14.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing GOTO inside blocks +--FILE-- +<?php + +goto A; + +{ + B: + goto C; + return; +} + +A: + goto B; + + + +{ + C: + { + print "Done!\n"; + } +} + +?> +--EXPECT-- +Done! diff --git a/Zend/tests/list_001.phpt b/Zend/tests/list_001.phpt new file mode 100644 index 0000000..a9fff55 --- /dev/null +++ b/Zend/tests/list_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +"Nested" list() +--FILE-- +<?php + +list($a, list($b)) = array(new stdclass, array(new stdclass)); +var_dump($a, $b); + +?> +--EXPECT-- +object(stdClass)#1 (0) { +} +object(stdClass)#2 (0) { +} diff --git a/Zend/tests/list_002.phpt b/Zend/tests/list_002.phpt new file mode 100644 index 0000000..ac0d897 --- /dev/null +++ b/Zend/tests/list_002.phpt @@ -0,0 +1,20 @@ +--TEST-- +Testing full-reference on list() +--FILE-- +<?php + +error_reporting(E_ALL); + +$a = new stdclass; +$b =& $a; + +list($a, list($b)) = array($a, array($b)); +var_dump($a, $b, $a === $b); + +?> +--EXPECT-- +object(stdClass)#1 (0) { +} +object(stdClass)#1 (0) { +} +bool(true) diff --git a/Zend/tests/list_003.phpt b/Zend/tests/list_003.phpt new file mode 100644 index 0000000..4a509f6 --- /dev/null +++ b/Zend/tests/list_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +list() with non-array +--FILE-- +<?php + +list($a) = NULL; + +list($b) = 1; + +list($c) = 1.; + +list($d) = 'foo'; + +list($e) = print ''; + +var_dump($a, $b, $c, $d, $e); + +?> +--EXPECT-- +NULL +NULL +NULL +NULL +NULL diff --git a/Zend/tests/list_004.phpt b/Zend/tests/list_004.phpt new file mode 100644 index 0000000..862a4e4 --- /dev/null +++ b/Zend/tests/list_004.phpt @@ -0,0 +1,21 @@ +--TEST-- +list() with array reference +--FILE-- +<?php + +$arr = array(2, 1); +$b =& $arr; + +list(,$a) = $b; + +var_dump($a, $b); + +?> +--EXPECT-- +int(1) +array(2) { + [0]=> + int(2) + [1]=> + int(1) +} diff --git a/Zend/tests/list_005.phpt b/Zend/tests/list_005.phpt new file mode 100644 index 0000000..4afc353 --- /dev/null +++ b/Zend/tests/list_005.phpt @@ -0,0 +1,47 @@ +--TEST-- +Testing list() with several variables +--FILE-- +<?php + +$a = "foo"; + +list($a, $b, $c) = $a; + +var_dump($a, $b, $c); + +print "----\n"; + +$a = 1; + +list($a, $b, $c) = $a; + +var_dump($a, $b, $c); + +print "----\n"; + +$a = new stdClass; + +list($a, $b, $c) = $a; + +var_dump($a, $b, $c); + +print "----\n"; + +$a = array(1, 2, 3); + +list($a, $b, $c) = $a; + +var_dump($a, $b, $c); + +?> +--EXPECTF-- +string(1) "f" +string(1) "o" +string(1) "o" +---- +NULL +NULL +NULL +---- + +Fatal error: Cannot use object of type stdClass as array in %s on line %d diff --git a/Zend/tests/list_006.phpt b/Zend/tests/list_006.phpt new file mode 100644 index 0000000..f5f5970 --- /dev/null +++ b/Zend/tests/list_006.phpt @@ -0,0 +1,14 @@ +--TEST-- +Testing nested list() with empty array +--FILE-- +<?php + +list($a, list($b, list(list($d)))) = array(); + +?> +--EXPECTF-- +Notice: Undefined offset: 1 in %s on line %d + +Notice: Undefined offset: 1 in %s on line %d + +Notice: Undefined offset: 0 in %s on line %d diff --git a/Zend/tests/list_007.phpt b/Zend/tests/list_007.phpt new file mode 100644 index 0000000..35a25bc --- /dev/null +++ b/Zend/tests/list_007.phpt @@ -0,0 +1,13 @@ +--TEST-- +Using lambda with list() +--FILE-- +<?php + +list($x, $y) = function() { }; + +var_dump($x, $y); + +?> +--EXPECT-- +NULL +NULL diff --git a/Zend/tests/lsb_001.phpt b/Zend/tests/lsb_001.phpt new file mode 100644 index 0000000..20a2fd8 --- /dev/null +++ b/Zend/tests/lsb_001.phpt @@ -0,0 +1,61 @@ +--TEST-- +ZE2 Late Static Binding in a static function +--FILE-- +<?php + +class TestClass { + protected static $staticVar = 'TestClassStatic'; + const CLASS_CONST = 'TestClassConst'; + + protected static function staticFunction() { + return 'TestClassFunction'; + } + + public static function testStaticVar() { + return static::$staticVar; + } + + public static function testClassConst() { + return static::CLASS_CONST; + } + + public static function testStaticFunction() { + return static::staticFunction(); + } +} + +class ChildClass1 extends TestClass { + protected static $staticVar = 'ChildClassStatic'; + const CLASS_CONST = 'ChildClassConst'; + + protected static function staticFunction() { + return 'ChildClassFunction'; + } +} + +class ChildClass2 extends TestClass {} + +echo TestClass::testStaticVar() . "\n"; +echo TestClass::testClassConst() . "\n"; +echo TestClass::testStaticFunction() . "\n"; + +echo ChildClass1::testStaticVar() . "\n"; +echo ChildClass1::testClassConst() . "\n"; +echo ChildClass1::testStaticFunction() . "\n"; + +echo ChildClass2::testStaticVar() . "\n"; +echo ChildClass2::testClassConst() . "\n"; +echo ChildClass2::testStaticFunction() . "\n"; +?> +==DONE== +--EXPECTF-- +TestClassStatic +TestClassConst +TestClassFunction +ChildClassStatic +ChildClassConst +ChildClassFunction +TestClassStatic +TestClassConst +TestClassFunction +==DONE== diff --git a/Zend/tests/lsb_002.phpt b/Zend/tests/lsb_002.phpt new file mode 100644 index 0000000..4fca6dd --- /dev/null +++ b/Zend/tests/lsb_002.phpt @@ -0,0 +1,66 @@ +--TEST-- +ZE2 Late Static Binding in an instance function +--FILE-- +<?php + +class TestClass { + protected static $staticVar = 'TestClassStatic'; + const CLASS_CONST = 'TestClassConst'; + + protected static function staticFunction() { + return 'TestClassFunction'; + } + + public function testStaticVar() { + return static::$staticVar; + } + + public function testClassConst() { + return static::CLASS_CONST; + } + + public function testStaticFunction() { + return static::staticFunction(); + } +} + +class ChildClass1 extends TestClass { + protected static $staticVar = 'ChildClassStatic'; + const CLASS_CONST = 'ChildClassConst'; + + protected static function staticFunction() { + return 'ChildClassFunction'; + } +} + +class ChildClass2 extends TestClass {} + +$testClass = new TestClass(); +$childClass1 = new ChildClass1(); +$childClass2 = new ChildClass2(); + + +echo $testClass->testStaticVar() . "\n"; +echo $testClass->testClassConst() . "\n"; +echo $testClass->testStaticFunction() . "\n"; + +echo $childClass1->testStaticVar() . "\n"; +echo $childClass1->testClassConst() . "\n"; +echo $childClass1->testStaticFunction() . "\n"; + +echo $childClass2->testStaticVar() . "\n"; +echo $childClass2->testClassConst() . "\n"; +echo $childClass2->testStaticFunction() . "\n"; +?> +==DONE== +--EXPECTF-- +TestClassStatic +TestClassConst +TestClassFunction +ChildClassStatic +ChildClassConst +ChildClassFunction +TestClassStatic +TestClassConst +TestClassFunction +==DONE== diff --git a/Zend/tests/lsb_003.phpt b/Zend/tests/lsb_003.phpt new file mode 100644 index 0000000..4e9fe1f --- /dev/null +++ b/Zend/tests/lsb_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +ZE2 Late Static Binding creating a new class with 'static' +--FILE-- +<?php + +class TestClass { + public static function createInstance() { + return new static(); + } +} + +class ChildClass extends TestClass {} + +$testClass = TestClass::createInstance(); +$childClass = ChildClass::createInstance(); + +echo get_class($testClass) . "\n"; +echo get_class($childClass) . "\n"; +?> +==DONE== +--EXPECTF-- +TestClass +ChildClass +==DONE== diff --git a/Zend/tests/lsb_004.phpt b/Zend/tests/lsb_004.phpt new file mode 100644 index 0000000..6baeba0 --- /dev/null +++ b/Zend/tests/lsb_004.phpt @@ -0,0 +1,21 @@ +--TEST-- +ZE2 Late Static Binding testing get_called_class() +--FILE-- +<?php + +class TestClass { + public static function getClassName() { + return get_called_class(); + } +} + +class ChildClass extends TestClass {} + +echo TestClass::getClassName() . "\n"; +echo ChildClass::getClassName() . "\n"; +?> +==DONE== +--EXPECTF-- +TestClass +ChildClass +==DONE== diff --git a/Zend/tests/lsb_005.phpt b/Zend/tests/lsb_005.phpt new file mode 100644 index 0000000..00647a5 --- /dev/null +++ b/Zend/tests/lsb_005.phpt @@ -0,0 +1,51 @@ +--TEST-- +ZE2 Late Static Binding stacking static calleds +--FILE-- +<?php + +class TestA { + public static function test() { + echo get_class(new static()) . "\n"; + TestB::test(); + echo get_class(new static()) . "\n"; + TestC::test(); + echo get_class(new static()) . "\n"; + TestBB::test(); + echo get_class(new static()) . "\n"; + } +} + +class TestB { + public static function test() { + echo get_class(new static()) . "\n"; + TestC::test(); + echo get_class(new static()) . "\n"; + } +} + +class TestC { + public static function test() { + echo get_class(new static()) . "\n"; + } +} + +class TestBB extends TestB { +} + +TestA::test(); + +?> +==DONE== +--EXPECTF-- +TestA +TestB +TestC +TestB +TestA +TestC +TestA +TestBB +TestC +TestBB +TestA +==DONE== diff --git a/Zend/tests/lsb_006.phpt b/Zend/tests/lsb_006.phpt new file mode 100644 index 0000000..84cd22a --- /dev/null +++ b/Zend/tests/lsb_006.phpt @@ -0,0 +1,13 @@ +--TEST-- +ZE2 Late Static Binding ensuring extending 'static' is not allowed +--FILE-- +<?php + +class Foo extends static { +} + +?> +==DONE== +--EXPECTF-- +Parse error: %s error,%sexpecting %s in %s on line %d + diff --git a/Zend/tests/lsb_007.phpt b/Zend/tests/lsb_007.phpt new file mode 100644 index 0000000..607f8ef --- /dev/null +++ b/Zend/tests/lsb_007.phpt @@ -0,0 +1,13 @@ +--TEST-- +ZE2 Late Static Binding ensuring implementing 'static' is not allowed +--FILE-- +<?php + +class Foo implements static { +} + +?> +==DONE== +--EXPECTF-- +Parse error: %s error,%sexpecting %s in %s on line %d + diff --git a/Zend/tests/lsb_008.phpt b/Zend/tests/lsb_008.phpt new file mode 100644 index 0000000..b700e2d --- /dev/null +++ b/Zend/tests/lsb_008.phpt @@ -0,0 +1,9 @@ +--TEST-- +ZE2 Late Static Binding class name "static" +--FILE-- +<?php +class static { +} +--EXPECTF-- +Parse error: %s error,%sexpecting %s in %s on line %d + diff --git a/Zend/tests/lsb_009.phpt b/Zend/tests/lsb_009.phpt new file mode 100644 index 0000000..d8d4181 --- /dev/null +++ b/Zend/tests/lsb_009.phpt @@ -0,0 +1,9 @@ +--TEST-- +ZE2 Late Static Binding interface name "static" +--FILE-- +<?php +interface static { +} +--EXPECTF-- +Parse error: %s error,%sexpecting %s in %s on line %d + diff --git a/Zend/tests/lsb_010.phpt b/Zend/tests/lsb_010.phpt new file mode 100644 index 0000000..2ac0306 --- /dev/null +++ b/Zend/tests/lsb_010.phpt @@ -0,0 +1,38 @@ +--TEST-- +ZE2 Late Static Binding using static:: in functions called by non execute() calls and constructors. +--FILE-- +<?php + +class Foo { + protected static $className = 'Foo'; + public static function bar() { + echo static::$className . "::bar\n"; + } + public function __construct() { + echo static::$className . "::__construct\n"; + } + public function __destruct() { + echo static::$className . "::__destruct\n"; + } +} + +class FooChild extends Foo { + protected static $className = 'FooChild'; +} + +register_shutdown_function(array('Foo', 'bar')); +register_shutdown_function(array('FooChild', 'bar')); + +$foo = new Foo(); +$fooChild = new FooChild(); +unset($foo); +unset($fooChild); + +?> +--EXPECTF-- +Foo::__construct +FooChild::__construct +Foo::__destruct +FooChild::__destruct +Foo::bar +FooChild::bar diff --git a/Zend/tests/lsb_011.phpt b/Zend/tests/lsb_011.phpt new file mode 100644 index 0000000..3c5bbbe --- /dev/null +++ b/Zend/tests/lsb_011.phpt @@ -0,0 +1,23 @@ +--TEST-- +ZE2 Late Static Binding call to static::method() from internal function (array) +--FILE-- +<?php + +class Test1 { + static function ok() { + echo "bug"; + } + static function test() { + call_user_func(array("static","ok")); + } +} + +class Test2 extends Test1 { + static function ok() { + echo "ok"; + } +} +Test2::test(); +?> +--EXPECT-- +ok diff --git a/Zend/tests/lsb_012.phpt b/Zend/tests/lsb_012.phpt new file mode 100644 index 0000000..3ac8d38 --- /dev/null +++ b/Zend/tests/lsb_012.phpt @@ -0,0 +1,23 @@ +--TEST-- +ZE2 Late Static Binding call to static::method() from internal function (string) +--FILE-- +<?php + +class Test1 { + static function ok() { + echo "bug"; + } + static function test() { + call_user_func("static::ok"); + } +} + +class Test2 extends Test1 { + static function ok() { + echo "ok"; + } +} +Test2::test(); +?> +--EXPECT-- +ok diff --git a/Zend/tests/lsb_013.phpt b/Zend/tests/lsb_013.phpt new file mode 100644 index 0000000..3f32dc3 --- /dev/null +++ b/Zend/tests/lsb_013.phpt @@ -0,0 +1,24 @@ +--TEST-- +ZE2 Late Static Binding is_callable() and static::method() +--FILE-- +<?php + +class Test1 { + static function test() { + var_dump(is_callable("static::ok")); + var_dump(is_callable(array("static","ok"))); + } +} + +class Test2 extends Test1 { + static function ok() { + } +} +Test1::test(); +Test2::test(); +?> +--EXPECT-- +bool(false) +bool(false) +bool(true) +bool(true) diff --git a/Zend/tests/lsb_014.phpt b/Zend/tests/lsb_014.phpt new file mode 100644 index 0000000..19cf913 --- /dev/null +++ b/Zend/tests/lsb_014.phpt @@ -0,0 +1,24 @@ +--TEST-- +ZE2 Late Static Binding access to static::const through defined() and get_constant() +--FILE-- +<?php + +class Test1 { + static function test() { + var_dump(defined("static::ok")); + if (defined("static::ok")) { + echo constant("static::ok"); + } + } +} + +class Test2 extends Test1 { + const ok = "ok"; +} +Test1::test(); +Test2::test(); +?> +--EXPECT-- +bool(false) +bool(true) +ok diff --git a/Zend/tests/lsb_015.phpt b/Zend/tests/lsb_015.phpt new file mode 100644 index 0000000..ba293a2 --- /dev/null +++ b/Zend/tests/lsb_015.phpt @@ -0,0 +1,92 @@ +--TEST-- +ZE2 Late Static Binding with exceptions +--FILE-- +<?php +function foo() { + B::throwException(); +} +class C { + public static function bla() { + B::throwException(); + } + public static function getException() { + return new Exception(); + + } +} +class A { + + public static function throwException_after() { + C::bla(); + } + public static function throwException() { + throw C::getException(); + } + public static function test() { + static::who(); + } + public static function who() { + echo "A\n"; + } + + public static function mycatch() { + try { + static::who(); + B::throwException_after(); + } catch(Exception $e) { + static::who(); + A::test(); + static::who(); + B::test(); + static::who(); + + self::simpleCatch(); + static::who(); + } + } + + public static function simpleCatch() { + try { + static::who(); + throw new Exception(); + } catch (Exception $e) { + static::who(); + } + } +} + +class B extends A { + public static function who() { + echo "B\n"; + } + +} + +echo "via A:\n"; +A::myCatch(); +echo "via B:\n"; +B::myCatch(); +?> +==DONE== +--EXPECTF-- +via A: +A +A +A +A +B +A +A +A +A +via B: +B +B +A +B +B +B +B +B +B +==DONE== diff --git a/Zend/tests/lsb_016.phpt b/Zend/tests/lsb_016.phpt new file mode 100644 index 0000000..f19c6aa --- /dev/null +++ b/Zend/tests/lsb_016.phpt @@ -0,0 +1,41 @@ +--TEST-- +ZE2 Late Static Binding within hooks/magic methods +--FILE-- +<?php + +class TestChild extends TestParent { + + public static function who() { + echo __CLASS__."\n"; + } +} + +class TestParent { + + public function __get($var) { + static::who(); + } + + public function __set($var, $val) { + static::who(); + } + + public function __call($name, $args) { + static::who(); + } + + public static function who() { + echo __CLASS__."\n"; + } +} +$o = new TestChild; +$o->test(); +$o->a = "b"; +echo $o->a; +?> +==DONE== +--EXPECTF-- +TestChild +TestChild +TestChild +==DONE== diff --git a/Zend/tests/lsb_017.phpt b/Zend/tests/lsb_017.phpt new file mode 100644 index 0000000..5f5ca43 --- /dev/null +++ b/Zend/tests/lsb_017.phpt @@ -0,0 +1,29 @@ +--TEST-- +ZE2 Late Static Binding nested calls +--FILE-- +<?php +class A { + public static function test($x=null) { + if (!is_null($x)) { + echo "$x\n"; + } + return get_called_class(); + } +} + +class B extends A { +} +class C extends A { +} +class D extends A { +} + +echo A::test(B::test(C::test(D::test())))."\n"; +?> +==DONE== +--EXPECT-- +D +C +B +A +==DONE== diff --git a/Zend/tests/lsb_018.phpt b/Zend/tests/lsb_018.phpt new file mode 100644 index 0000000..c7877cd --- /dev/null +++ b/Zend/tests/lsb_018.phpt @@ -0,0 +1,95 @@ +--TEST-- +ZE2 Late Static Binding and Singleton +--FILE-- +<?php +abstract class Singleton +{ + static private $instances = array(); + static private $nextInstanceId = 0; + private $instanceId = NULL; + static final public function getInstance() + { + $caller = get_called_class(); + if (!isset(self::$instances[$caller])) { + self::$instances[$caller] = new $caller; + self::$instances[$caller]->instanceId = self::$nextInstanceId++; + } + return self::$instances[$caller]; + } + public final function getInstanceId() + { + return $this->instanceId; + } + public final function identify() + { + var_dump($this); + } +} + +class Foo extends Singleton { +} + +class Bar extends Singleton { +} + +class Baz extends Bar { +} + +$u = Foo::getInstance(); +$v = Bar::getInstance(); +$w = Baz::getInstance(); + +$u->identify(); +$v->identify(); +$w->identify(); + +$x = Foo::getInstance(); +$y = Bar::getInstance(); +$z = Baz::getInstance(); + +$u->identify(); +$v->identify(); +$w->identify(); +$x->identify(); +$y->identify(); +$z->identify(); +?> +===DONE=== +--EXPECTF-- +object(Foo)#%d (1) { + ["instanceId":"Singleton":private]=> + int(0) +} +object(Bar)#%d (1) { + ["instanceId":"Singleton":private]=> + int(1) +} +object(Baz)#%d (1) { + ["instanceId":"Singleton":private]=> + int(2) +} +object(Foo)#%d (1) { + ["instanceId":"Singleton":private]=> + int(0) +} +object(Bar)#%d (1) { + ["instanceId":"Singleton":private]=> + int(1) +} +object(Baz)#%d (1) { + ["instanceId":"Singleton":private]=> + int(2) +} +object(Foo)#%d (1) { + ["instanceId":"Singleton":private]=> + int(0) +} +object(Bar)#%d (1) { + ["instanceId":"Singleton":private]=> + int(1) +} +object(Baz)#%d (1) { + ["instanceId":"Singleton":private]=> + int(2) +} +===DONE=== diff --git a/Zend/tests/lsb_019.phpt b/Zend/tests/lsb_019.phpt new file mode 100644 index 0000000..1683ffe --- /dev/null +++ b/Zend/tests/lsb_019.phpt @@ -0,0 +1,48 @@ +--TEST-- +ZE2 Late Static Binding properties and methods declared as protected and overridden as public. +--FILE-- +<?php +class TestClass { + protected static $staticVar; + + protected static function staticFunction() { + return 'TestClassFunction'; + } + + public static function testStaticVar() { + TestClass::$staticVar = 'TestClassStatic'; + ChildClass1::$staticVar = 'ChildClassStatic'; + return static::$staticVar; + } + + public static function testStaticFunction() { + return static::staticFunction(); + } +} + +class ChildClass1 extends TestClass { + public static $staticVar; + + public static function staticFunction() { + return 'ChildClassFunction'; + } +} + +class ChildClass2 extends TestClass {} + +echo TestClass::testStaticVar() . "\n"; +echo TestClass::testStaticFunction() . "\n"; + +echo ChildClass1::testStaticVar() . "\n"; +echo ChildClass1::testStaticFunction() . "\n"; + +echo ChildClass2::testStaticVar() . "\n"; +echo ChildClass2::testStaticFunction() . "\n"; +?> +--EXPECTF-- +TestClassStatic +TestClassFunction +ChildClassStatic +ChildClassFunction +TestClassStatic +TestClassFunction diff --git a/Zend/tests/lsb_020.phpt b/Zend/tests/lsb_020.phpt new file mode 100644 index 0000000..65ef97a --- /dev/null +++ b/Zend/tests/lsb_020.phpt @@ -0,0 +1,48 @@ +--TEST-- +ZE2 Late Static Binding properties and methods declared as public and overridden as public. +--FILE-- +<?php +class TestClass { + public static $staticVar; + + public static function staticFunction() { + return 'TestClassFunction'; + } + + public static function testStaticVar() { + TestClass::$staticVar = 'TestClassStatic'; + ChildClass1::$staticVar = 'ChildClassStatic'; + return static::$staticVar; + } + + public static function testStaticFunction() { + return static::staticFunction(); + } +} + +class ChildClass1 extends TestClass { + public static $staticVar; + + public static function staticFunction() { + return 'ChildClassFunction'; + } +} + +class ChildClass2 extends TestClass {} + +echo TestClass::testStaticVar() . "\n"; +echo TestClass::testStaticFunction() . "\n"; + +echo ChildClass1::testStaticVar() . "\n"; +echo ChildClass1::testStaticFunction() . "\n"; + +echo ChildClass2::testStaticVar() . "\n"; +echo ChildClass2::testStaticFunction() . "\n"; +?> +--EXPECTF-- +TestClassStatic +TestClassFunction +ChildClassStatic +ChildClassFunction +TestClassStatic +TestClassFunction diff --git a/Zend/tests/lsb_021.phpt b/Zend/tests/lsb_021.phpt new file mode 100644 index 0000000..c591cfa --- /dev/null +++ b/Zend/tests/lsb_021.phpt @@ -0,0 +1,50 @@ +--TEST-- +ZE2 Late Static Binding parent::/self:: forwarding while classname doesn't +--FILE-- +<?php +class A { + public static function test() { + echo get_called_class()."\n"; + } +} + +class B extends A { + public static function testForward() { + parent::test(); + call_user_func("parent::test"); + call_user_func(array("parent", "test")); + self::test(); + call_user_func("self::test"); + call_user_func(array("self", "test")); + } + public static function testNoForward() { + A::test(); + call_user_func("A::test"); + call_user_func(array("A", "test")); + B::test(); + call_user_func("B::test"); + call_user_func(array("B", "test")); + } +} + +class C extends B { + +} + +C::testForward(); +C::testNoForward(); + +?> +--EXPECTF-- +C +C +C +C +C +C +A +A +A +B +B +B diff --git a/Zend/tests/lsb_022.phpt b/Zend/tests/lsb_022.phpt new file mode 100644 index 0000000..016fde8 --- /dev/null +++ b/Zend/tests/lsb_022.phpt @@ -0,0 +1,31 @@ +--TEST-- +ZE2 Late Static Binding parent::/self:: forwarding and __callStatic +--FILE-- +<?php +class A { + static function test() { + echo "A\n"; + } + static function __callstatic($name, $args) { + call_user_func("static::test"); + } +} +class B extends A { + static function test() { + echo "B\n"; + } + static function __callstatic($name, $args) { + parent::__callstatic($name, $args); + call_user_func_array("parent::__callstatic", array($name, $args)); + parent::foo(); + call_user_func_array("parent::foo", $args); + call_user_func_array(array("parent","foo"), $args); + } +} +B::foo(); +--EXPECT-- +B +B +B +B +B diff --git a/Zend/tests/magic_by_ref_001.phpt b/Zend/tests/magic_by_ref_001.phpt new file mode 100644 index 0000000..e9bcf8f --- /dev/null +++ b/Zend/tests/magic_by_ref_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +passing first parameter of __set() by ref +--FILE-- +<?php + +class test { + function __set(&$name, $val) { } +} + +$t = new test; +$name = "prop"; +$t->$name = 1; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__set() cannot take arguments by reference in %s on line %d diff --git a/Zend/tests/magic_by_ref_002.phpt b/Zend/tests/magic_by_ref_002.phpt new file mode 100644 index 0000000..cb62f67 --- /dev/null +++ b/Zend/tests/magic_by_ref_002.phpt @@ -0,0 +1,16 @@ +--TEST-- +passing second parameter of __set() by ref +--FILE-- +<?php + +class test { + function __set($name, &$val) { } +} + +$t = new test; +$t->prop = 1; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__set() cannot take arguments by reference in %s on line %d diff --git a/Zend/tests/magic_by_ref_003.phpt b/Zend/tests/magic_by_ref_003.phpt new file mode 100644 index 0000000..022cbd5 --- /dev/null +++ b/Zend/tests/magic_by_ref_003.phpt @@ -0,0 +1,17 @@ +--TEST-- +passing parameter of __get() by ref +--FILE-- +<?php + +class test { + function __get(&$name) { } +} + +$t = new test; +$name = "prop"; +var_dump($t->$name); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__get() cannot take arguments by reference in %s on line %d diff --git a/Zend/tests/magic_by_ref_004.phpt b/Zend/tests/magic_by_ref_004.phpt new file mode 100644 index 0000000..aa04d1a --- /dev/null +++ b/Zend/tests/magic_by_ref_004.phpt @@ -0,0 +1,18 @@ +--TEST-- +passing parameter of __unset() by ref +--FILE-- +<?php + +class test { + function __unset(&$name) { } +} + +$t = new test; +$name = "prop"; + +var_dump($t->$name); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__unset() cannot take arguments by reference in %s on line %d diff --git a/Zend/tests/magic_by_ref_005.phpt b/Zend/tests/magic_by_ref_005.phpt new file mode 100644 index 0000000..513c061 --- /dev/null +++ b/Zend/tests/magic_by_ref_005.phpt @@ -0,0 +1,18 @@ +--TEST-- +passing parameter of __isset() by ref +--FILE-- +<?php + +class test { + function __isset(&$name) { } +} + +$t = new test; +$name = "prop"; + +var_dump(isset($t->$name)); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__isset() cannot take arguments by reference in %s on line %d diff --git a/Zend/tests/magic_by_ref_006.phpt b/Zend/tests/magic_by_ref_006.phpt new file mode 100644 index 0000000..14d7d70 --- /dev/null +++ b/Zend/tests/magic_by_ref_006.phpt @@ -0,0 +1,18 @@ +--TEST-- +passing first parameter of __call() by ref +--FILE-- +<?php + +class test { + function __call(&$name, $args) { } +} + +$t = new test; +$func = "foo"; + +$t->$func(); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__call() cannot take arguments by reference in %s on line %d diff --git a/Zend/tests/magic_by_ref_007.phpt b/Zend/tests/magic_by_ref_007.phpt new file mode 100644 index 0000000..c962d45 --- /dev/null +++ b/Zend/tests/magic_by_ref_007.phpt @@ -0,0 +1,19 @@ +--TEST-- +passing second parameter of __call() by ref +--FILE-- +<?php + +class test { + function __call($name, &$args) { } +} + +$t = new test; +$func = "foo"; +$arg = 1; + +$t->$func($arg); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__call() cannot take arguments by reference in %s on line %d diff --git a/Zend/tests/magic_methods_001.phpt b/Zend/tests/magic_methods_001.phpt new file mode 100644 index 0000000..45701bf --- /dev/null +++ b/Zend/tests/magic_methods_001.phpt @@ -0,0 +1,49 @@ +--TEST-- +Testing several magic methods +--FILE-- +<?php + +class foo { + function __unset($a) { + print "unset\n"; + var_dump($a); + } + + public function __call($a, $b) { + print "call\n"; + var_dump($a); + } + function __clone() { + print "clone\n"; + } + static public function __callstatic($a, $b) { + print "callstatic\n"; + } + + public function __tostring() { + return 'foo'; + } +} + + +$a = new foo; + +$a->sdfdsa(); + +$a::test(); + +clone $a; + +var_dump((string)$a); + +unset($a->a); + +?> +--EXPECT-- +call +string(6) "sdfdsa" +callstatic +clone +string(3) "foo" +unset +string(1) "a" diff --git a/Zend/tests/magic_methods_002.phpt b/Zend/tests/magic_methods_002.phpt new file mode 100644 index 0000000..fe0a4dc --- /dev/null +++ b/Zend/tests/magic_methods_002.phpt @@ -0,0 +1,14 @@ +--TEST-- +Testing __unset with private visibility +--FILE-- +<?php + +class foo { + private function __unset($a) { + print "unset\n"; + } +} + +?> +--EXPECTF-- +Warning: The magic method __unset() must have public visibility and cannot be static in %s on line %d diff --git a/Zend/tests/magic_methods_003.phpt b/Zend/tests/magic_methods_003.phpt new file mode 100644 index 0000000..be354ec --- /dev/null +++ b/Zend/tests/magic_methods_003.phpt @@ -0,0 +1,14 @@ +--TEST-- +Testing __unset declaring as static +--FILE-- +<?php + +class foo { + static function __unset($a) { + print "unset\n"; + } +} + +?> +--EXPECTF-- +Warning: The magic method __unset() must have public visibility and cannot be static in %s on line %d diff --git a/Zend/tests/magic_methods_004.phpt b/Zend/tests/magic_methods_004.phpt new file mode 100644 index 0000000..33a0a60 --- /dev/null +++ b/Zend/tests/magic_methods_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +Testing __unset() with protected visibility +--FILE-- +<?php + +class foo { + protected function __unset($a) { + print "unset\n"; + } +} + +?> +--EXPECTF-- +Warning: The magic method __unset() must have public visibility and cannot be static in %s on line %d diff --git a/Zend/tests/magic_methods_005.phpt b/Zend/tests/magic_methods_005.phpt new file mode 100644 index 0000000..76ab300 --- /dev/null +++ b/Zend/tests/magic_methods_005.phpt @@ -0,0 +1,12 @@ +--TEST-- +Testing __call() declaration in interface with wrong modifier +--FILE-- +<?php + +interface a { + static function __call($a, $b); +} + +?> +--EXPECTF-- +Warning: The magic method __call() must have public visibility and cannot be static in %s on line %d diff --git a/Zend/tests/magic_methods_006.phpt b/Zend/tests/magic_methods_006.phpt new file mode 100644 index 0000000..2e84a41 --- /dev/null +++ b/Zend/tests/magic_methods_006.phpt @@ -0,0 +1,12 @@ +--TEST-- +Testing __callstatic declaration in interface with missing the 'static' modifier +--FILE-- +<?php + +interface a { + function __callstatic($a, $b); +} + +?> +--EXPECTF-- +Warning: The magic method __callStatic() must have public visibility and be static in %s on line %d diff --git a/Zend/tests/magic_methods_007.phpt b/Zend/tests/magic_methods_007.phpt new file mode 100644 index 0000000..0630c63 --- /dev/null +++ b/Zend/tests/magic_methods_007.phpt @@ -0,0 +1,14 @@ +--TEST-- +Testing __set() declaration in abstract class with wrong modifier +--FILE-- +<?php + +abstract class b { + abstract protected function __set($a); +} + +?> +--EXPECTF-- +Warning: The magic method __set() must have public visibility and cannot be static in %s on line %d + +Fatal error: Method b::__set() must take exactly 2 arguments in %s on line %d diff --git a/Zend/tests/magic_methods_008.phpt b/Zend/tests/magic_methods_008.phpt new file mode 100644 index 0000000..61c4fa0 --- /dev/null +++ b/Zend/tests/magic_methods_008.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing __set implementation with wrong declaration +--FILE-- +<?php + +abstract class b { + abstract function __set($a, $b); +} + +class a extends b { + private function __set($a, $b) { + } +} + +?> +--EXPECTF-- +Warning: The magic method __set() must have public visibility and cannot be static in %s on line %d + +Fatal error: Access level to a::__set() must be public (as in class b) in %s on line %d diff --git a/Zend/tests/magic_methods_009.phpt b/Zend/tests/magic_methods_009.phpt new file mode 100644 index 0000000..2b514c3 --- /dev/null +++ b/Zend/tests/magic_methods_009.phpt @@ -0,0 +1,13 @@ +--TEST-- +Testing __callstatic declaration with wrong modifier +--FILE-- +<?php + +class a { + static protected function __callstatic($a, $b) { + } +} + +?> +--EXPECTF-- +Warning: The magic method __callStatic() must have public visibility and be static in %s on line %d diff --git a/Zend/tests/magic_methods_010.phpt b/Zend/tests/magic_methods_010.phpt new file mode 100644 index 0000000..06d46db --- /dev/null +++ b/Zend/tests/magic_methods_010.phpt @@ -0,0 +1,15 @@ +--TEST-- +Testing __toString() declaration with wrong modifier +--FILE-- +<?php + +class a { + static protected function __toString($a, $b) { + } +} + +?> +--EXPECTF-- +Warning: The magic method __toString() must have public visibility and cannot be static in %s on line %d + +Fatal error: Method a::__tostring() cannot take arguments in %s on line %d diff --git a/Zend/tests/method_exists.phpt b/Zend/tests/method_exists.phpt new file mode 100644 index 0000000..63ea3bd --- /dev/null +++ b/Zend/tests/method_exists.phpt @@ -0,0 +1,11 @@ +--TEST-- +method_exists() segfaults +--FILE-- +<?php +class testclass { function testfunc() { } } +var_dump(method_exists('testclass','testfunc')); +var_dump(method_exists('testclass','nonfunc')); +?> +--EXPECT-- +bool(true) +bool(false) diff --git a/Zend/tests/method_exists_002.phpt b/Zend/tests/method_exists_002.phpt new file mode 100644 index 0000000..cd49bdf --- /dev/null +++ b/Zend/tests/method_exists_002.phpt @@ -0,0 +1,74 @@ +--TEST-- +Testing method_exists() +--FILE-- +<?php + +class bar { + static public function stat_a2() { + } + static private function stat_b2() { + } + static protected function stat_c2() { + } + + private function method_a() { + } + protected function method_b() { + } + public function method_c() { + } +} + + + +class baz extends bar { + static public function stat_a() { + } + static private function stat_b() { + } + static protected function stat_c() { + } + + private function method_a() { + } + protected function method_b() { + } + public function method_c() { + } +} + +var_dump(method_exists('baz', 'stat_a')); +var_dump(method_exists('baz', 'stat_b')); +var_dump(method_exists('baz', 'stat_c')); +print "----\n"; +var_dump(method_exists('baz', 'stat_a2')); +var_dump(method_exists('baz', 'stat_b2')); +var_dump(method_exists('baz', 'stat_c2')); +print "----\n"; + +$baz = new baz; +var_dump(method_exists($baz, 'method_a')); +var_dump(method_exists($baz, 'method_b')); +var_dump(method_exists($baz, 'method_c')); +print "----\n"; +var_dump(method_exists($baz, 'stat_a')); +var_dump(method_exists($baz, 'stat_b')); +var_dump(method_exists($baz, 'stat_c')); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +---- +bool(true) +bool(true) +bool(true) +---- +bool(true) +bool(true) +bool(true) +---- +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/method_static_var.phpt b/Zend/tests/method_static_var.phpt new file mode 100644 index 0000000..c5e82fe --- /dev/null +++ b/Zend/tests/method_static_var.phpt @@ -0,0 +1,30 @@ +--TEST-- +Initial value of static var in method depends on the include time of the class definition +--XFAIL-- +Maybe not a bug +--FILE-- +<?php +class Foo { + public function __construct() { + eval("class Bar extends Foo {}"); + } + public static function test() { + static $i = 0; + var_dump(++$i); + } +} + +foo::test(); +new Foo; +foo::test(); + +/** + * function_add_ref() makes a clone of static variables for inherited functions, so $i in Bar::test gets initial value 1 + */ +Bar::test(); +Bar::test(); +--EXPECT-- +int(1) +int(2) +int(1) +int(2) diff --git a/Zend/tests/mod_001.phpt b/Zend/tests/mod_001.phpt new file mode 100644 index 0000000..88596f3 --- /dev/null +++ b/Zend/tests/mod_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +modulus by zero +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(); + +$c = $a % $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Division by zero in %s on line %d +bool(false) +Done diff --git a/Zend/tests/mul_001.phpt b/Zend/tests/mul_001.phpt new file mode 100644 index 0000000..4c5a75e --- /dev/null +++ b/Zend/tests/mul_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +multiplying arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a * $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/multibyte/multibyte_encoding_001.phpt b/Zend/tests/multibyte/multibyte_encoding_001.phpt new file mode 100644 index 0000000..38aa80a --- /dev/null +++ b/Zend/tests/multibyte/multibyte_encoding_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +Zend Multibyte and ShiftJIS +--SKIPIF-- +<?php +if (!in_array("zend.detect_unicode", array_keys(ini_get_all()))) { + die("skip Requires configure --enable-zend-multibyte option"); +} +if (!extension_loaded("mbstring")) { + die("skip Requires mbstring extension"); +} +?> +--INI-- +zend.multibyte=1 +mbstring.internal_encoding=SJIS +--FILE-- +<?php +declare(encoding='Shift_JIS'); +$s = "•\"; // 0x95+0x5c in script, not somewhere else " +printf("%x:%x\n", ord($s[0]), ord($s[1])); +?> +===DONE=== +--EXPECT-- +95:5c +===DONE=== diff --git a/Zend/tests/multibyte/multibyte_encoding_002.phpt b/Zend/tests/multibyte/multibyte_encoding_002.phpt new file mode 100644 index 0000000..6e1ad80 --- /dev/null +++ b/Zend/tests/multibyte/multibyte_encoding_002.phpt @@ -0,0 +1,22 @@ +--TEST-- +Zend Multibyte and UTF-8 BOM +--SKIPIF-- +<?php +if (!in_array("zend.detect_unicode", array_keys(ini_get_all()))) { + die("skip Requires configure --enable-zend-multibyte option"); +} +if (!extension_loaded("mbstring")) { + die("skip Requires mbstring extension"); +} +?> +--INI-- +zend.multibyte=1 +mbstring.internal_encoding=iso-8859-1 +--FILE-- +<?php +print "Hello World\n"; +?> +===DONE=== +--EXPECT-- +Hello World +===DONE=== diff --git a/Zend/tests/multibyte/multibyte_encoding_003.phpt b/Zend/tests/multibyte/multibyte_encoding_003.phpt Binary files differnew file mode 100644 index 0000000..0f873dd --- /dev/null +++ b/Zend/tests/multibyte/multibyte_encoding_003.phpt diff --git a/Zend/tests/multibyte/multibyte_encoding_004.phpt b/Zend/tests/multibyte/multibyte_encoding_004.phpt new file mode 100644 index 0000000..6d121d6 --- /dev/null +++ b/Zend/tests/multibyte/multibyte_encoding_004.phpt @@ -0,0 +1,26 @@ +--TEST-- +test for mbstring script_encoding for flex unsafe encoding (Shift_JIS) +--SKIPIF-- +<?php +if (!in_array("zend.detect_unicode", array_keys(ini_get_all()))) { + die("skip Requires configure --enable-zend-multibyte option"); +} +if (!extension_loaded("mbstring")) { + die("skip Requires mbstring extension"); +} +?> +--INI-- +zend.multibyte=1 +zend.script_encoding=Shift_JIS +mbstring.internal_encoding=Shift_JIS +--FILE-- +<?php + function —\Ž\”\($ˆø”) + { + echo $ˆø”; + } + + —\Ž\”\("ƒhƒŒƒ~ƒtƒ@ƒ\"); +?> +--EXPECT-- +ƒhƒŒƒ~ƒtƒ@ƒ\ diff --git a/Zend/tests/multibyte/multibyte_encoding_005.phpt b/Zend/tests/multibyte/multibyte_encoding_005.phpt new file mode 100644 index 0000000..6fee687 --- /dev/null +++ b/Zend/tests/multibyte/multibyte_encoding_005.phpt @@ -0,0 +1,27 @@ +--TEST-- +encoding conversion from script encoding into internal encoding +--SKIPIF-- +<?php +if (!in_array("zend.detect_unicode", array_keys(ini_get_all()))) { + die("skip Requires configure --enable-zend-multibyte option"); +} +if (!extension_loaded("mbstring")) { + die("skip Requires mbstring extension"); +} +?> +--INI-- +zend.multibyte=1 +mbstring.encoding_translation = On +zend.script_encoding=Shift_JIS +mbstring.internal_encoding=UTF-8 +--FILE-- +<?php + function —\Ž\”\($ˆø”) + { + echo $ˆø”; + } + + —\Ž\”\("ƒhƒŒƒ~ƒtƒ@ƒ\"); +?> +--EXPECT-- +ドレミファソ diff --git a/Zend/tests/multibyte/multibyte_encoding_006.phpt b/Zend/tests/multibyte/multibyte_encoding_006.phpt Binary files differnew file mode 100644 index 0000000..b87b434 --- /dev/null +++ b/Zend/tests/multibyte/multibyte_encoding_006.phpt diff --git a/Zend/tests/not_001.phpt b/Zend/tests/not_001.phpt new file mode 100644 index 0000000..6eb0f00 --- /dev/null +++ b/Zend/tests/not_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +bitwise NOT, doubles and strings +--FILE-- +<?php + +$d = 23.67; +$s = "48484.22"; +$s1 = "test"; +$s2 = "some"; + +$s = ~$d; +var_dump($s); + +$s1 = ~$s2; +var_dump(bin2hex($s1)); + +echo "Done\n"; +?> +--EXPECTF-- +int(-24) +string(8) "8c90929a" +Done diff --git a/Zend/tests/not_002.phpt b/Zend/tests/not_002.phpt new file mode 100644 index 0000000..df27772 --- /dev/null +++ b/Zend/tests/not_002.phpt @@ -0,0 +1,15 @@ +--TEST-- +bitwise NOT and arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1,2); + +$a = ~$b; +var_dump($a); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/nowdoc.inc b/Zend/tests/nowdoc.inc new file mode 100644 index 0000000..98f9fba --- /dev/null +++ b/Zend/tests/nowdoc.inc @@ -0,0 +1,11 @@ +<?php + +// Common definitions for heredoc/nowdoc tests. +$a = 1; +$b = 2; +$c = array( 'c' => 3, ); +class d { public function __construct() { $this->d = 4; } }; +$d = new d; + +?> + diff --git a/Zend/tests/nowdoc_001.phpt b/Zend/tests/nowdoc_001.phpt new file mode 100644 index 0000000..3b9e3ef --- /dev/null +++ b/Zend/tests/nowdoc_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +basic nowdoc syntax +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<'ENDOFNOWDOC' +This is a nowdoc test. + +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +This is another nowdoc test. +With another line in it. +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is a nowdoc test. +This is another nowdoc test. +With another line in it. diff --git a/Zend/tests/nowdoc_002.phpt b/Zend/tests/nowdoc_002.phpt new file mode 100644 index 0000000..3b17da8 --- /dev/null +++ b/Zend/tests/nowdoc_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +basic binary nowdoc syntax +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print b<<<'ENDOFNOWDOC' +This is a nowdoc test. + +ENDOFNOWDOC; + +$x = b<<<'ENDOFNOWDOC' +This is another nowdoc test. + +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is a nowdoc test. +This is another nowdoc test. diff --git a/Zend/tests/nowdoc_003.phpt b/Zend/tests/nowdoc_003.phpt new file mode 100644 index 0000000..4282ab9 --- /dev/null +++ b/Zend/tests/nowdoc_003.phpt @@ -0,0 +1,23 @@ +--TEST-- +simple variable replacement test (nowdoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<'ENDOFNOWDOC' +This is nowdoc test #$a. + +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +This is nowdoc test #$b. + +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is nowdoc test #$a. +This is nowdoc test #$b. diff --git a/Zend/tests/nowdoc_004.phpt b/Zend/tests/nowdoc_004.phpt new file mode 100644 index 0000000..0e5b927 --- /dev/null +++ b/Zend/tests/nowdoc_004.phpt @@ -0,0 +1,23 @@ +--TEST-- +braces variable replacement test (nowdoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<'ENDOFNOWDOC' +This is nowdoc test #{$a}. + +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +This is nowdoc test #{$b}. + +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is nowdoc test #{$a}. +This is nowdoc test #{$b}. diff --git a/Zend/tests/nowdoc_005.phpt b/Zend/tests/nowdoc_005.phpt new file mode 100644 index 0000000..65e33d7 --- /dev/null +++ b/Zend/tests/nowdoc_005.phpt @@ -0,0 +1,23 @@ +--TEST-- +unbraced complex variable replacement test (nowdoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<'ENDOFNOWDOC' +This is nowdoc test #s $a, $b, $c['c'], and $d->d. + +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +This is nowdoc test #s $a, $b, $c['c'], and $d->d. + +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is nowdoc test #s $a, $b, $c['c'], and $d->d. +This is nowdoc test #s $a, $b, $c['c'], and $d->d. diff --git a/Zend/tests/nowdoc_006.phpt b/Zend/tests/nowdoc_006.phpt new file mode 100644 index 0000000..9d99973 --- /dev/null +++ b/Zend/tests/nowdoc_006.phpt @@ -0,0 +1,23 @@ +--TEST-- +braced complex variable replacement test (nowdoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<'ENDOFNOWDOC' +This is nowdoc test #s {$a}, {$b}, {$c['c']}, and {$d->d}. + +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +This is nowdoc test #s {$a}, {$b}, {$c['c']}, and {$d->d}. + +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is nowdoc test #s {$a}, {$b}, {$c['c']}, and {$d->d}. +This is nowdoc test #s {$a}, {$b}, {$c['c']}, and {$d->d}. diff --git a/Zend/tests/nowdoc_007.phpt b/Zend/tests/nowdoc_007.phpt new file mode 100644 index 0000000..d9e9411 --- /dev/null +++ b/Zend/tests/nowdoc_007.phpt @@ -0,0 +1,23 @@ +--TEST-- +braced and unbraced complex variable replacement test (nowdoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<'ENDOFNOWDOC' +This is nowdoc test #s $a, {$b}, {$c['c']}, and {$d->d}. + +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +This is nowdoc test #s $a, {$b}, {$c['c']}, and {$d->d}. + +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +This is nowdoc test #s $a, {$b}, {$c['c']}, and {$d->d}. +This is nowdoc test #s $a, {$b}, {$c['c']}, and {$d->d}. diff --git a/Zend/tests/nowdoc_008.phpt b/Zend/tests/nowdoc_008.phpt new file mode 100644 index 0000000..486f002 --- /dev/null +++ b/Zend/tests/nowdoc_008.phpt @@ -0,0 +1,17 @@ +--TEST-- +empty doc test (nowdoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<'ENDOFNOWDOC' +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- diff --git a/Zend/tests/nowdoc_009.phpt b/Zend/tests/nowdoc_009.phpt new file mode 100644 index 0000000..ec8b78f --- /dev/null +++ b/Zend/tests/nowdoc_009.phpt @@ -0,0 +1,40 @@ +--TEST-- +Torture the T_END_NOWDOC rules (nowdoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +print <<<'ENDOFNOWDOC' +ENDOFNOWDOC ; + ENDOFNOWDOC; +ENDOFNOWDOC + ENDOFNOWDOC +$ENDOFNOWDOC; + +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +ENDOFNOWDOC ; + ENDOFNOWDOC; +ENDOFNOWDOC + ENDOFNOWDOC +$ENDOFNOWDOC; + +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +ENDOFNOWDOC ; + ENDOFNOWDOC; +ENDOFNOWDOC + ENDOFNOWDOC +$ENDOFNOWDOC; +ENDOFNOWDOC ; + ENDOFNOWDOC; +ENDOFNOWDOC + ENDOFNOWDOC +$ENDOFNOWDOC; + diff --git a/Zend/tests/nowdoc_010.phpt b/Zend/tests/nowdoc_010.phpt new file mode 100644 index 0000000..6f28815 --- /dev/null +++ b/Zend/tests/nowdoc_010.phpt @@ -0,0 +1,33 @@ +--TEST-- +Torture the T_END_NOWDOC rules with variable expansions (nowdoc) +--FILE-- +<?php + +require_once 'nowdoc.inc'; +$fooledYou = ''; + +print <<<'ENDOFNOWDOC' +{$fooledYou}ENDOFNOWDOC{$fooledYou} +ENDOFNOWDOC{$fooledYou} +{$fooledYou}ENDOFNOWDOC + +ENDOFNOWDOC; + +$x = <<<'ENDOFNOWDOC' +{$fooledYou}ENDOFNOWDOC{$fooledYou} +ENDOFNOWDOC{$fooledYou} +{$fooledYou}ENDOFNOWDOC + +ENDOFNOWDOC; + +print "{$x}"; + +?> +--EXPECT-- +{$fooledYou}ENDOFNOWDOC{$fooledYou} +ENDOFNOWDOC{$fooledYou} +{$fooledYou}ENDOFNOWDOC +{$fooledYou}ENDOFNOWDOC{$fooledYou} +ENDOFNOWDOC{$fooledYou} +{$fooledYou}ENDOFNOWDOC + diff --git a/Zend/tests/nowdoc_011.phpt b/Zend/tests/nowdoc_011.phpt new file mode 100644 index 0000000..84bcdb6 --- /dev/null +++ b/Zend/tests/nowdoc_011.phpt @@ -0,0 +1,20 @@ +--TEST-- +Nowdocs CAN be used as static scalars. +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +class e { + + const E = <<<'THISMUSTNOTERROR' +If you DON'T see this, something's wrong. +THISMUSTNOTERROR; + +}; + +print e::E . "\n"; + +?> +--EXPECTF-- +If you DON'T see this, something's wrong. diff --git a/Zend/tests/nowdoc_012.phpt b/Zend/tests/nowdoc_012.phpt new file mode 100644 index 0000000..0bcb92e --- /dev/null +++ b/Zend/tests/nowdoc_012.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test false labels +--FILE-- +<?php + +require_once 'nowdoc.inc'; + +$x = <<<'ENDOFNOWDOC' +This is a nowdoc test. +NOTREALLYEND; +Another line +NOTENDEITHER; +ENDOFNOWDOCWILLBESOON +Now let's finish it +ENDOFNOWDOC; +print "{$x}\n"; + +?> +--EXPECT-- +This is a nowdoc test. +NOTREALLYEND; +Another line +NOTENDEITHER; +ENDOFNOWDOCWILLBESOON +Now let's finish it diff --git a/Zend/tests/nowdoc_013.phpt b/Zend/tests/nowdoc_013.phpt new file mode 100644 index 0000000..3e7d41f --- /dev/null +++ b/Zend/tests/nowdoc_013.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test whitespace following end of nowdoc +--INI-- +highlight.string = #DD0000 +highlight.comment = #FF8000 +highlight.keyword = #007700 +highlight.default = #0000BB +highlight.html = #000000 +--FILE-- +<?php +$code = <<<'EOF' +<?php + $x = <<<'EOT' +some string +EOT + $y = 2; +?> +EOF; +highlight_string($code); +?> +--EXPECT-- +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php<br /> $x </span><span style="color: #007700">= <<<'EOT'<br /></span><span style="color: #DD0000">some string <br /></span><span style="color: #007700">EOT<br /> </span><span style="color: #0000BB">$y </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> +</span> +</code> diff --git a/Zend/tests/nowdoc_014.phpt b/Zend/tests/nowdoc_014.phpt new file mode 100644 index 0000000..694490b --- /dev/null +++ b/Zend/tests/nowdoc_014.phpt @@ -0,0 +1,24 @@ +--TEST-- +Highlighting empty nowdoc +--INI-- +highlight.string = #DD0000 +highlight.comment = #FF8000 +highlight.keyword = #007700 +highlight.default = #0000BB +highlight.html = #000000 +--FILE-- +<?php +$code = <<<'EOF' +<?php + $x = <<<'EOT' +EOT + $y = 2; +?> +EOF; +highlight_string($code); +?> +--EXPECT-- +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php<br /> $x </span><span style="color: #007700">= <<<'EOT'<br />EOT<br /> </span><span style="color: #0000BB">$y </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> +</span> +</code> diff --git a/Zend/tests/nowdoc_015.phpt b/Zend/tests/nowdoc_015.phpt new file mode 100644 index 0000000..9eb83bd --- /dev/null +++ b/Zend/tests/nowdoc_015.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test nowdoc and line numbering +--FILE-- +<?php +function error_handler($num, $msg, $file, $line, $vars) { + echo $line,"\n"; +} +set_error_handler('error_handler'); +trigger_error("line", E_USER_ERROR); +$x = <<<EOF +EOF; +var_dump($x); +trigger_error("line", E_USER_ERROR); +$x = <<<'EOF' +EOF; +var_dump($x); +trigger_error("line", E_USER_ERROR); +$x = <<<EOF +test +EOF; +var_dump($x); +trigger_error("line", E_USER_ERROR); +$x = <<<'EOF' +test +EOF; +var_dump($x); +trigger_error("line", E_USER_ERROR); +$x = <<<EOF +test1 +test2 + +test3 + + +EOF; +var_dump($x); +trigger_error("line", E_USER_ERROR); +$x = <<<'EOF' +test1 +test2 + +test3 + + +EOF; +var_dump($x); +trigger_error("line", E_USER_ERROR); +echo "ok\n"; +?> +--EXPECT-- +6 +string(0) "" +10 +string(0) "" +14 +string(4) "test" +19 +string(4) "test" +24 +string(20) "test1 +test2 + +test3 + +" +34 +string(20) "test1 +test2 + +test3 + +" +44 +ok diff --git a/Zend/tests/nowdoc_016.phpt b/Zend/tests/nowdoc_016.phpt new file mode 100644 index 0000000..01eea4e --- /dev/null +++ b/Zend/tests/nowdoc_016.phpt @@ -0,0 +1,41 @@ +--TEST-- +Testing nowdocs with escape sequences +--FILE-- +<?php + +$test = <<<'TEST' +TEST; + +var_dump(strlen($test)); + +$test = <<<'TEST' +\ +TEST; + +var_dump(strlen($test)); + +$test = <<<'TEST' +\0 +TEST; + +var_dump(strlen($test)); + +$test = <<<'TEST' +\n +TEST; + +var_dump(strlen($test)); + +$test = <<<'TEST' +\\' +TEST; + +var_dump(strlen($test)); + +?> +--EXPECT-- +int(0) +int(1) +int(2) +int(2) +int(3) diff --git a/Zend/tests/nowdoc_017.phpt b/Zend/tests/nowdoc_017.phpt new file mode 100644 index 0000000..5d29a86 --- /dev/null +++ b/Zend/tests/nowdoc_017.phpt @@ -0,0 +1,16 @@ +--TEST-- +Testing nowdoc in default value for property +--FILE-- +<?php + +class foo { + public $bar = <<<'EOT' +bar +EOT; +} + +print "ok!\n"; + +?> +--EXPECT-- +ok! diff --git a/Zend/tests/ns_001.phpt b/Zend/tests/ns_001.phpt new file mode 100644 index 0000000..6771594 --- /dev/null +++ b/Zend/tests/ns_001.phpt @@ -0,0 +1,34 @@ +--TEST-- +001: Class in namespace +--FILE-- +<?php +namespace test\ns1; + +class Foo { + + function __construct() { + echo __CLASS__,"\n"; + } + + function bar() { + echo __CLASS__,"\n"; + } + + static function baz() { + echo __CLASS__,"\n"; + } +} + +$x = new Foo; +$x->bar(); +Foo::baz(); +$y = new \test\ns1\Foo; +$y->bar(); +\test\ns1\Foo::baz(); +--EXPECT-- +test\ns1\Foo +test\ns1\Foo +test\ns1\Foo +test\ns1\Foo +test\ns1\Foo +test\ns1\Foo diff --git a/Zend/tests/ns_002.phpt b/Zend/tests/ns_002.phpt new file mode 100644 index 0000000..3d9e098 --- /dev/null +++ b/Zend/tests/ns_002.phpt @@ -0,0 +1,27 @@ +--TEST-- +002: Import in namespace +--FILE-- +<?php +namespace test\ns1; + +class Foo { + static function bar() { + echo __CLASS__,"\n"; + } +} + +use test\ns1\Foo as Bar; +use test\ns1 as ns2; +use test\ns1; + +Foo::bar(); +\test\ns1\Foo::bar(); +Bar::bar(); +ns2\Foo::bar(); +ns1\Foo::bar(); +--EXPECT-- +test\ns1\Foo +test\ns1\Foo +test\ns1\Foo +test\ns1\Foo +test\ns1\Foo diff --git a/Zend/tests/ns_003.phpt b/Zend/tests/ns_003.phpt new file mode 100644 index 0000000..4372722 --- /dev/null +++ b/Zend/tests/ns_003.phpt @@ -0,0 +1,12 @@ +--TEST-- +003: Name conflict (ns name) +--FILE-- +<?php +namespace test\ns1; + +class Exception { +} + +echo get_class(new Exception()),"\n"; +--EXPECT-- +test\ns1\Exception diff --git a/Zend/tests/ns_004.phpt b/Zend/tests/ns_004.phpt new file mode 100644 index 0000000..d293f65 --- /dev/null +++ b/Zend/tests/ns_004.phpt @@ -0,0 +1,9 @@ +--TEST-- +004: Using global class name from namespace (unqualified - fail) +--FILE-- +<?php +namespace test\ns1; + +echo get_class(new Exception()),"\n"; +--EXPECTF-- +Fatal error: Class 'test\ns1\Exception' not found in %sns_004.php on line %d
\ No newline at end of file diff --git a/Zend/tests/ns_005.phpt b/Zend/tests/ns_005.phpt new file mode 100644 index 0000000..c082afc --- /dev/null +++ b/Zend/tests/ns_005.phpt @@ -0,0 +1,12 @@ +--TEST-- +005: Name conflict (php name in case if ns name exists) +--FILE-- +<?php +namespace test\ns1; + +class Exception { +} + +echo get_class(new \Exception()),"\n"; +--EXPECT-- +Exception diff --git a/Zend/tests/ns_006.phpt b/Zend/tests/ns_006.phpt new file mode 100644 index 0000000..1c0ec3a --- /dev/null +++ b/Zend/tests/ns_006.phpt @@ -0,0 +1,13 @@ +--TEST-- +006: Run-time name conflict (ns name) +--FILE-- +<?php +namespace test\ns1; + +class Exception { +} + +$x = "test\\ns1\\Exception"; +echo get_class(new $x),"\n"; +--EXPECT-- +test\ns1\Exception diff --git a/Zend/tests/ns_007.phpt b/Zend/tests/ns_007.phpt new file mode 100644 index 0000000..2f4d136 --- /dev/null +++ b/Zend/tests/ns_007.phpt @@ -0,0 +1,13 @@ +--TEST-- +007: Run-time name conflict (php name) +--FILE-- +<?php +namespace test\ns1; + +class Exception { +} + +$x = "Exception"; +echo get_class(new $x),"\n"; +--EXPECT-- +Exception diff --git a/Zend/tests/ns_008.phpt b/Zend/tests/ns_008.phpt new file mode 100644 index 0000000..2c2c918 --- /dev/null +++ b/Zend/tests/ns_008.phpt @@ -0,0 +1,13 @@ +--TEST-- +008: __NAMESPACE__ constant and runtime names (ns name) +--FILE-- +<?php +namespace test; + +class foo { +} + +$x = __NAMESPACE__ . "\\foo"; +echo get_class(new $x),"\n"; +--EXPECT-- +test\foo diff --git a/Zend/tests/ns_009.phpt b/Zend/tests/ns_009.phpt new file mode 100644 index 0000000..3481316 --- /dev/null +++ b/Zend/tests/ns_009.phpt @@ -0,0 +1,11 @@ +--TEST-- +009: __NAMESPACE__ constant and runtime names (php name) +--FILE-- +<?php +class foo { +} + +$x = __NAMESPACE__ . "\\foo"; +echo get_class(new $x),"\n"; +--EXPECT-- +foo diff --git a/Zend/tests/ns_010.phpt b/Zend/tests/ns_010.phpt new file mode 100644 index 0000000..28ef61b --- /dev/null +++ b/Zend/tests/ns_010.phpt @@ -0,0 +1,41 @@ +--TEST-- +010: Accesing internal namespace class +--FILE-- +<?php +namespace X; +use X as Y; +class Foo { + const C = "const ok\n"; + static $var = "var ok\n"; + function __construct() { + echo "class ok\n"; + } + static function bar() { + echo "method ok\n"; + } +} +new Foo(); +new Y\Foo(); +new \X\Foo(); +Foo::bar(); +Y\Foo::bar(); +\X\Foo::bar(); +echo Foo::C; +echo Y\Foo::C; +echo \X\Foo::C; +echo Foo::$var; +echo Y\Foo::$var; +echo \X\Foo::$var; +--EXPECT-- +class ok +class ok +class ok +method ok +method ok +method ok +const ok +const ok +const ok +var ok +var ok +var ok diff --git a/Zend/tests/ns_011.phpt b/Zend/tests/ns_011.phpt new file mode 100644 index 0000000..1706f2a --- /dev/null +++ b/Zend/tests/ns_011.phpt @@ -0,0 +1,24 @@ +--TEST-- +011: Function in namespace +--FILE-- +<?php +namespace test\ns1; + +function foo() { + echo __FUNCTION__,"\n"; +} + +foo(); +\test\ns1\foo(); +bar(); +\test\ns1\bar(); + +function bar() { + echo __FUNCTION__,"\n"; +} + +--EXPECT-- +test\ns1\foo +test\ns1\foo +test\ns1\bar +test\ns1\bar diff --git a/Zend/tests/ns_012.phpt b/Zend/tests/ns_012.phpt new file mode 100644 index 0000000..034f124 --- /dev/null +++ b/Zend/tests/ns_012.phpt @@ -0,0 +1,35 @@ +--TEST-- +012: Import in namespace and functions +--FILE-- +<?php +namespace test\ns1; + +function foo() { + echo __FUNCTION__,"\n"; +} + +use test\ns1 as ns2; +use test as ns3; + +foo(); +bar(); +\test\ns1\foo(); +\test\ns1\bar(); +ns2\foo(); +ns2\bar(); +ns3\ns1\foo(); +ns3\ns1\bar(); + +function bar() { + echo __FUNCTION__,"\n"; +} + +--EXPECT-- +test\ns1\foo +test\ns1\bar +test\ns1\foo +test\ns1\bar +test\ns1\foo +test\ns1\bar +test\ns1\foo +test\ns1\bar diff --git a/Zend/tests/ns_013.phpt b/Zend/tests/ns_013.phpt new file mode 100644 index 0000000..ef73b13 --- /dev/null +++ b/Zend/tests/ns_013.phpt @@ -0,0 +1,13 @@ +--TEST-- +013: Name conflict and functions (ns name) +--FILE-- +<?php +namespace test\ns1; + +function strlen($x) { + return __FUNCTION__; +} + +echo strlen("Hello"),"\n"; +--EXPECT-- +test\ns1\strlen diff --git a/Zend/tests/ns_014.phpt b/Zend/tests/ns_014.phpt new file mode 100644 index 0000000..6bcab51 --- /dev/null +++ b/Zend/tests/ns_014.phpt @@ -0,0 +1,9 @@ +--TEST-- +014: Name conflict and functions (php name) +--FILE-- +<?php +namespace test\ns1; + +echo strlen("Hello"),"\n"; +--EXPECT-- +5 diff --git a/Zend/tests/ns_015.phpt b/Zend/tests/ns_015.phpt new file mode 100644 index 0000000..ae2c818 --- /dev/null +++ b/Zend/tests/ns_015.phpt @@ -0,0 +1,14 @@ +--TEST-- +015: Name conflict and functions (php name in case if ns name exists) +--FILE-- +<?php +namespace test\ns1; + +function strlen($x) { + return __FUNCTION__; +} + +echo \strlen("Hello"),"\n"; +--EXPECT-- +5 + diff --git a/Zend/tests/ns_016.phpt b/Zend/tests/ns_016.phpt new file mode 100644 index 0000000..bee8b5b --- /dev/null +++ b/Zend/tests/ns_016.phpt @@ -0,0 +1,14 @@ +--TEST-- +016: Run-time name conflict and functions (ns name) +--FILE-- +<?php +namespace test\ns1; + +function strlen($x) { + return __FUNCTION__; +} + +$x = "test\\ns1\\strlen"; +echo $x("Hello"),"\n"; +--EXPECT-- +test\ns1\strlen diff --git a/Zend/tests/ns_017.phpt b/Zend/tests/ns_017.phpt new file mode 100644 index 0000000..888d8e5 --- /dev/null +++ b/Zend/tests/ns_017.phpt @@ -0,0 +1,14 @@ +--TEST-- +017: Run-time name conflict and functions (php name) +--FILE-- +<?php +namespace test\ns1; + +function strlen($x) { + return __FUNCTION__; +} + +$x = "strlen"; +echo $x("Hello"),"\n"; +--EXPECT-- +5
\ No newline at end of file diff --git a/Zend/tests/ns_018.phpt b/Zend/tests/ns_018.phpt new file mode 100644 index 0000000..5c2495c --- /dev/null +++ b/Zend/tests/ns_018.phpt @@ -0,0 +1,14 @@ +--TEST-- +018: __NAMESPACE__ constant and runtime names (ns name) +--FILE-- +<?php +namespace test; + +function foo() { + return __FUNCTION__; +} + +$x = __NAMESPACE__ . "\\foo"; +echo $x(),"\n"; +--EXPECT-- +test\foo diff --git a/Zend/tests/ns_019.phpt b/Zend/tests/ns_019.phpt new file mode 100644 index 0000000..c3db786 --- /dev/null +++ b/Zend/tests/ns_019.phpt @@ -0,0 +1,12 @@ +--TEST-- +019: __NAMESPACE__ constant and runtime names (php name) +--FILE-- +<?php +function foo() { + return __FUNCTION__; +} + +$x = __NAMESPACE__ . "\\foo"; +echo $x(),"\n"; +--EXPECT-- +foo diff --git a/Zend/tests/ns_020.phpt b/Zend/tests/ns_020.phpt new file mode 100644 index 0000000..ec4fda0 --- /dev/null +++ b/Zend/tests/ns_020.phpt @@ -0,0 +1,18 @@ +--TEST-- +020: Accesing internal namespace function +--FILE-- +<?php +namespace X; +use X as Y; +function foo() { + echo __FUNCTION__,"\n"; +} +foo(); +\X\foo(); +Y\foo(); +\X\foo(); +--EXPECT-- +X\foo +X\foo +X\foo +X\foo diff --git a/Zend/tests/ns_021.phpt b/Zend/tests/ns_021.phpt new file mode 100644 index 0000000..4054683 --- /dev/null +++ b/Zend/tests/ns_021.phpt @@ -0,0 +1,23 @@ +--TEST-- +021: Name search priority (first look into namespace) +--FILE-- +<?php +namespace test; + +class Test { + static function foo() { + echo __CLASS__,"::",__FUNCTION__,"\n"; + } +} + +function foo() { + echo __FUNCTION__,"\n"; +} + +foo(); +\test\foo(); +\test\test::foo(); +--EXPECT-- +test\foo +test\foo +test\Test::foo diff --git a/Zend/tests/ns_022.inc b/Zend/tests/ns_022.inc new file mode 100644 index 0000000..be571fc --- /dev/null +++ b/Zend/tests/ns_022.inc @@ -0,0 +1,6 @@ +<?php +class Test { + static function foo() { + echo __CLASS__,"::",__FUNCTION__,"\n"; + } +} diff --git a/Zend/tests/ns_022.phpt b/Zend/tests/ns_022.phpt new file mode 100644 index 0000000..7aebe1d --- /dev/null +++ b/Zend/tests/ns_022.phpt @@ -0,0 +1,19 @@ +--TEST-- +022: Name search priority (first look into import, then into current namespace and then for class) +--FILE-- +<?php +namespace a\b\c; + +use a\b\c as test; + +require "ns_022.inc"; + +function foo() { + echo __FUNCTION__,"\n"; +} + +test\foo(); +\test::foo(); +--EXPECT-- +a\b\c\foo +Test::foo diff --git a/Zend/tests/ns_023.phpt b/Zend/tests/ns_023.phpt new file mode 100644 index 0000000..34fbb56 --- /dev/null +++ b/Zend/tests/ns_023.phpt @@ -0,0 +1,9 @@ +--TEST-- +023: __NAMESPACE__ constant +--FILE-- +<?php +namespace test\foo; + +var_dump(__NAMESPACE__); +--EXPECT-- +string(8) "test\foo" diff --git a/Zend/tests/ns_024.phpt b/Zend/tests/ns_024.phpt new file mode 100644 index 0000000..019a89c --- /dev/null +++ b/Zend/tests/ns_024.phpt @@ -0,0 +1,7 @@ +--TEST-- +024: __NAMESPACE__ constant out of namespace +--FILE-- +<?php +var_dump(__NAMESPACE__); +--EXPECT-- +string(0) "" diff --git a/Zend/tests/ns_025.phpt b/Zend/tests/ns_025.phpt new file mode 100644 index 0000000..917a710 --- /dev/null +++ b/Zend/tests/ns_025.phpt @@ -0,0 +1,24 @@ +--TEST-- +025: Name ambiguity (class name & part of namespace name) +--FILE-- +<?php +namespace Foo\Bar; + +class Foo { + function __construct() { + echo __CLASS__,"\n"; + } + static function Bar() { + echo __CLASS__,"\n"; + } +} + +$x = new Foo; +Foo::Bar(); +$x = new \Foo\Bar\Foo; +\Foo\Bar\Foo::Bar(); +--EXPECT-- +Foo\Bar\Foo +Foo\Bar\Foo +Foo\Bar\Foo +Foo\Bar\Foo diff --git a/Zend/tests/ns_026.phpt b/Zend/tests/ns_026.phpt new file mode 100644 index 0000000..af2bf2c --- /dev/null +++ b/Zend/tests/ns_026.phpt @@ -0,0 +1,33 @@ +--TEST-- +026: Name ambiguity (class name & namespace name) +--FILE-- +<?php +namespace Foo; + +class Foo { + function __construct() { + echo "Method - ".__CLASS__."::".__FUNCTION__."\n"; + } + static function Bar() { + echo "Method - ".__CLASS__."::".__FUNCTION__."\n"; + } +} + +function Bar() { + echo "Func - ".__FUNCTION__."\n"; +} + +$x = new Foo; +\Foo\Bar(); +$x = new \Foo\Foo; +\Foo\Foo::Bar(); +\Foo\Bar(); +Foo\Bar(); +--EXPECTF-- +Method - Foo\Foo::__construct +Func - Foo\Bar +Method - Foo\Foo::__construct +Method - Foo\Foo::Bar +Func - Foo\Bar + +Fatal error: Call to undefined function Foo\Foo\Bar() in %sns_026.php on line %d
\ No newline at end of file diff --git a/Zend/tests/ns_027.inc b/Zend/tests/ns_027.inc new file mode 100644 index 0000000..3823818 --- /dev/null +++ b/Zend/tests/ns_027.inc @@ -0,0 +1,11 @@ +<?php +namespace Foo\Bar; + +class Foo { + function __construct() { + echo __CLASS__,"\n"; + } + static function Bar() { + echo __CLASS__,"\n"; + } +} diff --git a/Zend/tests/ns_027.phpt b/Zend/tests/ns_027.phpt new file mode 100644 index 0000000..88ef22f --- /dev/null +++ b/Zend/tests/ns_027.phpt @@ -0,0 +1,24 @@ +--TEST-- +027: Name ambiguity (class name & part of extertnal namespace name) +--FILE-- +<?php +require "ns_027.inc"; + +class Foo { + function __construct() { + echo __CLASS__,"\n"; + } + static function Bar() { + echo __CLASS__,"\n"; + } +} + +$x = new Foo; +Foo::Bar(); +$x = new Foo\Bar\Foo; +Foo\Bar\Foo::Bar(); +--EXPECT-- +Foo +Foo +Foo\Bar\Foo +Foo\Bar\Foo diff --git a/Zend/tests/ns_028.inc b/Zend/tests/ns_028.inc new file mode 100644 index 0000000..5bd3ae7 --- /dev/null +++ b/Zend/tests/ns_028.inc @@ -0,0 +1,15 @@ +<?php +namespace Foo; + +class Foo { + function __construct() { + echo "Method - ".__CLASS__."::".__FUNCTION__."\n"; + } + static function Bar() { + echo "Method - ".__CLASS__."::".__FUNCTION__."\n"; + } +} + +function Bar() { + echo "Func - ".__FUNCTION__."\n"; +} diff --git a/Zend/tests/ns_028.phpt b/Zend/tests/ns_028.phpt new file mode 100644 index 0000000..ec23dac --- /dev/null +++ b/Zend/tests/ns_028.phpt @@ -0,0 +1,26 @@ +--TEST-- +028: Name ambiguity (class name & external namespace name) +--FILE-- +<?php +require "ns_028.inc"; + +class Foo { + function __construct() { + echo "Method - ".__CLASS__."::".__FUNCTION__."\n"; + } + static function Bar() { + echo "Method - ".__CLASS__."::".__FUNCTION__."\n"; + } +} + +$x = new Foo; +Foo\Bar(); +$x = new Foo\Foo; +Foo\Foo::Bar(); +\Foo\Bar(); +--EXPECT-- +Method - Foo::__construct +Func - Foo\Bar +Method - Foo\Foo::__construct +Method - Foo\Foo::Bar +Func - Foo\Bar diff --git a/Zend/tests/ns_029.phpt b/Zend/tests/ns_029.phpt new file mode 100644 index 0000000..f1aa954 --- /dev/null +++ b/Zend/tests/ns_029.phpt @@ -0,0 +1,12 @@ +--TEST-- +029: Name ambiguity (class name & import name) +--FILE-- +<?php +use A\B as Foo; + +class Foo { +} + +new Foo(); +--EXPECTF-- +Fatal error: Cannot declare class Foo because the name is already in use in %sns_029.php on line 4 diff --git a/Zend/tests/ns_030.phpt b/Zend/tests/ns_030.phpt new file mode 100644 index 0000000..6972415 --- /dev/null +++ b/Zend/tests/ns_030.phpt @@ -0,0 +1,12 @@ +--TEST-- +030: Name ambiguity (import name & class name) +--FILE-- +<?php +class Foo { +} + +use A\B as Foo; + +new Foo(); +--EXPECTF-- +Fatal error: Cannot use A\B as Foo because the name is already in use in %sns_030.php on line 5 diff --git a/Zend/tests/ns_031.phpt b/Zend/tests/ns_031.phpt new file mode 100644 index 0000000..840c086 --- /dev/null +++ b/Zend/tests/ns_031.phpt @@ -0,0 +1,21 @@ +--TEST-- +031: Namespace support for user functions (ns name) +--FILE-- +<?php +namespace test; + +class Test { + static function foo() { + echo __CLASS__,"::",__FUNCTION__,"\n"; + } +} + +function foo() { + echo __FUNCTION__,"\n"; +} + +call_user_func(__NAMESPACE__."\\foo"); +call_user_func(__NAMESPACE__."\\test::foo"); +--EXPECT-- +test\foo +test\Test::foo diff --git a/Zend/tests/ns_032.phpt b/Zend/tests/ns_032.phpt new file mode 100644 index 0000000..5717a33 --- /dev/null +++ b/Zend/tests/ns_032.phpt @@ -0,0 +1,19 @@ +--TEST-- +032: Namespace support for user functions (php name) +--FILE-- +<?php +class Test { + static function foo() { + echo __CLASS__,"::",__FUNCTION__,"\n"; + } +} + +function foo() { + echo __FUNCTION__,"\n"; +} + +call_user_func(__NAMESPACE__."\\foo"); +call_user_func(__NAMESPACE__."\\test::foo"); +--EXPECT-- +foo +Test::foo diff --git a/Zend/tests/ns_033.phpt b/Zend/tests/ns_033.phpt new file mode 100644 index 0000000..dc431d8 --- /dev/null +++ b/Zend/tests/ns_033.phpt @@ -0,0 +1,8 @@ +--TEST-- +033: Import statement with non-compound name +--FILE-- +<?php +use A; +--EXPECTF-- +Warning: The use statement with non-compound name 'A' has no effect in %sns_033.php on line 2 + diff --git a/Zend/tests/ns_034.phpt b/Zend/tests/ns_034.phpt new file mode 100644 index 0000000..76775f1 --- /dev/null +++ b/Zend/tests/ns_034.phpt @@ -0,0 +1,31 @@ +--TEST-- +034: Support for namespaces in compile-time constant reference +--FILE-- +<?php +namespace A; +use A as B; +class Foo { + const C = "ok\n"; +} +function f1($x=Foo::C) { + echo $x; +} +function f2($x=B\Foo::C) { + echo $x; +} +function f3($x=\A\Foo::C) { + echo $x; +} +echo Foo::C; +echo B\Foo::C; +echo \A\Foo::C; +f1(); +f2(); +f3(); +--EXPECT-- +ok +ok +ok +ok +ok +ok diff --git a/Zend/tests/ns_035.phpt b/Zend/tests/ns_035.phpt new file mode 100644 index 0000000..fcc771a --- /dev/null +++ b/Zend/tests/ns_035.phpt @@ -0,0 +1,26 @@ +--TEST-- +035: Name ambiguity in compile-time constant reference (php name) +--SKIPIF-- +<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?> +--FILE-- +<?php +namespace A; +use \ArrayObject; + +function f1($x = ArrayObject::STD_PROP_LIST) { + var_dump($x); +} +function f2($x = \ArrayObject::STD_PROP_LIST) { + var_dump($x); +} +var_dump(ArrayObject::STD_PROP_LIST); +var_dump(\ArrayObject::STD_PROP_LIST); +f1(); +f2(); + +?> +--EXPECT-- +int(1) +int(1) +int(1) +int(1) diff --git a/Zend/tests/ns_036.phpt b/Zend/tests/ns_036.phpt new file mode 100644 index 0000000..245cf7d --- /dev/null +++ b/Zend/tests/ns_036.phpt @@ -0,0 +1,41 @@ +--TEST-- +036: Name ambiguity in compile-time constant reference (ns name) +--SKIPIF-- +<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?> +--FILE-- +<?php +namespace A; +use A as B; +class ArrayObject { + const STD_PROP_LIST = 2; +} +function f1($x = ArrayObject::STD_PROP_LIST) { + var_dump($x); +} +function f2($x = \ArrayObject::STD_PROP_LIST) { + var_dump($x); +} +function f3($x = \A\ArrayObject::STD_PROP_LIST) { + var_dump($x); +} +function f4($x = B\ArrayObject::STD_PROP_LIST) { + var_dump($x); +} +var_dump(ArrayObject::STD_PROP_LIST); +var_dump(\ArrayObject::STD_PROP_LIST); +var_dump(B\ArrayObject::STD_PROP_LIST); +var_dump(\A\ArrayObject::STD_PROP_LIST); +f1(); +f2(); +f3(); +f4(); +?> +--EXPECT-- +int(2) +int(1) +int(2) +int(2) +int(2) +int(1) +int(2) +int(2) diff --git a/Zend/tests/ns_037.phpt b/Zend/tests/ns_037.phpt new file mode 100644 index 0000000..db0a76e --- /dev/null +++ b/Zend/tests/ns_037.phpt @@ -0,0 +1,41 @@ +--TEST-- +037: Name ambiguity (namespace name or namespace's class name) +--FILE-- +<?php +namespace X; +use X as Y; +class X { + const C = "const ok\n"; + static $var = "var ok\n"; + function __construct() { + echo "class ok\n"; + } + static function bar() { + echo "method ok\n"; + } +} +new X(); +new Y\X(); +new \X\X(); +X::bar(); +Y\X::bar(); +\X\X::bar(); +echo X::C; +echo Y\X::C; +echo \X\X::C; +echo X::$var; +echo Y\X::$var; +echo \X\X::$var; +--EXPECT-- +class ok +class ok +class ok +method ok +method ok +method ok +const ok +const ok +const ok +var ok +var ok +var ok diff --git a/Zend/tests/ns_038.phpt b/Zend/tests/ns_038.phpt new file mode 100644 index 0000000..f3a8c8c --- /dev/null +++ b/Zend/tests/ns_038.phpt @@ -0,0 +1,15 @@ +--TEST-- +038: Name ambiguity (namespace name or internal class name) +--FILE-- +<?php +namespace Exception; +function foo() { + echo "ok\n"; +} +\Exception\foo(); +\Exception::bar(); +--EXPECTF-- +ok + +Fatal error: Call to undefined method Exception::bar() in %sns_038.php on line 7 + diff --git a/Zend/tests/ns_039.phpt b/Zend/tests/ns_039.phpt new file mode 100644 index 0000000..c5e79e4 --- /dev/null +++ b/Zend/tests/ns_039.phpt @@ -0,0 +1,25 @@ +--TEST-- +039: Constant declaration +--FILE-- +<?php +function foo($a = A) { + echo "$a\n"; +} +function bar($a = array(A => B)) { + foreach ($a as $key => $val) { + echo "$key\n"; + echo "$val\n"; + } +} +const A = "ok"; +const B = A; +echo A . "\n"; +echo B . "\n"; +foo(); +bar(); +--EXPECT-- +ok +ok +ok +ok +ok diff --git a/Zend/tests/ns_040.phpt b/Zend/tests/ns_040.phpt new file mode 100644 index 0000000..42a3ac0 --- /dev/null +++ b/Zend/tests/ns_040.phpt @@ -0,0 +1,59 @@ +--TEST-- +040: Constant declaration and usage in namespace +--FILE-- +<?php +namespace X; +use X as Y; +const A = "ok\n"; +const B = A; +function f1($x=A) { + echo $x; +} +function f2($x=\X\A) { + echo $x; +} +function f3($x=Y\A) { + echo $x; +} +function f4($x=\X\A) { + echo $x; +} +function f5($x=B) { + echo $x; +} +function f6($x=array(A)) { + echo $x[0]; +} +function f7($x=array("aaa"=>A)) { + echo $x["aaa"]; +} +function f8($x=array(A=>"aaa\n")) { + echo $x["ok\n"]; +} +echo A; +echo \X\A; +echo Y\A; +echo \X\A; +f1(); +f2(); +f3(); +f4(); +echo B; +f5(); +f6(); +f7(); +f8(); +--EXPECT-- +ok +ok +ok +ok +ok +ok +ok +ok +ok +ok +ok +ok +aaa diff --git a/Zend/tests/ns_041.phpt b/Zend/tests/ns_041.phpt new file mode 100644 index 0000000..0632fc9 --- /dev/null +++ b/Zend/tests/ns_041.phpt @@ -0,0 +1,22 @@ +--TEST-- +041: Constants in namespace +--FILE-- +<?php +namespace test\ns1; + +const FOO = "ok\n"; + +echo(FOO); +echo(\test\ns1\FOO); +echo(\test\ns1\FOO); +echo(BAR); + +const BAR = "ok\n"; + +--EXPECTF-- +ok +ok +ok + +Notice: Use of undefined constant BAR - assumed 'BAR' in %sns_041.php on line 9 +BAR diff --git a/Zend/tests/ns_042.phpt b/Zend/tests/ns_042.phpt new file mode 100644 index 0000000..ba420a7 --- /dev/null +++ b/Zend/tests/ns_042.phpt @@ -0,0 +1,22 @@ +--TEST-- +042: Import in namespace and constants +--FILE-- +<?php +namespace test\ns1; + +const FOO = "ok\n"; + +use test\ns1 as ns2; +use test as ns3; + +echo FOO; +echo \test\ns1\FOO; +echo \test\ns1\FOO; +echo ns2\FOO; +echo ns3\ns1\FOO; +--EXPECT-- +ok +ok +ok +ok +ok diff --git a/Zend/tests/ns_043.phpt b/Zend/tests/ns_043.phpt new file mode 100644 index 0000000..bd5ee74 --- /dev/null +++ b/Zend/tests/ns_043.phpt @@ -0,0 +1,11 @@ +--TEST-- +043: Name conflict and constants (ns name) +--FILE-- +<?php +namespace test\ns1; + +const INI_ALL = 0; + +var_dump(INI_ALL); +--EXPECT-- +int(0) diff --git a/Zend/tests/ns_044.phpt b/Zend/tests/ns_044.phpt new file mode 100644 index 0000000..dbdee2e --- /dev/null +++ b/Zend/tests/ns_044.phpt @@ -0,0 +1,9 @@ +--TEST-- +044: Name conflict and constants (php name) +--FILE-- +<?php +namespace test\ns1; + +var_dump(INI_ALL); +--EXPECT-- +int(7) diff --git a/Zend/tests/ns_045.phpt b/Zend/tests/ns_045.phpt new file mode 100644 index 0000000..d45f9cf --- /dev/null +++ b/Zend/tests/ns_045.phpt @@ -0,0 +1,11 @@ +--TEST-- +045: Name conflict and constants (php name in case if ns name exists) +--FILE-- +<?php +namespace test\ns1; + +const INI_ALL = 0; + +var_dump(\INI_ALL); +--EXPECT-- +int(7) diff --git a/Zend/tests/ns_046.phpt b/Zend/tests/ns_046.phpt new file mode 100644 index 0000000..d5203f1 --- /dev/null +++ b/Zend/tests/ns_046.phpt @@ -0,0 +1,11 @@ +--TEST-- +046: Run-time name conflict and constants (ns name) +--FILE-- +<?php +namespace test\ns1; + +const INI_ALL = 0; + +var_dump(constant("test\\ns1\\INI_ALL")); +--EXPECT-- +int(0) diff --git a/Zend/tests/ns_047.phpt b/Zend/tests/ns_047.phpt new file mode 100644 index 0000000..73e32a0 --- /dev/null +++ b/Zend/tests/ns_047.phpt @@ -0,0 +1,11 @@ +--TEST-- +047: Run-time name conflict and constants (php name) +--FILE-- +<?php +namespace test\ns1; + +const INI_ALL = 0; + +var_dump(constant("INI_ALL")); +--EXPECT-- +int(7) diff --git a/Zend/tests/ns_048.phpt b/Zend/tests/ns_048.phpt new file mode 100644 index 0000000..db21f89 --- /dev/null +++ b/Zend/tests/ns_048.phpt @@ -0,0 +1,11 @@ +--TEST-- +048: __NAMESPACE__ constant and runtime names (ns name) +--FILE-- +<?php +namespace test\ns1; + +const FOO = 0; + +var_dump(constant(__NAMESPACE__ . "\\FOO")); +--EXPECT-- +int(0) diff --git a/Zend/tests/ns_049.phpt b/Zend/tests/ns_049.phpt new file mode 100644 index 0000000..91e5165 --- /dev/null +++ b/Zend/tests/ns_049.phpt @@ -0,0 +1,9 @@ +--TEST-- +049: __NAMESPACE__ constant and runtime names (php name) +--FILE-- +<?php +const FOO = 0; + +var_dump(constant(__NAMESPACE__ . "\\FOO")); +--EXPECT-- +int(0) diff --git a/Zend/tests/ns_050.phpt b/Zend/tests/ns_050.phpt new file mode 100644 index 0000000..f827ec8 --- /dev/null +++ b/Zend/tests/ns_050.phpt @@ -0,0 +1,14 @@ +--TEST-- +050: Name conflict and compile-time constants (ns name) +--FILE-- +<?php +namespace test\ns1; + +const INI_ALL = 0; + +function foo($x = INI_ALL) { + var_dump($x); +} +foo(); +--EXPECT-- +int(0) diff --git a/Zend/tests/ns_051.phpt b/Zend/tests/ns_051.phpt new file mode 100644 index 0000000..b95b53f --- /dev/null +++ b/Zend/tests/ns_051.phpt @@ -0,0 +1,12 @@ +--TEST-- +051: Name conflict and compile-time constants (php name) +--FILE-- +<?php +namespace test\ns1; + +function foo($x = INI_ALL) { + var_dump($x); +} +foo(); +--EXPECT-- +int(7) diff --git a/Zend/tests/ns_052.phpt b/Zend/tests/ns_052.phpt new file mode 100644 index 0000000..cb0a05f --- /dev/null +++ b/Zend/tests/ns_052.phpt @@ -0,0 +1,14 @@ +--TEST-- +052: Name conflict and compile-time constants (php name in case if ns name exists) +--FILE-- +<?php +namespace test\ns1; + +const INI_ALL = 0; + +function foo($x = \INI_ALL) { + var_dump($x); +} +foo(); +--EXPECT-- +int(7) diff --git a/Zend/tests/ns_053.phpt b/Zend/tests/ns_053.phpt new file mode 100644 index 0000000..bc5ab12 --- /dev/null +++ b/Zend/tests/ns_053.phpt @@ -0,0 +1,13 @@ +--TEST-- +053: Run-time constant definition +--FILE-- +<?php +namespace test\ns1; + +define(__NAMESPACE__ . '\\NAME', basename(__FILE__)); +echo NAME."\n"; +echo \test\ns1\NAME."\n"; +--EXPECT-- +ns_053.php +ns_053.php + diff --git a/Zend/tests/ns_054.phpt b/Zend/tests/ns_054.phpt new file mode 100644 index 0000000..54ab958 --- /dev/null +++ b/Zend/tests/ns_054.phpt @@ -0,0 +1,31 @@ +--TEST-- +054: namespace and interfaces +--SKIPIF-- +<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?> +--FILE-- +<?php +namespace test\ns1; + +class Foo implements \SplObserver { + function update(\SplSubject $x) { + echo "ok\n"; + } +} + +class Bar implements \SplSubject { + function attach(\SplObserver $x) { + echo "ok\n"; + } + function notify() { + } + function detach(\SplObserver $x) { + } +} +$foo = new Foo(); +$bar = new Bar(); +$bar->attach($foo); +$foo->update($bar); +?> +--EXPECT-- +ok +ok diff --git a/Zend/tests/ns_055.phpt b/Zend/tests/ns_055.phpt new file mode 100644 index 0000000..a692e47 --- /dev/null +++ b/Zend/tests/ns_055.phpt @@ -0,0 +1,28 @@ +--TEST-- +055: typehints in namespaces +--FILE-- +<?php +namespace test\ns1; + +class Foo { + function test1(Foo $x) { + echo "ok\n"; + } + function test2(\test\ns1\Foo $x) { + echo "ok\n"; + } + function test3(\Exception $x) { + echo "ok\n"; + } +} + +$foo = new Foo(); +$ex = new \Exception(); +$foo->test1($foo); +$foo->test2($foo); +$foo->test3($ex); +?> +--EXPECT-- +ok +ok +ok diff --git a/Zend/tests/ns_056.phpt b/Zend/tests/ns_056.phpt new file mode 100644 index 0000000..2390608 --- /dev/null +++ b/Zend/tests/ns_056.phpt @@ -0,0 +1,32 @@ +--TEST-- +056: type-hint compatibility in namespaces +--SKIPIF-- +<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?> +--FILE-- +<?php +namespace test\ns1; +use \SplObserver; + +class Foo implements SplObserver { + function update(\SplSubject $x) { + echo "ok\n"; + } +} + +class Bar implements \SplSubject { + function attach(SplObserver $x) { + echo "ok\n"; + } + function notify() { + } + function detach(SplObserver $x) { + } +} +$foo = new Foo(); +$bar = new Bar(); +$bar->attach($foo); +$foo->update($bar); +?> +--EXPECT-- +ok +ok diff --git a/Zend/tests/ns_057.phpt b/Zend/tests/ns_057.phpt new file mode 100644 index 0000000..13bf305 --- /dev/null +++ b/Zend/tests/ns_057.phpt @@ -0,0 +1,59 @@ +--TEST-- +057: Usage of 'namespace' in compound names (inside namespace) +--FILE-- +<?php +namespace Test\ns1; + +const C = "const ok\n"; + +function foo() { + return "func ok\n"; +} + +class foo { + const C = "const ok\n"; + const C2 = namespace\C; + static $var = "var ok\n"; + function __construct() { + echo "class ok\n"; + } + static function bar() { + return "method ok\n"; + } +} + +function f1($x=namespace\C) { + return $x; +} +function f2($x=namespace\foo::C) { + return $x; +} + +function f3(namespace\foo $x) { + return "ok\n"; +} + +echo namespace\C; +echo namespace\foo(); +echo namespace\foo::C; +echo namespace\foo::C2; +echo namespace\foo::$var; +echo namespace\foo::bar(); +echo namespace\f1(); +echo namespace\f2(); +echo namespace\f3(new namespace\foo()); +echo namespace\unknown; +?> +--EXPECTF-- +const ok +func ok +const ok +const ok +var ok +method ok +const ok +const ok +class ok +ok + +Fatal error: Undefined constant 'Test\ns1\unknown' in %sns_057.php on line %d
\ No newline at end of file diff --git a/Zend/tests/ns_058.phpt b/Zend/tests/ns_058.phpt new file mode 100644 index 0000000..7a0cd97 --- /dev/null +++ b/Zend/tests/ns_058.phpt @@ -0,0 +1,57 @@ +--TEST-- +058: Usage of 'namespace' in compound names (out of namespase) +--FILE-- +<?php +const C = "const ok\n"; + +function foo() { + return "func ok\n"; +} + +class foo { + const C = "const ok\n"; + const C2 = namespace\C; + static $var = "var ok\n"; + function __construct() { + echo "class ok\n"; + } + static function bar() { + return "method ok\n"; + } +} + +function f1($x=namespace\C) { + return $x; +} +function f2($x=namespace\foo::C) { + return $x; +} + +function f3(namespace\foo $x) { + return "ok\n"; +} + +echo namespace\C; +echo namespace\foo(); +echo namespace\foo::C; +echo namespace\foo::C2; +echo namespace\foo::$var; +echo namespace\foo::bar(); +echo namespace\f1(); +echo namespace\f2(); +echo namespace\f3(new namespace\foo()); +echo namespace\unknown; +?> +--EXPECTF-- +const ok +func ok +const ok +const ok +var ok +method ok +const ok +const ok +class ok +ok + +Fatal error: Undefined constant 'unknown' in %sns_058.php on line %d diff --git a/Zend/tests/ns_059.phpt b/Zend/tests/ns_059.phpt new file mode 100644 index 0000000..ea66037 --- /dev/null +++ b/Zend/tests/ns_059.phpt @@ -0,0 +1,8 @@ +--TEST-- +059: Constant arrays +--FILE-- +<?php +const C = array(); +--EXPECTF-- +Fatal error: Arrays are not allowed as constants in %sns_059.php on line 2 + diff --git a/Zend/tests/ns_060.phpt b/Zend/tests/ns_060.phpt new file mode 100644 index 0000000..16c8024 --- /dev/null +++ b/Zend/tests/ns_060.phpt @@ -0,0 +1,23 @@ +--TEST-- +060: multiple namespaces per file +--FILE-- +<?php +namespace Foo; +use Bar\A as B; +class A {} +$a = new B; +$b = new A; +echo get_class($a)."\n"; +echo get_class($b)."\n"; +namespace Bar; +use Foo\A as B; +$a = new B; +$b = new A; +echo get_class($a)."\n"; +echo get_class($b)."\n"; +class A {} +--EXPECT-- +Bar\A +Foo\A +Foo\A +Bar\A diff --git a/Zend/tests/ns_061.phpt b/Zend/tests/ns_061.phpt new file mode 100644 index 0000000..948f675 --- /dev/null +++ b/Zend/tests/ns_061.phpt @@ -0,0 +1,9 @@ +--TEST-- +061: use in global scope +--FILE-- +<?php +class A {} +use \A as B; +echo get_class(new B)."\n"; +--EXPECT-- +A diff --git a/Zend/tests/ns_062.phpt b/Zend/tests/ns_062.phpt new file mode 100644 index 0000000..d795da4 --- /dev/null +++ b/Zend/tests/ns_062.phpt @@ -0,0 +1,12 @@ +--TEST-- +062: use \global class +--FILE-- +<?php +namespace Foo; +use \stdClass; +use \stdClass as A; +echo get_class(new stdClass)."\n"; +echo get_class(new A)."\n"; +--EXPECT-- +stdClass +stdClass diff --git a/Zend/tests/ns_063.phpt b/Zend/tests/ns_063.phpt new file mode 100644 index 0000000..dbe34b4 --- /dev/null +++ b/Zend/tests/ns_063.phpt @@ -0,0 +1,14 @@ +--TEST-- +063: Old-style constructors in namesapces (not supported!) +--FILE-- +<?php +namespace Foo; +class Bar { + function Bar() { + echo "ok\n"; + } +} +new Bar(); +echo "ok\n"; +--EXPECT-- +ok diff --git a/Zend/tests/ns_064.phpt b/Zend/tests/ns_064.phpt new file mode 100644 index 0000000..0a7c4bc --- /dev/null +++ b/Zend/tests/ns_064.phpt @@ -0,0 +1,40 @@ +--TEST-- +Magic methods in overrided stdClass inside namespace +--FILE-- +<?php + +namespace test; + +class foo { + public $e = array(); + + public function __construct() { + $this->e[] = $this; + } + + public function __set($a, $b) { + var_dump($a, $b); + } + public function __get($a) { + var_dump($a); + return $this; + } +} + +use test\foo as stdClass; + +$x = new stdClass; +$x->a = 1; +$x->b->c = 1; +$x->d->e[0]->f = 2; + +?> +--EXPECT-- +string(1) "a" +int(1) +string(1) "b" +string(1) "c" +int(1) +string(1) "d" +string(1) "f" +int(2) diff --git a/Zend/tests/ns_065.inc b/Zend/tests/ns_065.inc new file mode 100644 index 0000000..963a74e --- /dev/null +++ b/Zend/tests/ns_065.inc @@ -0,0 +1,9 @@ +<?php +namespace X\Y; +function foo() { + echo __FUNCTION__."\n"; +} +namespace X\Z; +function foo() { + echo __FUNCTION__."\n"; +} diff --git a/Zend/tests/ns_065.phpt b/Zend/tests/ns_065.phpt new file mode 100644 index 0000000..40ccd1e --- /dev/null +++ b/Zend/tests/ns_065.phpt @@ -0,0 +1,13 @@ +--TEST-- +065: Multiple names in use statement +--FILE-- +<?php +use X\Y as test, X\Z as test2; + +require "ns_065.inc"; + +test\foo(); +test2\foo(); +--EXPECT-- +X\Y\foo +X\Z\foo diff --git a/Zend/tests/ns_066.phpt b/Zend/tests/ns_066.phpt new file mode 100644 index 0000000..881589c --- /dev/null +++ b/Zend/tests/ns_066.phpt @@ -0,0 +1,10 @@ +--TEST-- +066: Name ambiguity (import name & internal class name) +--FILE-- +<?php +include __DIR__ . '/ns_027.inc'; +use Foo\Bar\Foo as stdClass; + +new stdClass(); +--EXPECT-- +Foo\Bar\Foo diff --git a/Zend/tests/ns_067.inc b/Zend/tests/ns_067.inc new file mode 100644 index 0000000..c3c14b1 --- /dev/null +++ b/Zend/tests/ns_067.inc @@ -0,0 +1,3 @@ +<?php +use Foo\Bar\Foo as Test; +new Test(); diff --git a/Zend/tests/ns_067.phpt b/Zend/tests/ns_067.phpt new file mode 100644 index 0000000..b94eb30 --- /dev/null +++ b/Zend/tests/ns_067.phpt @@ -0,0 +1,9 @@ +--TEST-- +067: Name ambiguity (import name & internal class name) +--FILE-- +<?php +include __DIR__ . '/ns_022.inc'; +include __DIR__ . '/ns_027.inc'; +include __DIR__ . '/ns_067.inc'; +--EXPECT-- +Foo\Bar\Foo diff --git a/Zend/tests/ns_068.phpt b/Zend/tests/ns_068.phpt new file mode 100644 index 0000000..97e4356 --- /dev/null +++ b/Zend/tests/ns_068.phpt @@ -0,0 +1,14 @@ +--TEST-- +068: Code before namespace +--FILE-- +<?php +echo __NAMESPACE__ . "\n"; +namespace foo; +echo __NAMESPACE__ . "\n"; +namespace bar; +echo __NAMESPACE__ . "\n"; +?> +===DONE=== +--EXPECTF-- + +Fatal error: Namespace declaration statement has to be the very first statement in the script in %sns_068.php on line %d diff --git a/Zend/tests/ns_069.inc b/Zend/tests/ns_069.inc new file mode 100644 index 0000000..4f18639 --- /dev/null +++ b/Zend/tests/ns_069.inc @@ -0,0 +1,3 @@ +<?php + +var_dump((binary)__NAMESPACE__); diff --git a/Zend/tests/ns_069.phpt b/Zend/tests/ns_069.phpt new file mode 100644 index 0000000..63269d0 --- /dev/null +++ b/Zend/tests/ns_069.phpt @@ -0,0 +1,24 @@ +--TEST-- +069: Include inside namespaced method +--FILE-- +<?php + +namespace foo; + +class Test { + static function f() { + var_dump((binary)__NAMESPACE__); + include __DIR__ . '/ns_069.inc'; + var_dump((binary)__NAMESPACE__); + } +} + +Test::f(); + +?> +===DONE=== +--EXPECT-- +string(3) "foo" +string(0) "" +string(3) "foo" +===DONE=== diff --git a/Zend/tests/ns_070.phpt b/Zend/tests/ns_070.phpt new file mode 100644 index 0000000..37cb6a0 --- /dev/null +++ b/Zend/tests/ns_070.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing parameter type-hinted with default value inside namespace +--FILE-- +<?php + +namespace foo; + +class bar { + public function __construct(\stdclass $x = NULL) { + var_dump($x); + } +} + +new bar(new \stdclass); +new bar(null); + +?> +--EXPECTF-- +object(stdClass)#%d (0) { +} +NULL diff --git a/Zend/tests/ns_071.phpt b/Zend/tests/ns_071.phpt new file mode 100644 index 0000000..604e649 --- /dev/null +++ b/Zend/tests/ns_071.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing parameter type-hinted (array) with default value inside namespace +--FILE-- +<?php + +namespace foo; + +class bar { + public function __construct(array $x = NULL) { + var_dump($x); + } +} + +new bar(null); +new bar(new \stdclass); + +?> +--EXPECTF-- +NULL + +Catchable fatal error: Argument 1 passed to foo\bar::__construct() must be of the type array, object given, called in %s on line %d and defined in %s on line %d diff --git a/Zend/tests/ns_072.phpt b/Zend/tests/ns_072.phpt new file mode 100644 index 0000000..c500bfd --- /dev/null +++ b/Zend/tests/ns_072.phpt @@ -0,0 +1,33 @@ +--TEST-- +Testing parameter type-hinted with interface +--FILE-- +<?php + +namespace foo; + +interface foo { + +} + +class bar { + public function __construct(foo $x = NULL) { + var_dump($x); + } +} + +class test implements foo { + +} + + +new bar(new test); +new bar(null); +new bar(new \stdclass); + +?> +--EXPECTF-- +object(foo\test)#%d (0) { +} +NULL + +Catchable fatal error: Argument 1 passed to foo\bar::__construct() must implement interface foo\foo, instance of stdClass given, called in %s on line %d and defined in %s on line %d diff --git a/Zend/tests/ns_073.phpt b/Zend/tests/ns_073.phpt new file mode 100644 index 0000000..bb03308 --- /dev/null +++ b/Zend/tests/ns_073.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing type-hinted lambda parameter inside namespace +--FILE-- +<?php + +namespace foo; + +$x = function (\stdclass $x = NULL) { + var_dump($x); +}; + +$x(NULL); +$x(new \stdclass); + +?> +--EXPECTF-- +NULL +object(stdClass)#%d (0) { +} diff --git a/Zend/tests/ns_074.phpt b/Zend/tests/ns_074.phpt new file mode 100644 index 0000000..28d8bf9 --- /dev/null +++ b/Zend/tests/ns_074.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing type-hinted lambda parameter inside namespace +--FILE-- +<?php + +namespace foo; + +$x = function (\stdclass $x = NULL) { + var_dump($x); +}; + +class stdclass extends \stdclass { } + +$x(NULL); +$x(new stdclass); +$x(new \stdclass); + +?> +--EXPECTF-- +NULL +object(foo\stdclass)#%d (0) { +} +object(stdClass)#%d (0) { +} diff --git a/Zend/tests/ns_075.phpt b/Zend/tests/ns_075.phpt new file mode 100644 index 0000000..0156e99 --- /dev/null +++ b/Zend/tests/ns_075.phpt @@ -0,0 +1,10 @@ +--TEST-- +075: Redefining compile-time constants +--FILE-- +<?php +namespace foo; +const NULL = 1; + +echo NULL; +--EXPECTF-- +Fatal error: Cannot redeclare constant 'NULL' in %sns_075.php on line %d diff --git a/Zend/tests/ns_076.phpt b/Zend/tests/ns_076.phpt new file mode 100644 index 0000000..eeda39b --- /dev/null +++ b/Zend/tests/ns_076.phpt @@ -0,0 +1,25 @@ +--TEST-- +076: Unknown constants in namespace +--FILE-- +<?php +namespace foo; + +$a = array(unknown => unknown); + +echo unknown; +echo "\n"; +var_dump($a); +echo \unknown; +--EXPECTF-- +Notice: Use of undefined constant unknown - assumed 'unknown' in %sns_076.php on line %d + +Notice: Use of undefined constant unknown - assumed 'unknown' in %sns_076.php on line %d + +Notice: Use of undefined constant unknown - assumed 'unknown' in %sns_076.php on line %d +unknown +array(1) { + ["unknown"]=> + %s(7) "unknown" +} + +Fatal error: Undefined constant 'unknown' in %sns_076.php on line %d diff --git a/Zend/tests/ns_077_1.phpt b/Zend/tests/ns_077_1.phpt new file mode 100644 index 0000000..5a9c4b1 --- /dev/null +++ b/Zend/tests/ns_077_1.phpt @@ -0,0 +1,13 @@ +--TEST-- +077: Unknown compile-time constants in namespace +--FILE-- +<?php +namespace foo; + +function foo($a = array(0 => \unknown)) +{ +} + +foo(); +--EXPECTF-- +Fatal error: Undefined constant 'unknown' in %sns_077_%d.php on line %d diff --git a/Zend/tests/ns_077_2.phpt b/Zend/tests/ns_077_2.phpt new file mode 100644 index 0000000..8c26721 --- /dev/null +++ b/Zend/tests/ns_077_2.phpt @@ -0,0 +1,13 @@ +--TEST-- +077: Unknown compile-time constants in namespace +--FILE-- +<?php +namespace foo; + +function foo($a = array(\unknown => unknown)) +{ +} + +foo(); +--EXPECTF-- +Fatal error: Undefined constant 'unknown' in %sns_077_%d.php on line %d diff --git a/Zend/tests/ns_077_3.phpt b/Zend/tests/ns_077_3.phpt new file mode 100644 index 0000000..bdeb792 --- /dev/null +++ b/Zend/tests/ns_077_3.phpt @@ -0,0 +1,13 @@ +--TEST-- +077: Unknown compile-time constants in namespace +--FILE-- +<?php +namespace foo; + +function foo($a = array(namespace\unknown => unknown)) +{ +} + +foo(); +--EXPECTF-- +Fatal error: Undefined constant 'foo\unknown' in %sns_077_%d.php on line %d diff --git a/Zend/tests/ns_077_4.phpt b/Zend/tests/ns_077_4.phpt new file mode 100644 index 0000000..aef91fd --- /dev/null +++ b/Zend/tests/ns_077_4.phpt @@ -0,0 +1,13 @@ +--TEST-- +077: Unknown compile-time constants in namespace +--FILE-- +<?php +namespace foo; + +function foo($a = array(0 => namespace\unknown)) +{ +} + +foo(); +--EXPECTF-- +Fatal error: Undefined constant 'foo\unknown' in %sns_077_%d.php on line %d diff --git a/Zend/tests/ns_077_5.phpt b/Zend/tests/ns_077_5.phpt new file mode 100644 index 0000000..17afe03 --- /dev/null +++ b/Zend/tests/ns_077_5.phpt @@ -0,0 +1,12 @@ +--TEST-- +077: Unknown compile-time constants in namespace +--FILE-- +<?php + +function foo($a = array(0 => \unknown)) +{ +} + +foo(); +--EXPECTF-- +Fatal error: Undefined constant 'unknown' in %sns_077_%d.php on line %d diff --git a/Zend/tests/ns_077_6.phpt b/Zend/tests/ns_077_6.phpt new file mode 100644 index 0000000..17afe03 --- /dev/null +++ b/Zend/tests/ns_077_6.phpt @@ -0,0 +1,12 @@ +--TEST-- +077: Unknown compile-time constants in namespace +--FILE-- +<?php + +function foo($a = array(0 => \unknown)) +{ +} + +foo(); +--EXPECTF-- +Fatal error: Undefined constant 'unknown' in %sns_077_%d.php on line %d diff --git a/Zend/tests/ns_077_7.phpt b/Zend/tests/ns_077_7.phpt new file mode 100644 index 0000000..9bf5baf --- /dev/null +++ b/Zend/tests/ns_077_7.phpt @@ -0,0 +1,12 @@ +--TEST-- +077: Unknown compile-time constants in namespace +--FILE-- +<?php + +function foo($a = array(0 => namespace\unknown)) +{ +} + +foo(); +--EXPECTF-- +Fatal error: Undefined constant 'unknown' in %sns_077_%d.php on line %d diff --git a/Zend/tests/ns_077_8.phpt b/Zend/tests/ns_077_8.phpt new file mode 100644 index 0000000..9f9240d --- /dev/null +++ b/Zend/tests/ns_077_8.phpt @@ -0,0 +1,12 @@ +--TEST-- +077: Unknown compile-time constants in namespace +--FILE-- +<?php + +function foo($a = array(namespace\unknown => unknown)) +{ +} + +foo(); +--EXPECTF-- +Fatal error: Undefined constant 'unknown' in %sns_077_%d.php on line %d diff --git a/Zend/tests/ns_078.phpt b/Zend/tests/ns_078.phpt new file mode 100644 index 0000000..ed6770f --- /dev/null +++ b/Zend/tests/ns_078.phpt @@ -0,0 +1,33 @@ +--TEST-- +002: Import - different syntaxes +--FILE-- +<?php +namespace test\ns1; + +class Foo { + static function bar() { + echo __CLASS__,"\n"; + } +} + +class Foo2 { + static function bar() { + echo __CLASS__,"\n"; + } +} + +namespace xyz; +use test\ns1\Foo; +use test\ns1\Foo as Bar; +use \test\ns1\Foo2; +use \test\ns1\Foo2 as Bar2; + +Foo::bar(); +Bar::bar(); +Foo2::bar(); +Bar2::bar(); +--EXPECT-- +test\ns1\Foo +test\ns1\Foo +test\ns1\Foo2 +test\ns1\Foo2 diff --git a/Zend/tests/ns_079.phpt b/Zend/tests/ns_079.phpt new file mode 100644 index 0000000..c11181c --- /dev/null +++ b/Zend/tests/ns_079.phpt @@ -0,0 +1,12 @@ +--TEST-- +079: nested namespaces +--FILE-- +<?php +namespace foo { + namespace oops { + } +} +?> +===DONE=== +--EXPECTF-- +Fatal error: Namespace declarations cannot be nested in %s on line %d diff --git a/Zend/tests/ns_080.phpt b/Zend/tests/ns_080.phpt new file mode 100644 index 0000000..9c81c0d --- /dev/null +++ b/Zend/tests/ns_080.phpt @@ -0,0 +1,15 @@ +--TEST-- +080: bracketed namespaces and __HALT_COMPILER(); +--FILE-- +<?php +namespace foo { +echo "hi\n"; +} +__HALT_COMPILER(); +namespace unprocessed { +echo "should not echo\n"; +} +?> +===DONE=== +--EXPECT-- +hi
\ No newline at end of file diff --git a/Zend/tests/ns_081.phpt b/Zend/tests/ns_081.phpt new file mode 100644 index 0000000..e08a808 --- /dev/null +++ b/Zend/tests/ns_081.phpt @@ -0,0 +1,23 @@ +--TEST-- +081: bracketed namespace with nested unbracketed namespace +--FILE-- +<?php +namespace foo { +use \foo; +class bar { + function __construct() {echo __METHOD__,"\n";} +} +new foo; +new bar; +namespace oops; +class foo { + function __construct() {echo __METHOD__,"\n";} +} +use foo\bar as foo1; +new foo1; +new foo; +} +?> +===DONE=== +--EXPECTF-- +Fatal error: Cannot mix bracketed namespace declarations with unbracketed namespace declarations in %sns_081.php on line 9 diff --git a/Zend/tests/ns_082.phpt b/Zend/tests/ns_082.phpt new file mode 100644 index 0000000..3220974 --- /dev/null +++ b/Zend/tests/ns_082.phpt @@ -0,0 +1,12 @@ +--TEST-- +082: bracketed namespace with closing tag +--FILE-- +<?php +namespace foo { +} +namespace ok { +echo "ok\n"; +} +?> +--EXPECT-- +ok
\ No newline at end of file diff --git a/Zend/tests/ns_083.phpt b/Zend/tests/ns_083.phpt new file mode 100644 index 0000000..4b821db --- /dev/null +++ b/Zend/tests/ns_083.phpt @@ -0,0 +1,14 @@ +--TEST-- +083: bracketed namespace with junk before the ns declaration +--FILE-- +<?php +$a = 'oops'; +echo $a; +namespace foo { +} +namespace ok { +echo "ok\n"; +} +?> +--EXPECTF-- +Fatal error: Namespace declaration statement has to be the very first statement in the script in %s on line %d diff --git a/Zend/tests/ns_084.phpt b/Zend/tests/ns_084.phpt new file mode 100644 index 0000000..cb1ae55 --- /dev/null +++ b/Zend/tests/ns_084.phpt @@ -0,0 +1,23 @@ +--TEST-- +084: unbracketed namespace with nested bracketed namespace +--FILE-- +<?php +namespace foo; +use \foo; +class bar { + function __construct() {echo __METHOD__,"\n";} +} +new foo; +new bar; +namespace oops { +class foo { + function __construct() {echo __METHOD__,"\n";} +} +use foo\bar as foo1; +new foo1; +new foo; +} +?> +===DONE=== +--EXPECTF-- +Fatal error: Cannot mix bracketed namespace declarations with unbracketed namespace declarations in %sns_084.php on line 9 diff --git a/Zend/tests/ns_085.phpt b/Zend/tests/ns_085.phpt new file mode 100644 index 0000000..377da6a --- /dev/null +++ b/Zend/tests/ns_085.phpt @@ -0,0 +1,27 @@ +--TEST-- +085: bracketed namespace +--FILE-- +<?php +namespace foo { +use \foo; +class bar { + function __construct() {echo __METHOD__,"\n";} +} +new foo; +new bar; +} +namespace { +class foo { + function __construct() {echo __METHOD__,"\n";} +} +use foo\bar as foo1; +new foo1; +new foo; +echo "===DONE===\n"; +} +--EXPECT-- +foo::__construct +foo\bar::__construct +foo\bar::__construct +foo::__construct +===DONE===
\ No newline at end of file diff --git a/Zend/tests/ns_086.phpt b/Zend/tests/ns_086.phpt new file mode 100644 index 0000000..00657f6 --- /dev/null +++ b/Zend/tests/ns_086.phpt @@ -0,0 +1,36 @@ +--TEST-- +086: bracketed namespace with encoding +--SKIPIF-- +<?php +if (!extension_loaded("mbstring")) { + die("skip Requires mbstring extension"); +} +?> +--INI-- +zend.multibyte=1 +--FILE-- +<?php +declare(encoding='utf-8'); +namespace foo { +use \foo; +class bar { + function __construct() {echo __METHOD__,"\n";} +} +new foo; +new bar; +} +namespace { +class foo { + function __construct() {echo __METHOD__,"\n";} +} +use foo\bar as foo1; +new foo1; +new foo; +echo "===DONE===\n"; +} +--EXPECT-- +foo::__construct +foo\bar::__construct +foo\bar::__construct +foo::__construct +===DONE===
\ No newline at end of file diff --git a/Zend/tests/ns_087.phpt b/Zend/tests/ns_087.phpt new file mode 100644 index 0000000..b2f0a89 --- /dev/null +++ b/Zend/tests/ns_087.phpt @@ -0,0 +1,24 @@ +--TEST-- +087: bracketed namespace with stuff in between +--FILE-- +<?php +namespace foo { +use \foo; +class bar { + function __construct() {echo __METHOD__,"\n";} +} +new foo; +new bar; +} +$a = 'oops'; +namespace { +class foo { + function __construct() {echo __METHOD__,"\n";} +} +use foo\bar as foo1; +new foo1; +new foo; +echo "===DONE===\n"; +} +--EXPECTF-- +Fatal error: No code may exist outside of namespace {} in %s on line 10 diff --git a/Zend/tests/object-null.phpt b/Zend/tests/object-null.phpt new file mode 100644 index 0000000..650178c --- /dev/null +++ b/Zend/tests/object-null.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test whether an object is NULL or not. +--FILE-- +<?php + +class Bla +{ +} + +$b = new Bla; + +var_dump($b != null); +var_dump($b == null); +var_dump($b !== null); +var_dump($b === null); +?> +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) diff --git a/Zend/tests/object_handlers.phpt b/Zend/tests/object_handlers.phpt new file mode 100644 index 0000000..3e8dfcc --- /dev/null +++ b/Zend/tests/object_handlers.phpt @@ -0,0 +1,177 @@ +--TEST-- +Magic object handlers segfaults and memory errors +--FILE-- +<?php +function f($x) { + return $x; +} + +class foo implements ArrayAccess { + function __get($property) { + $GLOBALS["y"] = $property; + } + function __set($property, $value) { + $GLOBALS["y"] = $property; + } + function __call($func, $args) { + $GLOBALS["y"] = $func; + } + static function __callStatic($func, $args) { + $GLOBALS["y"] = $func; + } + function offsetGet($index) { + $GLOBALS["y"] = $index; + } + function offsetSet($index, $newval) { + $GLOBALS["y"] = $index; + } + function offsetExists($index) { + $GLOBALS["y"] = $index; + } + function offsetUnset($index) { + $GLOBALS["y"] = $index; + } +} + +$x = new foo(); +$y = null; + +// IS_CONST +$z = $x->const_get; +echo $y,"\n"; +$x->const_set = 1; +echo $y,"\n"; +$x->const_call(); +echo $y,"\n"; +foo::const_callstatic(); +echo $y,"\n"; +$z = $x["const_dim_get"]; +echo $y,"\n"; +$x["const_dim_set"] = 1; +echo $y,"\n"; +isset($x["const_dim_isset"]); +echo $y,"\n"; +unset($x["const_dim_unset"]); +echo $y,"\n"; + +// IS_CONST + conversion +$z = $x->{1}; +echo $y,"\n"; +$x->{2} = 1; +echo $y,"\n"; + +// IS_TMP_VAR +$c = "tmp"; +$z = $x->{$c."_get"}; +echo $y,"\n"; +$x->{$c."_set"} = 1; +echo $y,"\n"; +$x->{$c."_call"}(); +echo $y,"\n"; +$z = $x[$c."_dim_get"]; +echo $y,"\n"; +$x[$c."_dim_set"] = 1; +echo $y,"\n"; +isset($x[$c."_dim_isset"]); +echo $y,"\n"; +unset($x[$c."_dim_unset"]); +echo $y,"\n"; + +// IS_TMP_VAR + conversion +$c = 0; +$z = $x->{$c+3}; +echo $y,"\n"; +$x->{$c+4} = 1; +echo $y,"\n"; + +// IS_CV +$c = "cv_get"; +$z = $x->{$c}; +echo $y,"\n"; +$c = "cv_set"; +$x->{$c} = 1; +echo $y,"\n"; +$c = "cv_call"; +$x->{$c}(); +echo $y,"\n"; +$c = "cv_dim_get"; +$z = $x[$c]; +echo $y,"\n"; +$c = "cv_dim_set"; +$x[$c] = 1; +echo $y,"\n"; +$c = "cv_dim_isset"; +isset($x[$c]); +echo $y,"\n"; +$c = "cv_dim_unset"; +unset($x[$c]); +echo $y,"\n"; + +// IS_CV + conversion +$c = 5; +$z = $x->{$c}; +echo $y,"\n"; +$c = 6; +$x->{$c} = 1; +echo $y,"\n"; + +// IS_VAR +$z = $x->{f("var_get")}; +echo $y,"\n"; +$x->{f("var_set")} = 1; +echo $y,"\n"; +$x->{f("var_call")}(); +echo $y,"\n"; +$z = $x[f("var_dim_get")]; +echo $y,"\n"; +$x[f("var_dim_set")] = 1; +echo $y,"\n"; +isset($x[f("var_dim_isset")]); +echo $y,"\n"; +unset($x[f("var_dim_unset")]); +echo $y,"\n"; + +// IS_VAR + conversion +$z = $x->{f(7)}; +echo $y,"\n"; +$x->{f(8)} = 1; +echo $y,"\n"; +?> +--EXPECT-- +const_get +const_set +const_call +const_callstatic +const_dim_get +const_dim_set +const_dim_isset +const_dim_unset +1 +2 +tmp_get +tmp_set +tmp_call +tmp_dim_get +tmp_dim_set +tmp_dim_isset +tmp_dim_unset +3 +4 +cv_get +cv_set +cv_call +cv_dim_get +cv_dim_set +cv_dim_isset +cv_dim_unset +5 +6 +var_get +var_set +var_call +var_dim_get +var_dim_set +var_dim_isset +var_dim_unset +7 +8 diff --git a/Zend/tests/objects_001.phpt b/Zend/tests/objects_001.phpt new file mode 100644 index 0000000..5cdc3dd --- /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 0000000..e2db140 --- /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 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 0000000..7e0f083 --- /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 test::foo($arg) 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 0000000..eb04124 --- /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 test::foo($arg) 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 0000000..908e797 --- /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 & 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 0000000..f84a305 --- /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 test::foo($arg, $arg2 = NULL) 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 0000000..75e0817 --- /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 test::foo($arg, &$arg2 = NULL) 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 0000000..f6d5826 --- /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 test::foo(Test $arg) 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 0000000..04b1118 --- /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 test::foo(Test $arg) 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 0000000..5d00462 --- /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 0000000..c7d1e87 --- /dev/null +++ b/Zend/tests/objects_011.phpt @@ -0,0 +1,18 @@ +--TEST-- +redefining constructor (__construct first) +--INI-- +error_reporting=8191 +--FILE-- +<?php + +class test { + function __construct() { + } + function test() { + } +} + +echo "Done\n"; +?> +--EXPECT-- +Done diff --git a/Zend/tests/objects_012.phpt b/Zend/tests/objects_012.phpt new file mode 100644 index 0000000..95cce3e --- /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 0000000..3f7bea8 --- /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 0000000..c422b39 --- /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 100644 index 0000000..a923ee0 --- /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/objects_017.phpt b/Zend/tests/objects_017.phpt new file mode 100644 index 0000000..6303030 --- /dev/null +++ b/Zend/tests/objects_017.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing visibility of object returned by function +--FILE-- +<?php + +class foo { + private $test = 1; +} + +function test() { + return new foo; +} + +test()->test = 2; + +?> +--EXPECTF-- +Fatal error: Cannot access private property foo::$test in %s on line %d diff --git a/Zend/tests/objects_018.phpt b/Zend/tests/objects_018.phpt new file mode 100644 index 0000000..ca5b4b8 --- /dev/null +++ b/Zend/tests/objects_018.phpt @@ -0,0 +1,21 @@ +--TEST-- +Using the same function name on interface with inheritance +--FILE-- +<?php + +interface Itest { + function a(); +} + +interface Itest2 { + function a(); +} + +interface Itest3 extends Itest, Itest2 { +} + +echo "done!\n"; + +?> +--EXPECTF-- +done! diff --git a/Zend/tests/objects_019.phpt b/Zend/tests/objects_019.phpt new file mode 100644 index 0000000..53889ed --- /dev/null +++ b/Zend/tests/objects_019.phpt @@ -0,0 +1,32 @@ +--TEST-- +Testing references of dynamic properties +--FILE-- +<?php + +error_reporting(E_ALL); + +$foo = array(new stdclass, new stdclass); + +$foo[1]->a = &$foo[0]->a; +$foo[0]->a = 2; + +$x = $foo[1]->a; +$x = 'foo'; + +var_dump($foo, $x); + +?> +--EXPECT-- +array(2) { + [0]=> + object(stdClass)#1 (1) { + ["a"]=> + &int(2) + } + [1]=> + object(stdClass)#2 (1) { + ["a"]=> + &int(2) + } +} +string(3) "foo" diff --git a/Zend/tests/objects_020.phpt b/Zend/tests/objects_020.phpt new file mode 100644 index 0000000..14e34b9 --- /dev/null +++ b/Zend/tests/objects_020.phpt @@ -0,0 +1,25 @@ +--TEST-- +Accessing members of standard object through of variable variable +--FILE-- +<?php + +error_reporting(E_ALL); + +$test = 'stdclass'; + +$$test->a =& $$test; +$$test->a->b[] = 2; + +var_dump($$test); + +?> +--EXPECTF-- +object(stdClass)#%d (2) { + ["a"]=> + *RECURSION* + ["b"]=> + array(1) { + [0]=> + int(2) + } +} diff --git a/Zend/tests/objects_021.phpt b/Zend/tests/objects_021.phpt new file mode 100644 index 0000000..70dcbfb --- /dev/null +++ b/Zend/tests/objects_021.phpt @@ -0,0 +1,39 @@ +--TEST-- +Testing magic methods __set, __get and __call in cascade +--FILE-- +<?php + +class test { + static public $i = 0; + + public function __construct() { + self::$i++; + } + + public function __set($a, $b) { + return x(); + } + + public function __get($a) { + return x(); + } + + public function __call($a, $b) { + return x(); + } +} + +function x() { + return new test; +} + +x() + ->a + ->b() + ->c = 1; + +var_dump(test::$i); + +?> +--EXPECT-- +int(4) diff --git a/Zend/tests/objects_022.phpt b/Zend/tests/objects_022.phpt new file mode 100644 index 0000000..5a80e0a --- /dev/null +++ b/Zend/tests/objects_022.phpt @@ -0,0 +1,39 @@ +--TEST-- +Testing 'self', 'parent' as type-hint +--FILE-- +<?php + +interface iTest { } + +class baz implements iTest {} + +class bar { } + +class foo extends bar { + public function testFoo(self $obj) { + var_dump($obj); + } + public function testBar(parent $obj) { + var_dump($obj); + } + public function testBaz(iTest $obj) { + var_dump($obj); + } +} + +$foo = new foo; +$foo->testFoo(new foo); +$foo->testBar(new bar); +$foo->testBaz(new baz); +$foo->testFoo(new stdClass); // Catchable fatal error + +?> +--EXPECTF-- +object(foo)#%d (0) { +} +object(bar)#%d (0) { +} +object(baz)#%d (0) { +} + +Catchable fatal error: Argument 1 passed to foo::testFoo() must be an instance of foo, instance of stdClass given, called in %s on line %d and defined in %s on line %d diff --git a/Zend/tests/objects_023.phpt b/Zend/tests/objects_023.phpt new file mode 100644 index 0000000..042a20e --- /dev/null +++ b/Zend/tests/objects_023.phpt @@ -0,0 +1,15 @@ +--TEST-- +Creating instances dynamically +--FILE-- +<?php + +$arr = array(new stdClass, 'stdClass'); + +new $arr[0](); +new $arr[1](); + +print "ok\n"; + +?> +--EXPECT-- +ok diff --git a/Zend/tests/objects_024.phpt b/Zend/tests/objects_024.phpt new file mode 100644 index 0000000..af3f879 --- /dev/null +++ b/Zend/tests/objects_024.phpt @@ -0,0 +1,53 @@ +--TEST-- +Testing direct assigning for property of object returned by function +--FILE-- +<?php + +class foo { + static $bar = array(); + + public function __set($a, $b) { + self::$bar[] = $b; + } + + public function __get($a) { + /* last */ + return self::$bar[count(self::$bar)-1]; + } +} + +function test() { + return new foo; +} + +$a = test()->bar = 1; +var_dump($a, count(foo::$bar), test()->whatever); + +print "\n"; + +$a = test()->bar = NULL; +var_dump($a, count(foo::$bar), test()->whatever); + +print "\n"; + +$a = test()->bar = test(); +var_dump($a, count(foo::$bar), test()->whatever); + +print "\n"; + +?> +--EXPECTF-- +int(1) +int(1) +int(1) + +NULL +int(2) +NULL + +object(foo)#%d (0) { +} +int(3) +object(foo)#%d (0) { +} + diff --git a/Zend/tests/objects_025.phpt b/Zend/tests/objects_025.phpt new file mode 100644 index 0000000..110ffc6 --- /dev/null +++ b/Zend/tests/objects_025.phpt @@ -0,0 +1,46 @@ +--TEST-- +Testing invalid method names with __call and __callstatic +--FILE-- +<?php + +class foo { + public function __call($a, $b) { + print "non-static - ok\n"; + } + + public static function __callstatic($a, $b) { + print "static - ok\n"; + } +} + +$a = new foo; +$a->foooo(); +$a::foooo(); + +$b = 'aaaaa1'; +$a->$b(); +$a::$b(); + +$b = ' '; +$a->$b(); +$a::$b(); + +$b = str_repeat('a', 10000); +$a->$b(); +$a::$b(); + +$b = NULL; +$a->$b(); + +?> +--EXPECTF-- +non-static - ok +static - ok +non-static - ok +static - ok +non-static - ok +static - ok +non-static - ok +static - ok + +Fatal error: Method name must be a string in %s on line %d diff --git a/Zend/tests/objects_026.phpt b/Zend/tests/objects_026.phpt new file mode 100644 index 0000000..eb3a89f --- /dev/null +++ b/Zend/tests/objects_026.phpt @@ -0,0 +1,13 @@ +--TEST-- +Using $this when out of context +--FILE-- +<?php + +try { + $this->a = 1; +} catch (Exception $e) { +} + +?> +--EXPECTF-- +Fatal error: Using $this when not in object context in %s on line %d diff --git a/Zend/tests/objects_027.phpt b/Zend/tests/objects_027.phpt new file mode 100644 index 0000000..184b471 --- /dev/null +++ b/Zend/tests/objects_027.phpt @@ -0,0 +1,44 @@ +--TEST-- +Testing 'new static;' calling parent method +--FILE-- +<?php + +class bar { + public function show() { + var_dump(new static); + } +} + +class foo extends bar { + public function test() { + parent::show(); + } +} + +$foo = new foo; +$foo->test(); +$foo::test(); + +call_user_func(array($foo, 'test')); +call_user_func(array('foo', 'test')); + +?> +--EXPECTF-- +object(foo)#%d (0) { +} + +Strict Standards: Non-static method foo::test() should not be called statically in %s on line %d + +Strict Standards: Non-static method bar::show() should not be called statically in %s on line %d +object(foo)#%d (0) { +} +object(foo)#%d (0) { +} + +Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method foo::test() should not be called statically in %s on line %d + +Strict Standards: Non-static method bar::show() should not be called statically in %s on line %d +object(foo)#%d (0) { +} + + diff --git a/Zend/tests/objects_028.phpt b/Zend/tests/objects_028.phpt new file mode 100644 index 0000000..5c76612 --- /dev/null +++ b/Zend/tests/objects_028.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing 'static::' and 'parent::' in calls +--FILE-- +<?php + +class bar { + public function __call($a, $b) { + print "hello\n"; + } +} + +class foo extends bar { + public function __construct() { + static::bar(); + parent::bar(); + } +} + + +new foo; + +?> +--EXPECT-- +hello +hello diff --git a/Zend/tests/objects_029.phpt b/Zend/tests/objects_029.phpt new file mode 100644 index 0000000..5e8de18 --- /dev/null +++ b/Zend/tests/objects_029.phpt @@ -0,0 +1,26 @@ +--TEST-- +Trying to access undeclared static property +--FILE-- +<?php + +class bar { + public function __set($a, $b) { + print "hello\n"; + } +} + +class foo extends bar { + public function __construct() { + static::$f = 1; + } + public function __set($a, $b) { + print "foo\n"; + } +} + + +new foo; + +?> +--EXPECTF-- +Fatal error: Access to undeclared static property: foo::$f in %s on line %d diff --git a/Zend/tests/objects_030.phpt b/Zend/tests/objects_030.phpt new file mode 100644 index 0000000..8b7cfe3 --- /dev/null +++ b/Zend/tests/objects_030.phpt @@ -0,0 +1,26 @@ +--TEST-- +Trying to access undeclared parent property +--FILE-- +<?php + +class bar { + public function __set($a, $b) { + print "hello\n"; + } +} + +class foo extends bar { + public function __construct() { + parent::$f = 1; + } + public function __set($a, $b) { + print "foo\n"; + } +} + + +new foo; + +?> +--EXPECTF-- +Fatal error: Access to undeclared static property: bar::$f in %s on line %d diff --git a/Zend/tests/objects_031.phpt b/Zend/tests/objects_031.phpt new file mode 100644 index 0000000..0bf2182 --- /dev/null +++ b/Zend/tests/objects_031.phpt @@ -0,0 +1,28 @@ +--TEST-- +Cloning stdClass +--FILE-- +<?php + +$x[] = clone new stdclass; +$x[] = clone new stdclass; +$x[] = clone new stdclass; + +$x[0]->a = 1; + +var_dump($x); + +?> +--EXPECTF-- +array(3) { + [0]=> + object(stdClass)#%d (1) { + ["a"]=> + int(1) + } + [1]=> + object(stdClass)#%d (0) { + } + [2]=> + object(stdClass)#%d (0) { + } +} diff --git a/Zend/tests/objects_032.phpt b/Zend/tests/objects_032.phpt new file mode 100644 index 0000000..e5e3eca --- /dev/null +++ b/Zend/tests/objects_032.phpt @@ -0,0 +1,40 @@ +--TEST-- +Covariant return-by-ref constraints +--FILE-- +<?php + +class A implements ArrayAccess { + public $foo = array(); + + public function &offsetGet($n) { + return $this->foo[$n]; + } + + public function offsetSet($n, $v) { + } + public function offsetUnset($n) { + } + public function offsetExists($n) { + } +} + +$a = new A; + +$a['foo']['bar'] = 2; + +var_dump($a); + +?> +==DONE== +--EXPECTF-- +object(A)#1 (1) { + ["foo"]=> + array(1) { + ["foo"]=> + array(1) { + ["bar"]=> + int(2) + } + } +} +==DONE== diff --git a/Zend/tests/oct_overflow_32bit.phpt b/Zend/tests/oct_overflow_32bit.phpt new file mode 100644 index 0000000..d27c1f5 --- /dev/null +++ b/Zend/tests/oct_overflow_32bit.phpt @@ -0,0 +1,31 @@ +--TEST-- +testing integer overflow (32bit) +--INI-- +precision=14 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 076545676543223, + 032325463734, + 077777797777777, + 07777777777777977777777777, + 03333333333333382222222222222, + ); + +foreach ($doubles as $d) { + $l = (double)$d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECTF-- +float(4308640384%d) +float(3545655%d) +float(262143) +float(549755813%d) +float(1884877076%d) +Done diff --git a/Zend/tests/offset_array.phpt b/Zend/tests/offset_array.phpt new file mode 100644 index 0000000..eba6611 --- /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_assign.phpt b/Zend/tests/offset_assign.phpt new file mode 100644 index 0000000..6a00591 --- /dev/null +++ b/Zend/tests/offset_assign.phpt @@ -0,0 +1,13 @@ +--TEST-- +Crash on $x['x']['y'] += 1 when $x is string +--FILE-- +<?php +$x = "a"; +$x['x']['y'] += 1; + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Illegal string offset 'x' in %soffset_assign.php on line %d + +Fatal error: Cannot use string offset as an array in %soffset_assign.php on line %d diff --git a/Zend/tests/offset_bool.phpt b/Zend/tests/offset_bool.phpt new file mode 100644 index 0000000..9bf8a89 --- /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 0000000..c65a5ba --- /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 0000000..9364f0a --- /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 0000000..b570fd2 --- /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 0000000..f7cb81b --- /dev/null +++ b/Zend/tests/offset_string.phpt @@ -0,0 +1,65 @@ +--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["13"]); +var_dump($str["14.5"]); +var_dump($str["15 and then some"]); + +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" + +Notice: String offset cast occurred in %s on line %d +string(1) "S" + +Notice: String offset cast occurred in %s on line %d +string(1) "S" + +Warning: Illegal string offset 'run away' in %s on line %d +string(1) "S" +string(1) "c" + +Warning: Illegal string offset '14.5' in %s on line %d +string(1) "o" + +Notice: A non well formed numeric value encountered in %s on line %d +string(1) "r" + +Notice: String offset cast occurred in %s on line %d +string(1) "i" + +Notice: String offset cast occurred in %s on line %d +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
\ No newline at end of file diff --git a/Zend/tests/or_001.phpt b/Zend/tests/or_001.phpt new file mode 100644 index 0000000..1e4e513 --- /dev/null +++ b/Zend/tests/or_001.phpt @@ -0,0 +1,29 @@ +--TEST-- +bitwise OR and strings +--FILE-- +<?php + +$s = "323423"; +$s1 = "2323.555"; + +var_dump($s | $s1); +var_dump($s1 | $s); + +$s = "some"; +$s1 = "test"; + +var_dump($s | $s1); + +$s = "some"; +$s |= "test"; + +var_dump($s); + +echo "Done\n"; +?> +--EXPECTF-- +string(8) "3337>755" +string(8) "3337>755" +string(4) "wou" +string(4) "wou" +Done diff --git a/Zend/tests/property_exists.phpt b/Zend/tests/property_exists.phpt new file mode 100644 index 0000000..f6d9a4a --- /dev/null +++ b/Zend/tests/property_exists.phpt @@ -0,0 +1,57 @@ +--TEST-- +Testing property_exists() +--FILE-- +<?php + +class aParent { + public static function staticTest() { + $a = new A; + var_dump(property_exists($a, "prot")); + var_dump(property_exists($a, "prot2")); + var_dump(property_exists($a, "prot3")); + print "------------------\n"; + var_dump(property_exists("A", "prot")); + var_dump(property_exists("A", "prot2")); + var_dump(property_exists("A", "prot3")); + print "------------------\n"; + } + public function nonstaticTest() { + $a = new A; + var_dump(property_exists($a, "prot")); + var_dump(property_exists($a, "prot2")); + var_dump(property_exists($a, "prot3")); + print "------------------\n"; + var_dump(property_exists("A", "prot")); + var_dump(property_exists("A", "prot2")); + var_dump(property_exists("A", "prot3")); + } +} + +class A extends aParent { + static public $prot = "prot"; + static protected $prot2 = "prot"; + static private $prot3 = "prot"; +} + +A::staticTest(); + +$a = new a; +$a->nonstaticTest(); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +------------------ +bool(true) +bool(true) +bool(true) +------------------ +bool(true) +bool(true) +bool(true) +------------------ +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/result_unused.phpt b/Zend/tests/result_unused.phpt new file mode 100644 index 0000000..0db744d --- /dev/null +++ b/Zend/tests/result_unused.phpt @@ -0,0 +1,29 @@ +--TEST-- +Unused result of fetch operations +--FILE-- +<?php +$x = array(1); +$a = "x"; +$$a; + +$x = array(array(2)); +$x[0]; + +$x = "str"; +$x[0]; +$x[3]; + +class Foo { + public $prop = array(3); + function __get($name) { + return array(4); + } +} +$x = new Foo(); +$x->prop; +$x->y; +echo "ok\n"; +--EXPECTF-- +Notice: Uninitialized string offset: 3 in %sresult_unused.php on line %d +ok + diff --git a/Zend/tests/selfParent_001.phpt b/Zend/tests/selfParent_001.phpt new file mode 100644 index 0000000..9d8cd6e --- /dev/null +++ b/Zend/tests/selfParent_001.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test when constants are initialised. See also selfParent_002.phpt. +--FILE-- +<?php +class A { + const myConst = "const in A"; + const myDynConst = self::myConst; + + public static function test() { + var_dump(self::myDynConst); + } +} + +class B extends A { + const myConst = "const in B"; + + public static function test() { + var_dump(parent::myDynConst); + } +} + +A::test(); +B::test(); +?> +--EXPECT-- +string(10) "const in A" +string(10) "const in A" diff --git a/Zend/tests/selfParent_002.phpt b/Zend/tests/selfParent_002.phpt new file mode 100644 index 0000000..18a8f09 --- /dev/null +++ b/Zend/tests/selfParent_002.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test when constants are initialised. See also selfParent_001.phpt. +--FILE-- +<?php +class A { + const myConst = "const in A"; + const myDynConst = self::myConst; + + public static function test() { + var_dump(self::myDynConst); + } +} + +class B extends A { + const myConst = "const in B"; + + public static function test() { + var_dump(parent::myDynConst); + } +} + +B::test(); +A::test(); +?> +--EXPECT-- +string(10) "const in A" +string(10) "const in A" diff --git a/Zend/tests/settype_array.phpt b/Zend/tests/settype_array.phpt Binary files differnew file mode 100644 index 0000000..5da0232 --- /dev/null +++ b/Zend/tests/settype_array.phpt diff --git a/Zend/tests/settype_bool.phpt b/Zend/tests/settype_bool.phpt new file mode 100644 index 0000000..cf59200 --- /dev/null +++ b/Zend/tests/settype_bool.phpt @@ -0,0 +1,53 @@ +--TEST-- +casting different variables to boolean using settype() +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + settype($var, "bool"); + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(true) +Done diff --git a/Zend/tests/settype_double.phpt b/Zend/tests/settype_double.phpt new file mode 100644 index 0000000..ed63f8a --- /dev/null +++ b/Zend/tests/settype_double.phpt @@ -0,0 +1,57 @@ +--TEST-- +casting different variables to double using settype() +--INI-- +precision=14 +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + settype($var, "double"); + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +float(0) +float(8754456) +float(0) +float(0) +float(9876545) +float(0.1) +float(0) +float(1) +float(0) +float(1) +float(0) +float(%d) + +Notice: Object of class test could not be converted to double in %s on line %d +float(1) +Done diff --git a/Zend/tests/settype_int.phpt b/Zend/tests/settype_int.phpt new file mode 100644 index 0000000..7b96cd5 --- /dev/null +++ b/Zend/tests/settype_int.phpt @@ -0,0 +1,55 @@ +--TEST-- +casting different variables to integer using settype() +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + settype($var, "int"); + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(0) +int(8754456) +int(0) +int(0) +int(9876545) +int(0) +int(0) +int(1) +int(0) +int(1) +int(0) +int(%d) + +Notice: Object of class test could not be converted to int in %s on line %d +int(1) +Done diff --git a/Zend/tests/settype_null.phpt b/Zend/tests/settype_null.phpt new file mode 100644 index 0000000..0abf2f9 --- /dev/null +++ b/Zend/tests/settype_null.phpt @@ -0,0 +1,53 @@ +--TEST-- +casting different variables to null using settype() +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + settype($var, "null"); + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +Done diff --git a/Zend/tests/settype_object.phpt b/Zend/tests/settype_object.phpt Binary files differnew file mode 100644 index 0000000..d619dce --- /dev/null +++ b/Zend/tests/settype_object.phpt diff --git a/Zend/tests/settype_resource.phpt b/Zend/tests/settype_resource.phpt Binary files differnew file mode 100644 index 0000000..cc8cde3 --- /dev/null +++ b/Zend/tests/settype_resource.phpt diff --git a/Zend/tests/settype_string.phpt b/Zend/tests/settype_string.phpt Binary files differnew file mode 100644 index 0000000..d3beb54 --- /dev/null +++ b/Zend/tests/settype_string.phpt diff --git a/Zend/tests/shift_001.phpt b/Zend/tests/shift_001.phpt new file mode 100644 index 0000000..aeb3994 --- /dev/null +++ b/Zend/tests/shift_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +shifting strings left +--FILE-- +<?php + +$s = "123"; +$s1 = "test"; +$s2 = "45345some"; + +$s <<= 2; +var_dump($s); + +$s1 <<= 1; +var_dump($s1); + +$s2 <<= 3; +var_dump($s2); + +echo "Done\n"; +?> +--EXPECTF-- +int(492) +int(0) +int(362760) +Done diff --git a/Zend/tests/shift_002.phpt b/Zend/tests/shift_002.phpt new file mode 100644 index 0000000..4d8421a --- /dev/null +++ b/Zend/tests/shift_002.phpt @@ -0,0 +1,25 @@ +--TEST-- +shifting strings right +--FILE-- +<?php + +$s = "123"; +$s1 = "test"; +$s2 = "45345some"; + +$s >>= 2; +var_dump($s); + +$s1 >>= 1; +var_dump($s1); + +$s2 >>= 3; +var_dump($s2); + +echo "Done\n"; +?> +--EXPECTF-- +int(30) +int(0) +int(5668) +Done diff --git a/Zend/tests/str_offset_001.phpt b/Zend/tests/str_offset_001.phpt new file mode 100644 index 0000000..8a6b91b --- /dev/null +++ b/Zend/tests/str_offset_001.phpt @@ -0,0 +1,51 @@ +--TEST--
+string offset 001
+--FILE--
+<?php
+function foo($x) {
+ var_dump($x);
+}
+
+$str = "abc";
+var_dump($str[-1]);
+var_dump($str[0]);
+var_dump($str[1]);
+var_dump($str[2]);
+var_dump($str[3]);
+var_dump($str[1][0]);
+var_dump($str[2][1]);
+
+foo($str[-1]);
+foo($str[0]);
+foo($str[1]);
+foo($str[2]);
+foo($str[3]);
+foo($str[1][0]);
+foo($str[2][1]);
+?>
+--EXPECTF--
+Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line %d
+string(0) ""
+string(1) "a"
+string(1) "b"
+string(1) "c"
+
+Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line %d
+string(0) ""
+string(1) "b"
+
+Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line %d
+string(0) ""
+
+Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line %d
+string(0) ""
+string(1) "a"
+string(1) "b"
+string(1) "c"
+
+Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line %d
+string(0) ""
+string(1) "b"
+
+Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line %d
+string(0) ""
diff --git a/Zend/tests/str_offset_002.phpt b/Zend/tests/str_offset_002.phpt new file mode 100644 index 0000000..1c465e5 --- /dev/null +++ b/Zend/tests/str_offset_002.phpt @@ -0,0 +1,9 @@ +--TEST--
+string offset 002
+--FILE--
+<?php
+$a = "aaa";
+$x = array(&$a[1]);
+?>
+--EXPECTF--
+Fatal error: Cannot create references to/from string offsets in %sstr_offset_002.php on line 3
diff --git a/Zend/tests/strict_001.phpt b/Zend/tests/strict_001.phpt new file mode 100644 index 0000000..8070eb9 --- /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 0000000..d8a5af2 --- /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 diff --git a/Zend/tests/sub_001.phpt b/Zend/tests/sub_001.phpt new file mode 100644 index 0000000..2a8b3cd --- /dev/null +++ b/Zend/tests/sub_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +subtracting arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a - $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/trait_exists_001.phpt b/Zend/tests/trait_exists_001.phpt new file mode 100644 index 0000000..10ce3fa --- /dev/null +++ b/Zend/tests/trait_exists_001.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing trait_exists() +--FILE-- +<?php + +trait foo { +} + +var_dump(trait_exists('foo')); +var_dump(trait_exists(1)); +var_dump(trait_exists(NULL)); +var_dump(trait_exists(new stdClass)); + +?> +--EXPECTF-- +bool(true) +bool(false) +bool(false) + +Warning: trait_exists() expects parameter 1 to be string, object given in %s on line %d +NULL diff --git a/Zend/tests/trait_exists_002.phpt b/Zend/tests/trait_exists_002.phpt new file mode 100644 index 0000000..7b5c899 --- /dev/null +++ b/Zend/tests/trait_exists_002.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing trait_exists() inside a namespace +--FILE-- +<?php + +namespace foo; + +trait IFoo { } + +trait ITest { } + + +var_dump(trait_exists('IFoo')); +var_dump(trait_exists('foo\\IFoo')); +var_dump(trait_exists('FOO\\ITEST')); + +?> +--EXPECT-- +bool(false) +bool(true) +bool(true) diff --git a/Zend/tests/trait_exists_003.phpt b/Zend/tests/trait_exists_003.phpt new file mode 100644 index 0000000..2d57d86 --- /dev/null +++ b/Zend/tests/trait_exists_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +Checking trait_exists(): interface, trait, abstract and final class +--FILE-- +<?php + +interface a { } + +abstract class b { } + +final class c { } + +trait d {} + +var_dump(trait_exists('a')); +var_dump(trait_exists('b')); +var_dump(trait_exists('c')); +var_dump(trait_exists('d')); + +?> +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(true) diff --git a/Zend/tests/traits/bug54441.phpt b/Zend/tests/traits/bug54441.phpt new file mode 100644 index 0000000..84139f3 --- /dev/null +++ b/Zend/tests/traits/bug54441.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #54441 (Changing trait static method visibility) +--FILE-- +<?php + +trait Foo { + public function bar() {} +} + +class Boo { + use Foo { + bar as dontKnow; + dontKnow as protected; + } +} + +?> +--EXPECTF-- +Fatal error: The modifiers for the trait alias dontKnow() need to be changed in the same statment in which the alias is defined. Error in %s on line %d diff --git a/Zend/tests/traits/bug55137.phpt b/Zend/tests/traits/bug55137.phpt new file mode 100644 index 0000000..4a4e6e6 --- /dev/null +++ b/Zend/tests/traits/bug55137.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #55137 (Changing trait static method visibility) +--FILE-- +<?php + +trait A { + protected static function foo() { echo "abc\n"; } + private static function bar() { echo "def\n"; } +} + + +class B { + use A { + A::foo as public; + A::bar as public baz; + } +} + +B::foo(); +B::baz(); + + +?> +--EXPECT-- +abc +def diff --git a/Zend/tests/traits/bug55214.phpt b/Zend/tests/traits/bug55214.phpt new file mode 100644 index 0000000..890fc37 --- /dev/null +++ b/Zend/tests/traits/bug55214.phpt @@ -0,0 +1,71 @@ +--TEST-- +Bug #55214 (Use of __CLASS__ within trait returns trait name not class name) +--FILE-- +<?php + +trait ATrait { + public static $static_var = __CLASS__; + public $var = __CLASS__; + + public static function get_class_name() { + return __CLASS__; + } + + public function get_class_name_obj() { + return __CLASS__; + } + + public static function get_class_name2() { + return self::$static_var; + } + + public function get_class_name_obj2() { + return $this->var; + } +} + +trait Indirect { + use ATrait; +} + +class SomeClass { + use ATrait; +} + +class UsingIndirect { + use Indirect; +} + +$r = SomeClass::get_class_name(); +var_dump($r); +$r = SomeClass::get_class_name2(); +var_dump($r); + +$o = new SomeClass(); +$r = $o->get_class_name_obj(); +var_dump($r); +$r = $o->get_class_name_obj2(); +var_dump($r); + +$r = UsingIndirect::get_class_name(); +var_dump($r); +$r = UsingIndirect::get_class_name2(); +var_dump($r); + +$o = new UsingIndirect(); +$r = $o->get_class_name_obj(); +var_dump($r); +$r = $o->get_class_name_obj2(); +var_dump($r); + + +?> +--EXPECT-- +string(9) "SomeClass" +string(9) "SomeClass" +string(9) "SomeClass" +string(9) "SomeClass" +string(13) "UsingIndirect" +string(13) "UsingIndirect" +string(13) "UsingIndirect" +string(13) "UsingIndirect" diff --git a/Zend/tests/traits/bug55355.phpt b/Zend/tests/traits/bug55355.phpt new file mode 100644 index 0000000..301ceee --- /dev/null +++ b/Zend/tests/traits/bug55355.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #55355 (Abstract functions required by a trait are not correctly found when implemented in an ancestor class) +--FILE-- +<?php + +// A trait that has a abstract function +trait ATrait { + function bar() { + $this->foo(); + } + abstract function foo(); +} + +// A class on the second level in the +// inheritance chain +class Level2Impl { + function foo() {} +} + +class Level1Indirect extends Level2Impl {} + +// A class on the first level in the +// inheritance chain +class Level1Direct { + function foo() {} +} + +// Trait Uses + +class Direct { + use ATrait; + function foo() {} +} + +class BaseL2 extends Level1Indirect { + use ATrait; +} + +class BaseL1 extends Level1Direct { + use ATrait; +} + +echo 'DONE'; +?> +--EXPECT-- +DONE diff --git a/Zend/tests/traits/bug55372.phpt b/Zend/tests/traits/bug55372.phpt new file mode 100644 index 0000000..e215d96 --- /dev/null +++ b/Zend/tests/traits/bug55372.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #55372 (Literal handling in methods is inconsistent, causing memory corruption) +--FILE-- +<?php + +trait testTrait { + public function testMethod() { + if (1) { + $letters1 = range('a', 'z', 1); + $letters2 = range('A', 'Z', 1); + $letters1 = 'foo'; + $letters2 = 'baarr'; + var_dump($letters1); + var_dump($letters2); + } + } +} + +class foo { + use testTrait; +} + +$x = new foo; +$x->testMethod(); +?> +--EXPECT-- +string(3) "foo" +string(5) "baarr" diff --git a/Zend/tests/traits/bug55424.phpt b/Zend/tests/traits/bug55424.phpt new file mode 100644 index 0000000..b6c3b54 --- /dev/null +++ b/Zend/tests/traits/bug55424.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #55424 (Method got missing from class when a trait defined an abstract method to express a requirement) +--FILE-- +<?php + + trait ATrait + { + function setRequired() + { + $this->setAttribute(); + } + + abstract function setAttribute(); + } + + class Base + { + function setAttribute() { } + } + + class MyClass extends Base + { + use ATrait; + } + + $i = new Base(); + $i->setAttribute(); + + $t = new MyClass(); + /* setAttribute used to disappear for no good reason. */ + $t->setRequired(); + echo 'DONE'; +?> +--EXPECT-- +DONE diff --git a/Zend/tests/traits/bug55524.phpt b/Zend/tests/traits/bug55524.phpt new file mode 100644 index 0000000..1379759 --- /dev/null +++ b/Zend/tests/traits/bug55524.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #55524 Traits should not be able to extend a class +--FILE-- +<?php + +class Base {} + +trait Foo extends Base { + function bar() {} +} + +echo 'DONE'; +?> +--EXPECTF-- +Fatal error: A trait (Foo) cannot extend a class. Traits can only be composed from other traits with the 'use' keyword. Error in %s on line %d diff --git a/Zend/tests/traits/bug55554a.phpt b/Zend/tests/traits/bug55554a.phpt new file mode 100644 index 0000000..b92a81f --- /dev/null +++ b/Zend/tests/traits/bug55554a.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #55137 (Legacy constructor not registered for class) +--FILE-- +<?php + +// All constructors should be registered as such + +trait TConstructor { + public function constructor() { + echo "ctor executed\n"; + } +} + +class NewConstructor { + use TConstructor { + constructor as __construct; + } +} + +class LegacyConstructor { + use TConstructor { + constructor as LegacyConstructor; + } +} + +echo "New constructor: "; +$o = new NewConstructor; + +echo "Legacy constructor: "; +$o = new LegacyConstructor; + +--EXPECT-- +New constructor: ctor executed +Legacy constructor: ctor executed diff --git a/Zend/tests/traits/bug55554b.phpt b/Zend/tests/traits/bug55554b.phpt new file mode 100644 index 0000000..bf40e89 --- /dev/null +++ b/Zend/tests/traits/bug55554b.phpt @@ -0,0 +1,56 @@ +--TEST-- +Bug #55137 (Legacy constructor not registered for class) +--FILE-- +<?php + +trait TConstructor { + public function foo() { + echo "foo executed\n"; + } + public function bar() { + echo "bar executed\n"; + } +} + +class OverridingIsSilent1 { + use TConstructor { + foo as __construct; + } + + public function __construct() { + echo "OverridingIsSilent1 __construct\n"; + } +} + +$o = new OverridingIsSilent1; + +class OverridingIsSilent2 { + use TConstructor { + foo as OverridingIsSilent2; + } + + public function OverridingIsSilent2() { + echo "OverridingIsSilent2 OverridingIsSilent2\n"; + } +} + +$o = new OverridingIsSilent2; + +class ReportCollision { + use TConstructor { + bar as ReportCollision; + foo as __construct; + } +} + + +echo "ReportCollision: "; +$o = new ReportCollision; + + +--EXPECTF-- +OverridingIsSilent1 __construct +OverridingIsSilent2 OverridingIsSilent2 + +Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d + diff --git a/Zend/tests/traits/bug55554c.phpt b/Zend/tests/traits/bug55554c.phpt new file mode 100644 index 0000000..466b3f1 --- /dev/null +++ b/Zend/tests/traits/bug55554c.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #55137 (Legacy constructor not registered for class) +--FILE-- +<?php + +// Test that the behavior is consistent with the existing handling of new +// and legacy constructors. +// Here, the traits conflicts are overridden by local definitions, +// and the two constructor definitions do not directly collide in that case. + +trait TC1 { + public function __construct() { + echo "TC1 executed\n"; + } + public function ReportCollision() { + echo "TC1 executed\n"; + } +} + +trait TC2 { + public function __construct() { + echo "TC2 executed\n"; + } + public function ReportCollision() { + echo "TC1 executed\n"; + } +} + +class ReportCollision { + use TC1, TC2; + + public function __construct() { + echo "New constructor executed\n"; + } + public function ReportCollision() { + echo "Legacy constructor executed\n"; + } +} + + +echo "ReportCollision: "; +$o = new ReportCollision; + + +--EXPECTF-- +ReportCollision: New constructor executed diff --git a/Zend/tests/traits/bug55554d.phpt b/Zend/tests/traits/bug55554d.phpt new file mode 100644 index 0000000..10f2e29 --- /dev/null +++ b/Zend/tests/traits/bug55554d.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #55137 (Legacy constructor not registered for class) +--FILE-- +<?php + +// Test mixed constructors from different traits, we are more strict about +// these cases, since that can lead to un-expected behavior. +// It is not consistent with the normal constructor handling, but +// here we have a chance to be more strict for the new traits. + +trait TNew { + public function __construct() { + echo "TNew executed\n"; + } +} + +trait TLegacy { + public function ReportCollision() { + echo "ReportCollision executed\n"; + } +} + +class ReportCollision { + use TNew, TLegacy; +} + +$o = new ReportCollision; + +--EXPECTF-- + +Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d + diff --git a/Zend/tests/traits/bug55554e.phpt b/Zend/tests/traits/bug55554e.phpt new file mode 100644 index 0000000..5db508f --- /dev/null +++ b/Zend/tests/traits/bug55554e.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #55137 (Legacy constructor not registered for class) +--FILE-- +<?php + +// Ensuring that the collision still occurs as expected. + +trait TC1 { + public function ReportCollision() { + echo "TC1 executed\n"; + } +} + +trait TC2 { + public function ReportCollision() { + echo "TC1 executed\n"; + } +} + +class ReportCollision { + use TC1, TC2; +} + + +echo "ReportCollision: "; +$o = new ReportCollision; + + +--EXPECTF-- +Fatal error: Trait method ReportCollision has not been applied, because there are collisions with other trait methods on ReportCollision in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/bug55554f.phpt b/Zend/tests/traits/bug55554f.phpt new file mode 100644 index 0000000..34b327d --- /dev/null +++ b/Zend/tests/traits/bug55554f.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #55137 (Legacy constructor not registered for class) +--FILE-- +<?php + +// Ensuring that inconsistent constructor use results in an error to avoid +// problems creeping in. + +trait TNew { + public function __construct() { + echo "TNew executed\n"; + } +} + +class ReportCollision { + use TNew; + + public function ReportCollision() { + echo "ReportCollision executed\n"; + } +} + + +echo "ReportCollision: "; +$o = new ReportCollision; + + +--EXPECTF-- +Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/bug55554g.phpt b/Zend/tests/traits/bug55554g.phpt new file mode 100644 index 0000000..22d2696 --- /dev/null +++ b/Zend/tests/traits/bug55554g.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #55137 (Legacy constructor not registered for class) +--FILE-- +<?php + +// Ensuring that inconsistent constructor use results in an error to avoid +// problems creeping in. + +trait TLegacy { + public function ReportCollision() { + echo "TLegacy executed\n"; + } +} + +class ReportCollision { + use TLegacy; + + public function __construct() { + echo "ReportCollision executed\n"; + } +} + + +echo "ReportCollision: "; +$o = new ReportCollision; + + +--EXPECTF-- +Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/bug60145.phpt b/Zend/tests/traits/bug60145.phpt new file mode 100644 index 0000000..fcd0cfa --- /dev/null +++ b/Zend/tests/traits/bug60145.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #60145 (Usage of trait's use statement inside interfaces not properly checked.) +--FILE-- +<?php + +trait foo { + +} + +interface MyInterface { + use foo; + + public function b(); + +} +--EXPECTF-- +Fatal error: Cannot use traits inside of interfaces. foo is used in MyInterface in %s on line %d diff --git a/Zend/tests/traits/bug60153.phpt b/Zend/tests/traits/bug60153.phpt new file mode 100644 index 0000000..979eced --- /dev/null +++ b/Zend/tests/traits/bug60153.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #60153 (Interface method prototypes not enforced when implementd via traits.) +--FILE-- +<?php + +interface IFoo { + public function oneArgument($a); +} + +trait TFoo { + public function oneArgument() {} +} + +class C implements IFoo { + use TFoo; +} + +--EXPECTF-- +Fatal error: Declaration of TFoo::oneArgument() must be compatible with IFoo::oneArgument($a) in %s on line %d diff --git a/Zend/tests/traits/bug60165a.phpt b/Zend/tests/traits/bug60165a.phpt new file mode 100644 index 0000000..245bb94 --- /dev/null +++ b/Zend/tests/traits/bug60165a.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #60165 (Aliasing unexisting trait should throw/trigger the exception/error) +--FILE-- +<?php + +trait A { + public function bar() {} +} + +class MyClass { + use A { + nonExistent as barA; + } +} + +--EXPECTF-- +Fatal error: An alias (barA) was defined for method nonExistent(), but this method does not exist in %s on line %d diff --git a/Zend/tests/traits/bug60165b.phpt b/Zend/tests/traits/bug60165b.phpt new file mode 100644 index 0000000..7b4855a --- /dev/null +++ b/Zend/tests/traits/bug60165b.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #60165 (Aliasing unexisting trait should throw/trigger the exception/error) +--FILE-- +<?php + +trait A { + public function bar() {} +} + +class MyClass { + use A { + A::nonExistent as barA; + } +} + +--EXPECTF-- +Fatal error: An alias was defined for A::nonExistent but this method does not exist in %s on line %d diff --git a/Zend/tests/traits/bug60165c.phpt b/Zend/tests/traits/bug60165c.phpt new file mode 100644 index 0000000..d72491f --- /dev/null +++ b/Zend/tests/traits/bug60165c.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #60165 (Aliasing unexisting trait should throw/trigger the exception/error) +--FILE-- +<?php + +trait A { + public function bar() {} +} + +trait B { + public function foo() {} +} + +class MyClass { + use A, B { + foo as fooB; + baz as foobar; + } +} + +--EXPECTF-- +Fatal error: An alias (foobar) was defined for method baz(), but this method does not exist in %s on line %d diff --git a/Zend/tests/traits/bug60165d.phpt b/Zend/tests/traits/bug60165d.phpt new file mode 100644 index 0000000..26ac927 --- /dev/null +++ b/Zend/tests/traits/bug60165d.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #60165 (Aliasing unexisting trait should throw/trigger the exception/error) +--FILE-- +<?php + +// The same is true for the insteadof operator to resolve conflicts + +trait A {} + +trait B { + public function bar() {} +} + +class MyClass { + use A, B { + A::bar insteadof B; + } +} + +--EXPECTF-- +Fatal error: A precedence rule was defined for A::bar but this method does not exist in %s on line %d diff --git a/Zend/tests/traits/bug60173.phpt b/Zend/tests/traits/bug60173.phpt new file mode 100644 index 0000000..a28a103 --- /dev/null +++ b/Zend/tests/traits/bug60173.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #60173 (Wrong error message on reflective trait instantiation) +--FILE-- +<?php + +trait foo { } + +$rc = new ReflectionClass('foo'); +$rc->newInstance(); + +--EXPECTF-- +Fatal error: Cannot instantiate trait foo in %s on line %d diff --git a/Zend/tests/traits/bug60217a.phpt b/Zend/tests/traits/bug60217a.phpt new file mode 100644 index 0000000..62a3515 --- /dev/null +++ b/Zend/tests/traits/bug60217a.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #60217 (Requiring the same method from different traits.) +--FILE-- +<?php + +trait T1 { + public abstract function foo(); +} + +trait T2 { + public abstract function foo(); +} + +class C { + use T1, T2; + + public function foo() { + echo "C::foo() works.\n"; + } +} + +$o = new C; +$o->foo(); + +--EXPECTF-- +C::foo() works. diff --git a/Zend/tests/traits/bug60217b.phpt b/Zend/tests/traits/bug60217b.phpt new file mode 100644 index 0000000..eb852a4 --- /dev/null +++ b/Zend/tests/traits/bug60217b.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #60217 (Requiring the same method from different traits and abstract methods have to be compatible) +--FILE-- +<?php + +trait TBroken1 { + public abstract function foo($a); +} + +trait TBroken2 { + public abstract function foo($a, $b = 0); +} + +class CBroken { + use TBroken1, TBroken2; + + public function foo($a) { + echo 'FOO'; + } +} + +$o = new CBroken; +$o->foo(1); + +--EXPECTF-- +Fatal error: Declaration of TBroken2::foo($a, $b = 0) must be compatible with TBroken1::foo($a) in %s on line %d diff --git a/Zend/tests/traits/bug60217c.phpt b/Zend/tests/traits/bug60217c.phpt new file mode 100644 index 0000000..baa4314 --- /dev/null +++ b/Zend/tests/traits/bug60217c.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #60217 (Requiring the same method from different traits and abstract methods have to be compatible, in both directions.) +--FILE-- +<?php + +trait TBroken1 { + public abstract function foo($a, $b = 0); +} + +trait TBroken2 { + public abstract function foo($a); +} + +class CBroken { + use TBroken1, TBroken2; + + public function foo($a) { + echo 'FOO'; + } +} + +$o = new CBroken; +$o->foo(1); + +--EXPECTF-- +Fatal error: Declaration of TBroken2::foo($a) must be compatible with TBroken1::foo($a, $b = 0) in %s on line %d diff --git a/Zend/tests/traits/bug60369.phpt b/Zend/tests/traits/bug60369.phpt new file mode 100644 index 0000000..bfc1ee3 --- /dev/null +++ b/Zend/tests/traits/bug60369.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #60369 (Crash with static property in trait) +--FILE-- +<?php + +trait PropertiesTrait { + static $same = true; +} + +class Properties { + use PropertiesTrait; + public $same = true; +} + +?> +--EXPECTF-- +Fatal error: Properties and PropertiesTrait define the same property ($same) in the composition of Properties. However, the definition differs and is considered incompatible. Class was composed in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/bug60717.phpt b/Zend/tests/traits/bug60717.phpt new file mode 100644 index 0000000..bf3adb1 --- /dev/null +++ b/Zend/tests/traits/bug60717.phpt @@ -0,0 +1,73 @@ +--TEST-- +Bug #60717 (Order of traits in use statement can cause unexpected unresolved abstract method) +--FILE-- +<?php + +namespace HTML +{ + interface Helper + { + function text($text); + function attributes(array $attributes = null); + function textArea(array $attributes = null, $value); + } + + trait TextUTF8 + { + function text($text) {} + } + + trait TextArea + { + function textArea(array $attributes = null, $value) {} + abstract function attributes(array $attributes = null); + abstract function text($text); + } + + trait HTMLAttributes + { + function attributes(array $attributes = null) { } + abstract function text($text); + } + + class HTMLHelper implements Helper + { + use TextArea, HTMLAttributes, TextUTF8; + } + + class HTMLHelper2 implements Helper + { + use TextArea, TextUTF8, HTMLAttributes; + } + + class HTMLHelper3 implements Helper + { + use HTMLAttributes, TextArea, TextUTF8; + } + + class HTMLHelper4 implements Helper + { + use HTMLAttributes, TextUTF8, TextArea; + } + + class HTMLHelper5 implements Helper + { + use TextUTF8, TextArea, HTMLAttributes; + } + + class HTMLHelper6 implements Helper + { + use TextUTF8, HTMLAttributes, TextArea; + } + + $o = new HTMLHelper; + $o = new HTMLHelper2; + $o = new HTMLHelper3; + $o = new HTMLHelper4; + $o = new HTMLHelper5; + $o = new HTMLHelper6; + echo 'Done'; +} + +--EXPECT-- +Done diff --git a/Zend/tests/traits/bug60809.phpt b/Zend/tests/traits/bug60809.phpt new file mode 100644 index 0000000..78e7898 --- /dev/null +++ b/Zend/tests/traits/bug60809.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #60809 (TRAITS - PHPDoc Comment Style Bug) +--FILE-- +<?php +class ExampleParent { + private $hello_world = "hello foo\n"; + public function foo() { + echo $this->hello_world; + } +} + +class Example extends ExampleParent { + use ExampleTrait; +} + +trait ExampleTrait { + /** + * + */ + private $hello_world = "hello bar\n"; + /** + * + */ + public $prop = "ops"; + public function bar() { + echo $this->hello_world; + } +} + +$x = new Example(); +$x->foo(); +$x->bar(); +?> +--EXPECT-- +hello foo +hello bar diff --git a/Zend/tests/traits/bug61052.phpt b/Zend/tests/traits/bug61052.phpt new file mode 100644 index 0000000..421e907 --- /dev/null +++ b/Zend/tests/traits/bug61052.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #61052 (missing error check in trait 'insteadof' clause) +--FILE-- +<?php +trait T1 { + function foo(){ echo "T1\n"; } +} +trait T2 { + function foo(){ echo "T2\n"; } +} +class C { + use T1, T2 { + T1::foo insteadof T1; + } +} +C::foo(); +--EXPECTF-- +Fatal error: Inconsistent insteadof definition. The method foo is to be used from T1, but T1 is also on the exclude list in %s on line %d diff --git a/Zend/tests/traits/bug61998.phpt b/Zend/tests/traits/bug61998.phpt new file mode 100644 index 0000000..612caa0 --- /dev/null +++ b/Zend/tests/traits/bug61998.phpt @@ -0,0 +1,68 @@ +--TEST-- +Bug #61998 (Using traits with method aliases appears to result in crash during execution) +--FILE-- +<?php +class Foo { + use T1 { + func as newFunc; + } + + public function func() { + echo "From Foo\n"; + } +} + +trait T1 { + public function func() { + echo "From T1\n"; + } +} + +class Bar { + public function func() { + echo "From Bar\n"; + } + public function func2() { + echo "From Bar\n"; + } + public function func3() { + echo "From Bar\n"; + } + use T1 { + func as newFunc; + func as func2; + } + use T2 { + func2 as newFunc2; + func2 as newFunc3; + func2 as func3; + } +} + +trait T2 { + public function func2() { + echo "From T2\n"; + } +} + +$f = new Foo(); + +$f->newFunc(); //from T1 +$f->func(); //from Foo + +$b = new Bar(); +$b->newFunc(); //from T1 +$b->func(); //from Bar +$b->func2(); //from Bar +$b->newFunc2(); //from T2 +$b->newFunc3(); //from T2 +$b->func3(); //from Bar +--EXPECTF-- +From T1 +From Foo +From T1 +From Bar +From Bar +From T2 +From T2 +From Bar diff --git a/Zend/tests/traits/bug64070.phpt b/Zend/tests/traits/bug64070.phpt new file mode 100644 index 0000000..a5ee3b6 --- /dev/null +++ b/Zend/tests/traits/bug64070.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #64070 (Inheritance with Traits failed with error) +--FILE-- +<?php +trait first_trait +{ + function first_function() + { + echo "From First Trait\n"; + } +} + +trait second_trait +{ + use first_trait { + first_trait::first_function as second_function; + } + + function first_function() + { + echo "From Second Trait\n"; + } +} + +class first_class +{ + use second_trait; +} + +$obj = new first_class(); +$obj->first_function(); +$obj->second_function(); +?> +--EXPECT-- +From Second Trait +From First Trait diff --git a/Zend/tests/traits/bug64235.phpt b/Zend/tests/traits/bug64235.phpt new file mode 100644 index 0000000..d0a2a98 --- /dev/null +++ b/Zend/tests/traits/bug64235.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #64235 (Insteadof not work for class method in 5.4.11) +--FILE-- +<?php + +class TestParentClass +{ + public function method() + { + print_r('Parent method'); + print "\n"; + } +} + +trait TestTrait +{ + public function method() + { + print_r('Trait method'); + print "\n"; + } +} + +class TestChildClass extends TestParentClass +{ + use TestTrait + { + TestTrait::method as methodAlias; + TestParentClass::method insteadof TestTrait; + } +} +?> +--EXPECTF-- +Fatal error: Class TestParentClass is not a trait, Only traits may be used in 'as' and 'insteadof' statements in %sbug64235.php on line %d diff --git a/Zend/tests/traits/bug64235b.phpt b/Zend/tests/traits/bug64235b.phpt new file mode 100644 index 0000000..a326ec0 --- /dev/null +++ b/Zend/tests/traits/bug64235b.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #64235 (Insteadof not work for class method in 5.4.11) +--FILE-- +<?php + +class TestParentClass +{ + public function method() + { + print_r('Parent method'); + print "\n"; + } +} + +trait TestTrait +{ + public function method() + { + print_r('Trait method'); + print "\n"; + } +} + +class TestChildClass extends TestParentClass +{ + use TestTrait + { + TestTrait::method as methodAlias; + TestParentClass::method as TestParent; + } +} + +?> +--EXPECTF-- +Fatal error: Class TestParentClass is not a trait, Only traits may be used in 'as' and 'insteadof' statements in %sbug64235b.php on line %d diff --git a/Zend/tests/traits/bugs/abstract-methods01.phpt b/Zend/tests/traits/bugs/abstract-methods01.phpt new file mode 100644 index 0000000..6275caa --- /dev/null +++ b/Zend/tests/traits/bugs/abstract-methods01.phpt @@ -0,0 +1,19 @@ +--TEST-- +Abstract Trait Methods should behave like common abstract methods. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello { + public abstract function hello(); +} + +class TraitsTest { + use THello; +} + +$test = new TraitsTest(); +$test->hello(); +?> +--EXPECTF-- +Fatal error: Class %s contains %d abstract method and must therefore be declared abstract or implement the remaining methods (%s) in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/abstract-methods02.phpt b/Zend/tests/traits/bugs/abstract-methods02.phpt new file mode 100644 index 0000000..78abe7d --- /dev/null +++ b/Zend/tests/traits/bugs/abstract-methods02.phpt @@ -0,0 +1,26 @@ +--TEST-- +Abstract Trait Methods should behave like common abstract methods. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello { + public abstract function hello(); +} + +trait THelloImpl { + public function hello() { + echo 'Hello'; + } +} + +class TraitsTest { + use THello; + use THelloImpl; +} + +$test = new TraitsTest(); +$test->hello(); +?> +--EXPECTF-- +Hello
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/abstract-methods03.phpt b/Zend/tests/traits/bugs/abstract-methods03.phpt new file mode 100644 index 0000000..605b1d8 --- /dev/null +++ b/Zend/tests/traits/bugs/abstract-methods03.phpt @@ -0,0 +1,22 @@ +--TEST-- +Abstract Trait Methods should behave like common abstract methods. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello { + public abstract function hello(); +} + +class TraitsTest { + use THello; + public function hello() { + echo 'Hello'; + } +} + +$test = new TraitsTest(); +$test->hello(); +?> +--EXPECTF-- +Hello
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/abstract-methods04.phpt b/Zend/tests/traits/bugs/abstract-methods04.phpt new file mode 100644 index 0000000..56a3464 --- /dev/null +++ b/Zend/tests/traits/bugs/abstract-methods04.phpt @@ -0,0 +1,36 @@ +--TEST-- +Abstract Trait Methods should behave like common abstract methods and +implementstion may be provided by other traits. Sorting order shouldn't influence result. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello { + public abstract function hello(); +} + +trait THelloImpl { + public function hello() { + echo 'Hello'; + } +} + +class TraitsTest1 { + use THello; + use THelloImpl; +} + +$test = new TraitsTest1(); +$test->hello(); + +class TraitsTest2 { + use THelloImpl; + use THello; +} + +$test = new TraitsTest2(); +$test->hello(); + +?> +--EXPECTF-- +HelloHello
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/abstract-methods05.phpt b/Zend/tests/traits/bugs/abstract-methods05.phpt new file mode 100644 index 0000000..9a1315f --- /dev/null +++ b/Zend/tests/traits/bugs/abstract-methods05.phpt @@ -0,0 +1,25 @@ +--TEST-- +The compatibility with the signature of abstract methods should be checked. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THelloB { + public function hello() { + echo 'Hello'; + } +} + +trait THelloA { + public abstract function hello($a); +} + +class TraitsTest1 { + use THelloB; + use THelloA; +} + + +?> +--EXPECTF-- +Fatal error: Declaration of THelloA::hello($a) must be compatible with THelloB::hello() in %s on line %d diff --git a/Zend/tests/traits/bugs/abstract-methods06.phpt b/Zend/tests/traits/bugs/abstract-methods06.phpt new file mode 100644 index 0000000..8569aef --- /dev/null +++ b/Zend/tests/traits/bugs/abstract-methods06.phpt @@ -0,0 +1,26 @@ +--TEST-- +The compatibility with the signature of abstract methods should be checked. (also checking the second possible implementation branch) +--FILE-- +<?php +error_reporting(E_ALL); + +trait THelloB { + public function hello() { + echo 'Hello'; + } +} + +trait THelloA { + public abstract function hello($a); +} + +class TraitsTest1 { + use THelloA; + use THelloB; +} + + + +?> +--EXPECTF-- +Fatal error: Declaration of THelloB::hello() must be compatible with THelloA::hello($a) in %s on line %d diff --git a/Zend/tests/traits/bugs/alias-semantics.phpt b/Zend/tests/traits/bugs/alias-semantics.phpt new file mode 100644 index 0000000..ac86692 --- /dev/null +++ b/Zend/tests/traits/bugs/alias-semantics.phpt @@ -0,0 +1,23 @@ +--TEST-- +Semantic of alias operation is to provide an additional identifier for the method body of the original method. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello { + public function a() { + echo 'A'; + } +} + +class TraitsTest { + use THello { a as b; } +} + +$test = new TraitsTest(); +$test->a(); +$test->b(); + +?> +--EXPECTF-- +AA
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/alias-semantics02.phpt b/Zend/tests/traits/bugs/alias-semantics02.phpt new file mode 100644 index 0000000..e0b5286 --- /dev/null +++ b/Zend/tests/traits/bugs/alias-semantics02.phpt @@ -0,0 +1,25 @@ +--TEST-- +Semantic of alias operation is to provide an additional identifier for the +method body of the original method. +It should also work incase the method is fully qualified. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello { + public function a() { + echo 'A'; + } +} + +class TraitsTest { + use THello { THello::a as b; } +} + +$test = new TraitsTest(); +$test->a(); +$test->b(); + +?> +--EXPECTF-- +AA
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/alias01.phpt b/Zend/tests/traits/bugs/alias01.phpt new file mode 100644 index 0000000..b60261e --- /dev/null +++ b/Zend/tests/traits/bugs/alias01.phpt @@ -0,0 +1,26 @@ +--TEST-- +Aliases are applied to the correct methods, and only to them. +--FILE-- +<?php +trait T1 { + function m1() { echo "T:m1\n"; } + function m2() { echo "T:m2\n"; } +} + +class C1 { + use T1 { m1 as a1; } +} + +$o = new C1; +$o->m1(); +$o->a1(); +$o->m2(); +$o->a2(); + +?> +--EXPECTF-- +T:m1 +T:m1 +T:m2 + +Fatal error: Call to undefined method C1::a2() in %s on line %d diff --git a/Zend/tests/traits/bugs/case-sensitive.phpt b/Zend/tests/traits/bugs/case-sensitive.phpt new file mode 100644 index 0000000..13d4188 --- /dev/null +++ b/Zend/tests/traits/bugs/case-sensitive.phpt @@ -0,0 +1,23 @@ +--TEST--
+Check for problems with case sensitivity in compositions
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait A {
+ public function M1() {}
+ public function M2() {}
+}
+
+trait B {
+ public function M1() {}
+ public function M2() {}
+}
+
+class MyClass {
+ use A;
+ use B;
+}
+?>
+--EXPECTF--
+Fatal error: Trait method M1 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
diff --git a/Zend/tests/traits/bugs/interfaces.phpt b/Zend/tests/traits/bugs/interfaces.phpt new file mode 100644 index 0000000..486bda7 --- /dev/null +++ b/Zend/tests/traits/bugs/interfaces.phpt @@ -0,0 +1,19 @@ +--TEST-- +Make sure trait does not implement an interface. +--FILE-- +<?php +error_reporting(E_ALL); + +interface MyInterface { + public function a(); +} + +trait THello implements MyInterface { + public function a() { + echo 'A'; + } +} + +?> +--EXPECTF-- +Fatal error: Cannot use 'MyInterface' as interface on 'THello' since it is a Trait in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/missing-trait.phpt b/Zend/tests/traits/bugs/missing-trait.phpt new file mode 100644 index 0000000..ce4fa5c --- /dev/null +++ b/Zend/tests/traits/bugs/missing-trait.phpt @@ -0,0 +1,15 @@ +--TEST-- +Check error message for missing traits +--FILE-- +<?php +error_reporting(E_ALL); + +class TraitsTest { + use THello; +} + +$test = new TraitsTest(); + +?> +--EXPECTF-- +Fatal error: Trait 'THello' not found in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt b/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt new file mode 100644 index 0000000..fc09a36 --- /dev/null +++ b/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt @@ -0,0 +1,31 @@ +--TEST-- +Overridding Conflicting Methods should not result in a notice/warning about collisions +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello1 { + public function hello() { + echo 'Hello'; + } +} + +trait THello2 { + public function hello() { + echo 'Hello'; + } +} + +class TraitsTest { + use THello1; + use THello2; + public function hello() { + echo 'Hello'; + } +} + +$test = new TraitsTest(); +$test->hello(); +?> +--EXPECTF-- +Hello
\ No newline at end of file diff --git a/Zend/tests/traits/bugs/overridding-conflicting-property-initializer.phpt b/Zend/tests/traits/bugs/overridding-conflicting-property-initializer.phpt new file mode 100644 index 0000000..1b9d98d --- /dev/null +++ b/Zend/tests/traits/bugs/overridding-conflicting-property-initializer.phpt @@ -0,0 +1,23 @@ +--TEST-- +Properties are considered incompatible if they are different in any of their +defined characteristics. Thus, initialization values have to be equal, too. +--FILE-- +<?php +error_reporting(E_ALL); + +trait foo +{ + public $zoo = 'foo::zoo'; +} + +class baz +{ + use foo; + public $zoo = 'baz::zoo'; +} + +$obj = new baz(); +echo $obj->zoo, "\n"; +?> +--EXPECTF-- +Fatal error: baz and foo define the same property ($zoo) in the composition of baz. However, the definition differs and is considered incompatible. Class was composed in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/conflict001.phpt b/Zend/tests/traits/conflict001.phpt new file mode 100644 index 0000000..32346b3 --- /dev/null +++ b/Zend/tests/traits/conflict001.phpt @@ -0,0 +1,25 @@ +--TEST-- +Method conflict in traits +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello1 { + private function hello() { + echo 'Hello'; + } +} + +trait THello2 { + private function hello() { + echo 'Hello'; + } +} + +class TraitsTest { + use THello1; + use THello2; +} +?> +--EXPECTF-- +Fatal error: Trait method hello has not been applied, because there are collisions with other trait methods on TraitsTest in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/conflict002.phpt b/Zend/tests/traits/conflict002.phpt new file mode 100644 index 0000000..64712d4 --- /dev/null +++ b/Zend/tests/traits/conflict002.phpt @@ -0,0 +1,32 @@ +--TEST-- +Overwridden methods do not cause a conflict. +--FILE-- +<?php +error_reporting(E_ALL); + +trait HelloWorld { + public function sayHello() { + echo 'Hello World!'; + } +} + +trait HelloWorld2 { + public function sayHello() { + echo 'Hello World2!'; + } +} + + +class TheWorldIsNotEnough { + use HelloWorld; + use HelloWorld2; + public function sayHello() { + echo 'Hello Universe!'; + } +} + +$o = new TheWorldIsNotEnough(); +$o->sayHello(); // echos Hello Universe! +?> +--EXPECTF-- +Hello Universe!
\ No newline at end of file diff --git a/Zend/tests/traits/conflict003.phpt b/Zend/tests/traits/conflict003.phpt new file mode 100644 index 0000000..0e71063 --- /dev/null +++ b/Zend/tests/traits/conflict003.phpt @@ -0,0 +1,31 @@ +--TEST-- +Two methods resulting in a conflict, should be reported both. +--FILE-- +<?php +error_reporting(E_ALL); + +trait A { + public function smallTalk() { + echo 'a'; + } + public function bigTalk() { + echo 'A'; + } +} + +trait B { + public function smallTalk() { + echo 'b'; + } + public function bigTalk() { + echo 'B'; + } +} + +class Talker { + use A, B; +} + +?> +--EXPECTF-- +Fatal error: Trait method smallTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/error_001.phpt b/Zend/tests/traits/error_001.phpt new file mode 100644 index 0000000..307e5c1 --- /dev/null +++ b/Zend/tests/traits/error_001.phpt @@ -0,0 +1,28 @@ +--TEST-- +Trying to use instanceof for a method twice +--FILE-- +<?php + +trait foo { + public function foo() { + return 1; + } +} + +trait foo2 { + public function foo() { + return 2; + } +} + + +class A extends foo { + use foo { + foo2::foo insteadof foo; + foo2::foo insteadof foo; + } +} + +?> +--EXPECTF-- +Fatal error: Class A cannot extend from trait foo in %s on line %d diff --git a/Zend/tests/traits/error_002.phpt b/Zend/tests/traits/error_002.phpt new file mode 100644 index 0000000..ac98769 --- /dev/null +++ b/Zend/tests/traits/error_002.phpt @@ -0,0 +1,12 @@ +--TEST-- +Trying to use an undefined trait +--FILE-- +<?php + +class A { + use abc; +} + +?> +--EXPECTF-- +Fatal error: Trait 'abc' not found in %s on line %d diff --git a/Zend/tests/traits/error_003.phpt b/Zend/tests/traits/error_003.phpt new file mode 100644 index 0000000..5122155 --- /dev/null +++ b/Zend/tests/traits/error_003.phpt @@ -0,0 +1,15 @@ +--TEST-- +Trying to use an interface as trait +--FILE-- +<?php + +interface abc { +} + +class A { + use abc; +} + +?> +--EXPECTF-- +Fatal error: A cannot use abc - it is not a trait in %s on line %d diff --git a/Zend/tests/traits/error_004.phpt b/Zend/tests/traits/error_004.phpt new file mode 100644 index 0000000..c7ac916 --- /dev/null +++ b/Zend/tests/traits/error_004.phpt @@ -0,0 +1,15 @@ +--TEST-- +Trying to use a class as trait +--FILE-- +<?php + +class abc { +} + +class A { + use abc; +} + +?> +--EXPECTF-- +Fatal error: A cannot use abc - it is not a trait in %s on line %d diff --git a/Zend/tests/traits/error_005.phpt b/Zend/tests/traits/error_005.phpt new file mode 100644 index 0000000..5aa5e10 --- /dev/null +++ b/Zend/tests/traits/error_005.phpt @@ -0,0 +1,15 @@ +--TEST-- +Trying to use a final class as trait +--FILE-- +<?php + +final class abc { +} + +class A { + use abc; +} + +?> +--EXPECTF-- +Fatal error: A cannot use abc - it is not a trait in %s on line %d diff --git a/Zend/tests/traits/error_006.phpt b/Zend/tests/traits/error_006.phpt new file mode 100644 index 0000000..0169321 --- /dev/null +++ b/Zend/tests/traits/error_006.phpt @@ -0,0 +1,15 @@ +--TEST-- +Trying to use an abstract class as trait +--FILE-- +<?php + +abstract class abc { +} + +class A { + use abc; +} + +?> +--EXPECTF-- +Fatal error: A cannot use abc - it is not a trait in %s on line %d diff --git a/Zend/tests/traits/error_007.phpt b/Zend/tests/traits/error_007.phpt new file mode 100644 index 0000000..82a6a2e --- /dev/null +++ b/Zend/tests/traits/error_007.phpt @@ -0,0 +1,13 @@ +--TEST-- +Trying to instantiate a trait +--FILE-- +<?php + +trait abc { +} + +new abc; + +?> +--EXPECTF-- +Fatal error: Cannot instantiate trait abc in %s on line %d diff --git a/Zend/tests/traits/error_008.phpt b/Zend/tests/traits/error_008.phpt new file mode 100644 index 0000000..ee97d75 --- /dev/null +++ b/Zend/tests/traits/error_008.phpt @@ -0,0 +1,12 @@ +--TEST-- +Trying to implement a trait +--FILE-- +<?php + +trait abc { } + +class foo implements abc { } + +?> +--EXPECTF-- +Fatal error: foo cannot implement abc - it is not an interface in %s on line %d diff --git a/Zend/tests/traits/error_009.phpt b/Zend/tests/traits/error_009.phpt new file mode 100644 index 0000000..a1eb6b4 --- /dev/null +++ b/Zend/tests/traits/error_009.phpt @@ -0,0 +1,12 @@ +--TEST-- +Trying to extend a trait +--FILE-- +<?php + +trait abc { } + +class foo extends abc { } + +?> +--EXPECTF-- +Fatal error: Class foo cannot extend from trait abc in %s on line %d diff --git a/Zend/tests/traits/error_010.phpt b/Zend/tests/traits/error_010.phpt new file mode 100644 index 0000000..de3741e --- /dev/null +++ b/Zend/tests/traits/error_010.phpt @@ -0,0 +1,23 @@ +--TEST-- +Trying to exclude trait method multiple times +--FILE-- +<?php + +trait foo { + public function test() { return 3; } +} +trait c { + public function test() { return 2; } +} + +class bar { + use foo, c { c::test insteadof foo; } + use foo, c { c::test insteadof foo; } +} + +$x = new bar; +var_dump($x->test()); + +?> +--EXPECTF-- +Fatal error: Failed to evaluate a trait precedence (test). Method of trait foo was defined to be excluded multiple times in %s on line %d diff --git a/Zend/tests/traits/error_011.phpt b/Zend/tests/traits/error_011.phpt new file mode 100644 index 0000000..2d266dd --- /dev/null +++ b/Zend/tests/traits/error_011.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing trait collisions +--FILE-- +<?php + +trait foo { + public function test() { return 3; } +} +trait c { + public function test() { return 2; } +} + +trait b { + public function test() { return 1; } +} + +class bar { + use foo, c, b; +} + +$x = new bar; +var_dump($x->test()); + +?> +--EXPECTF-- +Fatal error: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d diff --git a/Zend/tests/traits/error_012.phpt b/Zend/tests/traits/error_012.phpt new file mode 100644 index 0000000..b90e32a --- /dev/null +++ b/Zend/tests/traits/error_012.phpt @@ -0,0 +1,19 @@ +--TEST-- +Trying to access a protected trait method +--FILE-- +<?php + +trait foo { + public function test() { return 3; } +} + +class bar { + use foo { test as protected; } +} + +$x = new bar; +var_dump($x->test()); + +?> +--EXPECTF-- +Fatal error: Call to protected method bar::test() from context '' in %s on line %d diff --git a/Zend/tests/traits/error_013.phpt b/Zend/tests/traits/error_013.phpt new file mode 100644 index 0000000..d9fda2d --- /dev/null +++ b/Zend/tests/traits/error_013.phpt @@ -0,0 +1,19 @@ +--TEST-- +Trying to use static as method modifier +--FILE-- +<?php + +trait foo { + public function test() { return 3; } +} + +class bar { + use foo { test as static; } +} + +$x = new bar; +var_dump($x->test()); + +?> +--EXPECTF-- +Fatal error: Cannot use 'static' as method modifier in %s on line %d diff --git a/Zend/tests/traits/error_014.phpt b/Zend/tests/traits/error_014.phpt new file mode 100644 index 0000000..be1c919 --- /dev/null +++ b/Zend/tests/traits/error_014.phpt @@ -0,0 +1,23 @@ +--TEST-- +Trying to override final method +--FILE-- +<?php + +trait foo { + public function test() { return 3; } +} + +class baz { + final public function test() { return 4; } +} + +class bar extends baz { + use foo { test as public; } +} + +$x = new bar; +var_dump($x->test()); + +?> +--EXPECTF-- +Fatal error: Cannot override final method baz::test() in %s on line %d diff --git a/Zend/tests/traits/error_015.phpt b/Zend/tests/traits/error_015.phpt new file mode 100644 index 0000000..efcffea --- /dev/null +++ b/Zend/tests/traits/error_015.phpt @@ -0,0 +1,26 @@ +--TEST-- +Trying to add an alias to a trait method where there is another with same name. +Should warn about the conflict. +--FILE-- +<?php + +trait foo { + public function test() { return 3; } +} + +trait baz { + public function test() { return 4; } +} + +class bar { + use foo, baz { + baz::test as zzz; + } +} + +$x = new bar; +var_dump($x->test()); + +?> +--EXPECTF-- +Fatal error: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d diff --git a/Zend/tests/traits/error_016.phpt b/Zend/tests/traits/error_016.phpt new file mode 100644 index 0000000..65a3a83 --- /dev/null +++ b/Zend/tests/traits/error_016.phpt @@ -0,0 +1,12 @@ +--TEST-- +Trying to create a constant on Trait +--FILE-- +<?php + +trait foo { + const a = 1; +} + +?> +--EXPECTF-- +Fatal error: Traits cannot have constants in %s on line %d diff --git a/Zend/tests/traits/flattening001.phpt b/Zend/tests/traits/flattening001.phpt new file mode 100644 index 0000000..aa7f03d --- /dev/null +++ b/Zend/tests/traits/flattening001.phpt @@ -0,0 +1,42 @@ +--TEST-- +Methods using object properties +--FILE-- +<?php +error_reporting(E_ALL); + +trait T1 { + public function getText() { + return $this->text; + } +} + +trait T2 { + public function setTextT2($val) { + $this->text = $val; + } +} + +class TraitsTest { + use T1; + use T2; + private $text = 'test'; + public function setText($val) { + $this->text = $val; + } +} + +$o = new TraitsTest(); +var_dump($o->getText()); + +$o->setText('foo'); + +var_dump($o->getText()); + +$o->setText('bar'); + +var_dump($o->getText()); +?> +--EXPECTF-- +string(4) "test" +string(3) "foo" +string(3) "bar"
\ No newline at end of file diff --git a/Zend/tests/traits/flattening002.phpt b/Zend/tests/traits/flattening002.phpt new file mode 100644 index 0000000..251af29 --- /dev/null +++ b/Zend/tests/traits/flattening002.phpt @@ -0,0 +1,28 @@ +--TEST-- +parent:: works like in a method defined without traits. +--FILE-- +<?php +error_reporting(E_ALL); + +class Base { + public function sayHello() { + echo 'Hello '; + } +} + +trait SayWorld { + public function sayHello() { + parent::sayHello(); + echo 'World!'; + } +} + +class MyHelloWorld extends Base { + use SayWorld; +} + +$o = new MyHelloWorld(); +$o->sayHello(); +?> +--EXPECTF-- +Hello World!
\ No newline at end of file diff --git a/Zend/tests/traits/flattening003.phpt b/Zend/tests/traits/flattening003.phpt new file mode 100644 index 0000000..d189ca7 --- /dev/null +++ b/Zend/tests/traits/flattening003.phpt @@ -0,0 +1,32 @@ +--TEST-- +Traits are flattened recurivly. +--FILE-- +<?php +error_reporting(E_ALL); + +trait Hello { + public function sayHello() { + echo 'Hello '; + } +} + +trait World { + public function sayWorld() { + echo 'World!'; + } +} + +trait HelloWorld { + use Hello, World; +} + +class MyHelloWorld { + use HelloWorld; +} + +$o = new MyHelloWorld(); +$o->sayHello(); +$o->sayWorld(); +?> +--EXPECTF-- +Hello World!
\ No newline at end of file diff --git a/Zend/tests/traits/get_declared_traits_001.phpt b/Zend/tests/traits/get_declared_traits_001.phpt new file mode 100644 index 0000000..91f6b3d --- /dev/null +++ b/Zend/tests/traits/get_declared_traits_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing get_declared_traits() +--FILE-- +<?php + +class a { } +interface b { } +trait c { } +abstract class d { } +final class e { } + +var_dump(get_declared_traits()); + +?> +--EXPECT-- +array(1) { + [0]=> + string(1) "c" +} diff --git a/Zend/tests/traits/get_declared_traits_002.phpt b/Zend/tests/traits/get_declared_traits_002.phpt new file mode 100644 index 0000000..74fdcc4 --- /dev/null +++ b/Zend/tests/traits/get_declared_traits_002.phpt @@ -0,0 +1,20 @@ +--TEST-- +Testing get_declared_traits() inside namespace +--FILE-- +<?php + +namespace test { + class a { } + interface b { } + trait c { } + abstract class d { } + final class e { } + var_dump(get_declared_traits()); +} + +?> +--EXPECT-- +array(1) { + [0]=> + string(6) "test\c" +} diff --git a/Zend/tests/traits/get_declared_traits_003.phpt b/Zend/tests/traits/get_declared_traits_003.phpt new file mode 100644 index 0000000..4a68746 --- /dev/null +++ b/Zend/tests/traits/get_declared_traits_003.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing get_declared_classes() and get_declared_traits() +--FILE-- +<?php + +class a { } +interface b { } +trait c { } +abstract class d { } +final class e { } +var_dump(get_declared_classes()); +var_dump(get_declared_traits()); + +?> +--EXPECTF-- +%astring(1) "a" + [%d]=> + string(1) "d" + [%d]=> + string(1) "e" +} +array(1) { + [0]=> + string(1) "c" +} diff --git a/Zend/tests/traits/inheritance001.phpt b/Zend/tests/traits/inheritance001.phpt new file mode 100644 index 0000000..e8195c4 --- /dev/null +++ b/Zend/tests/traits/inheritance001.phpt @@ -0,0 +1,24 @@ +--TEST-- +Trait method overwridden by a method defined in the class. +--FILE-- +<?php +error_reporting(E_ALL); + +trait HelloWorld { + public function sayHello() { + echo 'Hello World!'; + } +} + +class TheWorldIsNotEnough { + use HelloWorld; + public function sayHello() { + echo 'Hello Universe!'; + } +} + +$o = new TheWorldIsNotEnough(); +$o->sayHello(); // echos Hello Universe! +?> +--EXPECTF-- +Hello Universe!
\ No newline at end of file diff --git a/Zend/tests/traits/inheritance002.phpt b/Zend/tests/traits/inheritance002.phpt new file mode 100644 index 0000000..51badc5 --- /dev/null +++ b/Zend/tests/traits/inheritance002.phpt @@ -0,0 +1,27 @@ +--TEST-- +Trait method overriddes base class method +--FILE-- +<?php +error_reporting(E_ALL); + +class Base { + public function sayHello() { + echo 'Hello '; + } +} + +trait SayWorld { + public function sayHello() { + echo 'World!'; + } +} + +class MyHelloWorld extends Base { + use SayWorld; +} + +$o = new MyHelloWorld(); +$o->sayHello(); +?> +--EXPECTF-- +World!
\ No newline at end of file diff --git a/Zend/tests/traits/inheritance003.phpt b/Zend/tests/traits/inheritance003.phpt new file mode 100644 index 0000000..22ff6e2 --- /dev/null +++ b/Zend/tests/traits/inheritance003.phpt @@ -0,0 +1,38 @@ +--TEST-- +Trait method overrides base class method and satisfies prototype +--FILE-- +<?php +error_reporting(E_ALL); + +abstract class Base { + public abstract function sayHello(array $a); +} + +class SubClass extends Base { + public function sayHello(array $a) { + echo "World!\n"; + } +} + +$s = new SubClass(); +$s->sayHello(array()); + + +trait SayWorld { + public function sayHello(Base $d) { + echo 'World!'; + } +} + +class MyHelloWorld extends Base { + use SayWorld; +} + +$o = new MyHelloWorld(); +$o->sayHello(array()); + +?> +--EXPECTF-- +World! + +Fatal error: Declaration of SayWorld::sayHello(Base $d) must be compatible with Base::sayHello(array $a) in %s on line %d diff --git a/Zend/tests/traits/interface_001.phpt b/Zend/tests/traits/interface_001.phpt new file mode 100644 index 0000000..a14f78e --- /dev/null +++ b/Zend/tests/traits/interface_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +Using traits to implement interface +--FILE-- +<?php + +trait foo { + public function abc() { + } +} + +interface baz { + public function abc(); +} + +class bar implements baz { + use foo; + +} + +new bar; +print "OK\n"; + +?> +--EXPECT-- +OK diff --git a/Zend/tests/traits/interface_002.phpt b/Zend/tests/traits/interface_002.phpt new file mode 100644 index 0000000..462d73f --- /dev/null +++ b/Zend/tests/traits/interface_002.phpt @@ -0,0 +1,24 @@ +--TEST-- +Checking error message when the trait doesn't implements the interface +--FILE-- +<?php + +trait foo { + public function a() { + } +} + +interface baz { + public function abc(); +} + +class bar implements baz { + use foo; + +} + +new bar; + +?> +--EXPECTF-- +Fatal error: Class bar contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (baz::abc) in %s on line %d diff --git a/Zend/tests/traits/interface_003.phpt b/Zend/tests/traits/interface_003.phpt new file mode 100644 index 0000000..aa13bd8 --- /dev/null +++ b/Zend/tests/traits/interface_003.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing to implement Serializable interface by traits +--FILE-- +<?php + +trait foo { + public function serialize() { + return 'foobar'; + } + public function unserialize($x) { + var_dump($x); + } +} + +class bar implements Serializable { + use foo; +} + +var_dump($o = serialize(new bar)); +var_dump(unserialize($o)); + +?> +--EXPECTF-- +string(20) "C:3:"bar":6:{foobar}" +string(6) "foobar" +object(bar)#%d (0) { +} diff --git a/Zend/tests/traits/language001.phpt b/Zend/tests/traits/language001.phpt new file mode 100644 index 0000000..d892112 --- /dev/null +++ b/Zend/tests/traits/language001.phpt @@ -0,0 +1,21 @@ +--TEST-- +Single Trait with simple trait method +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello { + public function hello() { + echo 'Hello'; + } +} + +class TraitsTest { + use THello; +} + +$test = new TraitsTest(); +$test->hello(); +?> +--EXPECTF-- +Hello diff --git a/Zend/tests/traits/language002.phpt b/Zend/tests/traits/language002.phpt new file mode 100644 index 0000000..d093f29 --- /dev/null +++ b/Zend/tests/traits/language002.phpt @@ -0,0 +1,32 @@ +--TEST-- +Use multiple traits. +--FILE-- +<?php +error_reporting(E_ALL); + +trait Hello { + public function sayHello() { + echo 'Hello '; + } +} + +trait World { + public function sayWorld() { + echo 'World'; + } +} + +class MyHelloWorld { + use Hello, World; + public function sayExclamationMark() { + echo '!'; + } +} + +$o = new MyHelloWorld(); +$o->sayHello(); +$o->sayWorld(); +$o->sayExclamationMark(); +?> +--EXPECTF-- +Hello World!
\ No newline at end of file diff --git a/Zend/tests/traits/language003.phpt b/Zend/tests/traits/language003.phpt new file mode 100644 index 0000000..77d4429 --- /dev/null +++ b/Zend/tests/traits/language003.phpt @@ -0,0 +1,29 @@ +--TEST-- +Use instead to solve a conflict. +--FILE-- +<?php +error_reporting(E_ALL); + +trait Hello { + public function saySomething() { + echo 'Hello'; + } +} + +trait World { + public function saySomething() { + echo 'World'; + } +} + +class MyHelloWorld { + use Hello, World { + Hello::saySomething insteadof World; + } +} + +$o = new MyHelloWorld(); +$o->saySomething(); +?> +--EXPECTF-- +Hello
\ No newline at end of file diff --git a/Zend/tests/traits/language004.phpt b/Zend/tests/traits/language004.phpt new file mode 100644 index 0000000..4df307a --- /dev/null +++ b/Zend/tests/traits/language004.phpt @@ -0,0 +1,31 @@ +--TEST-- +Use instead to solve a conflict and as to access the method. +--FILE-- +<?php +error_reporting(E_ALL); + +trait Hello { + public function saySomething() { + echo 'Hello'; + } +} + +trait World { + public function saySomething() { + echo ' World'; + } +} + +class MyHelloWorld { + use Hello, World { + Hello::saySomething insteadof World; + World::saySomething as sayWorld; + } +} + +$o = new MyHelloWorld(); +$o->saySomething(); +$o->sayWorld(); +?> +--EXPECTF-- +Hello World
\ No newline at end of file diff --git a/Zend/tests/traits/language005.phpt b/Zend/tests/traits/language005.phpt new file mode 100644 index 0000000..20eaeb3 --- /dev/null +++ b/Zend/tests/traits/language005.phpt @@ -0,0 +1,40 @@ +--TEST-- +Use instead to solve a conflict and as to access the method. +--FILE-- +<?php +error_reporting(E_ALL); + +trait A { + public function smallTalk() { + echo 'a'; + } + public function bigTalk() { + echo 'A'; + } +} + +trait B { + public function smallTalk() { + echo 'b'; + } + public function bigTalk() { + echo 'B'; + } +} + +class Talker { + use A, B { + B::smallTalk insteadof A; + A::bigTalk insteadof B; + B::bigTalk as talk; + } +} + +$t = new Talker; +$t->smallTalk(); +$t->bigTalk(); +$t->talk(); + +?> +--EXPECTF-- +bAB
\ No newline at end of file diff --git a/Zend/tests/traits/language006.phpt b/Zend/tests/traits/language006.phpt new file mode 100644 index 0000000..5a32359 --- /dev/null +++ b/Zend/tests/traits/language006.phpt @@ -0,0 +1,31 @@ +--TEST-- +Express requirements of a trait by abstract methods. +--FILE-- +<?php +error_reporting(E_ALL); + +trait Hello { + public function sayHelloWorld() { + echo 'Hello'.$this->getWorld(); + } + abstract public function getWorld(); + } + +class MyHelloWorld { + private $world; + use Hello; + public function getWorld() { + return $this->world; + } + public function setWorld($val) { + $this->world = $val; + } +} + +$o = new MyHelloWorld(); +$o->setWorld(' World!'); +$o->sayHelloWorld(); + +?> +--EXPECTF-- +Hello World!
\ No newline at end of file diff --git a/Zend/tests/traits/language007.phpt b/Zend/tests/traits/language007.phpt new file mode 100644 index 0000000..3b65d01 --- /dev/null +++ b/Zend/tests/traits/language007.phpt @@ -0,0 +1,30 @@ +--TEST-- +Traits can fulfill the requirements of abstract base classes. +--FILE-- +<?php +error_reporting(E_ALL); + +abstract class Base { + abstract function sayWorld(); +} + +trait Hello { + public function sayHello() { + echo 'Hello'; + } + public function sayWorld() { + echo ' World!'; + } + } + +class MyHelloWorld extends Base { + use Hello; +} + +$o = new MyHelloWorld(); +$o->sayHello(); +$o->sayWorld(); + +?> +--EXPECTF-- +Hello World!
\ No newline at end of file diff --git a/Zend/tests/traits/language008a.phpt b/Zend/tests/traits/language008a.phpt new file mode 100644 index 0000000..5a12a4e --- /dev/null +++ b/Zend/tests/traits/language008a.phpt @@ -0,0 +1,23 @@ +--TEST-- +Visibility can be changed with the as aliasing construct as well. +--FILE-- +<?php +error_reporting(E_ALL); + +trait HelloWorld { + public function sayHello() { + echo 'Hello World!'; + } +} + +class MyClass { + use HelloWorld { sayHello as protected; } +} + + +$o = new MyClass; +$o->sayHello(); + +?> +--EXPECTF-- +Fatal error: Call to protected method MyClass::sayHello() from context '' in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/language008b.phpt b/Zend/tests/traits/language008b.phpt new file mode 100644 index 0000000..9abbdbe --- /dev/null +++ b/Zend/tests/traits/language008b.phpt @@ -0,0 +1,30 @@ +--TEST-- +Visibility can be changed with the as aliasing construct as well. +--FILE-- +<?php +error_reporting(E_ALL); + +trait HelloWorld { + public function sayHello() { + echo 'Hello World!'; + } +} + +class MyClass { + use HelloWorld { sayHello as private sayHelloWorld; } + + public function callPrivateAlias() { + $this->sayHelloWorld(); + } +} + +$o = new MyClass(); +$o->sayHello(); +$o->callPrivateAlias(); +$o->sayHelloWorld(); + + +?> +--EXPECTF-- +Hello World!Hello World! +Fatal error: Call to private method MyClass::sayHelloWorld() from context '' in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/language009.phpt b/Zend/tests/traits/language009.phpt new file mode 100644 index 0000000..e55c8d8 --- /dev/null +++ b/Zend/tests/traits/language009.phpt @@ -0,0 +1,36 @@ +--TEST-- +In instead definitions all trait whose methods are meant to be hidden can be listed. +--FILE-- +<?php +error_reporting(E_ALL); + +trait A { + public function foo() { + echo 'a'; + } +} + +trait B { + public function foo() { + echo 'b'; + } +} + +trait C { + public function foo() { + echo 'c'; + } +} + +class MyClass { + use C, A, B { + B::foo insteadof A, C; + } +} + +$t = new MyClass; +$t->foo(); + +?> +--EXPECTF-- +b
\ No newline at end of file diff --git a/Zend/tests/traits/language010.phpt b/Zend/tests/traits/language010.phpt new file mode 100644 index 0000000..e550abb --- /dev/null +++ b/Zend/tests/traits/language010.phpt @@ -0,0 +1,30 @@ +--TEST-- +Aliasing leading to conflict should result in error message +--FILE-- +<?php +error_reporting(E_ALL); + +trait Hello { + public function hello() { + echo 'Hello'; + } +} + +trait World { + public function world() { + echo ' World!'; + } +} + + +class MyClass { + use Hello, World { hello as world; } +} + +$o = new MyClass(); +$o->hello(); +$o->world(); + +?> +--EXPECTF-- +Fatal error: Trait method world has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/language011.phpt b/Zend/tests/traits/language011.phpt new file mode 100644 index 0000000..585699d --- /dev/null +++ b/Zend/tests/traits/language011.phpt @@ -0,0 +1,30 @@ +--TEST-- +Aliasing on conflicting method should not cover up conflict. +--FILE-- +<?php +error_reporting(E_ALL); + +trait Hello { + public function sayHello() { + echo 'Hello'; + } +} + +trait World { + public function sayHello() { + echo ' World!'; + } +} + + +class MyClass { + use Hello, World { sayHello as sayWorld; } +} + +$o = new MyClass(); +$o->sayHello(); +$o->sayWorld(); + +?> +--EXPECTF-- +Fatal error: Trait method sayHello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d diff --git a/Zend/tests/traits/language012.phpt b/Zend/tests/traits/language012.phpt new file mode 100644 index 0000000..481dd64 --- /dev/null +++ b/Zend/tests/traits/language012.phpt @@ -0,0 +1,27 @@ +--TEST-- +Statics should work in traits, too. +--FILE-- +<?php +error_reporting(E_ALL); + +trait Counter { + public function inc() { + static $c = 0; + $c = $c + 1; + echo "$c\n"; + } +} + + +class C1 { + use Counter; +} + +$o = new C1(); +$o->inc(); +$o->inc(); + +?> +--EXPECTF-- +1 +2 diff --git a/Zend/tests/traits/language013.phpt b/Zend/tests/traits/language013.phpt new file mode 100644 index 0000000..a55cbbe --- /dev/null +++ b/Zend/tests/traits/language013.phpt @@ -0,0 +1,37 @@ +--TEST-- +Statics work like expected for language-based copy'n'paste. No link between methods from the same trait. +--FILE-- +<?php +error_reporting(E_ALL); + +trait Counter { + public function inc() { + static $c = 0; + $c = $c + 1; + echo "$c\n"; + } +} + + +class C1 { + use Counter; +} + +class C2 { + use Counter; +} + +$o = new C1(); +$o->inc(); +$o->inc(); + +$p = new C2(); +$p->inc(); +$p->inc(); + +?> +--EXPECTF-- +1 +2 +1 +2 diff --git a/Zend/tests/traits/language014.phpt b/Zend/tests/traits/language014.phpt new file mode 100644 index 0000000..102b9ae --- /dev/null +++ b/Zend/tests/traits/language014.phpt @@ -0,0 +1,30 @@ +--TEST-- +Aliasing leading to conflict should result in error message +--FILE-- +<?php +error_reporting(E_ALL); + +trait Hello { + public function hello() { + echo 'Hello'; + } +} + +trait World { + public function world() { + echo ' World!'; + } +} + + +class MyClass { + use Hello, World { world as hello; } +} + +$o = new MyClass(); +$o->hello(); +$o->world(); + +?> +--EXPECTF-- +Fatal error: Trait method hello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d diff --git a/Zend/tests/traits/language015.phpt b/Zend/tests/traits/language015.phpt new file mode 100644 index 0000000..0c9fb4a --- /dev/null +++ b/Zend/tests/traits/language015.phpt @@ -0,0 +1,17 @@ +--TEST-- +Invalid conflict resolution (unused trait as lhs of "insteadof") +--FILE-- +<?php +trait T1 { + function foo() {echo "T1\n";} +} +trait T2 { + function foo() {echo "T2\n";} +} +class C { + use T1 { + T2::foo insteadof T1; + } +} +--EXPECTF-- +Fatal error: Required Trait T2 wasn't added to C in %slanguage015.php on line %d diff --git a/Zend/tests/traits/language016.phpt b/Zend/tests/traits/language016.phpt new file mode 100644 index 0000000..1c6bbea --- /dev/null +++ b/Zend/tests/traits/language016.phpt @@ -0,0 +1,17 @@ +--TEST-- +Invalid conflict resolution (unused trait as rhs of "insteadof") +--FILE-- +<?php +trait T1 { + function foo() {echo "T1\n";} +} +trait T2 { + function foo() {echo "T2\n";} +} +class C { + use T1 { + T1::foo insteadof T2; + } +} +--EXPECTF-- +Fatal error: Required Trait T2 wasn't added to C in %slanguage016.php on line %d diff --git a/Zend/tests/traits/language017.phpt b/Zend/tests/traits/language017.phpt new file mode 100644 index 0000000..539a05d --- /dev/null +++ b/Zend/tests/traits/language017.phpt @@ -0,0 +1,17 @@ +--TEST-- +Invalid conflict resolution (unused trait as lhs of "as") +--FILE-- +<?php +trait T1 { + function foo() {echo "T1\n";} +} +trait T2 { + function foo() {echo "T2\n";} +} +class C { + use T1 { + T2::foo as private; + } +} +--EXPECTF-- +Fatal error: Required Trait T2 wasn't added to C in %slanguage017.php on line %d diff --git a/Zend/tests/traits/language018.phpt b/Zend/tests/traits/language018.phpt new file mode 100644 index 0000000..169cb50 --- /dev/null +++ b/Zend/tests/traits/language018.phpt @@ -0,0 +1,15 @@ +--TEST-- +abstract alias +--FILE-- +<?php +trait T1 { + function foo() {} +} +class C1 { + use T1 { + T1::foo as abstract; + } +} +?> +--EXPECTF-- +Fatal error: Cannot use 'abstract' as method modifier in %s on line %d diff --git a/Zend/tests/traits/language019.phpt b/Zend/tests/traits/language019.phpt new file mode 100644 index 0000000..83318c5 --- /dev/null +++ b/Zend/tests/traits/language019.phpt @@ -0,0 +1,15 @@ +--TEST-- +final alias +--FILE-- +<?php +trait T1 { + function foo() {} +} +class C1 { + use T1 { + T1::foo as final; + } +} +?> +--EXPECTF-- +Fatal error: Cannot use 'final' as method modifier in %s on line %d diff --git a/Zend/tests/traits/methods_001.phpt b/Zend/tests/traits/methods_001.phpt new file mode 100644 index 0000000..e1ee815 --- /dev/null +++ b/Zend/tests/traits/methods_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +Testing magic method on trait +--FILE-- +<?php + +trait foo { + public function __toString() { + return '123'; + } + + public function __get($x) { + var_dump($x); + } + + public function __set($attr, $val) { + var_dump($attr .'==='. $val); + } + + public function __clone() { + var_dump(__FUNCTION__); + } +} + +class bar { + use foo; +} + +$o = new bar; +echo $o, PHP_EOL; +$o->xyz; +$o->xyz = 2; +clone $o; + +?> +--EXPECT-- +123 +string(3) "xyz" +string(7) "xyz===2" +string(7) "__clone" diff --git a/Zend/tests/traits/methods_002.phpt b/Zend/tests/traits/methods_002.phpt new file mode 100644 index 0000000..4ed64c1 --- /dev/null +++ b/Zend/tests/traits/methods_002.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing collision with magic methods +--FILE-- +<?php + +trait foo { + public function __clone() { + var_dump(__FUNCTION__); + } +} + +trait baz { + public function __clone() { + var_dump(__FUNCTION__); + } +} + +class bar { + use foo; + use baz; +} + +$o = new bar; +var_dump(clone $o); + +?> +--EXPECTF-- +Fatal error: Trait method __clone has not been applied, because there are collisions with other trait methods on bar in %s on line %d diff --git a/Zend/tests/traits/methods_003.phpt b/Zend/tests/traits/methods_003.phpt new file mode 100644 index 0000000..1c1218a --- /dev/null +++ b/Zend/tests/traits/methods_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing __construct and __destruct with Trait +--FILE-- +<?php + +trait foo { + public function __construct() { + var_dump(__FUNCTION__); + } + public function __destruct() { + var_dump(__FUNCTION__); + } +} + +class bar { + use foo; +} + +new bar; + +?> +--EXPECT-- +string(11) "__construct" +string(10) "__destruct" diff --git a/Zend/tests/traits/noctor001.phpt b/Zend/tests/traits/noctor001.phpt new file mode 100644 index 0000000..d15acff --- /dev/null +++ b/Zend/tests/traits/noctor001.phpt @@ -0,0 +1,28 @@ +--TEST-- +Don't mark trait methods as constructor +--FILE-- +<?php +trait Foo { + public function Foo() { + } +} + +class Bar { + use Foo; + public function Bar() { + } +} + +$rfoofoo = new ReflectionMethod('Foo::Foo'); +var_dump($rfoofoo->isConstructor()); + +$rbarfoo = new ReflectionMethod('Bar::Foo'); +var_dump($rbarfoo->isConstructor()); + +$rbarbar = new ReflectionMethod('Bar::Bar'); +var_dump($rbarbar->isConstructor()); +?> +--EXPECT-- +bool(false) +bool(false) +bool(true) diff --git a/Zend/tests/traits/property001.phpt b/Zend/tests/traits/property001.phpt new file mode 100644 index 0000000..d5e4ddc --- /dev/null +++ b/Zend/tests/traits/property001.phpt @@ -0,0 +1,41 @@ +--TEST-- +Potentially conflicting properties should result in a strict notice. Property use is discorage for traits that are supposed to enable maintainable code reuse. Accessor methods are the language supported idiom for this. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello1 { + private $foo; +} + +trait THello2 { + private $foo; +} + +echo "PRE-CLASS-GUARD-TraitsTest\n"; +error_reporting(E_ALL & ~E_STRICT); // ensuring that it is only for E_STRICT + +class TraitsTest { + use THello1; + use THello2; +} + +error_reporting(E_ALL | E_STRICT); + +echo "PRE-CLASS-GUARD-TraitsTest2\n"; + +class TraitsTest2 { + use THello1; + use THello2; +} + +var_dump(property_exists('TraitsTest', 'foo')); +var_dump(property_exists('TraitsTest2', 'foo')); +?> +--EXPECTF-- +PRE-CLASS-GUARD-TraitsTest +PRE-CLASS-GUARD-TraitsTest2 + +Strict Standards: THello1 and THello2 define the same property ($foo) in the composition of TraitsTest2. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +bool(true) +bool(true)
\ No newline at end of file diff --git a/Zend/tests/traits/property002.phpt b/Zend/tests/traits/property002.phpt new file mode 100644 index 0000000..27361e0 --- /dev/null +++ b/Zend/tests/traits/property002.phpt @@ -0,0 +1,32 @@ +--TEST-- +Non-conflicting properties should work just fine. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello1 { + public $hello = "hello"; +} + +trait THello2 { + private $world = "World!"; +} + +class TraitsTest { + use THello1; + use THello2; + function test() { + echo $this->hello . ' ' . $this->world; + } +} + +var_dump(property_exists('TraitsTest', 'hello')); +var_dump(property_exists('TraitsTest', 'world')); + +$t = new TraitsTest; +$t->test(); +?> +--EXPECTF-- +bool(true) +bool(true) +hello World!
\ No newline at end of file diff --git a/Zend/tests/traits/property003.phpt b/Zend/tests/traits/property003.phpt new file mode 100644 index 0000000..b4f0105 --- /dev/null +++ b/Zend/tests/traits/property003.phpt @@ -0,0 +1,30 @@ +--TEST-- +Conflicting properties with different visibility modifiers should result in a fatal error, since this indicates that the code is incompatible. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello1 { + public $hello; +} + +trait THello2 { + private $hello; +} + +echo "PRE-CLASS-GUARD\n"; + +class TraitsTest { + use THello1; + use THello2; +} + +echo "POST-CLASS-GUARD\n"; + +$t = new TraitsTest; +$t->hello = "foo"; +?> +--EXPECTF-- +PRE-CLASS-GUARD + +Fatal error: THello1 and THello2 define the same property ($hello) in the composition of TraitsTest. However, the definition differs and is considered incompatible. Class was composed in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/property004.phpt b/Zend/tests/traits/property004.phpt new file mode 100644 index 0000000..393b492 --- /dev/null +++ b/Zend/tests/traits/property004.phpt @@ -0,0 +1,30 @@ +--TEST-- +Conflicting properties with different initial values are considered incompatible. +--FILE-- +<?php +error_reporting(E_ALL); + +trait THello1 { + public $hello = "foo"; +} + +trait THello2 { + private $hello = "bar"; +} + +echo "PRE-CLASS-GUARD\n"; + +class TraitsTest { + use THello1; + use THello2; + public function getHello() { + return $this->hello; + } +} + +$t = new TraitsTest; +?> +--EXPECTF-- +PRE-CLASS-GUARD + +Fatal error: THello1 and THello2 define the same property ($hello) in the composition of TraitsTest. However, the definition differs and is considered incompatible. Class was composed in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/traits/property005.phpt b/Zend/tests/traits/property005.phpt new file mode 100644 index 0000000..899a332 --- /dev/null +++ b/Zend/tests/traits/property005.phpt @@ -0,0 +1,40 @@ +--TEST-- +The same rules are applied for properties that are defined in the class hierarchy. Thus, if the properties are compatible, a notice is issued, if not a fatal error occures. +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class Base { + private $hello; +} + +trait THello1 { + private $hello; +} + +echo "PRE-CLASS-GUARD\n"; +class Notice extends Base { + use THello1; + private $hello; +} +echo "POST-CLASS-GUARD\n"; + +// now we do the test for a fatal error + +class TraitsTest { + use THello1; + public $hello; +} + +echo "POST-CLASS-GUARD2\n"; + +$t = new TraitsTest; +$t->hello = "foo"; +?> +--EXPECTF-- +PRE-CLASS-GUARD + +Strict Standards: Notice and THello1 define the same property ($hello) in the composition of Notice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +POST-CLASS-GUARD + +Fatal error: TraitsTest and THello1 define the same property ($hello) in the composition of TraitsTest. However, the definition differs and is considered incompatible. Class was composed in %s on line %d diff --git a/Zend/tests/traits/property006.phpt b/Zend/tests/traits/property006.phpt new file mode 100644 index 0000000..1a70919 --- /dev/null +++ b/Zend/tests/traits/property006.phpt @@ -0,0 +1,37 @@ +--TEST-- +Introducing new private variables of the same name in a subclass is ok, and does not lead to any output. That is consitent with normal inheritance handling. +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class Base { + private $hello; +} + +trait THello1 { + private $hello; +} + +// Now we use the trait, which happens to introduce another private variable +// but they are distinct, and not related to each other, so no warning. +echo "PRE-CLASS-GUARD\n"; +class SameNameInSubClassNoNotice extends Base { + use THello1; +} +echo "POST-CLASS-GUARD\n"; + +// now the same with a class that defines the property itself, +// that should give the expected strict warning. + +class Notice extends Base { + use THello1; + private $hello; +} +echo "POST-CLASS-GUARD2\n"; +?> +--EXPECTF-- +PRE-CLASS-GUARD +POST-CLASS-GUARD + +Strict Standards: Notice and THello1 define the same property ($hello) in the composition of Notice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +POST-CLASS-GUARD2 diff --git a/Zend/tests/traits/property007.phpt b/Zend/tests/traits/property007.phpt new file mode 100644 index 0000000..0f7c3b3 --- /dev/null +++ b/Zend/tests/traits/property007.phpt @@ -0,0 +1,38 @@ +--TEST-- +Introducing new private variables of the same name in a subclass is ok, and does not lead to any output. That is consitent with normal inheritance handling. +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class Base { + protected $hello; +} + +trait THello1 { + protected $hello; +} + +// Protected and public are handle more strict with a warning then what is +// expected from normal inheritance since they can have easier coliding semantics +echo "PRE-CLASS-GUARD\n"; +class SameNameInSubClassProducesNotice extends Base { + use THello1; +} +echo "POST-CLASS-GUARD\n"; + +// now the same with a class that defines the property itself, too. + +class Notice extends Base { + use THello1; + protected $hello; +} +echo "POST-CLASS-GUARD2\n"; +?> +--EXPECTF-- +PRE-CLASS-GUARD + +Strict Standards: Base and THello1 define the same property ($hello) in the composition of SameNameInSubClassProducesNotice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +POST-CLASS-GUARD + +Strict Standards: Notice and THello1 define the same property ($hello) in the composition of Notice. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +POST-CLASS-GUARD2 diff --git a/Zend/tests/traits/property008.phpt b/Zend/tests/traits/property008.phpt new file mode 100644 index 0000000..e263692 --- /dev/null +++ b/Zend/tests/traits/property008.phpt @@ -0,0 +1,62 @@ +--TEST-- +Handling of private fields with traits needs to have same semantics as with normal inheritance. +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class BaseWithPropA { + private $hello = 0; +} + +// This is how privates are handled in normal inheritance +class SubclassClassicInheritance extends BaseWithPropA { + private $hello = 0; +} + +// And here, we need to make sure, that the traits behave the same + +trait AHelloProperty { + private $hello = 0; +} + +class BaseWithTPropB { + use AHelloProperty; +} + +class SubclassA extends BaseWithPropA { + use AHelloProperty; +} + +class SubclassB extends BaseWithTPropB { + use AHelloProperty; +} + +$classic = new SubclassClassicInheritance; +var_dump($classic); + +$a = new SubclassA; +var_dump($a); + +$b = new SubclassB; +var_dump($b); + +?> +--EXPECTF-- +object(SubclassClassicInheritance)#1 (2) { + ["hello":"SubclassClassicInheritance":private]=> + int(0) + ["hello":"BaseWithPropA":private]=> + int(0) +} +object(SubclassA)#2 (2) { + ["hello":"SubclassA":private]=> + int(0) + ["hello":"BaseWithPropA":private]=> + int(0) +} +object(SubclassB)#3 (2) { + ["hello":"SubclassB":private]=> + int(0) + ["hello":"BaseWithTPropB":private]=> + int(0) +}
\ No newline at end of file diff --git a/Zend/tests/traits/property009.phpt b/Zend/tests/traits/property009.phpt new file mode 100644 index 0000000..135129d --- /dev/null +++ b/Zend/tests/traits/property009.phpt @@ -0,0 +1,59 @@ +--TEST-- +Handling of public fields with traits needs to have same semantics as with normal inheritance, however, we do add strict warnings since it is easier to run into something unexpeted with changing traits. +--FILE-- +<?php +error_reporting(E_ALL | E_STRICT); + +class BaseWithPropA { + public $hello = 0; +} + +// This is how publics are handled in normal inheritance +class SubclassClassicInheritance extends BaseWithPropA { + public $hello = 0; +} + +// And here, we need to make sure, that the traits behave the same + +trait AHelloProperty { + public $hello = 0; +} + +class BaseWithTPropB { + use AHelloProperty; +} + +class SubclassA extends BaseWithPropA { + use AHelloProperty; +} + +class SubclassB extends BaseWithTPropB { + use AHelloProperty; +} + +$classic = new SubclassClassicInheritance; +var_dump($classic); + +$a = new SubclassA; +var_dump($a); + +$b = new SubclassB; +var_dump($b); + +?> +--EXPECTF-- +Strict Standards: BaseWithPropA and AHelloProperty define the same property ($hello) in the composition of SubclassA. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d + +Strict Standards: BaseWithTPropB and AHelloProperty define the same property ($hello) in the composition of SubclassB. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in %s on line %d +object(SubclassClassicInheritance)#1 (1) { + ["hello"]=> + int(0) +} +object(SubclassA)#2 (1) { + ["hello"]=> + int(0) +} +object(SubclassB)#3 (1) { + ["hello"]=> + int(0) +}
\ No newline at end of file diff --git a/Zend/tests/traits/static_001.phpt b/Zend/tests/traits/static_001.phpt new file mode 100644 index 0000000..d86cb85 --- /dev/null +++ b/Zend/tests/traits/static_001.phpt @@ -0,0 +1,22 @@ +--TEST--
+Traits with static methods.
+--CREDITS--
+Simas Toleikis simast@gmail.com
+--FILE--
+<?php
+
+ trait TestTrait {
+ public static function test() {
+ return 'Test';
+ }
+ }
+
+ class A {
+ use TestTrait;
+ }
+
+ echo A::test();
+
+?>
+--EXPECT--
+Test
\ No newline at end of file diff --git a/Zend/tests/traits/static_002.phpt b/Zend/tests/traits/static_002.phpt new file mode 100644 index 0000000..c076085 --- /dev/null +++ b/Zend/tests/traits/static_002.phpt @@ -0,0 +1,23 @@ +--TEST--
+Traits with static methods referenced using variable.
+--CREDITS--
+Simas Toleikis simast@gmail.com
+--FILE--
+<?php
+
+ trait TestTrait {
+ public static function test() {
+ return 'Test';
+ }
+ }
+
+ class A {
+ use TestTrait;
+ }
+
+ $class = "A";
+ echo $class::test();
+
+?>
+--EXPECT--
+Test
\ No newline at end of file diff --git a/Zend/tests/traits/static_003.phpt b/Zend/tests/traits/static_003.phpt new file mode 100644 index 0000000..fbe5421 --- /dev/null +++ b/Zend/tests/traits/static_003.phpt @@ -0,0 +1,27 @@ +--TEST--
+Traits with late static bindings.
+--CREDITS--
+Simas Toleikis simast@gmail.com
+--FILE--
+<?php
+
+ trait TestTrait {
+ public static function test() {
+ return static::$test;
+ }
+ }
+
+ class A {
+ use TestTrait;
+ protected static $test = "Test A";
+ }
+
+ class B extends A {
+ protected static $test = "Test B";
+ }
+
+ echo B::test();
+
+?>
+--EXPECT--
+Test B
\ No newline at end of file diff --git a/Zend/tests/traits/static_004.phpt b/Zend/tests/traits/static_004.phpt new file mode 100644 index 0000000..c360f45 --- /dev/null +++ b/Zend/tests/traits/static_004.phpt @@ -0,0 +1,22 @@ +--TEST--
+Traits with __callStatic magic method.
+--CREDITS--
+Simas Toleikis simast@gmail.com
+--FILE--
+<?php
+
+ trait TestTrait {
+ public static function __callStatic($name, $arguments) {
+ return $name;
+ }
+ }
+
+ class A {
+ use TestTrait;
+ }
+
+ echo A::Test();
+
+?>
+--EXPECT--
+Test
\ No newline at end of file diff --git a/Zend/tests/traits/static_forward_static_call.phpt b/Zend/tests/traits/static_forward_static_call.phpt new file mode 100644 index 0000000..878cf1f --- /dev/null +++ b/Zend/tests/traits/static_forward_static_call.phpt @@ -0,0 +1,28 @@ +--TEST--
+Traits and forward_static_call().
+--CREDITS--
+Simas Toleikis simast@gmail.com
+--FILE--
+<?php
+
+ trait TestTrait {
+ public static function test() {
+ return 'Forwarded '.forward_static_call(array('A', 'test'));
+ }
+ }
+
+ class A {
+ public static function test() {
+ return "Test A";
+ }
+ }
+
+ class B extends A {
+ use TestTrait;
+ }
+
+ echo B::test();
+
+?>
+--EXPECT--
+Forwarded Test A
\ No newline at end of file diff --git a/Zend/tests/traits/static_get_called_class.phpt b/Zend/tests/traits/static_get_called_class.phpt new file mode 100644 index 0000000..dc29ece --- /dev/null +++ b/Zend/tests/traits/static_get_called_class.phpt @@ -0,0 +1,24 @@ +--TEST--
+Traits and get_called_class().
+--CREDITS--
+Simas Toleikis simast@gmail.com
+--FILE--
+<?php
+
+ trait TestTrait {
+ public static function test() {
+ return get_called_class();
+ }
+ }
+
+ class A {
+ use TestTrait;
+ }
+
+ class B extends A { }
+
+ echo B::test();
+
+?>
+--EXPECT--
+B
\ No newline at end of file diff --git a/Zend/tests/traits/trait_constant_001.phpt b/Zend/tests/traits/trait_constant_001.phpt new file mode 100644 index 0000000..0fd8ff9 --- /dev/null +++ b/Zend/tests/traits/trait_constant_001.phpt @@ -0,0 +1,36 @@ +--TEST--
+__TRAIT__: Basics, a constant denoiting the trait of definition.
+--FILE--
+<?php
+
+trait TestTrait {
+ public static function test() {
+ return __TRAIT__;
+ }
+}
+
+class Direct {
+ use TestTrait;
+}
+
+class IndirectInheritance extends Direct {
+
+}
+
+trait TestTraitIndirect {
+ use TestTrait;
+}
+
+class Indirect {
+ use TestTraitIndirect;
+}
+
+echo Direct::test()."\n";
+echo IndirectInheritance::test()."\n";
+echo Indirect::test()."\n";
+
+?>
+--EXPECT--
+TestTrait
+TestTrait
+TestTrait
diff --git a/Zend/tests/traits/trait_constant_002.phpt b/Zend/tests/traits/trait_constant_002.phpt new file mode 100644 index 0000000..327dd44 --- /dev/null +++ b/Zend/tests/traits/trait_constant_002.phpt @@ -0,0 +1,27 @@ +--TEST--
+__TRAIT__: Use outside of traits.
+--FILE--
+<?php
+
+ class MyClass {
+ static function test() {
+ return __TRAIT__;
+ }
+ }
+
+ function someFun() {
+ return __TRAIT__;
+ }
+
+
+ $t = __TRAIT__;
+ var_dump($t);
+ $t = MyClass::test();
+ var_dump($t);
+ $t = someFun();
+ var_dump($t);
+?>
+--EXPECT--
+string(0) ""
+string(0) ""
+string(0) ""
\ No newline at end of file diff --git a/Zend/tests/unexpected_ref_bug.phpt b/Zend/tests/unexpected_ref_bug.phpt new file mode 100644 index 0000000..61fe1aa --- /dev/null +++ b/Zend/tests/unexpected_ref_bug.phpt @@ -0,0 +1,18 @@ +--TEST-- +Crash when function parameter modified via unexpected reference +--FILE-- +<?php +function my_errorhandler($errno,$errormsg) { + global $my_var; + $my_var = 0; + return true; +} +set_error_handler("my_errorhandler"); +$my_var = str_repeat("A",64); +$data = call_user_func_array("explode",array(new StdClass(), &$my_var)); +$my_var=array(1,2,3); +$data = call_user_func_array("implode",array(&$my_var, new StdClass())); +echo "Done.\n"; +?> +--EXPECTF-- +Done. diff --git a/Zend/tests/unset.inc b/Zend/tests/unset.inc new file mode 100644 index 0000000..ef809b3 --- /dev/null +++ b/Zend/tests/unset.inc @@ -0,0 +1,5 @@ +<?php + +unset($x) + +?> diff --git a/Zend/tests/unset_cv01.phpt b/Zend/tests/unset_cv01.phpt new file mode 100644 index 0000000..99af118 --- /dev/null +++ b/Zend/tests/unset_cv01.phpt @@ -0,0 +1,13 @@ +--TEST-- +unset() CV 1 (unset() global variable) +--FILE-- +<?php +$x = "ok\n"; +echo $x; +unset($x); +echo $x; +?> +--EXPECTF-- +ok + +Notice: Undefined variable: x in %sunset_cv01.php on line %d diff --git a/Zend/tests/unset_cv02.phpt b/Zend/tests/unset_cv02.phpt new file mode 100644 index 0000000..cb24753 --- /dev/null +++ b/Zend/tests/unset_cv02.phpt @@ -0,0 +1,13 @@ +--TEST-- +unset() CV 2 (unset() global variable in $GLOBALS) +--FILE-- +<?php +$x = "ok\n"; +echo $x; +unset($GLOBALS["x"]); +echo $x; +?> +--EXPECTF-- +ok + +Notice: Undefined variable: x in %sunset_cv02.php on line %d diff --git a/Zend/tests/unset_cv03.phpt b/Zend/tests/unset_cv03.phpt new file mode 100644 index 0000000..221abe2 --- /dev/null +++ b/Zend/tests/unset_cv03.phpt @@ -0,0 +1,13 @@ +--TEST-- +unset() CV 3 (unset() global variable in included file) +--FILE-- +<?php +$x = "ok\n"; +echo $x; +include "unset.inc"; +echo $x; +?> +--EXPECTF-- +ok + +Notice: Undefined variable: x in %sunset_cv03.php on line %d diff --git a/Zend/tests/unset_cv04.phpt b/Zend/tests/unset_cv04.phpt new file mode 100644 index 0000000..5044cb1 --- /dev/null +++ b/Zend/tests/unset_cv04.phpt @@ -0,0 +1,16 @@ +--TEST-- +unset() CV 4 (unset() local variable in included file) +--FILE-- +<?php +function f() { + $x = "ok\n"; + echo $x; + include "unset.inc"; + echo $x; +} +f(); +?> +--EXPECTF-- +ok + +Notice: Undefined variable: x in %sunset_cv04.php on line %d diff --git a/Zend/tests/unset_cv05.phpt b/Zend/tests/unset_cv05.phpt new file mode 100644 index 0000000..36fea3b --- /dev/null +++ b/Zend/tests/unset_cv05.phpt @@ -0,0 +1,29 @@ +--TEST-- +unset() CV 5 (indirect unset() of global variable in session_start()) +--INI-- +session.auto_start=0 +session.save_handler=files +--SKIPIF-- +<?php + +include(dirname(__FILE__).'/../../ext/session/tests/skipif.inc'); + +?> +--FILE-- +<?php +$_SESSION = "ok\n"; +echo $_SESSION; +session_start(); +echo $_SESSION; +echo "\nok\n"; +?> +--EXPECTF-- +ok + +Warning: session_start(): Cannot send session cookie - headers already sent by (output started at %sunset_cv05.php on line %d + +Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at %sunset_cv05.php:%d) in %sunset_cv05.php on line %d + +Notice: Array to string conversion in %sunset_cv05.php on line %d +Array +ok diff --git a/Zend/tests/unset_cv06.phpt b/Zend/tests/unset_cv06.phpt new file mode 100644 index 0000000..dd78815 --- /dev/null +++ b/Zend/tests/unset_cv06.phpt @@ -0,0 +1,22 @@ +--TEST-- +unset() CV 6 (indirect unset() of global variable in session_unset()) +--SKIPIF-- +<?php include(dirname(__FILE__).'/../../ext/session/tests/skipif.inc'); ?> +--INI-- +session.auto_start=0 +session.save_handler=files +--FILE-- +<?php +session_start(); +$_SESSION['x'] = "1\n"; +echo $_SESSION['x']; + +session_unset(); +echo $_SESSION['x']; +echo "ok\n"; +?> +--EXPECTF-- +1 + +Notice: Undefined index: x in %sunset_cv06.php on line %d +ok diff --git a/Zend/tests/unset_cv07.phpt b/Zend/tests/unset_cv07.phpt new file mode 100644 index 0000000..3f893ca --- /dev/null +++ b/Zend/tests/unset_cv07.phpt @@ -0,0 +1,18 @@ +--TEST-- +unset() CV 7 (indirect unset() of global variable in import_request_variables()) +--SKIPIF-- +<?php if(PHP_VERSION_ID >= 50399){ die('skip not needed anymore without register_globals'); } ?> +--GET-- +x=2 +--FILE-- +<?php +$_x = "1\n"; +echo $_x; +import_request_variables("g","_"); +echo $_x; +echo "\nok\n"; +?> +--EXPECTF-- +1 +2 +ok diff --git a/Zend/tests/unset_cv08.phpt b/Zend/tests/unset_cv08.phpt new file mode 100644 index 0000000..9b8ab15 --- /dev/null +++ b/Zend/tests/unset_cv08.phpt @@ -0,0 +1,15 @@ +--TEST-- +unset() CV 8 (unset() of global variable in array_unique($GLOBALS)) +--FILE-- +<?php +$a = "ok\n"; +$b = "ok\n"; +@array_unique($GLOBALS); +echo $a; +echo $b; +echo "ok\n"; +?> +--EXPECTF-- +ok +ok +ok diff --git a/Zend/tests/unset_cv09.phpt b/Zend/tests/unset_cv09.phpt new file mode 100644 index 0000000..a5407ad --- /dev/null +++ b/Zend/tests/unset_cv09.phpt @@ -0,0 +1,14 @@ +--TEST-- +unset() CV 9 (unset() of global variable in array_pop($GLOBALS)) +--FILE-- +<?php +$x = "ok\n"; +echo array_pop($GLOBALS); +echo $x; +echo "ok\n"; +?> +--EXPECTF-- +ok + +Notice: Undefined variable: x in %sunset_cv09.php on line %d +ok diff --git a/Zend/tests/unset_cv10.phpt b/Zend/tests/unset_cv10.phpt new file mode 100644 index 0000000..3b943d8 --- /dev/null +++ b/Zend/tests/unset_cv10.phpt @@ -0,0 +1,18 @@ +--TEST-- +unset() CV 10 (unset() of global variable in ArrayObject::offsetUnset($GLOBALS)) +--SKIPIF-- +<?php if (!extension_loaded("spl")) print "skip SPL extension required"; ?> +--FILE-- +<?php +$a = new ArrayObject($GLOBALS); +$x = "ok\n"; +echo $x; +$a->offsetUnset('x'); +echo $x; +echo "ok\n"; +?> +--EXPECTF-- +ok + +Notice: Undefined variable: x in %sunset_cv10.php on line %d +ok diff --git a/Zend/tests/unset_cv11.phpt b/Zend/tests/unset_cv11.phpt new file mode 100644 index 0000000..152ea02 --- /dev/null +++ b/Zend/tests/unset_cv11.phpt @@ -0,0 +1,21 @@ +--TEST-- +unset() CV 11 (unset() of copy destoies original value) +--FILE-- +<?php +$x = array("default"=>"ok"); +var_dump($x); +$cf = $x; +unset($cf['default']); +var_dump($x); +echo "ok\n"; +?> +--EXPECT-- +array(1) { + ["default"]=> + string(2) "ok" +} +array(1) { + ["default"]=> + string(2) "ok" +} +ok diff --git a/Zend/tests/unset_cv12.phpt b/Zend/tests/unset_cv12.phpt new file mode 100644 index 0000000..a22b13d --- /dev/null +++ b/Zend/tests/unset_cv12.phpt @@ -0,0 +1,11 @@ +--TEST-- +unset() CV 12 (unset() in indirect called function) +--FILE-- +<?php +$x = 1; +function foo() {unset($GLOBALS["x"]);} +call_user_func("foo"); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/xor_001.phpt b/Zend/tests/xor_001.phpt new file mode 100644 index 0000000..e1a521d --- /dev/null +++ b/Zend/tests/xor_001.phpt @@ -0,0 +1,16 @@ +--TEST-- +XORing arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(); + +$c = $a ^ $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +Done diff --git a/Zend/tests/xor_002.phpt b/Zend/tests/xor_002.phpt new file mode 100644 index 0000000..0cf4054 --- /dev/null +++ b/Zend/tests/xor_002.phpt @@ -0,0 +1,39 @@ +--TEST-- +XORing strings +--FILE-- +<?php + +$s = "123"; +$s1 = "234"; +var_dump(bin2hex($s ^ $s1)); + +$s = "1235"; +$s1 = "234"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s1 = "test"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some long"; +$s1 = "test"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s1 = "test long"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s ^= "test long"; +var_dump(bin2hex($s)); + +echo "Done\n"; +?> +--EXPECTF-- +string(6) "030107" +string(6) "030107" +string(8) "070a1e11" +string(8) "070a1e11" +string(8) "070a1e11" +string(8) "070a1e11" +Done diff --git a/Zend/tests/xor_003.phpt b/Zend/tests/xor_003.phpt new file mode 100644 index 0000000..8aa1c63 --- /dev/null +++ b/Zend/tests/xor_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +XORing booleans +--FILE-- +<?php + +$t = true; +$f = false; + +var_dump($t ^ $f); +var_dump($t ^ $t); +var_dump($f ^ $f); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +int(0) +int(0) +Done diff --git a/Zend/tests/zend2.php.txt b/Zend/tests/zend2.php.txt new file mode 100644 index 0000000..afe422e --- /dev/null +++ b/Zend/tests/zend2.php.txt @@ -0,0 +1,275 @@ +Example 1: A singleton (static members) +======================================= + +<?php + + class Counter { + var $counter = 0; + + function increment_and_print() + { + print ++$this->counter; + print "\n"; + } + } + + + class SingletonCounter { + static $m_instance = NULL; + + function Instance() + { + if (self::$m_instance == NULL) { + self::$m_instance = new Counter(); + } + return self::$m_instance; + } + } + + SingletonCounter::Instance()->increment_and_print(); + SingletonCounter::Instance()->increment_and_print(); + SingletonCounter::Instance()->increment_and_print(); + +?> + +Example 2: Factory method (derefencing objects returned from functions) +======================================================================= + +<?php + + class Circle { + function draw() + { + print "Circle\n"; + } + } + + class Square { + function draw() + { + print "Square\n"; + } + } + + function ShapeFactoryMethod($shape) + { + switch ($shape) { + case "Circle": + return new Circle(); + case "Square": + return new Square(); + } + } + + ShapeFactoryMethod("Circle")->draw(); + ShapeFactoryMethod("Square")->draw(); + + +?> + +Example 3: Class constants and class scope +========================================== + +<?php + + class ErrorCodes { + const FATAL = "Fatal error\n"; + const WARNING = "Warning\n"; + const INFO = "Informational message\n"; + + function print_fatal_error_codes() + { + print "FATAL = " . FATAL; + print "self::FATAL = " . self::FATAL; + } + } + + /* Call the static function and move into the ErrorCodes scope */ + ErrorCodes::print_fatal_error_codes(); + +?> + +Example 4: Regular object method using both local and global functions +====================================================================== + +<?php + + class HelloWorld { + const HELLO_WORLD = "Hello, World!\n"; + + function get_hello_world() + { + return HELLO_WORLD; + } + + function length_of_hello_world() + { + $str = $this->get_hello_world(); + return strlen($str); + } + } + + $obj = new HelloWorld(); + print "length_of_hello_world() = " . $obj->length_of_hello_world(); + print "\n"; +?> + +Example 5: Multiple derefencing of objects returned from methods +================================================================ + +<?php + + + class Name { + function Name($_name) + { + $this->name = $_name; + } + + function display() + { + print $this->name; + print "\n"; + } + } + + class Person { + function Person($_name, $_address) + { + $this->name = new Name($_name); + } + + function getName() + { + return $this->name; + } + } + + $person = new Person("John", "New York"); + $person->getName()->display(); + +?> + +Example 6: Exception handling +============================= + +<? + class MyException { + function MyException($_error) { + $this->error = $_error; + } + + function getException() + { + return $this->error; + } + } + + function ThrowException() + { + throw new MyException("'This is an exception!'"); + } + + + try { + } catch (MyException $exception) { + print "There was an exception: " . $exception->getException(); + print "\n"; + } + + try { + ThrowException(); + } catch (MyException $exception) { + print "There was an exception: " . $exception->getException(); + print "\n"; + } + +?> + +Example 7: __clone() +=================== + +<? + class MyCloneable { + static $id = 0; + + function MyCloneable() + { + $this->id = self::$id++; + } + + function __clone() + { + $this->name = $that->name; + $this->address = "New York"; + $this->id = self::$id++; + } + } + + + + $obj = new MyCloneable(); + + $obj->name = "Hello"; + $obj->address = "Tel-Aviv"; + + print $obj->id; + print "\n"; + + $obj = $obj->__clone(); + + print $obj->id; + print "\n"; + print $obj->name; + print "\n"; + print $obj->address; + print "\n"; +?> + +Example 8: Unified constructors +=============================== + +<? + + class BaseClass { + function __construct() + { + print "In BaseClass constructor\n"; + } + } + + class SubClass extends BaseClass { + function __construct() + { + parent::__construct(); + print "In SubClass constructor\n"; + } + } + + $obj = new BaseClass(); + + $obj = new SubClass(); + +?> + +Example 9: Destructors +======================= + +<?php + +class MyDestructableClass { + function __construct() + { + print "In constructor\n"; + $this->name = "MyDestructableClass"; + } + + function __destruct() + { + print "Destroying " . $this->name . "\n"; + } +} + +$obj = new MyDestructableClass(); + +?> diff --git a/Zend/tests/zend_operators.phpt b/Zend/tests/zend_operators.phpt new file mode 100644 index 0000000..b07f259 --- /dev/null +++ b/Zend/tests/zend_operators.phpt @@ -0,0 +1,12 @@ +--TEST-- +Operator precedence +--FILE-- +<?php /* $Id$ */ + +var_dump((object)1 instanceof stdClass); +var_dump(! (object)1 instanceof Exception); + +?> +--EXPECT-- +bool(true) +bool(true) diff --git a/Zend/tests/zend_strtod.phpt b/Zend/tests/zend_strtod.phpt new file mode 100644 index 0000000..7f4bca5 --- /dev/null +++ b/Zend/tests/zend_strtod.phpt @@ -0,0 +1,19 @@ +--TEST-- +zend_strtod() leaks on big doubles +--INI-- +precision=14 +--FILE-- +<?php +var_dump("1139932690.21688500" - "1139932790.21688500"); +var_dump("1139932690000.21688500" - "331139932790.21688500"); +var_dump("339932690.21688500" - "4564645646456463461139932790.21688500"); +var_dump("123123139932690.21688500" - "11399327900000000.21688500"); + +echo "Done\n"; +?> +--EXPECTF-- +float(-100) +float(808792757210) +float(-4.5646456464565E+27) +float(-1.1276204760067E+16) +Done |