php-src/Zend/tests/first_class_callable_015.phpt
Joe Watkins d0b09a7be4 Add first-class callables
Support acquiring a Closure to a callable using the syntax
func(...), $obj->method(...), etc. This is essentially a
shortcut for Closure::fromCallable().

RFC: https://wiki.php.net/rfc/first_class_callable_syntax

Closes GH-7019.

Co-Authored-By: Nikita Popov <nikita.ppv@gmail.com>
2021-07-14 14:37:25 +02:00

25 lines
479 B
PHP

--TEST--
First class callables and strict types
--FILE--
<?php
declare(strict_types=1);
function test(int $i) {
var_dump($i);
}
require __DIR__ . '/first_class_callable_015_weak.inc';
require __DIR__ . '/first_class_callable_015_strict.inc';
$fn = test(...);
do_weak_call($fn);
try {
do_strict_call($fn);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
int(42)
test(): Argument #1 ($i) must be of type int, string given, called in %s on line %d