File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,33 @@ class ChildProducer extends Producer {
77
77
Full variance support is only available if autoloading is used. Inside a
78
78
single file only non-cyclic type references are possible, because all
79
79
classes need to be available before they are referenced.
80
+ <informalexample >
81
+ <programlisting role =" php" >
82
+ <![CDATA[
83
+ <?php
84
+
85
+ /**
86
+ * These classes satisfy the LSP requirements, because C is a subtype of A.
87
+ * However, at the time class B is declared, class C is not yet available
88
+ */
89
+ class A
90
+ {
91
+ public function method(): A {}
92
+ }
93
+
94
+ class B extends A
95
+ {
96
+ // Fatal error: Could not check compatibility between B::method():C and
97
+ // A::method(): A, because class С is not available
98
+ public function method(): С {}
99
+ }
100
+
101
+ class C extends B {}
102
+
103
+ ?>
104
+ ]]>
105
+ </programlisting >
106
+ </informalexample >
80
107
</para >
81
108
</sect3 >
82
109
You can’t perform that action at this time.
0 commit comments