Danack / PHP-to-Javascript

A tool for converting simple PHP objects/code to Javascript, so that code for manipulating objects can be used both server-side and client-side.
Other
104 stars 32 forks source link

global scope #32

Open ghost opened 11 years ago

ghost commented 11 years ago

in php you must use global scope in functions for disabling syntax highligter errors

$variable = 'foo';
function foo(){
    global $variable ;
    $variable = 5;
}

after converting to js variable name is remain.

var variable = 'foo';
function foo(){
     variable ;
    variable = 5;
}

of course, I can use /* @noinspection PhpUndefinedVariableInspection / . but it would be good to fix it

Danack commented 11 years ago

Technically this has no bad side effect, though it should be possible to add a new state that comments out the whole code from the global keyword the the semi-colon.

ghost commented 11 years ago

Im made simple solution https://github.com/tito100/PHP-to-Javascript/commit/b528329199f87644bbef0e9f55baa3e14a05a3b4 can you made me as commiter ? my references https://code.google.com/u/mostka.j/

Danack commented 11 years ago

Could you submit it as a pull request please - I'm not in a position to add committers at the moment.

Also, could you change the name of the state and class from 'State_SemiColon' to 'State_SkipToSemiColon' just to indicate better that the converter is skipping until it gets a semi-colon, rather than it having already reached a semi-colon.

cheers Dan