Skip to content

Commit 79ca9f7

Browse files
committed
Added information about type compatibility
1 parent dacd7ce commit 79ca9f7

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

contributing/code/bc.rst

+25-2
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,34 @@ Change return type Yes [1]_ [2]_ No
181181
.. [1] Should be avoided. When done, this change must be documented in the
182182
UGPRADE file.
183183
184-
.. [2] The return type may only be changed to compatible types. **TODO define
185-
type compatibility**
184+
.. [2] The return type may only be changed to compatible types. The following
185+
type changes are allowed:
186+
187+
=================== ==================================================================
188+
Original Type New Type
189+
=================== ==================================================================
190+
boolean any `scalar type`_ with equivalent `boolean values`_
191+
string any `scalar type`_ or object with equivalent `string values`_
192+
integer any `scalar type`_ with equivalent `integer values`_
193+
float any `scalar type`_ with equivalent `float values`_
194+
array instance of ``ArrayAccess``, ``Traversable`` and ``Countable``
195+
``ArrayAccess`` array
196+
``Traversable`` array
197+
``Countable`` array
198+
=================== ==================================================================
186199
187200
.. [3] When changing the parent class, the original parent class must remain an
188201
ancestor of the class.
189202
190203
.. [4] A type hint may only be added if passing a value with a different type
191204
previously generated a fatal error.
205+
206+
.. _scalar type: http://php.net/manual/en/function.is-scalar.php
207+
208+
.. _boolean values: http://php.net/manual/en/function.boolval.php
209+
210+
.. _string values: http://www.php.net/manual/en/function.strval.php
211+
212+
.. _integer values: http://www.php.net/manual/en/function.intval.php
213+
214+
.. _float values: http://www.php.net/manual/en/function.floatval.php

0 commit comments

Comments
 (0)