Move isBuiltin() method from ReflectionType to ReflectionNamedType

This method only makes sense for single types, e.g. it would be
meaningless for union types.

Note that we always return ReflectionNamedType right now, so this does
not break compatibility for code using any currently existing types.
This commit is contained in:
Nikita Popov 2019-09-02 14:55:04 +02:00
parent 603b9c43cb
commit bdf2cd7508

View file

@ -2817,22 +2817,6 @@ ZEND_METHOD(reflection_type, allowsNull)
}
/* }}} */
/* {{{ proto public bool ReflectionType::isBuiltin()
Returns whether parameter is a builtin type */
ZEND_METHOD(reflection_type, isBuiltin)
{
reflection_object *intern;
type_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
GET_REFLECTION_OBJECT_PTR(param);
RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->type));
}
/* }}} */
/* {{{ reflection_type_name */
static zend_string *reflection_type_name(type_reference *param) {
if (ZEND_TYPE_IS_NAME(param->type)) {
@ -2863,7 +2847,7 @@ ZEND_METHOD(reflection_type, __toString)
/* }}} */
/* {{{ proto public string ReflectionNamedType::getName()
Return the text of the type hint */
Return the name of the type */
ZEND_METHOD(reflection_named_type, getName)
{
reflection_object *intern;
@ -2878,6 +2862,22 @@ ZEND_METHOD(reflection_named_type, getName)
}
/* }}} */
/* {{{ proto public bool ReflectionNamedType::isBuiltin()
Returns whether type is a builtin type */
ZEND_METHOD(reflection_named_type, isBuiltin)
{
reflection_object *intern;
type_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
GET_REFLECTION_OBJECT_PTR(param);
RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->type));
}
/* }}} */
/* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
ZEND_METHOD(reflection_method, export)
@ -6645,13 +6645,13 @@ static const zend_function_entry reflection_parameter_functions[] = {
static const zend_function_entry reflection_type_functions[] = {
ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
ZEND_ME(reflection_type, allowsNull, arginfo_reflection__void, 0)
ZEND_ME(reflection_type, isBuiltin, arginfo_reflection__void, 0)
ZEND_ME(reflection_type, __toString, arginfo_reflection__void, ZEND_ACC_DEPRECATED)
PHP_FE_END
};
static const zend_function_entry reflection_named_type_functions[] = {
ZEND_ME(reflection_named_type, getName, arginfo_reflection__void, 0)
ZEND_ME(reflection_named_type, isBuiltin, arginfo_reflection__void, 0)
PHP_FE_END
};