Bug #42413 [Opn->Nab]: Cannot iterate IE's event object

From: Date: Thu, 06 Feb 2020 16:31:13 +0000
Subject: Bug #42413 [Opn->Nab]: Cannot iterate IE's event object
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225393@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=42413&edit=1 ID: 42413 Updated by: cmb@php.net Reported by: csaba at alum dot mit dot edu Summary: Cannot iterate IE's event object -Status: Open +Status: Not a bug Type: Bug Package: COM related Operating System: Win XP Pro PHP Version: 5.2.3 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: In JavaScript you can iterate over the public properties of any object. In PHP this works only if the object's isn't Traversable; however, COM objects are. Previous Comments: ------------------------------------------------------------------------ [2007-08-24 12:17:24] jani@php.net Assigned to the maintainer. ------------------------------------------------------------------------ [2007-08-24 12:06:04] csaba at alum dot mit dot edu Description: ------------ I can't iterate over IE's $ie->document->createEventObject() with PHP whereas I can in IE. Reproduce code: --------------- <?php // create a new internet explorer instance $ie = new COM("InternetExplorer.Application"); // So the alerts can be seen $ie->visible = true; // ensure a document exists within ie $ie->Navigate2 ("about:blank"); while ($ie->readyState!=4) usleep(100000); // convenience $doc = $ie->document; $window = $doc->parentWindow; // required - var must be declared $window->execScript ("var evt='';"); // create an event object $window->evt = $doc->createEventObject(); // proof the object is valid, iteratable $window->execScript(" var str=''; var idx; for (idx in evt) str+=idx+'; '; alert('Keys: '+str);"); // Bug: can't iterate the object in PHP foreach ($window->evt as $prop => $val) print "<br>$prop "; // ensure ie is still alive $window->execScript("alert('Alive');"); $ie->quit(); // necessary since visible ?> Expected result: ---------------- I expect PHP not to die at the foreach I expect the same text to be output as with the alert Actual result: -------------- PHP falls over upon hitting the foreach loop with: Fatal error: Uncaught exception 'Exception' with message 'Object of type variant did not create an Iterator' in c:\phpBugs\foreach.php: 28 Stack trace: #0 C:\phpBugs\foreach.php(28): unknown() #1 {main} thrown in C:\phpBugs\foreach.php on line 28 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=42413&edit=1

« previous php.bugs (#225393) next »