|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58983 Assigning JS anonymous functions to PHP object properties
Submitted: 2009-12-09 17:55 UTC Modified: 2017-01-10 08:01 UTC
Avg. Score:2.0 ± 1.0
Reproduced:0 of 0 (0.0%)
From: ionut dot g dot stan at gmail dot com Assigned:
Status: Suspended Package: spidermonkey (PECL)
PHP Version: 5.3.0 OS: Ubuntu 9.10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: ionut dot g dot stan at gmail dot com
New email:
PHP Version: OS:


 [2009-12-09 17:55 UTC] ionut dot g dot stan at gmail dot com
I'm not sure how to describe this bug (feature request) better than the code below.

Anyway, thanks for your work. What you've done is great!

Reproduce code:

$js     = new JSContext;
$window = new StdClass;

$js->assign('window', $window);

$script = <<<JS
    window.onload = function () {
        return 'foobar';


var_dump($window->onload instanceof Closure);

Expected result:
string 'foobar' (length=6)

boolean true

Actual result:
Exception: TypeError: window.onload is not a function in... for the first var_dump()


false for the second var_dump().

The onload property is actually an instance of StdClass, which isn't necessarily false for JavaScript, as functions are objects. Unfortunately StdClass isn't callable in PHP.

Having onload being an instance of Closure would be much better.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-10 08:01 UTC]
-Status: Open +Status: Suspended
 [2017-01-10 08:01 UTC]
Suspending this report as the extension have not had a release for almost 5 years.  Please revive this if the extension once again shows life
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 29 11:03:35 2022 UTC