Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123205 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 90F201A009C for ; Thu, 25 Apr 2024 05:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1714022263; bh=GjXuGWCVKBEgdaDCwJeOWVpPS8tgtBz8NquGOWFS9k0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=d2a9ACV9GgBxFq9r0w/xA43GdTBeQqOLyTXnxus+JgZXdNUWzZV0ctozy71eblrHL jkhboXHn2t2WBl+RBXesDyEca6T2MrtKwFQZumuVThGjQLNdRc8XemTLcgzdWnmIfK 6pOzo4tn+MSU0o+Q4cn0H+CtvHnjb6OGO88wI3/xLhnURt354dvB/IgAkIUm0mhdFD gOudmYxlaGE9n9Oy+o5KKhwfjB8tz7uakhSONli2fRlFUGa+8xSaWcipc4vZqWvoDF 1XS7lYBoetSPYb9nGjbwlYSxI0ZkmSLPGdlsd5y82s+mN8ZOMJsLOJtVgE6ZNvnFm0 C37tWpQG2Dcbg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8C8BC18002E for ; Thu, 25 Apr 2024 05:17:38 +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_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) (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, 25 Apr 2024 05:17:37 +0000 (UTC) Received: by mail-vs1-f46.google.com with SMTP id ada2fe7eead31-479d1454cb4so160984137.2 for ; Wed, 24 Apr 2024 22:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20230601.gappssmtp.com; s=20230601; t=1714022216; x=1714627016; 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=WHHYx+mtED+HYnIweKqt+F6Sh81TjUw/VZTG/n4n82M=; b=yZYV3dTh+qaNjEqbxeAeDpBozJbbPHa6SbKfGtVf+oTBUW5MTArQen0PKRR2O9l51c tMmDGpLASPdQiNir3IDKGDjhL8CqNYAhXb5R9ErRqlKQ/UmiQ+Nmfwil81fAJwUNbjZ6 gdBsbsfxnv7L/Wt5L2EWUBcA2g96M1iWYnP7reDl9ZWk6zRjviHUj0PFvFFYL2/ZKZdR bQQ8oy7TsarXk5giB7uRljbfLismGRhe9/LGzfyea9m3UIylh+EWbBm73iVCXIKrmX40 69rGBipl3tP6rymC/+o5eZuCarqO/+902sBdnTRh0zqhBuJ04N0ZlhvdFrFw6Tj0gscv r8LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714022216; x=1714627016; 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=WHHYx+mtED+HYnIweKqt+F6Sh81TjUw/VZTG/n4n82M=; b=XgTurXugrpqlo2sgmp+VYDa1l0kwPjDb/RdgxOGE+mda18AKaRpJFmzwEBguTfJ4f5 UnOx//7lsSYs8ZlLjQSNdK2BgYrzkNLAcqfSauyITItPcBiEohgku4vo8+SB8c2sYMEr 9lWWIYGKwShR+N+jlZCyOEQlMil/qhZTJznpR2rhrRu9lP8d+EQa9chBLZUVhCDXdi8M 53EDvxysu09wRNdAaZOx/YoB6eyUdOIcy4ydOHZjqQ7g/u3HLSGp5IqF2MWpNG7LH+xA OZ9sY0REn9HYtD60gm4oXCWW3/Hmr0LejJIaiqT5rWyVzeq1O/9ILvybrSb9X6pj1X99 6+TA== X-Forwarded-Encrypted: i=1; AJvYcCWiTDrjGSRBS5AuTI+9YceAUIBsGgCnsazKzIHKP0FuAIVWGoZDZ0J2t1ZjNxC9vcLgy0pTHMoL2GoIdQuYWL3zU9z6iyVTOA== X-Gm-Message-State: AOJu0YxkVp1XOqrmb/V8UqJiO5w8ftG5XadH0wrLSoNzmdp/xXVzT2oS Lh+tuWPoDmTtHnuV8/BmhDhBPYNtcCEtrCsDbGOmuZovzdC/XxLDY5tpw97OlxQh/FMcbhlNb4u XDe2PWMqRcEFdajhkOTq1ekmTwOVFmJ+BjqQQBw== X-Google-Smtp-Source: AGHT+IGDIhZLIaE8NfFDmiglrOEQMBhlgGX1G63onw1WKgYtl8QyC+XEtotuUGhufUhliBV/hrDFU3y5PfmuLDtZHN8= X-Received: by 2002:a67:ec57:0:b0:47b:c614:8bd8 with SMTP id z23-20020a67ec57000000b0047bc6148bd8mr4329323vso.12.1714022216247; Wed, 24 Apr 2024 22:16:56 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 25 Apr 2024 07:16:44 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] #[\Deprecated] attribute again v1.3 To: Jorg Sowa Cc: Lynn , PHP Internals , "tim@tideways-gmbh.com" Content-Type: multipart/alternative; boundary="000000000000564f830616e4e5da" From: kontakt@beberlei.de (=?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?=) --000000000000564f830616e4e5da Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 24, 2024 at 7:18=E2=80=AFPM Jorg Sowa wro= te: > I like the proposition and I like the idea of $since parameter, however, > this option is too ambiguous about what should store. Should it store the > PHP version, package version, or the date? > > What about setting this parameter vaguely as the boolean we can pass? > > #[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_FUNCTION)] > class Deprecated > { > public function __construct( > public readonly ?string $note =3D null, > public readonly ?bool $since =3D null > ) { > } > } > > #[Deprecated(since: $packageVersion > 5.5)] > #[Deprecated(since: PHP_VERSION_ID > 80100)] > #[Deprecated(since: date("Y-m-d") > "2024-01-21")] > These are not valid uses of attributes, the expressions for since parameter are illegal in the language. PHP Fatal error: Constant expression contains invalid operations in /private/tmp/dep.php on line 6 And this proposal would only make the condition human readable, the machine would see $since as either true or false, and that is not really something that tools will find valuable enough. But I agree on $since being less useful, users could put a date, a string, or anyhing in there. The way I see it vendors should add their own attributes, example: #[\Deprecated, Since(package: "symfony/http-request", version: "7.0.2")] or for PHPStorms replacement functinoality (potentially usable by Rector): #[]Deprecated, Replacement('%class%->setPublic(!%parameter0%)')] This is a.) composable, which increases the potential use-cases for different vendor and communities and doesn't restrict them to what core "designed in the ivory tower once". b.) allows vendors to have very strict validation on their attributes arguments. I.e. Symfony could enforce package to be a valid composer package string and version to follow composers version parser. This is something we cannot enforce in the engine. > > Kind regards, > Jorg > --000000000000564f830616e4e5da Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Apr 24, 2024 at 7:18=E2=80=AF= PM Jorg Sowa <jorg.sowa@gmail.com= > wrote:
I= like the proposition and I like the idea of $since parameter, however, thi= s option is too ambiguous about what should store. Should it store the PHP = version, package version, or the date?

What about setting this= parameter vaguely as the boolean we can pass?

#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_FUNCTION)]
class Deprecated
{
=C2=A0 =C2=A0 public function __construct(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public readonly ?string $note =3D null,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public readonly ?bool $since =3D null
=C2=A0 =C2=A0 ) {
=C2=A0 =C2=A0 }
}

#[Deprecated(since: $packageVersion > 5.5)]
#[Deprecated(since: PHP_V= ERSION_ID > 80100)]
#[Deprecated(since: date("Y-m-d") > = "2024-01-21")]

<= div>These are not valid uses of attributes, the expressions for since param= eter are illegal in the language.=C2=A0

PHP Fatal = error: =C2=A0Constant expression contains invalid operations in /private/tm= p/dep.php on line 6

And this proposal would only m= ake the condition human readable, the machine would see $since as either tr= ue or false, and that is not really something that tools will find valuable= enough.=C2=A0

But I agree on $since being less us= eful, users could put a date, a string, or anyhing in there.=C2=A0

The way I see it vendors should add their own attributes, = example:

#[\Deprecated, Since(package: "symfo= ny/http-request", version: "7.0.2")]

or for PHPStorms replacement functinoality (potentially usable by Rector)= :

#[]Deprecated, Replacement('%class%->setPublic(!%parameter0%)= 9;)]
<= br>
Th= is is=C2=A0
a.) composable, which increases the potential use-cases for different= vendor and communities and doesn't restrict them to what core "de= signed in the ivory tower once".
b.) allows vendors to have very strict vali= dation on their attributes arguments. I.e. Symfony could enforce package to= be a valid composer package string and version to follow composers version= parser. This is something we cannot enforce in the engine.

Kind regards,
Jorg
--000000000000564f830616e4e5da--