Skip to content

Commit 129f1ad

Browse files
committed
Add a variance test
It wasn't immediatly obvious to me while starring at the code that the case where a parent type is not loadable is handled. Just needed to understand that get_class_from_type() only returns NULL when it is not a class-type
1 parent a6d28dc commit 129f1ad

File tree

1 file changed

+20
-0
lines changed
  • Zend/tests/type_declarations/intersection_types/variance

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Replacing not-loadable parent intersection type with loadable child intersection type
3+
--FILE--
4+
<?php
5+
6+
// Let Y and Z be loadable.
7+
interface Y {}
8+
interface Z {}
9+
10+
class Test {
11+
function method(): X&Y {}
12+
}
13+
class Test2 extends Test {
14+
function method(): Y&Z {}
15+
}
16+
17+
?>
18+
===DONE===
19+
--EXPECTF--
20+
Fatal error: Could not check compatibility between Test2::method(): Y&Z and Test::method(): X&Y, because class X is not available in %s on line %d

0 commit comments

Comments
 (0)