Skip to content

Commit 5ccee0a

Browse files
committed
Move iterable variance section to OOP section
1 parent e5d4a84 commit 5ccee0a

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed

language/oop5/variance.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
<type>float</type> is changed to <type>int</type>
3232
</simpara>
3333
</listitem>
34+
<listitem>
35+
<simpara>
36+
<type>iterable</type> is changed to <type>array</type> or <classname>Traversable</classname>
37+
</simpara>
38+
</listitem>
3439
</itemizedlist>
3540

3641
A type class is considered less specific if the opposite is true.

language/types/iterable.xml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -113,42 +113,6 @@ function gen(): iterable {
113113
yield 3;
114114
}
115115
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-
152116
?>
153117
]]>
154118
</programlisting>

0 commit comments

Comments
 (0)