mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Added reflection test. Standardised filename for other tests.
This commit is contained in:
@@ -3,7 +3,7 @@ Testing closure() functionality
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include('closureFunction.inc');
|
||||
include('cloure_from_callbable.inc');
|
||||
|
||||
echo 'Access public static function';
|
||||
$fn = Closure::fromCallable(['Foo', 'publicStaticFunction']);
|
||||
@@ -3,7 +3,7 @@ Testing closure() functionality
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include('closureFunction.inc');
|
||||
include('cloure_from_callbable.inc');
|
||||
|
||||
echo 'Cannot access privateInstance method statically'."\n";
|
||||
try {
|
||||
48
Zend/tests/closures/cloure_from_callbable_reflection.phpt
Normal file
48
Zend/tests/closures/cloure_from_callbable_reflection.phpt
Normal file
@@ -0,0 +1,48 @@
|
||||
--TEST--
|
||||
Imagick::readImage test
|
||||
--SKIPIF--
|
||||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||
--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->__toString() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Bar
|
||||
int
|
||||
Bar
|
||||
int
|
||||
Bar
|
||||
int
|
||||
Bar
|
||||
int
|
||||
@@ -589,7 +589,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_call, 0, 0, 1)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_fromcallable, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, newthis)
|
||||
ZEND_ARG_INFO(0, callable)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static const zend_function_entry closure_functions[] = {
|
||||
|
||||
Reference in New Issue
Block a user