Is there a way get normal IntelliSense functionality in PhpStorm for types contained in a COM type library?
In FoxPro I get full IntelliSense as soon as a variable is declared as a COM interface (it pulls the info from the registry); in Delphi and Visual Studio I can have the IDE create some import artifacts for the type libraries (import unit, interop assembly) to make IntelliSense work. However, so far I couldn't find a way to make IntelliSense work with type libraries in PhpStorm.
All mentions of COM type libraries that I found referred only to PHP's ability to load constants (com_load_typelib()), but I want method and parameter info. I wouldn't mind generating files for PhpStorm from my type libraries or even hand-crafting some definitions for the COM interfaces that I use most often. However, I really need normal IntelliSense for the COM interfaces to keep from going crazy.
Is there a way to peel this cat?
As suggested by LazyOne, the manual approach can be as simple as writing a stub declaration and dumping the php file somewhere in the project tree or search path (like an apposite stubs directory):
From that point on IntelliSense works perfectly.
The manual process may give perfect results, but it is exceedingly laborious. I remembered a scriptable object for processing type libraries that shipped with FoxPro and earlier versions of Visual Studio,
tlbinf32.dll(+tlbinf32.chm). The ProgID to start with isTLI.TLIApplication.The only extant reference to this tool that I could find at microsoft.com is this old article:
Visual Basic: Inspect COM Components Using the TypeLib Information Object Library
The tool still ships with Visual Studio, but it is now called
vstlbinf.dlland no longer documented.vstlbinf.dllstill refers to the oldtlbinf32.chmas its help file but that doesn't get shipped anymore. The old documentation is still useful for understanding the object model, even though it refers to a version that is two decades older. (Note: it may be necessary to register the DLL manually.)So I took Delphi and set about taming
TLI.TLIApplication. It turned out not to be a whole lot easier than working withITypeLib,ITypeInfoetc. directly, but the advantage is thatTLI.TLIApplicationcan be used from any scripting language, including PHP itself.Here`s a sample of the information that can be ripped from a COM type library for use in a PHP stub:
Conspicuously absent are parameter comments, because there is no such thing in Microsoft IDL or type libraries. But on the whole the result of processing type libraries into PHP stubs seems quite satisfactory, and it certainly makes working with COM objects in PHP a lot easier.