31 lines
642 B
PHP
31 lines
642 B
PHP
<?php
|
|
/**
|
|
* SAMPLE ACTION: Say Hello
|
|
* -------------------------
|
|
* Demonstrates how to register and implement a simple action.
|
|
*
|
|
* Call format:
|
|
* @sayHello Alice 30
|
|
*
|
|
* Expected output:
|
|
* "Hello Alice, you are 30 years old!"
|
|
*/
|
|
|
|
// 1. Register the action with expected argument types
|
|
registerAction(
|
|
(new Action())
|
|
->setFunctionName("sayHello")
|
|
->setArgumentsTypes(["name", "age"]) // name, age
|
|
);
|
|
|
|
/**
|
|
* 2. Implement the function
|
|
*
|
|
* @param string $name
|
|
* @param int $age
|
|
* @return string
|
|
*/
|
|
function sayHello(string $name, int $age): string {
|
|
return "Hello $name, you are $age years old!";
|
|
}
|