phpv8 / v8js

V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine
http://pecl.php.net/package/v8js
MIT License
1.83k stars 200 forks source link

closures assigned to V8Js object not callable #117

Closed stesie closed 9 years ago

stesie commented 9 years ago
<?php

$a = new V8Js();
$b = new V8Js();

$func = $a->func = function() {
  print("Hallo\n");
};

var_dump($func);
$func(); // callable as usual

var_dump($a->func);
$a->func(); // Call to undefined method V8Js::func()
stesie commented 9 years ago

This isn't really a bug, since the code snippet from above doesn't work with stdClass instances likewise.

However we allow calling V8Function instances stored in V8Object properties like this, to be called as shown above. Hence we could implement that on the V8Js object for consistency with V8Object, but it's inconsistent with other PHP object then.

Since we intend to not have special "object export" code on the V8Js class (as per proposal in issue #72) this wouldn't even be possible in the long run.

Hence just closing this now.