Skip to content

Commit

Permalink
Support void return type in reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
hikari-no-yume committed Jan 28, 2016
1 parent 86f54fc commit 8412de9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
29 changes: 29 additions & 0 deletions ext/reflection/tests/ReflectionType_possible_types.phpt
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 8412de9

Please sign in to comment.