diff options
Diffstat (limited to 'Zend/tests')
-rw-r--r-- | Zend/tests/bug30998.phpt | 4 | ||||
-rw-r--r-- | Zend/tests/bug60909_1.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/bug63462.phpt | 74 | ||||
-rw-r--r-- | Zend/tests/bug63982.phpt | 15 | ||||
-rw-r--r-- | Zend/tests/class_name_as_scalar.phpt | 77 | ||||
-rw-r--r-- | Zend/tests/class_name_as_scalar_error_001.phpt | 13 | ||||
-rw-r--r-- | Zend/tests/class_name_as_scalar_error_002.phpt | 13 | ||||
-rw-r--r-- | Zend/tests/class_name_as_scalar_error_003.phpt | 13 | ||||
-rw-r--r-- | Zend/tests/class_name_as_scalar_error_004.phpt | 13 | ||||
-rw-r--r-- | Zend/tests/class_name_as_scalar_error_005.phpt | 10 | ||||
-rw-r--r-- | Zend/tests/class_name_as_scalar_error_006.phpt | 10 |
11 files changed, 241 insertions, 3 deletions
diff --git a/Zend/tests/bug30998.phpt b/Zend/tests/bug30998.phpt index d0ace9fa1..032da3d3b 100644 --- a/Zend/tests/bug30998.phpt +++ b/Zend/tests/bug30998.phpt @@ -15,7 +15,7 @@ $f = fopen("/tmp/blah", "r"); ?> ===DONE=== --EXPECTF-- -fopen(/tmp/blah): failed to open stream: No such file or directory (2) in %s:%d +fopen(/tmp/blah): failed to open stream: %s (2) in %s:%d -Warning: fopen(/tmp/blah): failed to open stream: No such file or directory in %s on line %d +Warning: fopen(/tmp/blah): failed to open stream: %s in %s on line %d ===DONE=== diff --git a/Zend/tests/bug60909_1.phpt b/Zend/tests/bug60909_1.phpt index 5150dfc02..cfe428928 100644 --- a/Zend/tests/bug60909_1.phpt +++ b/Zend/tests/bug60909_1.phpt @@ -10,7 +10,7 @@ set_error_handler(function($errno, $errstr, $errfile, $errline){ require 'notfound.php'; --EXPECTF-- -error(require(notfound.php): failed to open stream: No such file or directory) +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) diff --git a/Zend/tests/bug63462.phpt b/Zend/tests/bug63462.phpt new file mode 100644 index 000000000..e936a6fa6 --- /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/bug63982.phpt b/Zend/tests/bug63982.phpt new file mode 100644 index 000000000..31294f33e --- /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/class_name_as_scalar.phpt b/Zend/tests/class_name_as_scalar.phpt new file mode 100644 index 000000000..38e55b16d --- /dev/null +++ b/Zend/tests/class_name_as_scalar.phpt @@ -0,0 +1,77 @@ +--TEST-- +class name as scalar from ::class keyword +--FILE-- +<?php + +namespace Foo\Bar { + class One { + // compile time constants + const A = self::class; + const B = Two::class; + } + class Two extends One { + public static function run() { + var_dump(self::class); // self compile time lookup + var_dump(static::class); // runtime lookup + var_dump(parent::class); // runtime lookup + var_dump(Baz::class); // default compile time lookup + } + } + class Three extends Two { + // compile time static lookups + public static function checkCompileTime( + $one = self::class, + $two = Baz::class, + $three = One::A, + $four = self::B + ) { + var_dump($one, $two, $three, $four); + } + } + echo "In NS\n"; + var_dump(Moo::CLASS); // resolve in namespace +} + +namespace { + use Bee\Bop as Moo, + Foo\Bar\One; + echo "Top\n"; + var_dump(One::class); // resolve from use + var_dump(Boo::class); // resolve in global namespace + var_dump(Moo::CLASS); // resolve from use as + var_dump(\Moo::Class); // resolve fully qualified + $class = One::class; // assign class as scalar to var + $x = new $class; // create new class from original scalar assignment + var_dump($x); + Foo\Bar\Two::run(); // resolve runtime lookups + echo "Parent\n"; + Foo\Bar\Three::run(); // resolve runtime lookups with inheritance + echo "Compile Check\n"; + Foo\Bar\Three::checkCompileTime(); +} + +?> +--EXPECTF-- +In NS +string(11) "Foo\Bar\Moo" +Top +string(11) "Foo\Bar\One" +string(3) "Boo" +string(7) "Bee\Bop" +string(3) "Moo" +object(Foo\Bar\One)#1 (0) { +} +string(11) "Foo\Bar\Two" +string(11) "Foo\Bar\Two" +string(11) "Foo\Bar\One" +string(11) "Foo\Bar\Baz" +Parent +string(11) "Foo\Bar\Two" +string(13) "Foo\Bar\Three" +string(11) "Foo\Bar\One" +string(11) "Foo\Bar\Baz" +Compile Check +string(13) "Foo\Bar\Three" +string(11) "Foo\Bar\Baz" +string(11) "Foo\Bar\One" +string(11) "Foo\Bar\Two" diff --git a/Zend/tests/class_name_as_scalar_error_001.phpt b/Zend/tests/class_name_as_scalar_error_001.phpt new file mode 100644 index 000000000..1c7aa7ea8 --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_001.phpt @@ -0,0 +1,13 @@ +--TEST-- +class name as scalar from ::class keyword error using static in class constant +--FILE-- +<?php + +namespace Foo\Bar { + class One { + const Baz = static::class; + } +} +?> +--EXPECTF-- +Fatal error: static::class cannot be used for compile-time class name resolution in %s on line %d diff --git a/Zend/tests/class_name_as_scalar_error_002.phpt b/Zend/tests/class_name_as_scalar_error_002.phpt new file mode 100644 index 000000000..59b7a2edc --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_002.phpt @@ -0,0 +1,13 @@ +--TEST-- +class name as scalar from ::class keyword error using parent in class constant +--FILE-- +<?php + +namespace Foo\Bar { + class One { + const Baz = parent::class; + } +} +?> +--EXPECTF-- +Fatal error: parent::class cannot be used for compile-time class name resolution in %s on line %d diff --git a/Zend/tests/class_name_as_scalar_error_003.phpt b/Zend/tests/class_name_as_scalar_error_003.phpt new file mode 100644 index 000000000..929904169 --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_003.phpt @@ -0,0 +1,13 @@ +--TEST-- +class name as scalar from ::class keyword error using static in method signature +--FILE-- +<?php + +namespace Foo\Bar { + class One { + public function baz($x = static::class) {} + } +} +?> +--EXPECTF-- +Fatal error: static::class cannot be used for compile-time class name resolution in %s on line %d diff --git a/Zend/tests/class_name_as_scalar_error_004.phpt b/Zend/tests/class_name_as_scalar_error_004.phpt new file mode 100644 index 000000000..c00037fca --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_004.phpt @@ -0,0 +1,13 @@ +--TEST-- +class name as scalar from ::class keyword error using parent in method signature +--FILE-- +<?php + +namespace Foo\Bar { + class One { + public function baz($x = parent::class) {} + } +} +?> +--EXPECTF-- +Fatal error: parent::class cannot be used for compile-time class name resolution in %s on line %d diff --git a/Zend/tests/class_name_as_scalar_error_005.phpt b/Zend/tests/class_name_as_scalar_error_005.phpt new file mode 100644 index 000000000..39de69ffb --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_005.phpt @@ -0,0 +1,10 @@ +--TEST-- +class name as scalar from ::class keyword error using static non class context +--FILE-- +<?php + +$x = static::class; + +?> +--EXPECTF-- +Fatal error: Cannot access static::class when no class scope is active in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/class_name_as_scalar_error_006.phpt b/Zend/tests/class_name_as_scalar_error_006.phpt new file mode 100644 index 000000000..a4cc9a528 --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_006.phpt @@ -0,0 +1,10 @@ +--TEST-- +class name as scalar from ::class keyword error using parent in non class context +--FILE-- +<?php + +$x = parent::class; + +?> +--EXPECTF-- +Fatal error: Cannot access parent::class when no class scope is active in %s on line %d |