Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123980 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 C7C801A009C for ; Fri, 28 Jun 2024 00:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719535502; bh=p52BRBtv9VwwpGT8Ksm38VHcWwVnSsxpT3DefVXOna4=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=YwoIpLLU5uWqGjpDbBxUo+MAlYVO3yXKSYmfI4LnMyoDvhjiSTmHyhlIN2E+EvAaz tu//u56tha9qNgfedN+sRCxJBou09KK2G5qv9Bp6xRY8T6j7JAmuYU3iYjC4dvCP6h NRPLfKZScY5ai5BVXwyXkrTkrOdp+bHkP/McKCXhXSqkPsWlR7fYgT4JT56ZKlgwht tKC3RN+Vlg/s/h3XcGEvGFJYKxFmAw/yjoSwAlS5YwwnLHVKGMlh2eGNf1JbwJElBr KB6kC9T+296IVZ0Wx88KoieW5LrisZpxanl9oqZxBmm15NQTKVB8UK5Jf88WZBTSAV HLVB70qDkLeug== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 29D4118003F for ; Fri, 28 Jun 2024 00:45:02 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, 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-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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 00:45:01 +0000 (UTC) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6326f1647f6so576217b3.0 for ; Thu, 27 Jun 2024 17:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1719535422; x=1720140222; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iyqYMl9wIWHzwPKyNf8A2Cgke+6TXWRVIiebVroG6eY=; b=HfpoCe+lDj4SbXgcGLZsAuuNOyVONRStkLBr2WdlLjyl8aKR1cBgXOcqiMDV7kNijG uIrRNgN1IFuRkqqZaMTC9zPFB03bMyynTEy8BZIgisRfhNdw2LiHLcqgcLx9EjjCnGpj 3tfwLfhX3OmkG9DQmSx3ZUDnEiG4wGFEMnPSJi/CO6fFIpCeKrBVb8ze0hOm2UM8mi79 E+l0tSGHKxdDI5CIP+si9UINYCvm5rKf9PSoDBoGx+rF2lI83lfUoon5GukgYXeOVpTH s0tAyciMjLki0t4QWYGdxrpab7hhaV4B+UswtxO6VjiySicBWbokOIVTZ9/kOQUPdJTX nBKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719535422; x=1720140222; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iyqYMl9wIWHzwPKyNf8A2Cgke+6TXWRVIiebVroG6eY=; b=R4QGIMy2Y6lRyqZ4XITNIzmhAmbVlGE1WLA2i3JJaQIw1z/TCYjbJzpJMpEWiTy0iH bBo2qnTnyUqzEoPyUYMlobrAgAoRETLliMOmZY5XPxiju9TUGMB8esYVTu/CKo0GDOc1 ogrb4goTPbUWfTWBTJrGfvnlLmFEPsPL3c5znMd0SmkYRJIKRhlr3MQSTNLcOwPb8Z9J A+8iPjLDjQl2MSUaIzyGuX6ouE6ZEfMZCHlpQXNq8ggoIJiXnDG020BJNewbdh+p+lwy 2Emxd2ikomqWM1cm5HqGiyd8Q9XgIHkwYowHvtWFBK1Zb9AGJsEsyRSn+6jHJpX2SIQ7 n/MQ== X-Forwarded-Encrypted: i=1; AJvYcCWwicsQujktjfUzPJkpsV/J0DZJIVWUt1twCNaNGOJGWAAUOJjVktPYR9s7wcBLDoAGb9TtDiDTvZIDz5oruEdOTYLQO/9MZA== X-Gm-Message-State: AOJu0YwQOSaRukixn2EHbQiwP+qa7JSIjl6YfWxzu1YzzPxFOQDE5BTW 5qGMesHlgK/n5ZCbed+8oL1oFPVR4tZoYXmQdr3XcJQpziocx4HoRTsA3SmaOfM= X-Google-Smtp-Source: AGHT+IFhNcvGcW8fkUo22ir5fvA2Q9aa5Ob8WL4ruXDOumEFXujF9XgoqctWpnXOl/VDInYciHGb0w== X-Received: by 2002:a05:690c:ed2:b0:620:3c10:527a with SMTP id 00721157ae682-643aaa89c62mr187412267b3.15.1719535422539; Thu, 27 Jun 2024 17:43:42 -0700 (PDT) Received: from smtpclient.apple (c-98-252-216-111.hsd1.ga.comcast.net. [98.252.216.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-64a9a23c581sm1560677b3.56.2024.06.27.17.43.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Jun 2024 17:43:41 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.8\)) Subject: Re: [PHP-DEV] [RFC] Static class In-Reply-To: <554ffb9e-35c5-466e-aace-0501eee3d0bd@bastelstu.be> Date: Thu, 27 Jun 2024 20:43:40 -0400 Cc: Bilge , php internals , lnearwaju@gmail.com Content-Transfer-Encoding: quoted-printable Message-ID: <6452BECC-BB20-48DC-9595-324EA70E6A67@newclarity.net> References: <554ffb9e-35c5-466e-aace-0501eee3d0bd@bastelstu.be> To: =?utf-8?Q?Tim_D=C3=BCsterhus?= X-Mailer: Apple Mail (2.3696.120.41.1.8) From: mike@newclarity.net (Mike Schinkel) > On Jun 27, 2024, at 2:11 PM, Tim D=C3=BCsterhus = wrote: > Marking a class as 'static' *does* affect how the class may be used = and thus the static-ness is part of the public API. Therefore it should = be a keyword. Everything else would also be inconsistent with final = classes effectively making all members final and readonly classes making = all members readonly. Very insightful; that is a great rule of thumb. >> I also believe that static classes should be implictly final. Given = that no objects of such a class can exist, they cannot be exchanged by a = different class anyways=20 I object here.=20 There are functions in classes that I have built in the past that are = static and also benefit from inheritance. Could they be called directly = on the base class; yes? But that is less elegant and increases = complexity with two levels of inheritance are needed. =20 Specifically the functionality I am thinking of is the base class is = generic functionality for factory functions and then child factory = functions implement use-case specific logic for the type of the object = produced. For example, each of these functions has a MakeNew(...) = function, and children call self::MakeNew(...). Base -- Term -- User -- BasePost -- Post -- Page That is a subset of classes I used, and those classes were designed for = use with WordPress.=20 Further, these classes implemented "hooks" in WordPress. Using = inheritance allowed all the hooks to be managed without repeating them = in many places, being able to modify them for a class-specific need, and = also without accidentally forgetting to add them. >> 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. So I would really hate to finally get static classes but still not be = able to use them as intended for select use-cases only because someone = decided without knowing all applicable use-cases that they did not like = the idea of people using inheritance. -Mike