Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explore a COM Object in PHP

What would be the proper way to explode a COM object for debugging? I have a 3rd party function that returns a multilevel object. The documentation is non existant, so I'd like to be able to echo everything out of the object or debug it in Komodo IDE.

Komodo just says Object and nothing else. Maybe convert to array?

I know some of the existing options such as $com->Status, but there are more variables returned that I'd like to know what they are.

like image 864
shaiss Avatar asked Oct 26 '09 16:10

shaiss


1 Answers

You can use com_print_typeinfo() instead of var_dump(). This should work for COM, VARIANT and DOTNET objects. The output looks similar to this:

class IFile { /* GUID={C7C3F5A4-88A3-11D0-ABCB-00A0C90FFFC0} */

// some PHP-COM internal stuff ...

 /* DISPID=1610612736 */
 function QueryInterface(
  /* VT_PTR [26] [in] --> ? [29]  */ &$riid,
  /* VT_PTR [26] [out] --> VT_PTR [26]  */ &$ppvObj 
  )
 {
 }
 /* DISPID=1610612737 */
 /* VT_UI4 [19] */
 function AddRef(
  )
 {
 }

// ...
 /* DISPID=1610678275 */
 function Invoke(
  /* VT_I4 [3] [in] */ $dispidMember,
  /* VT_PTR [26] [in] --> ? [29]  */ &$riid,
  /* VT_UI4 [19] [in] */ $lcid,
  /* VT_UI2 [18] [in] */ $wFlags,
  /* VT_PTR [26] [in] --> ? [29]  */ &$pdispparams,
  /* VT_PTR [26] [out] --> VT_VARIANT [12]  */ &$pvarResult,
  /* VT_PTR [26] [out] --> ? [29]  */ &$pexcepinfo,
  /* VT_PTR [26] [out] --> VT_UINT [23]  */ &$puArgErr 
  )
 {
 }

// properties and methods of the COM object
// ...

 /* DISPID=1001 */
 /* VT_BSTR [8] */
 /* Short name */
 var $ShortName;

 /* DISPID=1004 */
 /* VT_PTR [26] */
 /* Get drive that contains file */
 var $Drive;

 /* DISPID=1005 */
 /* VT_PTR [26] */
 /* Get folder that contains file */
 var $ParentFolder;


// ...

 /* DISPID=1204 */
 function Move(
  /* VT_BSTR [8] [in] */ $Destination 
  )
 {
  /* Move this file */
 }
 /* DISPID=1100 */
 /* VT_PTR [26] */
 function OpenAsTextStream(
  /* ? [29] [in] */ $IOMode,
  /* ? [29] [in] */ $Format 
  )
 {
  /* Open a file as a TextStream */
 }
}
like image 189
fireweasel Avatar answered Sep 27 '22 21:09

fireweasel