You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry for keeping opening issues, but I an trying to figure out if it would be feasible for me to use KPHP, but it is hard to know what is supported when compilation does not work (See #1045 regarding the compilation problem)
In a CLI application that I need to make KPHP compatible, an App class has this method:
publicfunctionrun(array$argv): void
{
$key = mb_strtolower($argv[1] ?? 'default'); // Are multibyte functions supported ?$findArr = array_filter($this->commands, static fn(Command$cmd): bool => mb_strtolower($cmd->key) === $key);
$command = array_values($findArr)[0] ?? null;
if ($command === null && $key === self::HELP_CMD) {
$this->helper();
return;
}
$command ?? thrownewInvalidArgumentException('Command not found.');
$this->writeAppHeader($command);
// Handle argv$argv = array_splice($argv, 1);
$context = newContext(
params: $this->parseParams(
$command,
[
'cmd',
...$argv, /* What about variadic arguments ? Are they supported */
],
),
);
if (isset($command->service['handler']) && is_callable($command->service['handler'])) {
$command->service['handler']($context);
return;
}
if (is_string($command->service['instance'])) {
$instance = new ($command->service['instance'])(); // Is this syntax supported - I tend to say yes due to #726 being merged ?
} elseif (is_callable($command->service['instance'])) { // since is_callable() appears to be missing in built-in/functions.txt I guess this won't work or ?$instance = $command->service['instance']();
} else {
thrownewInvalidArgumentException('Invalid service provided to command '.$key);
}
if (!method_exists($instance, $command->service['entrypoint'])) { // What about method_exists() ? Is that supported ?thrownewInvalidArgumentException('Invalid entrypoint provided to command '.$key);
}
$instance->{$command->service['entrypoint']}($context);
}
Both $command->service['entrypoint'] (a string) - example: 'run' ,
and
$command->service['instance'] (a string such typically produced from Foo::class)
are known at compile-time
Please inform me !
Thanks !
The text was updated successfully, but these errors were encountered:
Sorry for keeping opening issues, but I an trying to figure out if it would be feasible for me to use KPHP, but it is hard to know what is supported when compilation does not work (See #1045 regarding the compilation problem)
In a CLI application that I need to make KPHP compatible, an App class has this method:
Both $command->service['entrypoint'] (a string) - example: 'run' ,
and
$command->service['instance'] (a string such typically produced from Foo::class)
are known at compile-time
Please inform me !
Thanks !
The text was updated successfully, but these errors were encountered: