1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 05:21:02 +02:00
Files
archived-php-src/Zend/tests/closures/closure_from_callable_reflection.phpt
Gabriel Caruso ded3d984c6 Use EXPECT instead of EXPECTF when possible
EXPECTF logic in run-tests.php is considerable, so let's avoid it.
2018-02-20 21:53:48 +01:00

47 lines
743 B
PHP

--TEST--
Testing Closure::fromCallable() functionality: Reflection
--FILE--
<?php
class Bar {
public static function staticMethod(Bar $bar, int $int, $none) {}
public static function instanceMethod(Bar $bar, int $int, $none) {}
}
function foo(Bar $bar, int $int, $none) {
}
$fn = function (Bar $bar, int $x, $none) {};
$bar = new Bar();
$callables = [
'foo',
$fn,
'Bar::staticMethod',
[$bar, 'instanceMethod']
];
foreach ($callables as $callable) {
$closure = Closure::fromCallable($callable);
$refl = new ReflectionFunction($closure);
foreach ($refl->getParameters() as $param) {
if ($param->hasType()) {
$type = $param->getType();
echo $type->getName() . "\n";
}
}
}
?>
--EXPECT--
Bar
int
Bar
int
Bar
int
Bar
int