Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127402 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 18C4F1A00BC for ; Mon, 19 May 2025 15:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747668662; bh=z7KNxvwuw2SMq13mshK2/jcnufw1Vfdg7fsKikANNns=; h=Date:To:From:Subject:From; b=GEenEeYna3ScVScFEi7FU+TOOBbFpTzCJawaKpTnZwBVOm/8teg4Um3wxebUTwa41 oZEwyyKgprGv4VL/96ujfe1+5P5Yp3Ez/N8bNdtQlkErbvb0ThF1/QD9CCl/hZHTWL kyQ0ETS98S0aCHUgyzLwEOHBX/J+KVeQx4QmURAGYmqYG3Qm1uJJbYO/9kufVroCKO qbWckER1iIixEPHwpPukprPXYjHLcUEH9RHZskXGxvQudqdJb2eSBdwSP2awFfB8ef kuZCRzQiOUX5nCUAGlrvG3gYJXdBsN4N2rTmXrypOOjEZpkjJx7/cQIw4altKe8NBE v4zTB86SzYo4A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C798C18007C for ; Mon, 19 May 2025 15:31:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-108-mta144.mxroute.com (mail-108-mta144.mxroute.com [136.175.108.144]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 19 May 2025 15:31:01 +0000 (UTC) Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta144.mxroute.com (ZoneMTA) with ESMTPSA id 196e92d5a800008631.001 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 19 May 2025 15:33:05 +0000 X-Zone-Loop: 354be665dc56528edc76d6b9624b656fb5da93663b8c X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sandfox.me; s=x; h=Content-Transfer-Encoding:Content-Type:Subject:From:To:MIME-Version: Date:Sender:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=XBaIWAGr06dyrSTfYHcKkypBPsF6sE+xNJMt/EyjUek=; b=h 7mbiN7cdk6WnMnWXO/Eg1kbW0NX4R4iExJIyVMcj5qXCvR3rHyTiNWGXRO/VspT6HZgQj/KqhzdFD D1uTEW6Z6qRVXAVImU3oE8v2thXwwd/YaxkuwM7k9NPvD8NzEnMO3Jpvgx5aZ8G+wJO8VGLVBUQti MdDc6VC5moLVnghT0NuYAdmdvxMbJj1bepZzJWZYjrHrkXbUgjp7Fpn6UYcmmtP6Pv5VGJBj2haja MAoDiWbEZj58uvKQNAUzTKUnv3ZYb92p0RyTv7D4RWrzJdmrxDmQZXZCH9KM6t1Zv7MpAdUZyfWGt /ON1gHg/2X2qyNkdoNG8alSMqFvxYT/vA==; Message-ID: <46b4ad7e-5d95-4e3a-9146-b7efb71648b0@sandfox.me> Date: Mon, 19 May 2025 18:33:01 +0300 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: PHP internals Subject: [PHP-DEV] Forced named parameters Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Id: sandfox@sandfox.me From: sandfox@sandfox.me (Anton Smirnov) Hi everyone, Looking [RFC] Clone with v2, especially Larry's message (https://externals.io/message/127353#127399) I'm thinking that it might be a good idea to allow forcing function calls to use named arguments. Python has it by defining arguments after the variadic argument: https://peps.python.org/pep-3102/ def compare(a, b, *v, key=None): ... Since PHP named args work similarly, borrowing syntax makes sense. It would look like function f(Type $pos1, Type $pos2, ...$v, Type $named1, Type $named2) or without the variadic function f(Type $pos1, Type $pos2, ..., Type $named1, Type $named2) The scope is highly configurable functions and options objects: function json_encode( mixed $value, ..., int $depth = 512, // arguments instead of constants // easier for the code completion // and call strictness bool $hexTag = false, // arguments can be grouped by meaning // and new ones can be inserted into the middle // without breaking compatibility bool $hexAmp = false, // options can have values string $indent = ' ', // ... ): string { // ... } P.S. I'm just planting an idea for now, unlikely that I'm able to develop it