Class Kitab\Compiler\IntermediateRepresentation\Function_
class Function_ extends Kitab\Compiler\IntermediateRepresentation\Entity
{
public function __construct(string $name);
}
A named function intermediate representation.
A named function is one of the major entity in PHP. It has zero or many
inputs, and zero or one output. Each input is represented by a
Kitab\Compiler\IntermediateRepresentation\Parameter instance, while the
output is represented by a Kitab\Compiler\IntermediateRepresentation\Type
instance.
Examples
In this example, a new function f is created with 1 input: int $x, and
1 output: int.
$typeInt = new Kitab\Compiler\IntermediateRepresentation\Type();
$typeInt->name = 'int';
$input1 = new Kitab\Compiler\IntermediateRepresentation\Parameter('x');
$input1->type = $typeInt;
$output = $typeInt;
$function = new Kitab\Compiler\IntermediateRepresentation\Function_('f');
$function->inputs[] = $input1;
$function->output = $output;
Constants
public const TYPE = 'function';-
Type of the entity. See parent.
Attributes
public $inputs = [];-
Collection of
Kitab\Compiler\IntermediateRepresentation\Parameterinstances. public $output = null;-
An output is a
Kitab\Compiler\IntermediateRepresentation\Typeinstance if any.
Methods
-
public function __construct(string $name) -
Allocate a new named function with a name. This is the only mandatory information.