Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread David Rodrigues
Just to I know, it can't be done by an intermediary method like my previous example? Why are the limitations to that? About PR, could you provide some additional tests? Thanks! Em qui, 3 de set de 2020 13:37, Michael Voříšek - ČVUT FEL < voris...@fel.cvut.cz> escreveu: > The goal is to be able

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread Michael Voříšek - ČVUT FEL
The goal is to be able to access the original object and it's id/hash. Usecases: - something is associated with the object using the object id/hash and it needs to be cloned as well we need the original object to obtain it's id/hash for spl_object_id and spl_object_hash methods -

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread Sara Golemon
On Thu, Sep 3, 2020 at 11:03 AM David Rodrigues wrote: > It was just an example to avoid modify how clone works, using existing > features. :) > Right, but the question remains "Why would we want the original object during a clone operation?". No legitimate example of that has been provided

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread David Rodrigues
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

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread Sara Golemon
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. > >

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread David Rodrigues
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;

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread Sara Golemon
On Wed, Sep 2, 2020 at 2:11 PM David Rodrigues wrote: > I understand... seems that `$this` is very confusing inside `__clone()`: > when writing, it writes to the clone, when reading it reads from original. > > That's not an accurate description of what happens today. $newObj = clone $oldObj; //

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread David Rodrigues
I don't see problem to allow modify the original object, once that you are doing it by using a new argument, and not the $this itself. Em qui, 3 de set de 2020 08:49, Pedro Magalhães escreveu: > On Wed, Sep 2, 2020 at 7:41 PM Michael Voříšek - ČVUT FEL < > voris...@fel.cvut.cz> wrote: > > > do

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread Pedro Magalhães
On Wed, Sep 2, 2020 at 7:41 PM Michael Voříšek - ČVUT FEL < voris...@fel.cvut.cz> wrote: > do you have anything against updating PHP to pass "instance before > cloned" to any __clone call from php? > Yes, I think that allowing the original object to be modified by a cloning operation could be

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-03 Thread Nikita Popov
On Wed, Sep 2, 2020 at 8:42 PM Michael Voříšek - ČVUT FEL < voris...@fel.cvut.cz> wrote: > Hi, please look at > > https://stackoverflow.com/questions/63675888/get-original-source-instance-in-clone > > > do you have anything against updating PHP to pass "instance before > cloned" to any __clone

Re: [PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-02 Thread David Rodrigues
I understand... seems that `$this` is very confusing inside `__clone()`: when writing, it writes to the clone, when reading it reads from original. Seems valid a new optional parameter definition with the original source. Atenciosamente, David Rodrigues Em qua., 2 de set. de 2020 às 15:41,

[PHP-DEV] Pass source object to clone like __clone($origThis)

2020-09-02 Thread Michael Voříšek - ČVUT FEL
Hi, please look at https://stackoverflow.com/questions/63675888/get-original-source-instance-in-clone do you have anything against updating PHP to pass "instance before cloned" to any __clone call from php? no BC - user may accept this extra argument or declare function __clone() without any