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.
31 lines
1.0 KiB
31 lines
1.0 KiB
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace TypePhp\Generator;
|
|
|
|
trait ParameterCountCheckGenerator
|
|
{
|
|
/**
|
|
* Generate the runtime check used at a Zend-to-TypePHP call boundary.
|
|
*
|
|
* TypePHP requires dynamic calls to obey the same argument-count rules as
|
|
* statically resolved calls. This also keeps the generated internal-function
|
|
* arginfo consistent with what its wrapper accepts.
|
|
*
|
|
* PHPX owns the Zend boundary details. In particular, a bare
|
|
* ZEND_PARSE_PARAMETERS_START/END pair is invalid because ZPP expects every
|
|
* declared parameter to be consumed by a Z_PARAM_* macro.
|
|
*/
|
|
protected function genParameterCountCheck(int $requiredArgCount, int $declaredArgCount, bool $variadic): string
|
|
{
|
|
if ($requiredArgCount === 0 && $variadic) {
|
|
return '';
|
|
}
|
|
|
|
return 'php::checkCallArgCount('
|
|
. $requiredArgCount . ', '
|
|
. $declaredArgCount . ', '
|
|
. $this->escapeBool($variadic)
|
|
. ');' . PHP_EOL;
|
|
}
|
|
}
|
|
|