Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-20 Thread Erick de Azevedo Lima
> If we're talking syntax and introducing new keywords anyway, why not go with a new language construct like `is_initialized($obj->property)` ? It was one of my suggestions at the beginning of the thread. Also, I said that I'd love the "$objectVar->property is uninitialized" (answering to Larry) b

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-20 Thread Ilija Tovilo
On Sat, May 18, 2024 at 4:41 PM Rowan Tommins [IMSoP] wrote: > > On 18/05/2024 11:52, Luigi Cardamone wrote: > > Are there any downsides in adding a > > specific syntax to check if a property > > is initialized with any value? > > In my opinion - and I stress that others may not share this opinion

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-20 Thread Juliette Reinders Folmer
On 20-5-2024 19:41, Erick de Azevedo Lima wrote: > All of which is to say that, yes, there are use cases for an "is this property initialized" check that is less fugly than the get_object_vars() hack I have to rely on now. I'd like to see this: if ($objectVar->property is uninitialized) { ...

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-20 Thread Luigi Cardamone
On 18/05/2024 18:08, Rowan Tommins [IMSoP] wrote: > > In my opinion - and I stress that others may not share this opinion - > the entire concept of "uninitialized properties" is a wart on the > language, which we should be doing our best to eliminate, not adding > more features around it. > > As

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-20 Thread Erick de Azevedo Lima
> All of which is to say that, yes, there are use cases for an "is this property initialized" check that is less fugly than the get_object_vars() hack I have to rely on now. I'd like to see this: if ($objectVar->property is uninitialized) { ... } or/and: if ($objectVar->property is initialized)

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-20 Thread Larry Garfield
On Sat, May 18, 2024, at 5:41 PM, Rowan Tommins [IMSoP] wrote: > On 18 May 2024 17:13:49 BST, Larry Garfield wrote: >>However, that breaks down with readonly properties, which are not allowed to >>have a sentinel. Uninitialized is their sentinel, for better or worse. > > Sorry, I don't understan

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-18 Thread Rowan Tommins [IMSoP]
On 18 May 2024 17:13:49 BST, Larry Garfield wrote: >However, that breaks down with readonly properties, which are not allowed to >have a sentinel. Uninitialized is their sentinel, for better or worse. Sorry, I don't understand this statement at all. A readonly property can be set to PatchSt

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-18 Thread Larry Garfield
On Sat, May 18, 2024, at 9:40 AM, Rowan Tommins [IMSoP] wrote: > On 18/05/2024 11:52, Luigi Cardamone wrote: >> I am already using a solution like the one >> proposed by Robert: it works but it >> leaves some doubts since each project >> can have a different name for NotSet > > > An argument is oft

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-18 Thread Rowan Tommins [IMSoP]
On 18/05/2024 11:52, Luigi Cardamone wrote: I am already using a solution like the one proposed by Robert: it works but it leaves some doubts since each project can have a different name for NotSet An argument is often made that this is a good thing, in the sense that "null" and other "univer

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-18 Thread Erick de Azevedo Lima
> I am already using a solution like the one > proposed by Robert: it works but it leaves some doubts since each project > can have a different name for NotSet while it seems a general concept of the language Hi everyone. I just thought of some ways to standardize this: 1 - Create an RFC to crea

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-18 Thread Robert Landers
On Sat, May 18, 2024 at 12:52 PM Luigi Cardamone wrote: > > Thank you for your feedback. > > I am already using a solution like the one > proposed by Robert: it works but it > leaves some doubts since each project > can have a different name for NotSet > while it seems a general concept of the > l

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-18 Thread Luigi Cardamone
Thank you for your feedback. I am already using a solution like the one proposed by Robert: it works but it leaves some doubts since each project can have a different name for NotSet while it seems a general concept of the language. Besides the example I proposed, I think that there are many case

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-18 Thread Robert Landers
On Fri, May 17, 2024 at 11:43 PM Luigi Cardamone wrote: > > Hello Internals, > during last PHPDay in Verona I discussed this topic with some of > you and it was suggested to me to send an email here. > > Here is an example to describe my problem. Imagine a simple > DTO like this: > > class MyDTO{

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-17 Thread Ilija Tovilo
Hi Luigi On Fri, May 17, 2024 at 11:40 PM Luigi Cardamone wrote: > > Here is an example to describe my problem. Imagine a simple > DTO like this: > > class MyDTO{ > public ?int $propA; > public ?int $propB; > } > > Imagine that a Form processor or a generic mapper fill some of > these fie

Re: [PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-17 Thread Larry Garfield
On Fri, May 17, 2024, at 9:40 PM, Luigi Cardamone wrote: > Hello Internals, > during last PHPDay in Verona I discussed this topic with some of > you and it was suggested to me to send an email here. > > Here is an example to describe my problem. Imagine a simple > DTO like this: > > class MyDTO{ >

[PHP-DEV] [DISCUSSION] Checking uninitialized class properties

2024-05-17 Thread Luigi Cardamone
Hello Internals, during last PHPDay in Verona I discussed this topic with some of you and it was suggested to me to send an email here. Here is an example to describe my problem. Imagine a simple DTO like this: class MyDTO{ public ?int $propA; public ?int $propB; } Imagine that a Form pr