stmt/class: support static calls
This commit is contained in:
parent
6b40079884
commit
67932cd296
@ -7,6 +7,10 @@ class Base {
|
||||
$this->mX = $x;
|
||||
}
|
||||
|
||||
public function Val() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static function TheStatic() {}
|
||||
}
|
||||
|
||||
@ -19,4 +23,14 @@ class Child extends Base {
|
||||
$this->mY = 0;
|
||||
}
|
||||
|
||||
public function Val() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function Combine() {
|
||||
return $this->Val() + parent::Val();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo (new Child(0))->Combine();
|
||||
|
18
node.go
18
node.go
@ -459,6 +459,24 @@ func convert(n_ node.Node) (string, error) {
|
||||
|
||||
return funcName + callParams, nil // expr only, no semicolon/newline
|
||||
|
||||
case *expr.StaticCall:
|
||||
className, err := resolveName(n.Class)
|
||||
if err != nil {
|
||||
return "", parseErr{n, err}
|
||||
}
|
||||
|
||||
funcName, err := convert(n.Call)
|
||||
if err != nil {
|
||||
return "", parseErr{n, err}
|
||||
}
|
||||
|
||||
callParams, err := convertFuncCallArgsCommon(n.ArgumentList)
|
||||
if err != nil {
|
||||
return "", parseErr{n, err}
|
||||
}
|
||||
|
||||
return className + "." + funcName + callParams, nil // expr only, no semicolon/newline
|
||||
|
||||
case *expr.New:
|
||||
// new foo(xx)
|
||||
// Transparently convert to calling constructor function.
|
||||
|
Loading…
Reference in New Issue
Block a user