]> granicus.if.org Git - php/commitdiff
Move isBuiltin() method from ReflectionType to ReflectionNamedType
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 2 Sep 2019 12:55:04 +0000 (14:55 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 2 Sep 2019 12:59:31 +0000 (14:59 +0200)
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.

ext/reflection/php_reflection.c

index 5f7dd80435546a3d0bc5dd69637a5d3edea0062f..d31a99bd3fd51c895abbd828ae3127b736f56271 100644 (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
 };