Skip to content

Commit cf70177

Browse files
committed
Merge pull request #3 from morrisonlevi/returntypehinting
Returntypehinting
2 parents ca6fcba + 82a55ff commit cf70177

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Zend/tests/return_hint/016.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Fully qualified classes are allowed in return types
3+
4+
--FILE--
5+
<?php
6+
7+
namespace Collections;
8+
9+
class Foo {
10+
function foo(\Iterator $i): \Iterator {
11+
return $i;
12+
}
13+
}
14+
15+
$foo = new Foo;
16+
var_dump($foo->foo(new \EmptyIterator()));
17+
18+
--EXPECTF--

Zend/tests/return_hint/017.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Fully qualified classes in trait return types
3+
4+
--FILE--
5+
<?php
6+
7+
namespace FooSpace;
8+
9+
trait Fooable {
10+
function foo(): \Iterator {
11+
return new \EmptyIterator();
12+
}
13+
}
14+
15+
class Foo {
16+
use Fooable;
17+
}
18+
19+
$foo = new Foo;
20+
var_dump($foo->foo([]));
21+
22+
--EXPECTF--
23+
object(EmptyIterator)#%d (%d) {
24+
}

0 commit comments

Comments
 (0)