- Date: 2017-12-05
- Author: Levi Morrison [email protected]
- Proposed for: PHP 7.NEXT or 8.0
- Status: Draft
Taking parameters by references allows functions to modify variables and those modifications are viewable in the sender. This comes at a price: the variable must be moved to the heap to be reference counted. Additionally, the type of the argument is checked on function entry but not on function exit. Interested parties can return by reference and add a return type but this does not scale beyond one parameter. This RFC proposes out
and inout
parameters which solve these issues while providing additional safety.