Re: Forced named parameters

From: Date: Fri, 23 May 2025 08:13:07 +0000
Subject: Re: Forced named parameters
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 2025-05-23 13:24, Anton Smirnov wrote:
Hi Alwin Please explain the syntax you propose about this part: That way, you could even make it so that only specific arguments are required to be named because I see only 2 ways to call it:   #[AllArgsAreNamed] function f (/* ... */) and   function f($arg1, #[AllArgsAfterThisOneAreNamed] $arg2, $arg3) because   function f($arg1, #[NamedArg] $arg2, /* positional again */ $arg3) doesn't make sense, you cannot specify a positional argument after a forced-named because it would be impossible to fill position 2 on the function call.
Just chiming in, but I interpreted it as suggesting something like
    #[RequireNamedArgs('arg2', 'arg3')]
    function f($arg1, $arg2, $arg3)


Thread (5 messages)

« previous php.internals (#127435) next »