Permit Type-Hinting from extensions #107
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All extensions use
ZEND_ARG_INFO
,ZEND_ARG_OBJ_INFO
orZEND_ARG_ARRAY_INFO
, but none useZEND_ARG_TYPE_INFO
, because of a bug.The advantage of using the latter over the primer is that it permits giving a type hint to PHP.
The only impact of a type hint should be visible in the Reflection extension, as it merely is a hint.
However Zend emits a bug systematically if the type info is given:
PHP Fatal error: Unknown typehint in file.php on line 1
.The first commit fixes this bug, enabling widespread use of
ZEND_ARG_TYPE_INFO
.Currently only
ReflectionParameter::__toString()
permits getting back this information inside a PHP script, forcing ugly string analysis to get it back.The second commit makes the type hint information accessible through the
ReflectionParameter::getTypeHint()
method, which returns, likegettype()
, the string representation of the given type hint, or NULL if none is provided (yet).