TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
956 B

--TEST--
Mixed use class and use function imports
--FILE--
<?php
namespace Utils\Str {
function slug(string $s): string {
return str_replace(" ", "-", strtolower($s));
}
function prefix(string $s, string $p): string {
return "{$p}:{$s}";
}
}
namespace Utils\Math {
function double(int $x): int {
return $x * 2;
}
}
namespace App {
use Utils\Str\slug;
use Utils\Str\prefix;
use function Utils\Math\double;
class TextHelper {
public static function normalize(string $text): string {
return slug(prefix($text, "msg"));
}
}
function compute(int $v): int {
return double($v);
}
}
namespace {
use App\TextHelper;
use function App\compute;
function main() {
var_dump(TextHelper::normalize("Hello World"));
var_dump(compute(21));
echo "done\n";
}
}
?>
--EXPECT--
string(15) "msg:hello-world"
int(42)
done