Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127414 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 36F3A1A00BC for ; Wed, 21 May 2025 14:13:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747836671; bh=skUbE0It7Dil8xSn69c36Uc/fdqbjFwHCYjCaJcVbmQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mnCHo4rUyDF/XdM2ZmwmVP/+VclaWXSEAGqHOXWpI+y6svhuEefQq69xbtHvEPmLM mvmbzZlQckTMoEdJlI9pjaz77dF0oiIgKi9YGV87CrfX3o6UWSP0korwURMvxIKO6X pAYKOj4wuoActaI9DA7jHTcD7PmDmmWVVyLXdhrqxQNeK2ri3lxS6Cs0FgPp6IRzhc Hkxit4KSZaqwUThIRMPyIbaUvN1z+QAouFYrWIXsc41GQV33cDd4R19y4JTH912Y7w q0hBvT7QQ0I0Ue5KEP+sxmYs4XKQQ+EjnpF/XoQHPhR0vZHfqHuoY3tGa3seC194zD zlj4nVFIP9HkA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5929618006D for ; Wed, 21 May 2025 14:11:07 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Wed, 21 May 2025 14:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1747836792; bh=u4/jCm1XjNS1vMCcC0oviDxSQxW3tDfbFdU4jnUwAcE=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=H7cVK/sDJ7zNHVdSpf8cH7wCzlstE4LAJkMkMG2eWZxhTX0Mmgj+kBHfmERAsnXmi FDhM4oFk67a5vzlzQ1Ya6AacVNcX7wUcESD9XezEnikVBgZPLMbNHbvji0hqvcwZzC TtupwFw+gwGAIoASMCmK0KgeqtBkHujgRKle9xtzKN5/GkQ/AFE5VjSNuoE0HZ4wim ZperJrh+LyCG+1L/eFX0oLBj4QRSHMpb1E3n4lsAISUzvzF8KT/kZID5mxqk4EFPj1 4VGU3NUZep4S+usmgDdvXTxM/RPpLWy+/8uuuPYvy+CcfbA2iRVjJVw//upMGr+p9F YmxKy9Zhh4XcQ== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 21 May 2025 16:13:11 +0200 To: Volker Dusch Cc: php internals Subject: Re: [PHP-DEV] Re: [RFC] Clone with v2 In-Reply-To: References: Message-ID: <2f30cae4add309021e18d0f359a1814e@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-05-19 12:48, schrieb Volker Dusch: > We're still looking for feedback on the ...variadic approach to the > Syntax: > https://wiki.php.net/rfc/clone_with_v2#open_issues, as we only got one > reply so far on the topic. I was hoping for some additional opinions here before adding my own, but since this does not appear to happen, adding my personal opinion on this matter now: *Some* property name being completely incompatible with “clone with” (no matter how the first parameter is going to be called) is a limitation that should not exist, it feels like a feature that is broken by design and I think I really would hate it if the documentation of this RFC would need a “Caution: It is not possible to reassign a property called '$object', due to a parameter name conflict”. Adjusting the signature to `clone(object $object, array $withProperties)` would not have this problem and I don't consider the additional verbosity of an array literal to be a problem. Static analysis tools already understand array shapes and would need adjustments either way to understand the semantics. From an implementation PoV a regular array parameter would also be simpler, since the implementation would be able to simply pass along the input array, whereas the “variadic” syntax needs special handling to combine positional parameters with named parameters into a single array that is then used in the cloning process. Syntax-wise there might also be a middle-ground. Similarly to how this RFC turns `clone()` into a function, the `array()` syntax also looks like a function call and would naturally extend to named parameters. While mixing positional and named parameters would probably get complex, allowing purely named parameters would trivially be possible (without any function call overhead). It would also allow using the first-class-callable syntax with `array(...)`, something I would liked to have in the past. A proof of concept PR is at: https://github.com/php/php-src/pull/18613 Combining named-parameter `array()` syntax with clone taking a array as the second parameter would allow for the following, which might combine the best of both worlds? clone($obj, array(foo: 1, bar: "baz", object: "this is not blocked")); Best regards Tim Düsterhus