summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-01-14 10:04:47 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-01-14 10:04:47 +0100
commitad5ae0634de0e8f069d2c28beb223cf2c878aed1 (patch)
tree8da9736372cf7615e44ea51c9d5a83f5082d8aec /Zend/tests
parent5a5f0adb2f20f6ac4b05b882d0dc771209d76870 (diff)
parentf9fbba41b66e0e9ccd40ff064d00cfe987c2c5bb (diff)
downloadphp-git-ad5ae0634de0e8f069d2c28beb223cf2c878aed1.tar.gz
Merge branch 'PHP-8.0'
* PHP-8.0: Fixed bug #80596: Fix anonymous class union typehint errors
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/type_declarations/union_types/anonymous_class.phpt30
1 files changed, 30 insertions, 0 deletions
diff --git a/Zend/tests/type_declarations/union_types/anonymous_class.phpt b/Zend/tests/type_declarations/union_types/anonymous_class.phpt
new file mode 100644
index 0000000000..1e009f22b0
--- /dev/null
+++ b/Zend/tests/type_declarations/union_types/anonymous_class.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Union with anonymous class type
+--FILE--
+<?php
+
+$a = new class {
+ public function testParam(self|string $a)
+ {
+ }
+ public function test(): self|string
+ {
+ return new \stdClass;
+ }
+};
+
+try {
+ $a->testParam(null);
+} catch (\Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+
+try {
+ $a->test();
+} catch (\Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+?>
+--EXPECTF--
+class@anonymous(): Argument #1 ($a) must be of type class@anonymous|string, null given, called in %s on line %d
+class@anonymous::test(): Return value must be of type class@anonymous|string, stdClass returned