# On ReflectionParameter::canBePassedByValue()

- Thread: https://externals.io/message/49977
- Original archive: https://news-web.php.net/php.internals/49977
- Started by Gustavo Lopes on 2010-10-26T19:04:39+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #49977 — Gustavo Lopes — 2010-10-26T19:04:39+00:00

URL: https://externals.io/message/49977#49977

Hi.

As you may or may not know, the "zend_bool" arg_info->pass_by_reference,  
may take three values:

785 #define ZEND_SEND_BY_VAL     0
786 #define ZEND_SEND_BY_REF     1
787 #define ZEND_SEND_PREFER_REF 2

The last one is used one the function can either take a value or  
reference; see e.g. array_multisort.

ReflectionParameter has only only method, with an actual boolean return to  
test this, isPassedByReference(). This returns true for ZEND_SEND_BY_REF  
or ZEND_SEND_PREFER_REF, so there's no way to distinguish between the two.

To solve this, I added to trunk ReflectionParameter::canBePassedByValue(),  
which tests for ZEND_SEND_BY_VAL or ZEND_SEND_PREFER_REF.

Concerns have been raised over the naming of the method and over whether  
having three methods for three values would be more appropriate (with a  
minor BC break, changing the behavior of isPassedByReference() to return  
true only with ZEND_SEND_BY_REF).

Any comments on this issue are appreciated.

Thanks

-- 
Gustavo Lopes
