Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123994 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 974931A009C for ; Fri, 28 Jun 2024 19:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719601482; bh=CVfOJlW8hisC9WL066TFBEB5CqaLFiMV92xHsI2ScYU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BCPVvzf/U6w7LgNbwUvA8z6B2JPLouZeAeU7JD+48a96g3aUAG34HBaP33cTFkKYn ++fnM234EHlAI5ZEhxQJBnJepsmWJdfaHdE/eg8Ps0S/xC7U5bJwnicYNHG9cXcHE7 H0VZwOJaWpj+64+626SG2aaIeWreIUV6AiLXLNaRhPE+nVjCqkDFfNKYbc3PDS7WwY xrfWsXJ07SiUdDKbkjPQrQ75IvEClviFLZYXSPlU6b/tZFmHQJdBH8o0oWToTjWwnw 5Dzbu2AEdesAB3a9OGJmXvpMrs4mZVoC302MHeF/1AahTR1oP6jXieW4j2+kJ9YPrc yu1WLeW9QSI2w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A016A1805BE for ; Fri, 28 Jun 2024 19:04:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 28 Jun 2024 19:04:41 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-57cf8880f95so1271128a12.3 for ; Fri, 28 Jun 2024 12:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719601401; x=1720206201; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CVfOJlW8hisC9WL066TFBEB5CqaLFiMV92xHsI2ScYU=; b=RSV/ccb1oLkmIQv4CYzBQ336vgB43ogfhKGQGid7tUvPNaoqV7rGPlInt4hISm419/ w6+VRHLGNalGjAh4wE7fPo6UlSclyeYupjSGrYaNKZRzFDDB5R2gFqcFNe2EEx7o64t6 UwoG2nx09cqUfK27V6OoCn6CupoioZA3KxIHMiDn2oclsVT8EprlZe+28SWzNmLgAhxr DqMbOAmr3qNPNEC+8vfErlJvqb1JVyAq2QkMpmMmhxjHQVMxxbnuxAsrWCagQD8PT8eA o7ipfgAMYJh3NDmSdi6Ip4eUNbMa00Bjhq0ux9HJGx/dW0UROj6MhSzEwXtnUM/YBt6w pQjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719601401; x=1720206201; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CVfOJlW8hisC9WL066TFBEB5CqaLFiMV92xHsI2ScYU=; b=CW0ZpWTo+B3/FLFhM/cHKFtHQ6zeZDA0ik2Soh4h1BYDhZpVqvgkq6WtZz/z8XkLHF SvXeoeXWXW/BgTu36utrEJvdZa9MasEo2DnbtZFg/o++4z5ldq4geq0in1PQGyrCIXjW /BUiJT1sXUJpZ+vy0mK10G3S8Hl2fv7EwhnugWbvakIk+AY4XmCxjnGJG/Cvb/ps6k02 JY7W2voh5gFVX51tJ0ioBpdBTcLv2FQmWaSAqqUoHBxVI9Q9sE8+iwSGyDo/2Is2jc/A pmzY4g4DoqpeDPkzpEGYSlwur4rlfLlvG2AXLaKWqk47Mrpryspq1P4YrOBpW7IN1+MM PDZg== X-Forwarded-Encrypted: i=1; AJvYcCXaSr7qVKut/fRravuwq41blohocqMHNKVeTd4auhFG7rfzAhVbD7A4p4Uyp4Cqbmy0bXyggaCG5x6v5bE0a9wXM4iCISDi/A== X-Gm-Message-State: AOJu0YxsGCLCZk0Fa4eCmGhCBfhJynRh+8ai5aUgLU5iX+h+Cc82/Vzz c8f3N5xFHqtRR7VJAFEU1ysi+mn/FA82OsEUSJ0uT/pjQGyp6HKSHwtb1MIRE7Q898ohFmXOi3x kctgIeO1mIu8f8Iy/nEwhiLBYcu4= X-Google-Smtp-Source: AGHT+IG6LP7v4k4qEwMjhenoTuOFg1vkkwu3Q4hKTiTxD5UPqiNzeTZ2S/TIhmhRLHnA+pzS4/B28b6wWqqgdJTtXMw= X-Received: by 2002:a05:6402:40c9:b0:584:8feb:c3a1 with SMTP id 4fb4d7f45d1cf-5848febc3f6mr6182983a12.1.1719601400824; Fri, 28 Jun 2024 12:03:20 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <554ffb9e-35c5-466e-aace-0501eee3d0bd@bastelstu.be> <6452BECC-BB20-48DC-9595-324EA70E6A67@newclarity.net> <4148946E-7D16-46F8-8B88-9C7C5D61D129@koalephant.com> In-Reply-To: <4148946E-7D16-46F8-8B88-9C7C5D61D129@koalephant.com> Date: Fri, 28 Jun 2024 21:02:53 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Static class To: Stephen Reay Cc: Mike Schinkel , =?UTF-8?Q?Tim_D=C3=BCsterhus?= , Bilge , php internals , lnearwaju@gmail.com Content-Type: multipart/alternative; boundary="000000000000a6cca1061bf7e610" From: kjarli@gmail.com (Lynn) --000000000000a6cca1061bf7e610 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jun 28, 2024 at 8:04=E2=80=AFPM Stephen Reay wrote: > > > On 28 Jun 2024, at 14:05, Lynn wrote: > > > > On Fri, Jun 28, 2024 at 2:48=E2=80=AFAM Mike Schinkel 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 usin= g >> 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 wi= th >> 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 cla= ss > solve those issues for you, without preventing others from using the > capabilities of parent/child class relationships? > > > Cheers > > > Stephen > The main issue is that it's easy to mess up by default and not messing up requires you to understand why. I prefer defensive programming, close it and only open when it's really required. If there's legit scenarios where you need inheritance in a static context the requirement could be an "open" keyword or removing it being final, we can't do it the other way around without massive BC break. --000000000000a6cca1061bf7e610 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Jun 28, 2024 at 8:04=E2=80=AF= PM Stephen Reay <php-lists@k= oalephant.com> wrote:


On 28 Jun 2024, at 14:05, Lyn= n <kjarli@gmail.co= m> wrote:


=
On Fri= , Jun 28, 2024 at 2:48=E2=80=AFAM Mike Schinkel <mike@newclarity.net> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex"> >> 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 inher= itance 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 def= ault for the=C2=A0sake of consistency, though my preference would be to avo= id 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=C2=A0problem of ho= rizontal=C2=A0reuse?

Hi Lynn,

I under= stand it's frustrating when there are bugs/unexpected behaviour, but wo= uldn't the (existing) *ability* to add the `final` keyword to a class s= olve those issues for you, without preventing others from using the capabil= ities of parent/child class relationships?


Cheers


Stephen=C2=A0
<= /div>

The main issue is that it's easy = to mess up by default and not messing up requires you to understand why. I = prefer defensive programming, close it and only open when it's really r= equired. If there's legit scenarios where you need inheritance in a sta= tic context the requirement could be an "open" keyword or removin= g it being final, we can't do it the other way around without massive B= C break.
--000000000000a6cca1061bf7e610--