Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123809 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 3F3B61A009C for ; Tue, 25 Jun 2024 08:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719302682; bh=bKLRpW3/O08fREy91mmP2DA78FhAcDlMGTW08UzueEo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=hwrxPNc5F1pwhPF85VCbAguUEkdsO+c2JhErhCBwqGbo4tb0WSFjjAL288QIjxiDi esc2+jxk7bPZfXwzQPt+4JmVLs6NBZRxQrD3VXfGdRfRWdJkrhCB+vgnVt3C1yqYJS vTR4ZoCfUDsaqbnrTyAZ6ziSTCN1DdtyHB+R9cGTfpuDr/TtVARMBNieLM00dcHXIV 9CTykx03PC6KkS8TZpZC5YGXl8KqmjKbwOEgvCeVeitFWc1m0NQGdCO9LGxM1CWEL+ Pa/6V8axKa+yftzktLqKjy/HO4Px27okanPH1wMrrZNPDdzGzhKYEzFOAnU2HriHTN w58TpbXhwvQoA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A0616180AD2 for ; Tue, 25 Jun 2024 08: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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,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-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 ; Tue, 25 Jun 2024 08:04:41 +0000 (UTC) Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4249196a361so14517815e9.0 for ; Tue, 25 Jun 2024 01:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1719302603; x=1719907403; darn=lists.php.net; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Bkv+wxyPZI4jHs5RZYIDRsvFFVzPB9+hIHYwtog3PTU=; b=u5UHtnL7WHXUVj9z4WwsHIe3l9QAvTAsiTJWB19Zz2sMrQsKb1/joK13Ird+coyT/w dJoNj3S3sQYRwdFTUiGR5ShPOKRhuFs8O6ELwnnCFONfaKHO59DyIjmH3Sl+9CkeuPa4 2lJhTZ77h+zEpI2fgvkQ8vUKFniYgRKIinOc4BFgPJ8h3ZI9sFJxVGXNy7rrCdUdSSZA AO+Gsgal+etyiHYtV2h+Rb1/UexXSe6U+n++txnGs4faSPO8AsEMQSrE8qgHCLTNnS99 AbZ3MaCUBjOBQBkSa1l0Q4z0/Hkhecp6T0yCBqPeVZ8rGO1W8e4zBydeQ4/aWUZ0a977 vEcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719302603; x=1719907403; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Bkv+wxyPZI4jHs5RZYIDRsvFFVzPB9+hIHYwtog3PTU=; b=gjzjOhIx1GT/MZZ1gPsMH6vVbeh/2k1MSgpzlKJlRhD6XROj4yblooxSxwHCqwiX4d yOAshMM9COppqMITfM462ldfiXM93yPkM/EuFdRD5WphrBm1t2ZEP6sDyDOvMdM5oYLx E2yaxlRjYmUfF8ujMomzHSX8GzvC5/CrEpie/Gf9RT63c1iulBcN3bZWihgTfS8CdQ/f spDpMpEUGgW7v9H6Q9DXfQ1U7HSXXJ4U6y9DjxwS7sA3S4zFq38sZX0ARehk9UOuNfTf aMdfzNwAUDuHwg0itQVHAg8B1y8eemddCpp5imvPFCiPBU5Vhf6y2FVJSqyxHsgzlCNQ rcGQ== X-Forwarded-Encrypted: i=1; AJvYcCVPYk9IMm5wguHT6Z5dKPta2C7Qrv+tn7ldnDWUnIFOzLTqq0VLJRZTkTJaCuhHXMqMmijUWu+FiOuW0mQiC86lNBkaOMc0IA== X-Gm-Message-State: AOJu0YwHbOqaECB2Z/zOnZqDfX0iBuScPkQNu43RXmLrEATSOe5mZlBE lSx1nbqnKhxlchaGEitlgmxU+fQIM6c3k16wQq67NMRaaEk3+9Nc2qPUiAkdxa0= X-Google-Smtp-Source: AGHT+IGlfwIKP6It4P3ryu4ZEEAeapI/02Vl8SIt32xY2hyT/De7X1xMbc1Rl3xjsknwSuQv7sSpRA== X-Received: by 2002:a05:600c:3b14:b0:424:8dba:4a4e with SMTP id 5b1f17b1804b1-4248dba4d43mr43986955e9.6.1719302602995; Tue, 25 Jun 2024 01:03:22 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:a8b2:dca5:631e:c4dd? ([2a01:4b00:bf09:5101:a8b2:dca5:631e:c4dd]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-366e88c0c38sm7783133f8f.32.2024.06.25.01.03.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jun 2024 01:03:22 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------fViKLKwCBmM8jI1dlOXodBsI" Message-ID: Date: Tue, 25 Jun 2024 09:03:20 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Static class To: Stephen Reay , Mike Schinkel Cc: Claude Pache , ayesh@php.watch, php internals References: <88D83E92-94BE-4548-B398-8F5C74765FFD@gmail.com> <882BD9E0-42E9-4C84-A144-7C1DFC4CE5EB@newclarity.net> Content-Language: en-GB In-Reply-To: From: bilge@scriptfusion.com (Bilge) This is a multi-part message in MIME format. --------------fViKLKwCBmM8jI1dlOXodBsI Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi guys, On 25/06/2024 04:17, Stephen Reay wrote: >> >> Given a primary purpose for being able to declare a class >> `static` is to *signal intent*, disallowing `abstract static` >> classes seems at odds with that goal. >> What is the /intent/ of `abstract static`? How is such intent different from just `static`? > I agree that the `static` keyword is a much better fit here, however > there is one other aspect here that may come into it (as much as I > prefer the keyword approach): the Attribute approach is backwards > compatible (with a polyfill) to let code using this feature also run > on previous PHP releases. Given that this is mostly intended as a way > to signal intent about a pattern that's already in use, this may be > significant for library authors. > > Personally (as a library author) I don't think that ability is worth > the weirdness of an attribute vs a keyword, but it may be more > important for others who are voting, and I'd rather have the feature > with slightly odd syntax rather than not at all. When I first saw the proposal to use an attribute instead of the keyword, I thought it absurd, but this idea has now been entertained by three people, and for the first time I have seen a compelling argument in favour of (early adoption). I must admit, I was too quick to judge this one. I had not considered that libraries will still not be able to use the `static` modifier with classes unless and until they drop support for PHP < 8.4, which may take a while! Of course, it is still of real benefit to first-party proprietary projects whom have upgraded. Nevertheless, the allure of early adoption is curious, and made me wonder whether we could do both, just to support early adoption in a backwards-compatible manner. However, this would be unprecedented and most likely not accepted; never before has the same feature been implemented two ways just to appease early adopters. I think the best compromise would be, for anyone so eager, to implement such support in community tools, e.g. PHPStan. That is, it should be perfectly possible to enforce the core semantics of the static class feature with a userland attribute and the necessary logic in static analysis tools, provided the library is well behaved and doesn't do anything too weird with variable variables, references, reflection or unserialize() to deliberately circumvent the restriction. Cheers, Bilge --------------fViKLKwCBmM8jI1dlOXodBsI Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hi guys,

On 25/06/2024 04:17, Stephen Reay wrote:
Given a primary purpose for being able to declare a class `static` is to signal intent, disallowing `abstract static` classes seems at odds with that goal.
What is the intent of `abstract static`? How is such intent different from just `static`?
I agree that the `static` keyword is a much better fit here, however there is one other aspect here that may come into it (as much as I prefer the keyword approach): the Attribute approach is backwards compatible (with a polyfill) to let code using this feature also run on previous PHP releases. Given that this is mostly intended as a way to signal intent about a pattern that's already in use, this may be significant for library authors.

Personally (as a library author) I don't think that ability is worth the weirdness of an attribute vs a keyword, but it may be more important for others who are voting, and I'd rather have the feature with slightly odd syntax rather than not at all.
When I first saw the proposal to use an attribute instead of the keyword, I thought it absurd, but this idea has now been entertained by three people, and for the first time I have seen a compelling argument in favour of (early adoption). I must admit, I was too quick to judge this one. I had not considered that libraries will still not be able to use the `static` modifier with classes unless and until they drop support for PHP < 8.4, which may take a while! Of course, it is still of real benefit to first-party proprietary projects whom have upgraded. Nevertheless, the allure of early adoption is curious, and made me wonder whether we could do both, just to support early adoption in a backwards-compatible manner. However, this would be unprecedented and most likely not accepted; never before has the same feature been implemented two ways just to appease early adopters. I think the best compromise would be, for anyone so eager, to implement such support in community tools, e.g. PHPStan. That is, it should be perfectly possible to enforce the core semantics of the static class feature with a userland attribute and the necessary logic in static analysis tools, provided the library is well behaved and doesn't do anything too weird with variable variables, references, reflection or unserialize() to deliberately circumvent the restriction.

Cheers,
Bilge

--------------fViKLKwCBmM8jI1dlOXodBsI--