Hi
On 5/9/24 15:10, Andreas Hennings wrote:
The syntax is well suited for the most common case, which is regular
wither methods for one or more known properties.
I don't like the array syntax as a default. It has inferior DX for
regular withers, and possible performance impact from the
On Thu, May 9, 2024, at 1:10 PM, Andreas Hennings wrote:
>> Where all properties are readonly, and if an object those are *also*
>> readonly, and all are assigned in the constructor...
>>
>> Yeah, that ideal case is kinda narrow, and likely will remain so for a long
>> while yet.
>>
>>
On Tue, 13 Jun 2023 at 22:13, Larry Garfield wrote:
>
> On Tue, Jun 13, 2023, at 3:51 PM, Máté Kocsis wrote:
> > Hi Larry,
> >
> > In this case, if the `with` happens first, then the new address object is
> >> cloned needlessly, but that *probably* doesn't hurt anything. But $newAddr
> >> !==
On Wed, Jun 28, 2023 at 9:11 AM Nicolas Grekas
wrote:
> > Also, I'm wondering whether it's worth the complexity to add support for
> > another magic method,
> > or would we be fine without this feature and its benefits? To put it
> > another way: how much
> > complexity is it worth to fix the
> Instead of passing arguments to __clone(), I wondered about a new
>> __clone_with(array
>> $properties) that could be implemented next to __clone(), with the
>> following behavior:
>>
>>- if only __clone is implemented, same behavior as always
>>- if __clone_with is implemented, __clone
Hi Everyone,
I'd like to let you know that I'm not going to propose "clone with" for PHP
8.3 in its current form due to
the questions and possible complexity which were revealed during the last
couple of emails.
Hopefully, we'll be able to come up with something for PHP 8.4...
Regards,
Máté
Hey Nicolas,
Instead of passing arguments to __clone(), I wondered about a new
> __clone_with(array
> $properties) that could be implemented next to __clone(), with the
> following behavior:
>
>- if only __clone is implemented, same behavior as always
>- if __clone_with is implemented,
(Resending my earlier message to Levi:)
Hi Levi,
I apologize if this has been discussed before, as I have fallen very
> behind on internals discussions. I think it would be helpful to add an
> example where the object being cloned accesses its properties.
> Something like this:
>
>$b = clone
On Tue, Jun 13, 2023, at 3:51 PM, Máté Kocsis wrote:
> Hi Larry,
>
> In this case, if the `with` happens first, then the new address object is
>> cloned needlessly, but that *probably* doesn't hurt anything. But $newAddr
>> !== $p3->address.
>>
>
> Yes, I agree with this: "clone $this with ["x"
Hi Larry,
In this case, if the `with` happens first, then the new address object is
> cloned needlessly, but that *probably* doesn't hurt anything. But $newAddr
> !== $p3->address.
>
Yes, I agree with this: "clone $this with ["x" => "y"];" is the easiest to
mentally model as a shorthand for
On Mon, Apr 17, 2023 at 12:32 AM Máté Kocsis wrote:
>
> Hi Everyone,
>
> Quite some time after mentioning the "clone with" construct the first time
> (at the end of the
> https://wiki.php.net/rfc/write_once_properties#run-time_behaviour section),
> finally I managed to create a working
Le ven. 9 juin 2023 à 02:11, Larry Garfield a
écrit :
> On Thu, Jun 8, 2023, at 5:39 PM, Stephen Reay wrote:
>
> > Is there a specific reason `clone with (foo: $bar);` can’t simply pass
> > the arguments given to with(), to the __clone() magic method?
> >
> > It leaves the developer free to use
> On 9 Jun 2023, at 20:55, Larry Garfield wrote:
>
> On Fri, Jun 9, 2023, at 5:34 AM, Stephen Reay wrote:
>
>> If the property hooks RFC had already passed a vote, I’d suggest that
>> some expansion of hooks could provide a cleaner solution here, but it
>> hasn’t yet (and I understand it’s
On Fri, Jun 9, 2023, at 5:34 AM, Stephen Reay wrote:
> If the property hooks RFC had already passed a vote, I’d suggest that
> some expansion of hooks could provide a cleaner solution here, but it
> hasn’t yet (and I understand it’s not desirable to tie the fate of one
> RFC to another so
> On 9 Jun 2023, at 07:11, Larry Garfield wrote:
>
> On Thu, Jun 8, 2023, at 5:39 PM, Stephen Reay wrote:
>
>> Is there a specific reason `clone with (foo: $bar);` can’t simply pass
>> the arguments given to with(), to the __clone() magic method?
>>
>> It leaves the developer free to use
On Thu, Jun 8, 2023, at 5:39 PM, Stephen Reay wrote:
> Is there a specific reason `clone with (foo: $bar);` can’t simply pass
> the arguments given to with(), to the __clone() magic method?
>
> It leaves the developer free to use the passed argument(s) or deep
> clone existing properties or a
Sent from my iPhone
> On 9 Jun 2023, at 02:33, Larry Garfield wrote:
>
> On Thu, Jun 8, 2023, at 6:15 PM, Nicolas Grekas wrote:
>>> On Tue, May 30, 2023, at 10:04 PM, Alexandru Pătrănescu wrote:
> On Tue, May 30, 2023, 19:39 Larry Garfield
wrote:
>
>>> On Mon, May 29,
On Thu, Jun 8, 2023, at 6:15 PM, Nicolas Grekas wrote:
>> On Tue, May 30, 2023, at 10:04 PM, Alexandru Pătrănescu wrote:
>> > > On Tue, May 30, 2023, 19:39 Larry Garfield
>> > wrote:
>> > >
>> > >> On Mon, May 29, 2023, at 11:22 PM, Máté Kocsis wrote:
>> > >> > To be honest, the current behavior
> On Tue, May 30, 2023, at 10:04 PM, Alexandru Pătrănescu wrote:
> > > On Tue, May 30, 2023, 19:39 Larry Garfield
> > wrote:
> > >
> > >> On Mon, May 29, 2023, at 11:22 PM, Máté Kocsis wrote:
> > >> > To be honest, the current behavior seemed like the natural choice
> for
> > >> > me, and I
On Wed, May 31, 2023 at 2:53 AM Larry Garfield
wrote:
> On Tue, May 30, 2023, at 10:04 PM, Alexandru Pătrănescu wrote:
> > On Tue, May 30, 2023, 19:39 Larry Garfield
> wrote:
> >
> >> On Mon, May 29, 2023, at 11:22 PM, Máté Kocsis wrote:
> >> > To be honest, the current behavior seemed like the
On Tue, May 30, 2023, at 10:04 PM, Alexandru Pătrănescu wrote:
> On Tue, May 30, 2023, 19:39 Larry Garfield wrote:
>
>> On Mon, May 29, 2023, at 11:22 PM, Máté Kocsis wrote:
>> > To be honest, the current behavior seemed like the natural choice for
>> > me, and I didn't really consider to execute
On Tue, May 30, 2023, 19:39 Larry Garfield wrote:
> On Mon, May 29, 2023, at 11:22 PM, Máté Kocsis wrote:
> > To be honest, the current behavior seemed like the natural choice for
> > me, and I didn't really consider to execute the __clone() method after
> the
> > clone assignments.
> > Do you
Hi
On 5/30/23 18:37, Larry Garfield wrote:
To be honest, the current behavior seemed like the natural choice for
me, and I didn't really consider to execute the __clone() method after the
clone assignments.
Do you have a use-case in mind when you need to forward-pass information to
__clone()?
On Mon, May 29, 2023, at 11:22 PM, Máté Kocsis wrote:
> Hi Michał and Larry,
>
> As Tim has already clarified, using literal strings in the left-hand side
> of "clone with expressions" won't cause any issues
> for IDEs and static analysers to identify the correct property. I got rid
> of the
Hi Michał and Larry,
As Tim has already clarified, using literal strings in the left-hand side
of "clone with expressions" won't cause any issues
for IDEs and static analysers to identify the correct property. I got rid
of the shorthand syntax from the proposal because
it is not strictly required
Hi
On 5/29/23 13:47, Michał Marcin Brzuchalski wrote:
So there would be no option to vote on shorthand properties, right?
Array syntax with all properties as strings in quotes probably means no
support from IDE.
I think this is a really bad move, I'd be against it.
I expect any IDE or SA
On 29.05.2023 14:12, Aleksander Machniak wrote:
In "Property name expressions" section's first code example I think you
intended to do `clone $self` (not `clone $this`) inside the foreach() loop.
Also, I have a feeling that it would be better to implement `clone
$object with $properties`
Hello everyone,
On Mon, May 29, 2023 at 6:48 AM Michał Marcin Brzuchalski
wrote:
> So there would be no option to vote on shorthand properties, right?
>
> Array syntax with all properties as strings in quotes probably means no
> support from IDE.
> I think this is a really bad move, I'd be
On Mon, May 29, 2023, at 6:47 AM, Michał Marcin Brzuchalski wrote:
> Hi Máté,
>
> pon., 29 maj 2023 o 11:18 Máté Kocsis napisał(a):
>
>> Hi Everyone,
>>
>> In the meanwhile, I changed my proposal to use [] instead of {} after the
>> "with" clause due to its better receptance.
>> Additionally, I
On 29.05.2023 11:18, Máté Kocsis wrote:
Hi Everyone,
In the meanwhile, I changed my proposal to use [] instead of {} after the
"with" clause due to its better receptance.
In "Property name expressions" section's first code example I think you
intended to do `clone $self` (not `clone $this`)
Hi Máté,
pon., 29 maj 2023 o 11:18 Máté Kocsis napisał(a):
> Hi Everyone,
>
> In the meanwhile, I changed my proposal to use [] instead of {} after the
> "with" clause due to its better receptance.
> Additionally, I removed support for the shorthand "property assignment"
> syntax (clone $this
Hi Everyone,
In the meanwhile, I changed my proposal to use [] instead of {} after the
"with" clause due to its better receptance.
Additionally, I removed support for the shorthand "property assignment"
syntax (clone $this with [property1: "foo"]) in
favor the more powerful one where the
On Mon, 17 Apr 2023, Máté Kocsis wrote:
> Hi Everyone,
>
> Quite some time after mentioning the "clone with" construct the first time
> (at the end of the
> https://wiki.php.net/rfc/write_once_properties#run-time_behaviour section),
> finally I managed to create a working implementation for this
> > > What about using a real closure to define the scope we need for
> cloning?
> > > That closure would take the cloned instance as argument to allow
> > > manipulating it at will.
> >
> > I believe someone mentioned that one previously in the thread.
>
>
> Yes, Nicolas mentioned me.
> I wanted
On Wed, Apr 26, 2023 at 3:25 AM Larry Garfield
wrote:
> On Tue, Apr 25, 2023, at 11:23 AM, Nicolas Grekas wrote:
>
> > What about using a real closure to define the scope we need for cloning?
> > That closure would take the cloned instance as argument to allow
> > manipulating it at will.
>
> I
On Tue, Apr 25, 2023, at 11:23 AM, Nicolas Grekas wrote:
> What about using a real closure to define the scope we need for cloning?
> That closure would take the cloned instance as argument to allow
> manipulating it at will.
I believe someone mentioned that one previously in the thread. The
Hi again,
Quite some time after mentioning the "clone with" construct the first time
> (at the end of the
> https://wiki.php.net/rfc/write_once_properties#run-time_behaviour
> section),
> finally I managed to create a working implementation for this feature which
> would make it possible to
Hi Mate,
Quite some time after mentioning the "clone with" construct the first time
> (at the end of the
> https://wiki.php.net/rfc/write_once_properties#run-time_behaviour
> section),
> finally I managed to create a working implementation for this feature which
> would make it possible to
Hi
On 4/24/23 01:01, Máté Kocsis wrote:
2) How does this interact with an __clone() method? I'm guessing the
__clone() would be called first, and then the with-clause applied?
Yeah, thanks for pointing this out! I agree that the clarification is very
much needed. BTW the evaluation order
is
On Sun, Apr 23, 2023, at 6:01 PM, Máté Kocsis wrote:
> What about argument unpacking?
>> I don't know if we can combine this with ":" syntax or only with "=>".
>
>
> For now, argument unpacking (property unpacking?) is not possible. But it
> is definitely something that could be added in the
Hey Everyone,
Thank you for the lot of feedback! Sorry, I'm going to have to answer in a
single email otherwise I would have to send too many emails.
Alexandru wrote:
How about just allowing a block of code after the clone statement that
> would execute it in the same context as the clone
Hi Tim,
czw., 20 kwi 2023 o 16:39 Tim Düsterhus napisał(a):
> ...
> But please no entirely new syntax with braces as it currently is shown
> in the examples in the RFC.
>
Then we should vote for syntax. Personally, I prefer braces here
because it doesn't look like a regular function call
On 20.04.2023 16:15, Larry Garfield wrote:
or $point = clone($point, x: $x, y: $y, z: $z);
Also, I didn't see it mentioned, but maybe for future scope, these new
arguments should be passed to __clone().
They should not. See
Hi
On 4/20/23 16:17, Larry Garfield wrote:
On Thu, Apr 20, 2023, at 7:00 AM, Rowan Tommins wrote:
Rather than making everything use an array or array-like syntax, I
would probably go the other way and scrap the special syntax for
dynamic names, making the whole thing look like a function
On Thu, Apr 20, 2023, at 7:00 AM, Rowan Tommins wrote:
> Rather than making everything use an array or array-like syntax, I
> would probably go the other way and scrap the special syntax for
> dynamic names, making the whole thing look like a function call, with
> support for array unpacking:
On Thu, Apr 20, 2023, at 7:22 AM, Aleksander Machniak wrote:
> On 20.04.2023 09:00, Rowan Tommins wrote:
>> Rather than making everything use an array or array-like syntax, I would
>> probably go the other way and scrap the special syntax for dynamic names,
>> making the whole thing look like a
On 20/04/2023 08:11, Robert Landers wrote:
public function withStatus($code, $reasonPhrase = ''): Response
{
return clone $this {
$this->statusCode = $code;
$this->reasonPhrase = "Old: $this->reasonPhrase, New: $reasonPhrase";
}
};
Note that this is not the
On 20.04.2023 09:00, Rowan Tommins wrote:
Rather than making everything use an array or array-like syntax, I would
probably go the other way and scrap the special syntax for dynamic names,
making the whole thing look like a function call, with support for array
unpacking:
$point = clone
On Thu, Apr 20, 2023 at 9:01 AM Rowan Tommins wrote:
>
> On 18 April 2023 17:48:00 BST, "Tim Düsterhus" wrote:
> >I'd rather see only the fat-arrow being allowed. Unless I'm missing
> >something, braces with colon is not used anywhere else, whereas braces +
> >'=>' is known from match() and
On 18 April 2023 17:48:00 BST, "Tim Düsterhus" wrote:
>I'd rather see only the fat-arrow being allowed. Unless I'm missing something,
>braces with colon is not used anywhere else, whereas braces + '=>' is known
>from match() and '=>' more generally is already used with array literals [1].
Hi
On 4/19/23 17:26, Andreas Hennings wrote:
I wonder what this means for performance.
Will the expression always be evaluated as an array first, and then
applied, or can php do a "shortcut" where it internally treats it as
an argument list, even though the syntax implies array?
The different
On Tue, 18 Apr 2023 at 22:01, Bob Magic wrote:
>
> > [1] In fact if the right hand side of with may be an expression that
> > evaluates to an array, folks wouldn't need to learn new syntax at all:
> >
> > $newProperties = [ "foo" => "bar" ];
> > clone $object with $newProperties;
> >
> >
> [1] In fact if the right hand side of with may be an expression that
> evaluates to an array, folks wouldn't need to learn new syntax at all:
>
> $newProperties = [ "foo" => "bar" ];
> clone $object with $newProperties;
>
> and
>
> clone $object with [ "foo" => "bar" ];
in my
Hi
On 4/18/23 17:45, Larry Garfield wrote:
I agree with the discussion of Nicolas's alternative, which has its merits but also
some possible limitations. My only major concern myself is the potential confusion
between when to use : and when to use =>. Using the => version only for
dynamic
On Mon, Apr 17, 2023, at 7:43 AM, Alexandru Pătrănescu wrote:
> On Mon, Apr 17, 2023, 07:32 Máté Kocsis wrote:
>
>> finally I managed to create a working implementation for this feature which
>> would make it possible to properly modify readonly properties
>> while simplifying how we write
> The biggest advantage of Nicolas' proposal over “clone with” is that it could
> be made part of the interface contract whether a method modifies the object
> state. So the PSR-7 ResponseInterface could look like the following:
> [..]
> public clone function withStatus($code, $reasonPhrase =
Hello Máté, internals,
I have been waiting for this to happen :)
Some feedback
> However, in some cases it would be useful to reference property names as
> expressions, e.g. when one needs to use “clone with” in a foreach loop where
> the index is the property name and the loop variable is the
wt., 18 kwi 2023 o 10:20 Tim Düsterhus napisał(a):
> Hi
>
> On 4/18/23 10:10, Rowan Tommins wrote:
> > 2) How does this interact with an __clone() method? I'm guessing the
> > __clone() would be called first, and then the with-clause applied?
> >
>
> More generally the order of operations with
Hi
On 4/18/23 10:10, Rowan Tommins wrote:
2) How does this interact with an __clone() method? I'm guessing the
__clone() would be called first, and then the with-clause applied?
More generally the order of operations with regard to possible side
effects and/or exceptions would be
On 17/04/2023 07:32, Máté Kocsis wrote:
https://wiki.php.net/rfc/clone_with
I look the look of this; very concise.
A couple of clarifications that might be useful to add to the RFC:
1) You mention in the Alternatives sometimes needing access to the
original instance; it would be good to
Hi Zoltán,
On Mon, Apr 17, 2023 at 11:13 PM Zoltán Fekete
wrote:
> Hey,
> > public function withStatus($code, $reasonPhrase = ''): Response
> > {
> > return clone $this {
> > $this->statusCode = $code;
> > $this->reasonPhrase = $reasonPhrase;
> > };
> > }
>
> How to
Hey,
> public function withStatus($code, $reasonPhrase = ''): Response
> {
> return clone $this {
> $this->statusCode = $code;
>
> $this->reasonPhrase = $reasonPhrase;
> }
> };
How to refer to any of the properties of the current instance? Let's say
this:
```
class Foo {
Hi Máté,
pon., 17 kwi 2023 o 08:32 Máté Kocsis napisał(a):
> Hi Everyone,
>
> Quite some time after mentioning the "clone with" construct the first time
> (at the end of the
> https://wiki.php.net/rfc/write_once_properties#run-time_behaviour
> section),
> finally I managed to create a working
On Mon, Apr 17, 2023, 07:32 Máté Kocsis wrote:
> finally I managed to create a working implementation for this feature which
> would make it possible to properly modify readonly properties
> while simplifying how we write "wither" methods:
> https://wiki.php.net/rfc/clone_with
Hey Máté,
How
64 matches
Mail list logo