com php-src: ReflectionProperty::hasType: ext/reflection/php_ reflection.c ext/reflection/tests/ReflectionType_00 1.phpt
| From: | Bob Weinand | Date: | Fri, 11 Mar 2016 07:01:04 +0000 |
| Subject: | com php-src: ReflectionProperty::hasType: ext/reflection/php_ reflection.c ext/reflection/tests/ReflectionType_00 1.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95686@lists.php.net to get a copy of this message | ||
Commit: 2fde206041392f75df8f9e7eeeb92d0dfe2e9c48
Author: Joe Watkins <krakjoe@php.net> Fri, 11 Mar 2016 07:01:04 +0000
Parents: 61da1b9c8ea940851abd323e95c4ae1ac3c7917b
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2fde206041392f75df8f9e7eeeb92d0dfe2e9c48
Log:
ReflectionProperty::hasType
Changed paths:
M ext/reflection/php_reflection.c
M ext/reflection/tests/ReflectionType_001.phpt
Diff:
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index b92bfde..451a6e7 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -5884,6 +5884,23 @@ ZEND_METHOD(reflection_property, getType)
}
/* }}} */
+/* {{{ proto public bool ReflectionProperty::hasType()
+ Returns whether property has a type */
+ZEND_METHOD(reflection_property, hasType)
+{
+ reflection_object *intern;
+ property_reference *ref;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ GET_REFLECTION_OBJECT_PTR(ref);
+
+ RETVAL_BOOL(ref->prop.type != 0);
+}
+/* }}} */
+
/* {{{ proto public static mixed ReflectionExtension::export(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_extension, export)
@@ -6754,6 +6771,7 @@ static const zend_function_entry reflection_property_functions[] = {
ZEND_ME(reflection_property, getDocComment, arginfo_reflection__void, 0)
ZEND_ME(reflection_property, setAccessible, arginfo_reflection_property_setAccessible, 0)
ZEND_ME(reflection_property, getType, arginfo_reflection__void, 0)
+ ZEND_ME(reflection_property, hasType, arginfo_reflection__void, 0)
PHP_FE_END
};
diff --git a/ext/reflection/tests/ReflectionType_001.phpt
b/ext/reflection/tests/ReflectionType_001.phpt
index fe6b989..01fdd94 100644
--- a/ext/reflection/tests/ReflectionType_001.phpt
+++ b/ext/reflection/tests/ReflectionType_001.phpt
@@ -83,13 +83,16 @@ class PropTypeTest {
public callable $callable;
public stdClass $std;
public OtherThing $other;
+ public $mixed;
}
$reflector = new ReflectionClass(PropTypeTest::class);
foreach ($reflector->getProperties() as $name => $property) {
- printf("public %s $%s;\n",
- $property->getType(), $property->getName());
+ if ($property->hasType()) {
+ printf("public %s $%s;\n",
+ $property->getType(), $property->getName());
+ } else printf("public $%s;\n", $property->getName());
}
echo "** property types\n";
@@ -211,4 +214,5 @@ public array $arr;
public callable $callable;
public stdClass $std;
public OtherThing $other;
+public $mixed;
** property types