summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/bug45742.phpt2
-rw-r--r--Zend/tests/bug50816.phpt48
-rw-r--r--Zend/tests/bug53727.phpt22
-rw-r--r--Zend/tests/bug54039.phpt58
-rw-r--r--Zend/tests/bug54265.phpt17
-rw-r--r--Zend/tests/bug54268.phpt35
-rw-r--r--Zend/tests/bug54305.phpt22
-rw-r--r--Zend/tests/bug54358.phpt39
-rw-r--r--Zend/tests/bug54367.phpt24
-rw-r--r--Zend/tests/bug54372.phpt23
-rw-r--r--Zend/tests/bug54585.phpt15
-rw-r--r--Zend/tests/bug54624.phpt26
-rw-r--r--Zend/tests/bug54804.inc3
-rw-r--r--Zend/tests/bug54804.phpt11
-rw-r--r--Zend/tests/bug54910.phpt28
-rw-r--r--Zend/tests/bug55007.phpt23
-rw-r--r--Zend/tests/bug55156.phpt30
-rw-r--r--Zend/tests/bug55339.phpt31
-rw-r--r--Zend/tests/concat_001.phpt2
-rwxr-xr-xZend/tests/constants_005.phpt2
-rw-r--r--Zend/tests/function_arguments_001.phpt9
-rw-r--r--Zend/tests/function_arguments_002.phpt9
-rwxr-xr-xZend/tests/is_a.phpt2
23 files changed, 477 insertions, 4 deletions
diff --git a/Zend/tests/bug45742.phpt b/Zend/tests/bug45742.phpt
index b21e09304..bde690b39 100644
--- a/Zend/tests/bug45742.phpt
+++ b/Zend/tests/bug45742.phpt
@@ -20,5 +20,5 @@ var_dump( ArrayProperty::$array );
--EXPECT--
array(1) {
[1]=>
- int(23)
+ int(42)
}
diff --git a/Zend/tests/bug50816.phpt b/Zend/tests/bug50816.phpt
new file mode 100644
index 000000000..98a89380c
--- /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/bug53727.phpt b/Zend/tests/bug53727.phpt
new file mode 100644
index 000000000..22cd5232c
--- /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/bug54039.phpt b/Zend/tests/bug54039.phpt
new file mode 100644
index 000000000..ccdfe9430
--- /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/bug54265.phpt b/Zend/tests/bug54265.phpt
new file mode 100644
index 000000000..43db028a2
--- /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 000000000..b544cd882
--- /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 000000000..8e85d2be5
--- /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 000000000..faeeeacc5
--- /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 000000000..1ca6ad425
--- /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 000000000..e2e9911f8
--- /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/bug54585.phpt b/Zend/tests/bug54585.phpt
new file mode 100644
index 000000000..2ca11f3e6
--- /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 000000000..1d0c1ce87
--- /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 000000000..74b7a1681
--- /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 000000000..c68e94698
--- /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 000000000..8808cd060
--- /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 000000000..12fbf120a
--- /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/bug55156.phpt b/Zend/tests/bug55156.phpt
new file mode 100644
index 000000000..6c0ff768d
--- /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/bug55339.phpt b/Zend/tests/bug55339.phpt
new file mode 100644
index 000000000..7d5ab4a78
--- /dev/null
+++ b/Zend/tests/bug55339.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #55339 (Segfault with allow_call_time_pass_reference = Off)
+--INI--
+allow_call_time_pass_reference=off
+--FILE--
+<?php
+function error_handler($errno, $errstr, $errfile, $errline) {
+ eval(';');
+}
+
+set_error_handler('error_handler');
+
+eval(<<<'EOF'
+function foo()
+{
+ $array = array();
+ foreach ($array as $key => $value) {
+ bar($key, &$value);
+ }
+}
+
+function bar()
+{
+
+}
+EOF
+);
+
+echo "OK\n";
+--EXPECT--
+OK
diff --git a/Zend/tests/concat_001.phpt b/Zend/tests/concat_001.phpt
index be1297655..d7bc525c4 100644
--- a/Zend/tests/concat_001.phpt
+++ b/Zend/tests/concat_001.phpt
@@ -1,5 +1,5 @@
--TEST--
-concat difffent types
+concat different types
--INI--
precision=14
--FILE--
diff --git a/Zend/tests/constants_005.phpt b/Zend/tests/constants_005.phpt
index 097be97e1..55f90fd94 100755
--- a/Zend/tests/constants_005.phpt
+++ b/Zend/tests/constants_005.phpt
@@ -1,5 +1,5 @@
--TEST--
-Persistent case insensetive and user defined constants
+Persistent case insensitive and user defined constants
--FILE--
<?php
var_dump(ZEND_THREAD_safe);
diff --git a/Zend/tests/function_arguments_001.phpt b/Zend/tests/function_arguments_001.phpt
new file mode 100644
index 000000000..bf0cd4a20
--- /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: syntax error, unexpected T_STRING, expecting ')' 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 000000000..79dd31f33
--- /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: syntax error, unexpected '/', expecting ')' in %sfunction_arguments_002.php on line %d
+
diff --git a/Zend/tests/is_a.phpt b/Zend/tests/is_a.phpt
index a074194c4..0a01eb756 100755
--- a/Zend/tests/is_a.phpt
+++ b/Zend/tests/is_a.phpt
@@ -38,6 +38,6 @@ bool(true)
bool(false)
bool(false)
bool(true)
-bool(false)
+bool(true)
AUTOLOAD 'X1'
bool(false)