1
0
mirror of synced 2025-02-09 00:39:25 +03:00

Drop PHP version specifics

This commit is contained in:
Adrien Crivelli 2017-09-21 21:28:19 +09:00 committed by GitHub
parent d995203ee1
commit 3d3ecc77bd

View File

@ -240,17 +240,12 @@ Notice how both sides of the bidirectional association are always
updated. Unidirectional associations are consequently simpler to updated. Unidirectional associations are consequently simpler to
handle. handle.
Also note that if you use type-hinting in your methods, i.e. Also note that if you use type-hinting in your methods, you will
``setAddress(Address $address)``, you will have to specifically have to specify a nullable type, i.e. ``setAddress(?Address $address)``,
allow null values, otherwise ``setAddress(null)`` will fail to otherwise ``setAddress(null)`` will fail to remove the association.
remove the association. Starting from PHP 7.1 you should use Another way to deal with this is to provide a special method, like
nullable types by prefixing the type with a ``?``, ``removeAddress()``. This can also provide better encapsulation as
``setAddress(?Address $address)``. Older PHP versions will only it hides the internal meaning of not having an address.
allow null values if ``null`` is set as default value,
``setAddress(Address $address = null)``. Yet another way to deal
with this is to provide a special method, like ``removeAddress()``.
This can also provide better encapsulation as it hides the internal
meaning of not having an address.
When working with collections, keep in mind that a Collection is When working with collections, keep in mind that a Collection is
essentially an ordered map (just like a PHP array). That is why the essentially an ordered map (just like a PHP array). That is why the