At a minimum I tried, but PHP throws a syntax error:
Parse error: syntax error, unexpected 'function' (T_FUNCTION)
In short, I can not declare functions in my array.
When I create my array $ast
out of the block of class PMoon
, it works. Is there any other way to declare this array containing functions?
<?php
/* ... */
class PMoon {
/* ... */
public $ast = array(
"labelStatement" => function($label) { // o erro começa aqui
return array(
"type" => 'LabelStatement',
"label" => $label
);
}
/* ... */
);
/* ... */
}