com php-src: Support void return type in reflection: ext/reflection/php_reflection.c ext/reflection/tests/Refl ectionType_possible_types.phpt
| From: | Andrea Faulds | Date: | Thu, 28 Jan 2016 18:01:48 +0000 |
| Subject: | com php-src: Support void return type in reflection: ext/reflection/php_reflection.c ext/reflection/tests/Refl ectionType_possible_types.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90771@lists.php.net to get a copy of this message | ||
Commit: 8412de9da5304ca0ea287277c7e0d916e2c490be
Author: Andrea Faulds <ajf@ajf.me> Thu, 28 Jan 2016 18:01:48 +0000
Parents: 86f54fcdf7b304395bd85ec003cc149699792617
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8412de9da5304ca0ea287277c7e0d916e2c490be
Log:
Support void return type in reflection
Changed paths:
M ext/reflection/php_reflection.c
A ext/reflection/tests/ReflectionType_possible_types.phpt
Diff:
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 461104f..af1e972 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -3029,6 +3029,7 @@ ZEND_METHOD(reflection_type, __toString)
case _IS_BOOL: RETURN_STRINGL("bool", sizeof("bool") - 1);
case IS_LONG: RETURN_STRINGL("int", sizeof("int") - 1);
case IS_DOUBLE: RETURN_STRINGL("float", sizeof("float") - 1);
+ case IS_VOID: RETURN_STRINGL("void", sizeof("void") - 1);
EMPTY_SWITCH_DEFAULT_CASE()
}
}
diff --git a/ext/reflection/tests/ReflectionType_possible_types.phpt
b/ext/reflection/tests/ReflectionType_possible_types.phpt
new file mode 100644
index 0000000..9f876cb
--- /dev/null
+++ b/ext/reflection/tests/ReflectionType_possible_types..phpt
@@ -0,0 +1,29 @@
+--TEST--
+ReflectionType possible types
+--FILE--
+<?php
+
+$functions = [
+ function(): int {},
+ function(): float {},
+ function(): string {},
+ function(): bool {},
+ function(): array {},
+ function(): callable {},
+ function(): StdClass {}
+];
+
+foreach ($functions as $function) {
+ $reflectionFunc = new ReflectionFunction($function);
+ $returnType = $reflectionFunc->getReturnType();
+ var_dump($returnType->__toString());
+}
+?>
+--EXPECTF--
+string(3) "int"
+string(5) "float"
+string(6) "string"
+string(4) "bool"
+string(5) "array"
+string(8) "callable"
+string(8) "StdClass"