Bug #43275 [Opn->Nab]: get_class problem with COM objects
| From: | cmb@php.net | Date: | Tue, 07 Apr 2015 17:47:40 +0000 |
| Subject: | Bug #43275 [Opn->Nab]: get_class problem with COM objects | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191882@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=43275&edit=1
ID: 43275
Updated by: cmb@php.net
Reported by: csaba at alum dot mit dot edu
Summary: get_class problem with COM objects
-Status: Open
+Status: Not a bug
Type: Bug
Package: COM related
Operating System: Win XP Pro
PHP Version: 5.2.5
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
$ie and $excel are instances of COM (they have been created by `new
COM`), whereas the other objects are instances of Variant (they
have been returned by the automation servers and wrapped by PHP's
com extension).
Changing the behavior of gettype() and get_class() would be
inconsistent with PHP's view, and would furthermore be a massive BC
break. However, as you have demonstrated with the typeName()
function, retrieving the class of the automation object itself can
easily be implemented in userland.
Previous Comments:
------------------------------------------------------------------------
[2007-11-13 11:49:26] csaba at alum dot mit dot edu
Description:
------------
Anomaly: get_class returns "com" with InternetExplorer and Excel COM objects. But with
other COM objects it returns "variant". This seems inconsistent to me.
Reproduce code:
---------------
<?php
$ie = new COM("InternetExplorer.Application");
$ie->Navigate2 ("about:blank");
while ($ie->readyState<4) {
com_message_pump(200); }
$doc = $ie->document;
$body = $doc->body;
$excel = new COM("Excel.Application");
$wb = $excel->workbooks->add();
$aCom = array(ie, doc, body, excel, wb);
foreach ($aCom as $comObj)
print "$comObj: " . gettype($$comObj) .
" => " . get_class($$comObj) . "\n";
?>
Expected result:
----------------
ie: com => IWebBrowser2
doc: com => HTMLDocument
body: com => HTMLBody
excel: com => Application
wb: com => Workbook
or
ie: object => com:IWebBrowser2
doc: object => com:HTMLDocument
body: object => com:HTMLBody
excel: object => com:Application
wb: object => com:Workbook
or at a bare minimum
ie: object => com
doc: object => com
body: object => com
excel: object => com
wb: object => com
To be specific: I am advocating that gettype() on a com object return "com". More
importantly, get_class on a COM object should return consistently: either always "com",
or "com:" followed by the typename, or (my preference) simply the typename.
Typename here refers to the VB typename function (or use my typeName function found on http://php.net/com_print_typeinfo)
Csaba Gabor from Vienna
Actual result:
--------------
ie: object => com
doc: object => variant
body: object => variant
excel: object => com
wb: object => variant
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=43275&edit=1