diff options
Diffstat (limited to 'tests')
27 files changed, 370 insertions, 54 deletions
diff --git a/tests/classes/__call_007.phpt b/tests/classes/__call_007.phpt index b061d17d85..cc7a2773bd 100644 --- a/tests/classes/__call_007.phpt +++ b/tests/classes/__call_007.phpt @@ -54,21 +54,25 @@ try { --EXPECTF-- Warning: The magic method __call() must have public visibility and cannot be static in %s on line 3 ---> Invoke __call via simple method call. -NULL +object(A)#1 (0) { +} Exception caught OK; continuing. ---> Invoke __call via scope resolution operator within instance. -NULL +object(A)#1 (0) { +} Exception caught OK; continuing. ---> Invoke __call via scope resolution operator within child instance. -NULL +object(B)#2 (0) { +} Exception caught OK; continuing. ---> Invoke __call via callback. -NULL +object(B)#2 (0) { +} Exception caught OK; continuing. ==DONE== diff --git a/tests/classes/constants_comments_001.phpt b/tests/classes/constants_comments_001.phpt new file mode 100644 index 0000000000..dbdd67c332 --- /dev/null +++ b/tests/classes/constants_comments_001.phpt @@ -0,0 +1,34 @@ +--TEST-- +Class constants and doc comments +--INI-- +opcache.save_comments=1 +--FILE-- +<?php +class X { + /** comment X1 */ + const X1 = 1; + const X2 = 2; + /** comment X3 */ + const X3 = 3; +} +class Y extends X { + /** comment Y1 */ + const Y1 = 1; + const Y2 = 2; + /** comment Y3 */ + const Y3 = 3; +} +$r = new ReflectionClass('Y'); +foreach ($r->getReflectionConstants() as $rc) { + echo $rc->getName() . " : " . $rc->getDocComment() . "\n"; +} + + +?> +--EXPECT-- +Y1 : /** comment Y1 */ +Y2 : +Y3 : /** comment Y3 */ +X1 : /** comment X1 */ +X2 : +X3 : /** comment X3 */ diff --git a/tests/classes/constants_visibility_001.phpt b/tests/classes/constants_visibility_001.phpt new file mode 100644 index 0000000000..37a0154d92 --- /dev/null +++ b/tests/classes/constants_visibility_001.phpt @@ -0,0 +1,23 @@ +--TEST-- +Class public constant visibility +--FILE-- +<?php +class A { + public const publicConst = 'publicConst'; + static function staticConstDump() { + var_dump(self::publicConst); + } + function constDump() { + var_dump(self::publicConst); + } +} + +var_dump(A::publicConst); +A::staticConstDump(); +(new A())->constDump(); + +?> +--EXPECTF-- +string(11) "publicConst" +string(11) "publicConst" +string(11) "publicConst" diff --git a/tests/classes/constants_visibility_002.phpt b/tests/classes/constants_visibility_002.phpt new file mode 100644 index 0000000000..82bdd6df1f --- /dev/null +++ b/tests/classes/constants_visibility_002.phpt @@ -0,0 +1,30 @@ +--TEST-- +Class protected constant visibility +--FILE-- +<?php +class A { + protected const protectedConst = 'protectedConst'; + static function staticConstDump() { + var_dump(self::protectedConst); + } + function constDump() { + var_dump(self::protectedConst); + } +} + +A::staticConstDump(); +(new A())->constDump(); +constant('A::protectedConst'); + +?> +--EXPECTF-- +string(14) "protectedConst" +string(14) "protectedConst" + +Warning: constant(): Couldn't find constant A::protectedConst in %s on line 14 + +Fatal error: Uncaught Error: Cannot access protected const A::protectedConst in %s:14 +Stack trace: +#0 %s(14): constant('A::protectedCon...') +#1 {main} + thrown in %s on line 14 diff --git a/tests/classes/constants_visibility_003.phpt b/tests/classes/constants_visibility_003.phpt new file mode 100644 index 0000000000..7f049abffb --- /dev/null +++ b/tests/classes/constants_visibility_003.phpt @@ -0,0 +1,30 @@ +--TEST-- +Class private constant visibility +--FILE-- +<?php +class A { + private const privateConst = 'privateConst'; + static function staticConstDump() { + var_dump(self::privateConst); + } + function constDump() { + var_dump(self::privateConst); + } +} + +A::staticConstDump(); +(new A())->constDump(); +constant('A::privateConst'); + +?> +--EXPECTF-- +string(12) "privateConst" +string(12) "privateConst" + +Warning: constant(): Couldn't find constant A::privateConst in %s on line 14 + +Fatal error: Uncaught Error: Cannot access private const A::privateConst in %s:14 +Stack trace: +#0 %s(14): constant('A::privateConst') +#1 {main} + thrown in %s on line 14 diff --git a/tests/classes/constants_visibility_004.phpt b/tests/classes/constants_visibility_004.phpt new file mode 100644 index 0000000000..93acacf3c9 --- /dev/null +++ b/tests/classes/constants_visibility_004.phpt @@ -0,0 +1,28 @@ +--TEST-- +Only public and protected class constants should be inherited +--FILE-- +<?php +class A { + public const X = 1; + protected const Y = 2; + private const Z = 3; +} +class B extends A { + static public function checkConstants() { + var_dump(self::X); + var_dump(self::Y); + var_dump(self::Z); + } +} + +B::checkConstants(); +?> +--EXPECTF-- +int(1) +int(2) + +Fatal error: Uncaught Error: Undefined class constant 'Z' in %s:11 +Stack trace: +#0 %s(15): B::checkConstants() +#1 {main} + thrown in %s on line 11 diff --git a/tests/classes/constants_visibility_005.phpt b/tests/classes/constants_visibility_005.phpt new file mode 100644 index 0000000000..813009c675 --- /dev/null +++ b/tests/classes/constants_visibility_005.phpt @@ -0,0 +1,10 @@ +--TEST-- +Static constants are not allowed +--FILE-- +<?php +class A { + static const X = 1; +} +?> +--EXPECTF-- +Fatal error: Cannot use 'static' as constant modifier in %s on line 3 diff --git a/tests/classes/constants_visibility_006.phpt b/tests/classes/constants_visibility_006.phpt new file mode 100644 index 0000000000..537c8eac0f --- /dev/null +++ b/tests/classes/constants_visibility_006.phpt @@ -0,0 +1,11 @@ +--TEST-- +Abstract constants are not allowed +--FILE-- +<?php +class A { + abstract const X = 1; +} +?> +--EXPECTF-- +Fatal error: Cannot use 'abstract' as constant modifier in %s on line 3 + diff --git a/tests/classes/constants_visibility_007.phpt b/tests/classes/constants_visibility_007.phpt new file mode 100644 index 0000000000..f1b040c5c3 --- /dev/null +++ b/tests/classes/constants_visibility_007.phpt @@ -0,0 +1,10 @@ +--TEST-- +Final constants are not allowed +--FILE-- +<?php +class A { + final const X = 1; +} +?> +--EXPECTF-- +Fatal error: Cannot use 'final' as constant modifier in %s on line 3 diff --git a/tests/classes/constants_visibility_error_001.phpt b/tests/classes/constants_visibility_error_001.phpt new file mode 100644 index 0000000000..397dd24882 --- /dev/null +++ b/tests/classes/constants_visibility_error_001.phpt @@ -0,0 +1,16 @@ +--TEST-- +Class private constant visibility error +--FILE-- +<?php +class A { + private const privateConst = 'privateConst'; +} + +var_dump(A::privateConst); + +?> +--EXPECTF-- +Fatal error: Uncaught Error: Cannot access private const A::privateConst in %s:6 +Stack trace: +#0 {main} + thrown in %s on line 6 diff --git a/tests/classes/constants_visibility_error_002.phpt b/tests/classes/constants_visibility_error_002.phpt new file mode 100644 index 0000000000..2980b52c37 --- /dev/null +++ b/tests/classes/constants_visibility_error_002.phpt @@ -0,0 +1,16 @@ +--TEST-- +Class protected constant visibility error +--FILE-- +<?php +class A { + protected const protectedConst = 'protectedConst'; +} + +var_dump(A::protectedConst); + +?> +--EXPECTF-- +Fatal error: Uncaught Error: Cannot access protected const A::protectedConst in %s:6 +Stack trace: +#0 {main} + thrown in %s on line 6 diff --git a/tests/classes/constants_visibility_error_003.phpt b/tests/classes/constants_visibility_error_003.phpt new file mode 100644 index 0000000000..c385bbd300 --- /dev/null +++ b/tests/classes/constants_visibility_error_003.phpt @@ -0,0 +1,16 @@ +--TEST-- +A redeclared class constant must have the same or higher visibility +--FILE-- +<?php + +class A { + public const publicConst = 0; +} + +class B extends A { + protected const publicConst = 1; +} + + +--EXPECTF-- +Fatal error: Access level to B::publicConst must be public (as in class A) in %s on line 9 diff --git a/tests/classes/constants_visibility_error_004.phpt b/tests/classes/constants_visibility_error_004.phpt new file mode 100644 index 0000000000..fe37b0691f --- /dev/null +++ b/tests/classes/constants_visibility_error_004.phpt @@ -0,0 +1,16 @@ +--TEST-- +A redeclared class constant must have the same or higher visibility +--FILE-- +<?php + +class A { + protected const protectedConst = 0; +} + +class B extends A { + private const protectedConst = 1; +} + + +--EXPECTF-- +Fatal error: Access level to B::protectedConst must be protected (as in class A) or weaker in %s on line 9 diff --git a/tests/classes/interface_constant_inheritance_005.phpt b/tests/classes/interface_constant_inheritance_005.phpt new file mode 100644 index 0000000000..60bf222e85 --- /dev/null +++ b/tests/classes/interface_constant_inheritance_005.phpt @@ -0,0 +1,12 @@ +--TEST-- +Ensure a interface can have public constants +--FILE-- +<?php +interface IA { + public const FOO = 10; +} + +echo "Done\n"; +?> +--EXPECT-- +Done
\ No newline at end of file diff --git a/tests/classes/interface_constant_inheritance_006.phpt b/tests/classes/interface_constant_inheritance_006.phpt new file mode 100644 index 0000000000..125326b224 --- /dev/null +++ b/tests/classes/interface_constant_inheritance_006.phpt @@ -0,0 +1,10 @@ +--TEST-- +Ensure a interface can not have protected constants + +--FILE-- +<?php +interface A { + protected const FOO = 10; +} +--EXPECTF-- +Fatal error: Access type for interface constant A::FOO must be public in %s on line 3 diff --git a/tests/classes/interface_constant_inheritance_007.phpt b/tests/classes/interface_constant_inheritance_007.phpt new file mode 100644 index 0000000000..52695343e1 --- /dev/null +++ b/tests/classes/interface_constant_inheritance_007.phpt @@ -0,0 +1,10 @@ +--TEST-- +Ensure a interface can not have private constants + +--FILE-- +<?php +interface A { + private const FOO = 10; +} +--EXPECTF-- +Fatal error: Access type for interface constant A::FOO must be public in %s on line 3 diff --git a/tests/classes/interfaces_003.phpt b/tests/classes/interfaces_003.phpt index e1cbfdaf54..e66a86491c 100644 --- a/tests/classes/interfaces_003.phpt +++ b/tests/classes/interfaces_003.phpt @@ -23,7 +23,7 @@ $obj = new MyTestClass; ===DONE=== --EXPECTF-- -Fatal error: Uncaught TypeError: Argument 1 passed to MyTestClass::__construct() must be an instance of MyObject, none given, called in %sinterfaces_003.php:%d +Fatal error: Uncaught Error: Too few arguments to function MyTestClass::__construct(), 0 passed in %sinterfaces_003.php on line 17 and exactly 1 expected in %sinterfaces_003.php:12 Stack trace: #0 %s(%d): MyTestClass->__construct() #1 {main} diff --git a/tests/classes/static_this.phpt b/tests/classes/static_this.phpt index 91b0287195..f7a11f5481 100644 --- a/tests/classes/static_this.phpt +++ b/tests/classes/static_this.phpt @@ -28,12 +28,4 @@ TestClass::Test2(new stdClass); ?> ===DONE=== --EXPECTF-- - -Notice: Undefined variable: this in %sstatic_this.php on line %d -NULL - -Notice: Undefined variable: this in %sstatic_this.php on line %d -NULL -object(stdClass)#%d (0) { -} -===DONE=== +Fatal error: Cannot use $this as parameter in %sstatic_this.php on line 16 diff --git a/tests/lang/045.phpt b/tests/lang/045.phpt index 11598cf035..44fb801410 100644 --- a/tests/lang/045.phpt +++ b/tests/lang/045.phpt @@ -3,7 +3,10 @@ Timeout again inside register_shutdown_function --SKIPIF-- <?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); +if (PHP_ZTS) die("skip hard_timeout works only on no-zts builds"); ?> +--INI-- +hard_timeout=1 --FILE-- <?php set_time_limit(1); diff --git a/tests/lang/bug22592.phpt b/tests/lang/bug22592.phpt index 270584185f..4614efc169 100644 --- a/tests/lang/bug22592.phpt +++ b/tests/lang/bug22592.phpt @@ -32,7 +32,8 @@ var_dump($result); $e = $result[1] = $result[6]; var_dump($result); var_dump($a, $b, $c, $d, $e); -$result[-1] = 'a'; +$result[0] = $result[-4] = $result[-1] = 'a'; +var_dump($result); ?> --EXPECT-- string(5) "* *-*" @@ -50,4 +51,4 @@ string(1) "s" string(1) "4" string(1) "5" string(1) "5" -[Illegal string offset: -1] +string(9) "a54s4a50a" diff --git a/tests/lang/bug28800.phpt b/tests/lang/bug28800.phpt index f81ad7fec9..8bd2c306e1 100644 --- a/tests/lang/bug28800.phpt +++ b/tests/lang/bug28800.phpt @@ -7,11 +7,23 @@ Bug #28800 (Incorrect string to number conversion for strings starting with 'inf echo ($v+0)."\n"; } ?> ---EXPECT-- +--EXPECTF-- + +Warning: A non-numeric value encountered in %s on line %d 0 + +Warning: A non-numeric value encountered in %s on line %d 0 + +Warning: A non-numeric value encountered in %s on line %d 0 + +Warning: A non-numeric value encountered in %s on line %d 0 + +Warning: A non-numeric value encountered in %s on line %d 0 + +Warning: A non-numeric value encountered in %s on line %d 0 diff --git a/tests/lang/bug71897.phpt b/tests/lang/bug71897.phpt new file mode 100644 index 0000000000..bd76921af6 --- /dev/null +++ b/tests/lang/bug71897.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #71897 (ASCII 0x7F Delete control character permitted in identifiers) +--FILE-- +<?php + +eval(" + \$a\x7Fb = 3; + var_dump(\$a\x7Fb); +"); + +?> +--EXPECTF-- + +Warning: Unexpected character in input: '%s' (ASCII=127) state=0 in %s(%d) : eval()'d code on line %d + +Parse error: syntax error, unexpected 'b' (T_STRING) in %s(%d) : eval()'d code on line %d diff --git a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt index d5888d837f..69fd90f1c8 100644 --- a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt +++ b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt @@ -226,17 +226,17 @@ int(984) --- testing: '123abc' << 'a5.9' ---
int(123)
--- testing: '123e5' << '0' ---
-int(123)
+int(12300000)
--- testing: '123e5' << '65' ---
int(0)
--- testing: '123e5' << '-44' ---
Exception: Bit shift by negative number
--- testing: '123e5' << '1.2' ---
-int(246)
+int(24600000)
--- testing: '123e5' << '-7.7' ---
Exception: Bit shift by negative number
--- testing: '123e5' << 'abc' ---
-int(123)
+int(12300000)
--- testing: '123e5' << '123abc' ---
int(0)
--- testing: '123e5' << '123e5' ---
@@ -250,21 +250,21 @@ int(0) --- testing: '123e5' << '123abc ' ---
int(0)
--- testing: '123e5' << '3.4a' ---
-int(984)
+int(98400000)
--- testing: '123e5' << 'a5.9' ---
-int(123)
+int(12300000)
--- testing: '123e5xyz' << '0' ---
-int(123)
+int(12300000)
--- testing: '123e5xyz' << '65' ---
int(0)
--- testing: '123e5xyz' << '-44' ---
Exception: Bit shift by negative number
--- testing: '123e5xyz' << '1.2' ---
-int(246)
+int(24600000)
--- testing: '123e5xyz' << '-7.7' ---
Exception: Bit shift by negative number
--- testing: '123e5xyz' << 'abc' ---
-int(123)
+int(12300000)
--- testing: '123e5xyz' << '123abc' ---
int(0)
--- testing: '123e5xyz' << '123e5' ---
@@ -278,9 +278,9 @@ int(0) --- testing: '123e5xyz' << '123abc ' ---
int(0)
--- testing: '123e5xyz' << '3.4a' ---
-int(984)
+int(98400000)
--- testing: '123e5xyz' << 'a5.9' ---
-int(123)
+int(12300000)
--- testing: ' 123abc' << '0' ---
int(123)
--- testing: ' 123abc' << '65' ---
diff --git a/tests/lang/operators/bitwiseShiftRight_variationStr.phpt b/tests/lang/operators/bitwiseShiftRight_variationStr.phpt index a86d0cfddb..a4c425aab3 100644 --- a/tests/lang/operators/bitwiseShiftRight_variationStr.phpt +++ b/tests/lang/operators/bitwiseShiftRight_variationStr.phpt @@ -222,17 +222,17 @@ int(15) --- testing: '123abc' >> 'a5.9' --- int(123) --- testing: '123e5' >> '0' --- -int(123) +int(12300000) --- testing: '123e5' >> '65' --- int(0) --- testing: '123e5' >> '-44' --- Exception: Bit shift by negative number --- testing: '123e5' >> '1.2' --- -int(61) +int(6150000) --- testing: '123e5' >> '-7.7' --- Exception: Bit shift by negative number --- testing: '123e5' >> 'abc' --- -int(123) +int(12300000) --- testing: '123e5' >> '123abc' --- int(0) --- testing: '123e5' >> '123e5' --- @@ -246,21 +246,21 @@ int(0) --- testing: '123e5' >> '123abc ' --- int(0) --- testing: '123e5' >> '3.4a' --- -int(15) +int(1537500) --- testing: '123e5' >> 'a5.9' --- -int(123) +int(12300000) --- testing: '123e5xyz' >> '0' --- -int(123) +int(12300000) --- testing: '123e5xyz' >> '65' --- int(0) --- testing: '123e5xyz' >> '-44' --- Exception: Bit shift by negative number --- testing: '123e5xyz' >> '1.2' --- -int(61) +int(6150000) --- testing: '123e5xyz' >> '-7.7' --- Exception: Bit shift by negative number --- testing: '123e5xyz' >> 'abc' --- -int(123) +int(12300000) --- testing: '123e5xyz' >> '123abc' --- int(0) --- testing: '123e5xyz' >> '123e5' --- @@ -274,9 +274,9 @@ int(0) --- testing: '123e5xyz' >> '123abc ' --- int(0) --- testing: '123e5xyz' >> '3.4a' --- -int(15) +int(1537500) --- testing: '123e5xyz' >> 'a5.9' --- -int(123) +int(12300000) --- testing: ' 123abc' >> '0' --- int(123) --- testing: ' 123abc' >> '65' --- diff --git a/tests/lang/operators/modulus_variationStr.phpt b/tests/lang/operators/modulus_variationStr.phpt index c647ecd380..4cfd7768ff 100644 --- a/tests/lang/operators/modulus_variationStr.phpt +++ b/tests/lang/operators/modulus_variationStr.phpt @@ -208,9 +208,9 @@ Exception: Modulo by zero --- testing: '123abc' % '123abc' ---
int(0)
--- testing: '123abc' % '123e5' ---
-int(0)
+int(123)
--- testing: '123abc' % '123e5xyz' ---
-int(0)
+int(123)
--- testing: '123abc' % ' 123abc' ---
int(0)
--- testing: '123abc' % '123 abc' ---
@@ -224,13 +224,13 @@ Exception: Modulo by zero --- testing: '123e5' % '0' ---
Exception: Modulo by zero
--- testing: '123e5' % '65' ---
-int(58)
+int(50)
--- testing: '123e5' % '-44' ---
-int(35)
+int(20)
--- testing: '123e5' % '1.2' ---
int(0)
--- testing: '123e5' % '-7.7' ---
-int(4)
+int(6)
--- testing: '123e5' % 'abc' ---
Exception: Modulo by zero
--- testing: '123e5' % '123abc' ---
@@ -252,13 +252,13 @@ Exception: Modulo by zero --- testing: '123e5xyz' % '0' ---
Exception: Modulo by zero
--- testing: '123e5xyz' % '65' ---
-int(58)
+int(50)
--- testing: '123e5xyz' % '-44' ---
-int(35)
+int(20)
--- testing: '123e5xyz' % '1.2' ---
int(0)
--- testing: '123e5xyz' % '-7.7' ---
-int(4)
+int(6)
--- testing: '123e5xyz' % 'abc' ---
Exception: Modulo by zero
--- testing: '123e5xyz' % '123abc' ---
@@ -292,9 +292,9 @@ Exception: Modulo by zero --- testing: ' 123abc' % '123abc' ---
int(0)
--- testing: ' 123abc' % '123e5' ---
-int(0)
+int(123)
--- testing: ' 123abc' % '123e5xyz' ---
-int(0)
+int(123)
--- testing: ' 123abc' % ' 123abc' ---
int(0)
--- testing: ' 123abc' % '123 abc' ---
@@ -320,9 +320,9 @@ Exception: Modulo by zero --- testing: '123 abc' % '123abc' ---
int(0)
--- testing: '123 abc' % '123e5' ---
-int(0)
+int(123)
--- testing: '123 abc' % '123e5xyz' ---
-int(0)
+int(123)
--- testing: '123 abc' % ' 123abc' ---
int(0)
--- testing: '123 abc' % '123 abc' ---
@@ -348,9 +348,9 @@ Exception: Modulo by zero --- testing: '123abc ' % '123abc' ---
int(0)
--- testing: '123abc ' % '123e5' ---
-int(0)
+int(123)
--- testing: '123abc ' % '123e5xyz' ---
-int(0)
+int(123)
--- testing: '123abc ' % ' 123abc' ---
int(0)
--- testing: '123abc ' % '123 abc' ---
diff --git a/tests/lang/operators/negate_variationStr.phpt b/tests/lang/operators/negate_variationStr.phpt index a25bdda7f5..7405d42882 100644 --- a/tests/lang/operators/negate_variationStr.phpt +++ b/tests/lang/operators/negate_variationStr.phpt @@ -16,7 +16,7 @@ foreach ($strVals as $strVal) { ?>
===DONE===
---EXPECT--
+--EXPECTF--
--- testing: '0' --- int(0) --- testing: '65' --- @@ -28,21 +28,37 @@ float(-1.2) --- testing: '-7.7' --- float(7.7) --- testing: 'abc' --- + +Warning: A non-numeric value encountered in %s on line %d int(0) --- testing: '123abc' --- + +Notice: A non well formed numeric value encountered in %s on line %d int(-123) --- testing: '123e5' --- float(-12300000) --- testing: '123e5xyz' --- + +Notice: A non well formed numeric value encountered in %s on line %d float(-12300000) --- testing: ' 123abc' --- + +Notice: A non well formed numeric value encountered in %s on line %d int(-123) --- testing: '123 abc' --- + +Notice: A non well formed numeric value encountered in %s on line %d int(-123) --- testing: '123abc ' --- + +Notice: A non well formed numeric value encountered in %s on line %d int(-123) --- testing: '3.4a' --- + +Notice: A non well formed numeric value encountered in %s on line %d float(-3.4) --- testing: 'a5.9' --- + +Warning: A non-numeric value encountered in %s on line %d int(0)
===DONE===
diff --git a/tests/output/ob_010.phpt b/tests/output/ob_010.phpt index 24d650c50d..7e362cabe1 100644 --- a/tests/output/ob_010.phpt +++ b/tests/output/ob_010.phpt @@ -4,10 +4,10 @@ output buffering - fatalism <?php function obh($s) { - print_r($s, 1); + return print_r($s, 1); } ob_start("obh"); echo "foo\n"; ?> --EXPECTF-- -Fatal error: print_r(): Cannot use output buffering in output buffering display handlers in %sob_010.php on line %d +foo |
