setSingleAbstractMethodInterface(function () use ($console) { $console->log("closure"); return 1234; }); $sami = $JavaTypeTester->getSingleAbstractMethodInterface(); $console->log($sami->getInt()); // 方法二: 通过对象 class SingleAbstractMethodInterfaceImpl { var $console; function __construct($p) { $this->console = $p; } function getInt() { $this->console->log("getInt"); return 0; } } $JavaTypeTester->setSingleAbstractMethodInterface(new SingleAbstractMethodInterfaceImpl($console)); $sami = $JavaTypeTester->getSingleAbstractMethodInterface(); $console->log($sami->getInt());