We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be902fc commit 2daa357Copy full SHA for 2daa357
Zend/tests/return_hint/006.phpt
@@ -1,22 +1,27 @@
1
--TEST--
2
-Basic return hints covariance
+Return type where none previously existed
3
+
4
--FILE--
5
<?php
-class foo {}
6
-class bar extends foo {}
7
-class baz {}
8
9
-class qux extends baz {
10
- public function foo() : foo {
11
- return new bar();
12
- }
+class Comment {
13
}
14
15
-$qux = new qux();
16
-var_dump($qux->foo());
17
-?>
18
---EXPECTF--
19
-object(bar)#%d (%d) {
+class CommentsIterator extends ArrayIterator implements Iterator {
+ function current() : Comment {
+ return parent::current();
+ }
20
21
22
+$comments = new CommentsIterator([
+ new Comment
+]);
+foreach ($comments as $comment) {
+ var_dump($comment);
23
+}
24
+--EXPECTF--
25
+object(Comment)#%d (%d) {
26
27
0 commit comments