Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127323 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 lists.php.net (Postfix) with ESMTPS id A40441A00BC for ; Thu, 8 May 2025 15:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1746719174; bh=Beq86o0RN7jolaOpQKsUUgaTNjz/HBRQORRkY2Syb/I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aQO6Ozb+kwpmSLx6Ae1NzTo8MHawv2MrEAx0DPLZkl007NPSHdZ/417x6EVheN0lK rhE4Bj6n7aUVPlBickq5p3xKDZUZa2Uk957cUBjD5S/q9/dZAeF0+jTocwv1rX/XDt 1X3ZNDkmRdv8HxhMZPGH0CvVGJ/tA5jPxPbAF4RIgiTRiZ5kuYjaItHb8wh8Vpg6M+ 7OEPMPe3km9DK6WQxzvJZqsizj0XJlIwbju8z4un+a3W+/lD6cXnX7BCP1u2MRrnsQ KdhJUOTYaZYbFr4HUbWW2UZbGZFb2SVF15kjZ9eBFQKRoXU+qMs7uOjMmi/S3IpkNc cLXLn9bsuLKOA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 667EF180080 for ; Thu, 8 May 2025 15:46:13 +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.2 required=5.0 tests=BAYES_20,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 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-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) (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 ; Thu, 8 May 2025 15:46:13 +0000 (UTC) Received: by mail-ua1-f45.google.com with SMTP id a1e0cc1a2514c-87836f883e2so236912241.2 for ; Thu, 08 May 2025 08:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746719305; x=1747324105; 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=61qbVhMHch+43CndZiardjxK1VxDoIQ+dy88ZYx0K4U=; b=BMdTEsP2/w2GMqIW/UijMvkwOotA14bSQSIJCCm+kJK2f4UscmSaUpk5bS5NO8BDd2 Y+rUhVQ8oZclIsH8fcnq12YfQhP1AdJ8/TLn90VLYY5cb3e8wpF1m5X+7amM+nTOW5ps Jtzvyfc60UVX4+NqkH+HY0Ze2To78CaT9vzyF8pRUMql29UsXnCNdkU0R0jWfUeRmnG7 g8Nx2zELuT0sYo9cnX/0n5ZAXGgT3x90JKJOgCv4ewnpbOV6O95jiJNOxh/cpEoYmsXE e/l8baAQ5140sV+NrQ2yD0fM+hil/4SxmPVgG2CX0ovAspQoU2xzFUDvCQ5tEjdKOzHI oU+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746719305; x=1747324105; 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=61qbVhMHch+43CndZiardjxK1VxDoIQ+dy88ZYx0K4U=; b=eT7gdkl+O3MO9AjcyJwMMFWmfqlo2tjvi+Oj0IFyYF4sSLQtN5I5aHmdR1kLPf+P90 K5mfxBOZ21cILfXKhGRRmj/YbSNjoIRu7wePD5WY0mrItj9mABfULDpgCCs0YHb08D6a 4JRHhTi6HvMJu2b+u1BQgo0IvdT65EM2bDIsltpxlP3g6DPQ2QkA564YS/5IQBvyjSnN 0kewvehI9fyFQRAhO+ly1oMeVcd88i913YYPV5lE2pYGMiJqXYxSNdtebDcMNVJzskvY Nr2NtMRDOVFAqpGL6oKoJcUobZbJ1a537XWmORTAeo35kOm29oPMcD52u4D0aZOoWIvc fEgQ== X-Forwarded-Encrypted: i=1; AJvYcCWkGxX6Je7apNqTGN5u/Q+N3+og54Yg+V+B7k17vicmiy1A616sLa4COlHG2D2B5r0B77KlJykvB4c=@lists.php.net X-Gm-Message-State: AOJu0YyfxjJysSbCtzNrbm8hvDJ0ARkWWM8JBTHfRFow0H/Jp/XOk3Kf 4mhZdcVwQuuviUMHJceWMZukPlxi7REl9qVWMS2xiVWQRLNg34O2gRewmlIGSlUWLO5dkd7+D9S HJuds3o9y3UARMCPtbdXHmKb2RRc= X-Gm-Gg: ASbGncvkCC7D1+gWXLzFZWpQveorucyPeQhOPNXxRIS6S7KofPXEcoOpDg4nofJREv+ cNWvogGWwnLAB/DtGFgskWxAq/2Va3DqoKvtcHm5rO9oZzeX7lK0T6N3tfT4+u5L0o9BbDHJz4Y b3D96tx1NaNSFiXkfotf0FDMPyh1HbPNKLC5pAbaZFi+OXrSBmvVffA8r5CF1KDqs= X-Google-Smtp-Source: AGHT+IFy1OIAIifS4sYoaTkb8aRZkhuLgSnmNQGyKqHbVf9R/TWpy8q982akDfRwCutHwMKqOBn1QbpQEv9q0I120no= X-Received: by 2002:a05:6122:882:b0:529:2644:8c with SMTP id 71dfb90a1353d-52c53cb288cmr211125e0c.8.1746719305631; Thu, 08 May 2025 08:48:25 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <5eebf119-aeff-4d1e-8f84-0e91f7c89bb4@gmail.com> In-Reply-To: Date: Thu, 8 May 2025 08:47:49 -0700 X-Gm-Features: AX0GCFszpcXU2OWiDSiVmg6ck2hJ9OfGB9n0izfn1EimDbrc1K-VSvbb3k4Ngyk Message-ID: Subject: Re: [PHP-DEV] Initial discussion - more deprecation options To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: Niels Dossche , internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000bc0fc90634a1c740" From: daniel.e.scherzer@gmail.com (Daniel Scherzer) --000000000000bc0fc90634a1c740 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 8, 2025 at 8:38=E2=80=AFAM Tim D=C3=BCsterhus wrote: > Hi > > Am 2025-05-07 21:43, schrieb Niels Dossche: > > Definitely NAK on deprecating properties, which has the potential of > > adding lots of overhead. > > FWIW: Deprecating properties is already possibly by means of deprecating > a property hook. I guess this is an acceptable workaround to not require > a dedicated support + associated complexity. > > see: https://3v4l.org/C6jRQ > > class Foo > { > public string $foo > { > #[\Deprecated] > get { > return $this->foo; > } > > #[\Deprecated] > set { > $this->foo =3D $value; > } > } > } > > $f =3D new Foo(); > $f->foo =3D 'dummy'; > var_dump($f->foo); > > So this example would emit deprecation warnings on all getting and setting operations, but I was thinking that they would *not* be emitted when being accessed from within the same class (private scope). Consider a project tha= t * does not want to use hooks (which add overhead) * wants to support the deprecated behavior It would then want to * emit warnings when a property is accessed by protected/public scope * but need to handle any writes from outside of the class by accessing the property internally to see if the value changed I'm not sure what NAK means in this context, but I think that allowing `#[\Deprecated]` directly on the property instead of needing to use hooks be done in the same way that the property hooks were implemented in terms of dealing with VM handling and opcache, where things are not cached (I assume, haven't looked into this enough, this is just a preliminary discussion). Allowing deprecation directly on properties would also be more performant than needing to use hooks. -Daniel --000000000000bc0fc90634a1c740 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, May 8, 2025 at 8:38=E2=80=AFAM Ti= m D=C3=BCsterhus <tim@bastelstu.be> wrote:
Hi

Am 2025-05-07 21:43, schrieb Niels Dossche:
> Definitely NAK on deprecating properties, which has the potential of <= br> > adding lots of overhead.

FWIW: Deprecating properties is already possibly by means of deprecating a property hook. I guess this is an acceptable workaround to not require a dedicated support + associated complexity.

see:
https://3v4l.org/C6jRQ

=C2=A0 =C2=A0 =C2=A0class Foo
=C2=A0 =C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0public string $foo
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0#[\Deprecated]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0get {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return $this-= >foo;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0#[\Deprecated]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0set {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$this->foo= =3D $value;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0}

=C2=A0 =C2=A0 =C2=A0$f =3D new Foo();
=C2=A0 =C2=A0 =C2=A0$f->foo =3D 'dummy';
=C2=A0 =C2=A0 =C2=A0var_dump($f->foo);



So this example would emit deprecation warnings on al= l getting and setting operations, but I was thinking that they would *not* = be emitted when being accessed from within the same class (private scope). = Consider a project that
* does not want to use hooks (which add o= verhead)
* wants to support the deprecated behavior
It would then want to
* emit warnings when a property= is accessed by protected/public scope
* but need to handle any w= rites from outside of the class by accessing the property internally to see= if the value changed

I'm not sure what NAK me= ans in this context, but I think that allowing `#[\Deprecated]` directly on= the property instead of needing to use hooks be done in the same way that = the property hooks were implemented in terms of dealing with=C2=A0VM handli= ng and opcache, where things are not cached (I assume, haven't looked i= nto this enough, this is just a preliminary discussion).

Allowing deprecation directly on properties would also be more perfo= rmant than needing to use hooks.

-Daniel=C2=A0=C2= =A0
--000000000000bc0fc90634a1c740--