Re: [PHP-DEV] Custom object equality

2023-10-23 Thread Jordan LeDoux
On Mon, Oct 23, 2023 at 10:20 AM Dik Takken wrote: > On 23-10-2023 18:34, Larry Garfield wrote: > > > > Jordan's RFC explained in detail why interfaces are not viable, which is > why we have to use magic methods (with or without a special keyword) > instead: > > > > >

[PHP-DEV] [RFC] [Discussion] Change the edge case of round()

2023-10-23 Thread Saki Takamachi
Hi, internals I would like to start the discussion for my RFC "Change the edge case of round()”. https://wiki.php.net/rfc/change_the_edge_case_of_round Regards. Saki -- PHP Internals - PHP Runtime Development Mailing List To

Re: [PHP-DEV] [RFC] [Discussion] Change the edge case of round()

2023-10-23 Thread Saki Takamachi
Sorry, I posted a completely unrelated URL. Correct url: https://wiki.php.net/rfc/change_the_edge_case_of_round Regards. Saki -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

[PHP-DEV] Constructor promoted property and default value

2023-10-23 Thread Pierre
Hello internals, I stumbled upon this behavior, if I write this: ```php class Foo {     public ?string $prop = null;     public function __construct(?string $prop = null)     {     $this->prop = $prop;     } } class Bar extends Foo {     public function __construct(     public ?string

Re: [PHP-DEV] Custom object equality

2023-10-23 Thread Dik Takken
On 18-10-2023 14:50, someniatko wrote: This approach allows combining - no BC break - `~=` is a new syntax which is unavailable in older PHP versions - explicitly showing an intent that objects are compared using a custom comparison, rather than standard PHP one - allow to skip writing

Re: [PHP-DEV] Constructor promoted property and default value

2023-10-23 Thread Larry Garfield
On Mon, Oct 23, 2023, at 2:18 PM, Pierre wrote: > Hello internals, > > I stumbled upon this behavior, if I write this: > > ```php > class Foo > { >     public ?string $prop = null; > >     public function __construct(?string $prop = null) >     { >     $this->prop = $prop; >     } > } > >

Re: [PHP-DEV] Constructor promoted property and default value

2023-10-23 Thread Pierre
Le 23/10/2023 à 17:16, Larry Garfield a écrit : Where this becomes a problem is readonly properties, since those are not allowed to have default values. (That would make them constants with worse performance.) A solution would need to be able to detect that the parent::__construct() isn't

Re: [PHP-DEV] Constructor promoted property and default value

2023-10-23 Thread Saki Takamachi
Hi, Pierre You may have overlooked the existence of the magic method `__unserialize()`. Constructor is not the only way to create instances. When rebuilding a serialized object, you may need the initial values ​​of properties. This can easily happen if you are using rolling updates and using

Re: [PHP-DEV] Constructor promoted property and default value

2023-10-23 Thread Pierre
Le 23/10/2023 à 17:35, Saki Takamachi a écrit : Hi, Pierre You may have overlooked the existence of the magic method `__unserialize()`. Constructor is not the only way to create instances. When rebuilding a serialized object, you may need the initial values ​​of properties. This can easily

Re: [PHP-DEV] [RFC] [Discussion] Change the edge case of round()

2023-10-23 Thread Max Semenik
This sounds like a subtle breakage to a lot of code. Could you elaborate the motivation for such change? One sentence doesn't seem enough. Also, have you tried assessing how much existing code might be affected? On Mon, Oct 23, 2023 at 2:19 PM Saki Takamachi wrote: > Sorry, I posted a

Re: [PHP-DEV] Constructor promoted property and default value

2023-10-23 Thread Saki Takamachi
> If I understand your use case properly, you should be confused by properties > with default values that are not constructor-promoted as well ? Am I wrong ? > In this case, your problem is not with promoted properties ? If we specify it the way you say, the initial values ​​of the constructor

Re: [PHP-DEV] [RFC] [Discussion] Change the edge case of round()

2023-10-23 Thread Saki Takamachi
Hi, Max This was originally discussed in a pull request. If you're interested in the original discussion, check out this pull request. https://github.com/php/php-src/pull/12268 Regards. Saki -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit:

Re: [PHP-DEV] Constructor promoted property and default value

2023-10-23 Thread Pierre
Le 23/10/2023 à 18:11, Saki Takamachi a écrit : If I understand your use case properly, you should be confused by properties with default values that are not constructor-promoted as well ? Am I wrong ? In this case, your problem is not with promoted properties ? If we specify it the way you

Re: [PHP-DEV] Custom object equality

2023-10-23 Thread Larry Garfield
On Mon, Oct 23, 2023, at 3:14 PM, Dik Takken wrote: > On 18-10-2023 14:50, someniatko wrote: >> This approach allows combining >> - no BC break - `~=` is a new syntax which is unavailable in older PHP >> versions >> - explicitly showing an intent that objects are compared using a custom >>

Re: [PHP-DEV] Custom object equality

2023-10-23 Thread Dik Takken
On 23-10-2023 18:34, Larry Garfield wrote: Jordan's RFC explained in detail why interfaces are not viable, which is why we have to use magic methods (with or without a special keyword) instead: https://wiki.php.net/rfc/user_defined_operator_overloads#why_not_interfaces (Seriously, it has an