1
0
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:
Danack
2016-06-01 21:53:01 +01:00
parent ea355206f6
commit fc92eeeadf
5 changed files with 51 additions and 3 deletions

View File

@@ -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']);

View File

@@ -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 {

View 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

View File

@@ -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[] = {