Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111828 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 26637 invoked from network); 3 Sep 2020 16:58:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Sep 2020 16:58:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B11C91804E3 for ; Thu, 3 Sep 2020 09:03:45 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, MISSING_HEADERS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 3 Sep 2020 09:03:45 -0700 (PDT) Received: by mail-ot1-f53.google.com with SMTP id v16so3166126otp.10 for ; Thu, 03 Sep 2020 09:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc; bh=HjVKvBLkeOlwMdQe/pnTvnkXfWMd5E9YXF7seUa7SLI=; b=LLS72yig21+3vzTpgx5P8nzvGDf43ndwdGW4kcQDhPpkug2zPV1nFLGRh6610mkqes I9B7FbHwwEwHcwoSr6MCOc6wDDQlub1oUQKiUzPBRULL9JVIl+/Q65MvvnpzPpVypmsX 9wO0F5fSguTLFPlaL1rgqvtFliG89oHV2/7nSGzk9DpNXXAWtR3eit+TpyfWknIBw2o2 x+gD5hJkCMBXs7ZNK86AvDV8PxT3yv44xgKY+043GTZ9ghsmnuW9zIJYKiNbnO7u4mub AMswuV4Lq7Ljk0V1OAnnpENC+pQfxpcxs/J77aNH6hZ1Twasd5J4r+xXM2wlL1E8WFki H1Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:cc; bh=HjVKvBLkeOlwMdQe/pnTvnkXfWMd5E9YXF7seUa7SLI=; b=QCnPG+BrsQDxijQw2250EiokeJCSYWjSq4+hHOyeJLLUuWvGHHToCaK4g2KgnErBNB G1BIgkpA1mtekWcOGgdYaRaxSzC/2el3z6Bq4GLTMj17v4kKDwPvh3FuH5JyMA/YGNyo alI6xA06Y06ZbrvwMf0ST462NcXkB8HnpA6DoM7KrdvGLUNWsb0FbH7j9otN4twArXyY qAY+4ICBoHyR+tNWPSksUfMclvEwtClHjyPBrXb9Vjtl3UaWFHUpECt3l7MWfABZMnt3 BI16CXXxbJixz1T2rtek6pYLzPMN1IwulgT+3vac16UiTrg6Zl7uUzlf7qcARHu2fciu ozPA== X-Gm-Message-State: AOAM532BXavuzoU3AV7ySWDefsBWvXptaAaGwW5ipZaChgQYge3SHBIQ kmJaqrq11IlpgIFj5y42oHYDkpPofZECAaSepJBG9FlU X-Google-Smtp-Source: ABdhPJz/xLLcuY5Tqz2xTbf3D5WIJJRgQK4c17qwO3gJHVMdOnDygmNukiYyVQT730S561Fg1A3S3QO4CEfJNHlmhRY= X-Received: by 2002:a9d:6e19:: with SMTP id e25mr2021268otr.219.1599149022650; Thu, 03 Sep 2020 09:03:42 -0700 (PDT) MIME-Version: 1.0 References: <2868e0ed4e7ebc09b568471c913079516f93fd2fc95e97b0ffea192db1e04275@mahalux.com> In-Reply-To: Date: Thu, 3 Sep 2020 13:03:29 -0300 Message-ID: Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000070294d05ae6ae5ff" Subject: Re: [PHP-DEV] Pass source object to clone like __clone($origThis) From: david.proweb@gmail.com (David Rodrigues) --00000000000070294d05ae6ae5ff Content-Type: text/plain; charset="UTF-8" It was just an example to avoid modify how clone works, using existing features. :) Em qui, 3 de set de 2020 13:00, Sara Golemon escreveu: > On Thu, Sep 3, 2020 at 10:40 AM David Rodrigues > wrote: > >> Now I rethinked about what I said. Really, maybe clone is not the best >> option. So maybe we can just use a method that will clone and will have >> access to both informations. But I don't know if it solves the original >> message. >> >> public function getUserCopy() { >> $userCopy = clone $this; >> $this->copies[] = $userCopy; >> >> return $userCopy; >> } >> >> > If your goal is to track copies, then a static makes much more sense. > > class AllKnowing { > private static $copies = []; > > public function __construct(...) { > self::$copies[] = $this; > .... > } > > public function __clone() { > self::$copies[] = $this; > } > } > > -Sara > --00000000000070294d05ae6ae5ff--