Re: [RFC] Default expression
| From: | Bilge | Date: | Sun, 25 Aug 2024 15:42:56 +0000 |
| Subject: | Re: [RFC] Default expression | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-125219@lists.php.net to get a copy of this message | ||
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 {As you have written it, no, you will get a parser error: Parse error: syntax error, unexpected token "->", expecting ")" However, you can wrap the// casespublic function buildSomeValidBasedOnCase(): int { // ... }} F(MyClass::makeBasedOnValue(default->buildSomeValidBasedOnCase()))
default in parens as in the following example:
class C {
function F() {
echo 'lol';
}
}
function G($V = new C) {}
G((default)->F()); // lol