-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
php_com_dotnet - can not create VT_ERROR variant type #8750
Comments
Thanks for reporting, and the good research!
Yeah. That is because as of PHP 5.0.0 the algorithm first creates a variant that matches the given While it certainly would be possible to allow to create However, PHP still doesn't allow to skip parameters, but has introduced named parameters, so using these might be an option. I gave that a quick try, but that leads to a crash in the following code: Lines 4747 to 4748 in 2dc9026
I don't think this is com_dotnet specific, but likely rather happens for all internal objects which allow dynamic methods (i.e. basically implement ::__call() ). I think that can be fixed, and named arguments could be supported by com_dotnet, but that would be a much bigger task than offering a way to get a VT_ERROR type variant with error DISP_E_PARAMNOTFOUND which could be passed explicitly by the programmer.
|
Thank you for detailed in-depth comment! |
Despite the current documentation claiming that `variant::__construct()` would allow to create `VT_ERROR` variants, that is not possible. It is not even clear whether this would be desirable, so we introduce `variant::createError()` which explicitly allows to do this. We also introduce `DISP_E_PARAMNOTFOUND` which might be the most important `scode` for this purpose, since this allows to skip optional parameters in method calls.
I had a further look at this, and have to admit that the constructor not working for
And
I'm no longer sure about that. There may be other use cases where creating |
As I see
|
First, an It is certainly debatable whether it is better to provide a new method ( We could support explicit conversion from error variants to integer variants via |
Thank you for providing more details! |
We add support for creating `VT_ERROR` variants via `__construct()`, and allow casting to int via `variant_cast()` and `variant_set_type()`. We do not, however, allow type conversion by other means, to avoid otherwise easily introduced type confusion. VB(A) also only allows explicit type conversion. We also introduce `DISP_E_PARAMNOTFOUND` which might be the most important `scode` for this purpose, since this allows to skip optional parameters in method calls.
I just submitted PR #8886 which would be an alternative implementation. |
Thank you! |
Description
Can not create VT_ERROR variant type. It's required for some COM method calls where you need to specify an empty argument, since it's VT_ERROR type variant with error DISP_E_PARAMNOTFOUND (0x80020004) as actual error code (see here).
The following code:
Resulted in this output:
But I expected this output instead:
Test file "database.mdb" can be any Microsoft Access database file, even without any tables inside.
More details can be found in this article (auto-translated from Russian):
VT_MISSING argument in PHP for COM objects
PHP Version
PHP 8.1.7 x64
Operating System
Windows 7 x64
The text was updated successfully, but these errors were encountered: