Skip to content

Commit 891f24d

Browse files
committed
Fix some implicit bound type issues
1 parent 229fcc9 commit 891f24d

11 files changed

+109
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Implicit interface inheritance with different bound types 3
3+
--FILE--
4+
<?php
5+
6+
interface I1<T> {
7+
public function foo(T $param): T;
8+
}
9+
10+
interface I2 extends I1<float> {
11+
public function bar(int $o, float $param): float;
12+
}
13+
14+
class C implements I2, I1<string> {
15+
public function foo(float $param): float {}
16+
public function bar(int $o, float $param): float {}
17+
}
18+
19+
?>
20+
--EXPECTF--
21+
Fatal error: Bound type T for interface I1 implemented explicitly in C with type string must match the implicitly bound type float from interface I2 in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Implicit interface inheritance with different bound types 4
3+
--FILE--
4+
<?php
5+
6+
interface I1<T> {
7+
public function foo(T $param): T;
8+
}
9+
10+
interface I2 extends I1<float> {
11+
public function bar(int $o, float $param): float;
12+
}
13+
14+
class C implements I1<string>, I2 {
15+
public function foo(string $param): string {}
16+
public function bar(int $o, float $param): float {}
17+
}
18+
19+
?>
20+
--EXPECTF--
21+
Fatal error: Bound type T for interface I1 implemented explicitly in C with type string must match the implicitly bound type float from interface I2 in %s on line %d

Zend/tests/type_declarations/abstract_generics/constraints/implicit_interface_no_bound_types.phpt renamed to Zend/tests/type_declarations/abstract_generics/bound_types/implicit_interface_no_bound_types.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
Implicit interface inheritance missing bound types
3-
--XFAIL--
4-
Wrong number of missing params
53
--FILE--
64
<?php
75

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Implicit interface inheritance missing bound types 3
3+
--FILE--
4+
<?php
5+
6+
interface I1<T> {
7+
public function foo(T $param): T;
8+
}
9+
10+
interface I2 extends I1<string> {
11+
public function bar(int $o, string $param): string;
12+
}
13+
14+
class C implements I1, I2 {
15+
public function foo(string $param): string {}
16+
public function bar(int $o, string $param): string {}
17+
}
18+
19+
?>
20+
--EXPECTF--
21+
Fatal error: Interface I1 expects 1 generic parameters, 0 given in %s on line %d
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Implicit interface inheritance missing bound types 4
3+
--FILE--
4+
<?php
5+
6+
interface I1<T> {
7+
public function foo(T $param): T;
8+
}
9+
10+
interface I2 extends I1<string> {
11+
public function bar(int $o, string $param): string;
12+
}
13+
14+
class C implements I2, I1 {
15+
public function foo(string $param): string {}
16+
public function bar(int $o, string $param): string {}
17+
}
18+
19+
?>
20+
--EXPECTF--
21+
Fatal error: Interface I1 expects 1 generic parameters, 0 given in %s on line %d

0 commit comments

Comments
 (0)