Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127362 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 26ED21A00BC for ; Wed, 14 May 2025 21:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747256274; bh=ppDPD7XI9IMOV3qaI0QryF0T8GhKAG9QxHxqOgjgsg4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=W+F0/FXIhxTeCKwgAHnW63KVUw5BVj+2bdwsc7idq8DJW32ZhKdpfPLlk88Xbk6oA eSZncoYbc9VOsKkR+O1d9wiIS5T+jrbGrWuv60hNnhL34EAQ3JAskm+JzksAgK03gE F5N+K/4zK+MF+5u+D3cZr8yO1PRniVJSTL5N3Bxo8Ay9ERcQ9YiM0xzwHIAxQIdObu 14K0p3cj6TTbzOUM2y3lRyVy4hJJkJlSwmKDd70omnS+Z8BPzw+vsO7d4OR2R39xxM zy6i7iO4kor+yD7gSzImc1WS16RtrhPcD05LgmOvtBw6Wd5di2OinxbtejEGQJYLWW 3i+NWhJng65kg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C1520180340 for ; Wed, 14 May 2025 20:57:53 +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.7 required=5.0 tests=BAYES_05,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, 14 May 2025 20:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1747256402; bh=7wsED97SXlp1HakUGDjEgib7OLf3OuJu74AAIVErEKA=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=MwBWiig+IfCXQad2O9MTNyMh233QEiQbXeZ7cbWWPaUaXlOugT9LBXwZLc5bPPfD3 Rue8p6VCoJgCjo9uDzud9b3uc5ew4lFcqAfsWeaW0V+p1kji3IWwO/fsNMb3bubfwI pr1hQ+7s7pLQJ3Z49/c+otsM7XW1goYEhC78H0/V9WaxXrvagiW2TZ+O5W12l201jN MJg4dfakDSG5DOjdUj/ONkh15a3SwOEfFMcU7Nyi5aEWMNvL47QiMFZkewYJXJoX56 iZi/CDFVm2UgxfOcM5UuF++HpJ0Iteguz5LosLT+DQs7X5SHmg94agxnjz6TF5cOBd N2OVO7CYkKHog== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 14 May 2025 23:00:01 +0200 To: Matthew Weier O'Phinney Cc: Volker Dusch , php internals Subject: Re: [PHP-DEV] [RFC] Clone with v2 In-Reply-To: References: Message-ID: <4a703db4174763586d84b9bf5606ff31@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-14 22:06, schrieb Matthew Weier O'Phinney: > The only question that arose for me is: what happens if a property name > is > provided to `clone()` that does not exist in the class definition; what > will be the behavior at that time? Will an exception or error be > thrown? If > so, will it be a new one, or an existing one? It's mentioned in the "Technical details" section: > Property assignments are made just as a regular assignment would be It literally goes through the same code path. Thus a dynamic property will be created (and the associated warnings triggered). You can also see that in test `Zend/tests/clone/clone_with_002.phpt` of the implementation: > Deprecated: Creation of dynamic property C::$c is deprecated in %s on > line %d The internal implementation is roughly equivalent to: $cloned = clone $object; foreach ($withProperties as $key => $value) { $cloned->{$key} = $value; } return $cloned; Just with the exception that writing readonly properties is allowed on the clone (unless already touched by `__clone()`). Best regards Tim Düsterhus