diff options
Diffstat (limited to 'Zend/tests')
29 files changed, 257 insertions, 56 deletions
diff --git a/Zend/tests/024.phpt b/Zend/tests/024.phpt index ff35a5c895..f89c49e613 100644 --- a/Zend/tests/024.phpt +++ b/Zend/tests/024.phpt @@ -11,7 +11,7 @@ var_dump($a++); var_dump(++$b); var_dump($a->$b); var_dump($a->$b); -var_dump($a->$b->$c[1]); +var_dump($a->$b->{$c[1]}); ?> --EXPECTF-- diff --git a/Zend/tests/bug27669.phpt b/Zend/tests/bug27669.phpt index 4d513e91aa..43591a9386 100644 --- a/Zend/tests/bug27669.phpt +++ b/Zend/tests/bug27669.phpt @@ -10,7 +10,7 @@ Bug #27669 (PHP 5 didn't support all possibilities for calling static methods dy } } $y[0] = 'hello'; - A::$y[0](); + A::{$y[0]}(); ?> ===DONE=== --EXPECTF-- diff --git a/Zend/tests/bug30080.phpt b/Zend/tests/bug30080.phpt index bd8401e1be..8cac75ab8d 100644 --- a/Zend/tests/bug30080.phpt +++ b/Zend/tests/bug30080.phpt @@ -10,9 +10,9 @@ class foo { new foo(array(new stdClass)); ?> ---EXPECT-- +--EXPECTF-- array(1) { [0]=> - object(stdClass)#2 (0) { + object(stdClass)#%d (0) { } } diff --git a/Zend/tests/bug39304.phpt b/Zend/tests/bug39304.phpt index 8303b82573..5540135fa4 100644 --- a/Zend/tests/bug39304.phpt +++ b/Zend/tests/bug39304.phpt @@ -9,8 +9,8 @@ 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 + +Notice: Uninitialized string offset: 1 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 index b0e6ddc72c..cc0709b424 100644 --- a/Zend/tests/bug39304_2_4.phpt +++ b/Zend/tests/bug39304_2_4.phpt @@ -11,8 +11,8 @@ Bug #39304 (Segmentation fault with list unpacking of string offset) --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 + +Notice: Uninitialized string offset: 1 in %sbug39304_2_4.php on line %d string(0) "" string(0) "" diff --git a/Zend/tests/bug43450.phpt b/Zend/tests/bug43450.phpt index a94eba312e..f0cd4f75bc 100644 --- a/Zend/tests/bug43450.phpt +++ b/Zend/tests/bug43450.phpt @@ -18,15 +18,15 @@ class Foo $num_repeats = 100000; -$start = (memory_get_usage() / 1024) + 16; +$start = memory_get_usage() / 1024; for ($i=1;$i<$num_repeats;$i++) { $foo = new Foo(); md5($foo); } -$end = memory_get_peak_usage() / 1024; +$end = memory_get_usage() / 1024; -if ($start < $end) { +if ($start + 16 < $end) { echo 'FAIL'; } else { echo 'PASS'; diff --git a/Zend/tests/bug44414.phpt b/Zend/tests/bug44414.phpt index 1f3a2583d7..e9e6de7b45 100644 --- a/Zend/tests/bug44414.phpt +++ b/Zend/tests/bug44414.phpt @@ -12,4 +12,4 @@ 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 +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 8 diff --git a/Zend/tests/bug55007.phpt b/Zend/tests/bug55007.phpt index 12fbf120a8..425ce8f296 100644 --- a/Zend/tests/bug55007.phpt +++ b/Zend/tests/bug55007.phpt @@ -4,7 +4,7 @@ Bug #55007 (compiler fail after previous fail) <?php function __autoload($classname) { - if ('CompileErrorClass'==$classname) eval('class CompileErrorClass { function foo() { $a[] } }'); + if ('CompileErrorClass'==$classname) eval('class CompileErrorClass { function foo() { $a[]; } }'); if ('MyErrorHandler'==$classname) eval('class MyErrorHandler { function __construct() { print "My error handler runs.\n"; } }'); } diff --git a/Zend/tests/bug60099.phpt b/Zend/tests/bug60099.phpt index 13e2f54b09..8cca3440fb 100644 --- a/Zend/tests/bug60099.phpt +++ b/Zend/tests/bug60099.phpt @@ -7,4 +7,4 @@ namespace foo { ?> --EXPECTF-- -Fatal error: __HALT_COMPILER() can only be used from the outermost scope in %s on line %d +Parse error: syntax error, unexpected end of file in %s on line %d diff --git a/Zend/tests/declare_001.phpt b/Zend/tests/declare_001.phpt index 21d797880e..4eff18045c 100644 --- a/Zend/tests/declare_001.phpt +++ b/Zend/tests/declare_001.phpt @@ -13,7 +13,6 @@ zend.multibyte=1 declare(encoding = 1); declare(encoding = 112313123213131232100); -declare(encoding = NULL); declare(encoding = 'utf-8'); declare(encoding = M_PI); @@ -25,6 +24,4 @@ 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 +Fatal error: Encoding must be a literal in %s on line %d diff --git a/Zend/tests/declare_003.phpt b/Zend/tests/declare_003.phpt index 2980f7589b..2f3e887380 100644 --- a/Zend/tests/declare_003.phpt +++ b/Zend/tests/declare_003.phpt @@ -8,7 +8,6 @@ zend.multibyte=1 declare(encoding = 1); declare(encoding = 11111111111111); -declare(encoding = NULL); declare(encoding = M_PI); print 'DONE'; @@ -19,6 +18,4 @@ 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 +Fatal error: Encoding must be a literal in %s on line %d diff --git a/Zend/tests/errmsg_014.phpt b/Zend/tests/errmsg_014.phpt deleted file mode 100644 index 77e12b05e9..0000000000 --- a/Zend/tests/errmsg_014.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---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/foreach_list_002.phpt b/Zend/tests/foreach_list_002.phpt index 251870ba09..bc17d94268 100644 --- a/Zend/tests/foreach_list_002.phpt +++ b/Zend/tests/foreach_list_002.phpt @@ -9,7 +9,7 @@ foreach (array(array(1,2), array(3,4)) as list($a, )) { $array = [['a', 'b'], 'c', 'd']; -foreach($array as list(list(), $a)) { +foreach($array as list(, $a)) { var_dump($a); } diff --git a/Zend/tests/isset_003.phpt b/Zend/tests/isset_003.phpt index 4db42a933b..92225b5906 100644 --- a/Zend/tests/isset_003.phpt +++ b/Zend/tests/isset_003.phpt @@ -14,7 +14,7 @@ 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(${$a}->{$b->{$c[$d]}})); var_dump(isset($GLOBALS)); diff --git a/Zend/tests/isset_003_2_4.phpt b/Zend/tests/isset_003_2_4.phpt index c05f3e26f4..42d8cc6a08 100644 --- a/Zend/tests/isset_003_2_4.phpt +++ b/Zend/tests/isset_003_2_4.phpt @@ -16,7 +16,7 @@ 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(${$a}->{$b->{$c[$d]}})); var_dump(isset($GLOBALS)); diff --git a/Zend/tests/isset_func_error.phpt b/Zend/tests/isset_func_error.phpt index 7d1036def8..7d6616b96d 100644 --- a/Zend/tests/isset_func_error.phpt +++ b/Zend/tests/isset_func_error.phpt @@ -5,4 +5,4 @@ Error message for isset(func()) isset(abc()); ?> --EXPECTF-- -Fatal error: Cannot use isset() on the result of a function call (you can use "null !== func()" instead) in %s on line %d +Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in %s on line %d diff --git a/Zend/tests/list_005.phpt b/Zend/tests/list_005.phpt index 4afc353b2f..ec5640a60a 100644 --- a/Zend/tests/list_005.phpt +++ b/Zend/tests/list_005.phpt @@ -3,33 +3,33 @@ Testing list() with several variables --FILE-- <?php -$a = "foo"; +$str = "foo"; -list($a, $b, $c) = $a; +list($a, $b, $c) = $str; var_dump($a, $b, $c); print "----\n"; -$a = 1; +$int = 1; -list($a, $b, $c) = $a; +list($a, $b, $c) = $int; var_dump($a, $b, $c); print "----\n"; -$a = new stdClass; +$obj = new stdClass; -list($a, $b, $c) = $a; +list($a, $b, $c) = $obj; var_dump($a, $b, $c); print "----\n"; -$a = array(1, 2, 3); +$arr = array(1, 2, 3); -list($a, $b, $c) = $a; +list($a, $b, $c) = $arr; var_dump($a, $b, $c); diff --git a/Zend/tests/list_006.phpt b/Zend/tests/list_006.phpt index f5f5970be4..d380235d25 100644 --- a/Zend/tests/list_006.phpt +++ b/Zend/tests/list_006.phpt @@ -7,8 +7,6 @@ list($a, list($b, list(list($d)))) = array(); ?> --EXPECTF-- -Notice: Undefined offset: 1 in %s on line %d +Notice: Undefined offset: 0 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/use_const/no_global_fallback.phpt b/Zend/tests/use_const/no_global_fallback.phpt index a128f353ed..64e2a154ce 100644 --- a/Zend/tests/use_const/no_global_fallback.phpt +++ b/Zend/tests/use_const/no_global_fallback.phpt @@ -10,5 +10,4 @@ var_dump(baz); ?> --EXPECTF-- -Notice: Use of undefined constant baz - assumed 'baz' in %s on line %d -string(3) "baz" +Fatal error: Undefined constant 'foo\bar\baz' in %s on line %d diff --git a/Zend/tests/varSyntax/globalNonSimpleVariableError.phpt b/Zend/tests/varSyntax/globalNonSimpleVariableError.phpt new file mode 100644 index 0000000000..ed04921f89 --- /dev/null +++ b/Zend/tests/varSyntax/globalNonSimpleVariableError.phpt @@ -0,0 +1,10 @@ +--TEST-- +Global keyword only accepts simple variables +--FILE-- +<?php + +global $$foo->bar; + +?> +--EXPECTF-- +Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';' in %s on line %d diff --git a/Zend/tests/varSyntax/indirectFcall.phpt b/Zend/tests/varSyntax/indirectFcall.phpt new file mode 100644 index 0000000000..4cc5c1171a --- /dev/null +++ b/Zend/tests/varSyntax/indirectFcall.phpt @@ -0,0 +1,53 @@ +--TEST-- +Indirect function calls +--FILE-- +<?php + +function id($x = 'id') { return $x; } + +var_dump(0); + +id('var_dump')(1); +id('id')('var_dump')(2); +id('id')('id')('var_dump')(3); +id()()('var_dump')(4); + +id(['udef', 'id'])[1]()('var_dump')(5); +(id((object) ['a' => 'id', 'b' => 'udef'])->a)()()()()('var_dump')(6); + +$id = function($x) { return $x; }; + +$id($id)('var_dump')(7); + +(function($x) { return $x; })('id')('var_dump')(8); + +($f = function($x = null) use (&$f) { + return $x ?: $f; +})()()()('var_dump')(9); + +class Test { + public static function id($x = [__CLASS__, 'id']) { return $x; } +} + +$obj = new Test; +[$obj, 'id']()('id')($id)('var_dump')(10); +['Test', 'id']()()('var_dump')(11); +'id'()('id')('var_dump')(12); +('i' . 'd')()('var_dump')(13); + +?> +--EXPECT-- +int(0) +int(1) +int(2) +int(3) +int(4) +int(5) +int(6) +int(7) +int(8) +int(9) +int(10) +int(11) +int(12) +int(13) diff --git a/Zend/tests/varSyntax/issetOnTemp.phpt b/Zend/tests/varSyntax/issetOnTemp.phpt new file mode 100644 index 0000000000..cd7bc006cd --- /dev/null +++ b/Zend/tests/varSyntax/issetOnTemp.phpt @@ -0,0 +1,26 @@ +--TEST-- +isset() can be used on dereferences of temporary expressions +--FILE-- +<?php + +var_dump(isset([0, 1][0])); +var_dump(isset(([0, 1] + [])[0])); +var_dump(isset([[0, 1]][0][0])); +var_dump(isset(([[0, 1]] + [])[0][0])); +var_dump(isset(((object) ['a' => 'b'])->a)); +var_dump(isset(['a' => 'b']->a)); +var_dump(isset("str"->a)); +var_dump(isset((['a' => 'b'] + [])->a)); +var_dump(isset((['a' => 'b'] + [])->a->b)); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/Zend/tests/varSyntax/newVariable.phpt b/Zend/tests/varSyntax/newVariable.phpt new file mode 100644 index 0000000000..360f99ac36 --- /dev/null +++ b/Zend/tests/varSyntax/newVariable.phpt @@ -0,0 +1,39 @@ +--TEST-- +Variable as class name for new expression +--FILE-- +<?php + +$className = 'stdClass'; +$array = ['className' => 'stdClass']; +$obj = (object) ['className' => 'stdClass']; + +class Test { + public static $className = 'stdClass'; +} +$test = 'Test'; +$weird = [0 => (object) ['foo' => 'Test']]; + +var_dump(new $className); +var_dump(new $array['className']); +var_dump(new $array{'className'}); +var_dump(new $obj->className); +var_dump(new Test::$className); +var_dump(new $test::$className); +var_dump(new $weird[0]->foo::$className); + +?> +--EXPECTF-- +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} diff --git a/Zend/tests/varSyntax/parenthesesDeref.phpt b/Zend/tests/varSyntax/parenthesesDeref.phpt new file mode 100644 index 0000000000..0ebfe9c5d7 --- /dev/null +++ b/Zend/tests/varSyntax/parenthesesDeref.phpt @@ -0,0 +1,20 @@ +--TEST-- +Dereferencing expression parentheses +--FILE-- +<?php + +$array = [&$array, 1]; +var_dump(($array)[1]); +var_dump((($array[0][0])[0])[1]); + +var_dump(((object) ['a' => 0, 'b' => 1])->b); + +$obj = (object) ['a' => 0, 'b' => ['var_dump', 1]]; +(clone $obj)->b[0](1); + +?> +--EXPECT-- +int(1) +int(1) +int(1) +int(1) diff --git a/Zend/tests/varSyntax/propertyOfStringError.phpt b/Zend/tests/varSyntax/propertyOfStringError.phpt new file mode 100644 index 0000000000..85abc5849a --- /dev/null +++ b/Zend/tests/varSyntax/propertyOfStringError.phpt @@ -0,0 +1,10 @@ +--TEST-- +Cannot take property of a string +--FILE-- +<?php + +"foo"->bar; + +?> +--EXPECTF-- +Notice: Trying to get property of non-object in %s on line %d diff --git a/Zend/tests/varSyntax/staticMember.phpt b/Zend/tests/varSyntax/staticMember.phpt new file mode 100644 index 0000000000..22a1fa2b13 --- /dev/null +++ b/Zend/tests/varSyntax/staticMember.phpt @@ -0,0 +1,37 @@ +--TEST-- +Static member access +--FILE-- +<?php + +class A { + public static $b = 0; + public static $c = [0, 1]; + public static $A_str = 'A'; +} + +$A_str = 'A'; +$A_obj = new A; +$b_str = 'b'; +$c_str = 'c'; + +var_dump(A::$b); +var_dump($A_str::$b); +var_dump($A_obj::$b); +var_dump(('A' . '')::$b); +var_dump('A'::$b); +var_dump('A'[0]::$b); +var_dump(A::$$b_str); +var_dump(A::$$c_str[1]); +var_dump(A::$A_str::$b); + +?> +--EXPECT-- +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(1) +int(0) diff --git a/Zend/tests/varSyntax/tempDimFetchByRefError.phpt b/Zend/tests/varSyntax/tempDimFetchByRefError.phpt new file mode 100644 index 0000000000..dbcac75ea9 --- /dev/null +++ b/Zend/tests/varSyntax/tempDimFetchByRefError.phpt @@ -0,0 +1,11 @@ +--TEST-- +Passing a dimention fetch on a temporary by reference is not allowed +--FILE-- +<?php + +$fn = function(&$ref) {}; +$fn([0, 1][0]); + +?> +--EXPECTF-- +Fatal error: Cannot use temporary expression in write context in %s on line %d diff --git a/Zend/tests/varSyntax/tempPropFetchByRefError.phpt b/Zend/tests/varSyntax/tempPropFetchByRefError.phpt new file mode 100644 index 0000000000..f8298a936d --- /dev/null +++ b/Zend/tests/varSyntax/tempPropFetchByRefError.phpt @@ -0,0 +1,11 @@ +--TEST-- +Passing a property fetch on a temporary by reference is not allowed +--FILE-- +<?php + +$fn = function(&$ref) {}; +$fn([0, 1]->prop); + +?> +--EXPECTF-- +Fatal error: Cannot use temporary expression in write context in %s on line %d diff --git a/Zend/tests/varSyntax/writeToTempExpr.phpt b/Zend/tests/varSyntax/writeToTempExpr.phpt new file mode 100644 index 0000000000..daeaf24938 --- /dev/null +++ b/Zend/tests/varSyntax/writeToTempExpr.phpt @@ -0,0 +1,10 @@ +--TEST-- +Writing to a temporary expression is not allowed +--FILE-- +<?php + +[0, 1][0] = 1; + +?> +--EXPECTF-- +Fatal error: Cannot use temporary expression in write context in %s on line %d |