mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

Move some low-hanging fruit, creating new directories for the tests for * access modifiers * `class_alias()` * constant expressions * constructor property promotion * `__debugInfo()` * dereferencing * first class callable syntax Additionally, move some tests into the existing subdirectory for closure-related tests Work towards GH-15631
53 lines
678 B
PHP
53 lines
678 B
PHP
--TEST--
|
|
Acquire callable through various dynamic constructs
|
|
--FILE--
|
|
<?php
|
|
|
|
class A {
|
|
public static function b($x) {
|
|
return $x;
|
|
}
|
|
|
|
public function c($x) {
|
|
return $x;
|
|
}
|
|
}
|
|
|
|
$name = 'strlen';
|
|
$fn = $name(...);
|
|
var_dump($fn('x'));
|
|
|
|
$name = ['A', 'b'];
|
|
$fn = $name(...);
|
|
var_dump($fn(2));
|
|
|
|
$name = [new A, 'c'];
|
|
$fn = $name(...);
|
|
var_dump($fn(3));
|
|
|
|
$name1 = 'A';
|
|
$name2 = 'b';
|
|
$fn = $name1::$name2(...);
|
|
var_dump($fn(4));
|
|
|
|
$name2 = 'c';
|
|
$fn = (new A)->$name2(...);
|
|
var_dump($fn(5));
|
|
|
|
$fn = [A::class, 'b'](...);
|
|
var_dump($fn(6));
|
|
|
|
$o = new stdClass;
|
|
$o->prop = A::b(...);
|
|
($o->prop)(7);
|
|
|
|
$nam
|
|
|
|
?>
|
|
--EXPECT--
|
|
int(1)
|
|
int(2)
|
|
int(3)
|
|
int(4)
|
|
int(5)
|
|
int(6)
|