Skip to content

Commit 0019a7e

Browse files
authored
ReturnTypeWillChange: Add warning about future strict return type (#5613)
1 parent 28192e8 commit 0019a7e

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

language/predefined/attributes/returntypewillchange.xml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,28 @@
77

88
<section xml:id="returntypewillchange.intro">
99
&reftitle.intro;
10-
<para>
10+
<simpara>
1111
Most non-final internal methods now require overriding methods to declare
1212
a compatible return type, otherwise a deprecated notice is emitted during
13-
inheritance validation.
13+
inheritance validation. This introduces a tentative return type phase:
14+
the engine emits a deprecation notice instead of a fatal error when return
15+
types are incompatible, before they become enforced in a future version.
1416
In case the return type cannot be declared for an overriding method due to
1517
PHP cross-version compatibility concerns,
1618
a <code>#[\ReturnTypeWillChange]</code> attribute can be added to silence
1719
the deprecation notice.
18-
</para>
20+
</simpara>
21+
22+
<warning>
23+
<simpara>
24+
The <classname>ReturnTypeWillChange</classname> attribute suppresses
25+
deprecation warnings during the tentative return type phase <emphasis>only</emphasis>.
26+
It has no effect when overriding methods defined in user-defined classes.
27+
Once internal methods adopt strict types, mismatches in overriding method
28+
signatures will cause a fatal error and this attribute will no longer have any effect.
29+
</simpara>
30+
</warning>
31+
1932
</section>
2033

2134
<section xml:id="returntypewillchange.synopsis">

0 commit comments

Comments
 (0)