mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
As is, methods of PHP can never be called, because we're first trying to read the property with the name of the method. We fix this by first checking for `DISPATCH_METHOD` and treat that as method call, if the method would be callable. Only otherwise we try to access the respective property. It needs to be noted that this breaks code which accesses a property of an object, which defines a method of the same name. However, instances of such classes should never be wrapped in variants, because this can't be distinguished by COM anyway. Closes GH-16945.
42 lines
735 B
PHP
42 lines
735 B
PHP
--TEST--
|
|
Testing reading properties and calling functions
|
|
--EXTENSIONS--
|
|
com_dotnet
|
|
--FILE--
|
|
<?php
|
|
class MyClass {
|
|
public $foo = "property";
|
|
public $bar = "bar";
|
|
public function foo() {
|
|
return "method";
|
|
}
|
|
public function stdClass() {
|
|
return new stdclass();
|
|
}
|
|
}
|
|
|
|
$o = new MyClass();
|
|
$v = new variant($o);
|
|
var_dump($v->foo);
|
|
var_dump($v->foo());
|
|
var_dump($v->bar);
|
|
var_dump($v->bar());
|
|
var_dump($v->stdclass);
|
|
var_dump($v->stdclass());
|
|
try {
|
|
var_dump($v->qux);
|
|
} catch (com_exception $ex) {
|
|
echo $ex->getMessage(), "\n";
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
string(6) "method"
|
|
string(6) "method"
|
|
string(3) "bar"
|
|
string(3) "bar"
|
|
object(variant)#%d (0) {
|
|
}
|
|
object(variant)#%d (0) {
|
|
}
|
|
Unable to lookup `qux': %s
|