Skip to content

Wrong this on V8Object method invocation #185

@stesie

Description

@stesie

If a JavaScript object is passed back to PHP and the PHP code then calls a method on that object, this points to the global object (within the method) instead of to the JS object itself.

php > $v8 = new V8Js();
php > $v8->executeString('function Bar(i) { this.theValue = i; }');
php > $v8->executeString('Bar.prototype.tell = function() { var_dump(this.theValue); }; ');
php > $v8->executeString('var inst = new Bar(23); ');
php > $v8->executeString('inst.tell(); ');
int(23)
php > $inst = $v8->executeString('(inst)');
php > $inst->tell();
NULL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions