<?php
class MyClass {
    protected $_who;
    public function __construct($who) {
        $this->_who = $who;
    }
    public function sayHello() {
        echo "Hello, {$this->_who}!";
    }
}
$my = new MyClass('World');

$ctx = new JSContext();
$ctx->assign('my', $my);

$js = file_get_contents(__DIR__ . '/test-assign-2.js');
$ctx->evaluateScript($js);

