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

private fields:critical #33

Open ghost opened 11 years ago

ghost commented 11 years ago
class Foo{
    private $foo=4;
    function __construct(){
        echo $this->foo;
    }
    public function foo2(){
        echo $this->foo;
    }
}
$f = new Foo();
$f->foo2();

alerted undefined,undefined

add to ClassExample.php test

....
private $privateFieldVal='foo';
public function privateField(){
    return $this->privateFieldVal;
}....
....
$value = $classExample->privateField();
assert($value, 'foo');