Closed ghost closed 11 years ago
when you use this. then will be worked add to TokenSteam.php
function moveBack(){
$this->current--;
}
add to FUNCTION.php
function processToken($name, $value, $parsedToken) {
......
if ($name=="("){
$this->stateMachine->pushScope(CODE_SCOPE_FUNCTION_PARAMETERS, '', $this->stateMachine->variableFlags);
$this->stateMachine->addJS("function ");
$this->changeToState(CONVERTER_STATE_DEFAULT);
$this->stateMachine->currentTokenStream->moveBack();
}
}
test https://github.com/tito100/PHP-to-Javascript/blob/master/tests/AnonymusFunction.php
Q::ajax(array(
'foo'=>5,
'callback'=>function(){
}
));
is parsed bad. to
Q.ajax({
'foo':5,
'callback':function (){
}
)}; // <- here is brackets exchanged
This should be supported, and has a test Closure.php
.
Just to note, you can tell the state-machine to reprocess to reprocess any token (e.g. because the current state didn't process the token, but instead changed to a new state) which amazingly is one of the few comments in the code: https://github.com/Danack/PHP-to-Javascript/blob/master/src/PHPToJavascript/CodeConverterState.php#L27
can you implement this? http://www.php.net/manual/en/functions.anonymous.php
for javascript is very important, (for jquery or events).