File tree Expand file tree Collapse file tree 2 files changed +5
-36
lines changed Expand file tree Collapse file tree 2 files changed +5
-36
lines changed Original file line number Diff line number Diff line change 31
31
<type >float</type > is changed to <type >int</type >
32
32
</simpara >
33
33
</listitem >
34
+ <listitem >
35
+ <simpara >
36
+ <type >iterable</type > is changed to <type >array</type > or <classname >Traversable</classname >
37
+ </simpara >
38
+ </listitem >
34
39
</itemizedlist >
35
40
36
41
A type class is considered less specific if the opposite is true.
Original file line number Diff line number Diff line change @@ -113,42 +113,6 @@ function gen(): iterable {
113
113
yield 3;
114
114
}
115
115
116
- ?>
117
- ]]>
118
- </programlisting >
119
- </example >
120
- </para >
121
- </sect2 >
122
-
123
- <sect2 xml : id =" language.types.iterable.variance" >
124
- <title >Iterable Type Variance</title >
125
-
126
- <para >
127
- Classes extending/implementing may broaden methods using &array; or
128
- <classname >Traversable</classname > as parameter types to
129
- <type >iterable</type > or narrow return types from <type >iterable</type > to
130
- &array; or <classname >Traversable</classname >.
131
- </para >
132
-
133
- <para >
134
- <example >
135
- <title >
136
- Iterable type variance example
137
- </title >
138
- <programlisting role =" php" >
139
- <![CDATA[
140
- <?php
141
-
142
- interface Example {
143
- public function method(array $array): iterable;
144
- }
145
-
146
- class ExampleImplementation implements Example {
147
- public function method(iterable $iterable): array {
148
- // Parameter broadened and return type narrowed.
149
- }
150
- }
151
-
152
116
?>
153
117
]]>
154
118
</programlisting >
You can’t perform that action at this time.
0 commit comments