On 25/08/2024 15:04, John Coggeshall wrote:
Other thoughts here are what happens when |default| resolves to an object or enumeration or something complex? Your original example had |CuteTheme| , so can you call a method of |default| ?? I could entirely see someone doing something like this for example:

enum Foo:string {
    // cases

    public function buildSomeValidBasedOnCase(): int { // ... }
}

F(MyClass::makeBasedOnValue(default->buildSomeValidBasedOnCase()))

As you have written it, no, you will get a parser error: Parse error: syntax error, unexpected token "->", expecting ")"

However, you can wrap the `default` in parens as in the following example:

class C {
    function F() {
        echo 'lol';
    }
}

function G($V = new C) {}

G((default)->F()); // lol

Reply via email to