Re: [RFC] Static class
| From: | Stephen Reay | Date: | Fri, 28 Jun 2024 18:04:12 +0000 |
| Subject: | Re: [RFC] Static class | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123992@lists.php.net to get a copy of this message | ||
> On 28 Jun 2024, at 14:05, Lynn <kjarli@gmail.com> wrote:
>
>
>
> On Fri, Jun 28, 2024 at 2:48 AM Mike Schinkel <mike@newclarity.net
> <mailto:mike@newclarity.net>> wrote:
>> >> and inheritance is not meant for code reuse.
>>
>> Just because code reuse in inheritance can be problematic it does not have to be in
>> all-cases. Moderation in all things. I used that approach for 10+ years and never once had any of
>> the problems people claim about using inheritance for code reuse. This was likely because my needs
>> were constrained by the use-case and by nature did not grow out of control with complexity.
>
> My experience is the opposite. There are subtle bugs I keep running into with static function
> and properties causing unexpected behavior. I'm not against having static classes open by
> default for the sake of consistency, though my preference would be to avoid the headache altogether
> and just make them final by default so I won't ever have to deal with it. Would traits not
> solve the problem of horizontal reuse?
Hi Lynn,
I understand it's frustrating when there are bugs/unexpected behaviour, but wouldn't the
(existing) *ability* to add the
final keyword to a class solve those issues for you,
without preventing others from using the capabilities of parent/child class relationships?
Cheers
Stephen