Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2023-01-20 Thread Máté Kocsis
Hey Tim, Thank you. It would probably make sense to create a separate copy of the > current version of the branch, possibly creating separate PR and then to > drop the unrelated commits from #9497 - or alternatively picking the > first 4 commits and creating a new clean PR from that. The latter is

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2023-01-20 Thread Tim Düsterhus
Hi On 1/20/23 17:54, Máté Kocsis wrote: Sorry for the confusion! The PR contains an implementation for the "clone with" indeed just because it builds on top of some specifics of the 2nd proposal in the "Readonly amendments" RFC. However, the first few (4) commits are related to allowing modifica

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2023-01-20 Thread Máté Kocsis
Hi Claude, Tim, One shortcoming around readonly classes that I just figured out, is that it > is not possible to use them as anonymous class: > Nice catch! As you wrote, it's indeed an oversight of the readonly class implementation. Fortunately, we already have a PR with the fix. :) I'm confused

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2023-01-19 Thread Tim Düsterhus
Hi On 1/19/23 09:01, Máté Kocsis wrote: As discussion apparently stalled, and since we managed to update the RFC with the recently brought up arguments, we would like to start the vote soon, possibly early next week, unless someone finds a new topic to discuss. I'm confused by the linked PRs f

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2023-01-19 Thread Claude Pache
> Le 19 janv. 2023 à 10:12, Claude Pache a écrit : > > > >> Le 19 janv. 2023 à 09:01, Máté Kocsis a écrit : >> >> Hi Everyone, >> >> As discussion apparently stalled, and since we managed to update the RFC >> with the recently brought up arguments, we would like to start the vote >> soon,

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2023-01-19 Thread Claude Pache
> Le 19 janv. 2023 à 09:01, Máté Kocsis a écrit : > > Hi Everyone, > > As discussion apparently stalled, and since we managed to update the RFC > with the recently brought up arguments, we would like to start the vote > soon, possibly early next week, unless someone finds a new topic to discu

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2023-01-19 Thread Máté Kocsis
Hi Everyone, As discussion apparently stalled, and since we managed to update the RFC with the recently brought up arguments, we would like to start the vote soon, possibly early next week, unless someone finds a new topic to discuss. Máté Larry Garfield ezt írta (időpont: 2022. nov. 30., Sze,

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-30 Thread Larry Garfield
On Wed, Nov 30, 2022, at 9:46 AM, Deleu wrote: > After reading GPB, Nicolas, Jordan and Larry's considerations, I no longer > have any objections to this RFC. Here is my summary of it all: > > - It's very easy for everyone to wrongly interpret readonly as somewhat > immutable, but it isn't (docs/ed

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-30 Thread Deleu
After reading GPB, Nicolas, Jordan and Larry's considerations, I no longer have any objections to this RFC. Here is my summary of it all: - It's very easy for everyone to wrongly interpret readonly as somewhat immutable, but it isn't (docs/education issue) - LSP is about the writer of the child cl

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-27 Thread G. P. B.
On Sat, 26 Nov 2022 at 23:06, Marco Pivetta wrote: > On Sat, 26 Nov 2022, 23:56 G. P. B., wrote: > >> As all the invariants will be maintained in the child classes >> > The invariant here is the immutability from a behavioural PoV. > LSP has 100% been broken in that example. > I've gone back to

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-27 Thread Nicolas Grekas
The code that Marco (Pivetta) shared was supposed to illustrate how readonly classes can be useful to enforce some invariants on child classes. Yet, here is another implementation that does use a readonly child class, but still provides the behavior that was supposedly prevented by the keyword: re

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-27 Thread Larry Garfield
On Sat, Nov 26, 2022, at 6:35 PM, Jordan LeDoux wrote: > On Sat, Nov 26, 2022 at 3:40 PM Deleu wrote: > >> >> As I think more about this, there's nothing about the current RFC in this >> code sample. What's breaking LSP here is the child class doing state >> modification, not PHP. To further expa

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-26 Thread Jordan LeDoux
On Sat, Nov 26, 2022 at 3:40 PM Deleu wrote: > > As I think more about this, there's nothing about the current RFC in this > code sample. What's breaking LSP here is the child class doing state > modification, not PHP. To further expand that rationale, PHP allows us to > create child classes. Wh

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-26 Thread Deleu
On Thu, Nov 17, 2022 at 11:47 AM Marco Pivetta wrote: > ```php > > /* readonly */ class ImmutableCounter { > public function __construct(private readonly int $count) {} > public function add1(): self { return new self($this->count + 1); } > public function value(): int { return $this

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-26 Thread Marco Pivetta
On Sat, 26 Nov 2022, 23:56 G. P. B., wrote: > > As all the invariants will be maintained in the child classes > > The invariant here is the immutability from a behavioural PoV. LSP has 100% been broken in that example. > >

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-26 Thread G. P. B.
On Thu, 17 Nov 2022 at 14:47, Marco Pivetta wrote: > Hey Máté, > > On Tue, 15 Nov 2022 at 07:30, Máté Kocsis wrote: > > > Hi Everyone, > > > > Following Nicolas' thread about "Issues with readonly classes" ( > > https://externals.io/message/118554), we created an RFC to fix two > issues > > with

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-26 Thread Marco Pivetta
On Sat, 26 Nov 2022, 20:45 Máté Kocsis, wrote: > We proposed this change because it wouldn't break anything that's already > not "broken". > That's quite a terrible rationale, TBH 😬 >

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-26 Thread Deleu
On Sat, Nov 26, 2022, 4:45 PM Máté Kocsis wrote: > We proposed this change because it wouldn't break anything that's already > not "broken". > > Regards: > Máté > The example provided already raised some eyebrows from people. I think the argument of "let's furthet enhance this 'broken' behavior"

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-26 Thread Máté Kocsis
Hi Marco, Sorry for the very late reply! As explained in > https://github.com/lcobucci/jwt/pull/979#discussion_r1025280053, a > consumer relying on a `readonly` > implementation of a class probably also expects replacement implementations > as read-only. > I am aware that we lack the `readonly` m

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-17 Thread Marco Pivetta
Hey Máté, On Tue, 15 Nov 2022 at 07:30, Máté Kocsis wrote: > Hi Everyone, > > Following Nicolas' thread about "Issues with readonly classes" ( > https://externals.io/message/118554), we created an RFC to fix two issues > with the readonly behavior: https://wiki.php.net/rfc/readonly_amendments >

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-15 Thread Rowan Tommins
On 15 November 2022 19:23:44 GMT, "Máté Kocsis" wrote: >I didn't bother to add a separate example for explicit readonly properties, >because I mainly regard >readonly classes as a shorthand for adding the readonly modifier for all >properties My two cents: examples are cheap, misunderstandings a

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-15 Thread Máté Kocsis
Hi Rowan and Alexandru, I'm not totally clear what this sentence is saying: > > > Reinitialization can only take place /during/ the |__clone()| magic > method call, no matter if the actual assignment happens in a different > method or function invoked inside |__clone()|. > > Are you saying that i

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-15 Thread Alexandru Pătrănescu
Hi Mate, On Tue, Nov 15, 2022 at 8:30 AM Máté Kocsis wrote: > Hi Everyone, > > Following Nicolas' thread about "Issues with readonly classes" ( > https://externals.io/message/118554), we created an RFC to fix two issues > with the readonly behavior: https://wiki.php.net/rfc/readonly_amendments >

Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-15 Thread Rowan Tommins
On 15/11/2022 06:30, Máté Kocsis wrote: Hi Everyone, Following Nicolas' thread about "Issues with readonly classes" ( https://externals.io/message/118554), we created an RFC to fix two issues with the readonly behavior:https://wiki.php.net/rfc/readonly_amendments Please let us know your thought

[PHP-DEV] [RFC] [Discussion] Readonly class amendments

2022-11-14 Thread Máté Kocsis
Hi Everyone, Following Nicolas' thread about "Issues with readonly classes" ( https://externals.io/message/118554), we created an RFC to fix two issues with the readonly behavior: https://wiki.php.net/rfc/readonly_amendments Please let us know your thoughts! Máté