On 27-11-2024 15:03, Tim Düsterhus wrote:
Hi

Am 2024-11-13 14:40, schrieb Tim Düsterhus:
we just started the vote the the "Support Closures in constant expressions" RFC. Please find the following resources for your reference:

RFC: https://wiki.php.net/rfc/closures_in_const_expr
Implementation: https://github.com/php/php-src/pull/16458
Discussion: https://externals.io/message/125872

The vote will end in two weeks, on November, 27th 2024 at 14:00 UTC.

Voting just closed. The RFC was accepted unanimously with 19 (Yes) to 0 (No) votes. Thank you for your participation.

Best regards
Tim Düsterhus


Congrats on the passed RFC! Sounds like a useful feature.

One thing I'm wondering about - and of which I saw no mention in the RFC nor in the preceding discussion - knowing that function names are case-insensitive, how is ambiguity handled when _calling_ a callback stored in a (class) constant ?

Consider the following code sample:

const STRTOUPPER = static function (string $text): string {
     return $text !== '' ? \strtoupper($text) : '';
};

STRTOUPPER('test'); // What will this do ? Call the PHP native function or the closure ?


And what about this one ?

class Foo {
    public const STRTOUPPER = static function (string $text): string {
         return $text !== '' ? \strtoupper($text) : '';
    };

    public function strtoupper(string $text) {
        return \ucfirst($text);
    }

    public function test() {
        self::STRTOUPPER('test'); // What will this do ?
    }
}

Foo::STRTOUPPER('test'); // What will this do ?


Curious for your reply.

Smile,
Juliette

Reply via email to