Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121601 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51058 invoked from network); 6 Nov 2023 14:15:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Nov 2023 14:15:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 700C4180511 for ; Mon, 6 Nov 2023 06:15:34 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 6 Nov 2023 06:15:34 -0800 (PST) Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5845a94dae1so2232660eaf.0 for ; Mon, 06 Nov 2023 06:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699280133; x=1699884933; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sPhRPQQBvo8KKO7Jv3FrChmDB1JqpsYuYVwpVjCFGIw=; b=iRZVcDdfLU/RHA3/iuqpoQ2XKs3Y1bmS/NSTvQqaLZbI7D9zCd31U+dGotIrHDAEpk 9h5nuRIIB4SKq8b7SDNnBdjyOUerqIP/qyMsOkuW+3LQYl9xHn3fO/id7RHwHzJpL6ki +TjpnETvy2FGempLdPxt98g3bXm9NPSm7L13cTyeO0yytuoj9YrlFqzMlZHcevsEmZgc k6ZXJiRoyz+FPsWtad4o730b7QK1lgonKuokxMNuGtFr9I1sgwksfIdkyTEbQc4WhqyD m69CEbaPKQEduLpadNpkwq2F3HxhshTP/wrEHsKQcljlBGan103/wud91ycYE1qd11nn KSCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699280133; x=1699884933; h=content-transfer-encoding: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=sPhRPQQBvo8KKO7Jv3FrChmDB1JqpsYuYVwpVjCFGIw=; b=PWLtNXUh+BVbH33OdgIbeltAAEkBfjFwhJTq7mjW6yMG29DwFdV9ZWvBEQveGWAhiu /uQb+BrNI+MjfGYCEo7j5L28aRsTL5X5tZxY9OyI4VtSGqytSdkulSExc9Cw+2RFl8d9 WoujUlDS4MRPGXmHr2JlI7Ye8Cv3AgBiFKBCe1L7XyYwgwQbBp6BGeZkOAsakSEOwHQW YOEc99UhXYnJ+asOtDv//MkEtWsBnYaIJcfd4SiSzNatR6eiP5an+nkguo3o6tZIg2qS evG/+os7lrPEtno4OGP/irNGm5+YWaI9Yx+vKiQIHyUdXP1XAAWuoxJDJdAuR0hjOGxR dKrQ== X-Gm-Message-State: AOJu0YwMyY6a2VqtoDbOdTQOdW8MS9iAAvWl+NeqX7Ek6LxfMXbV4BZ7 wrLRnxLzxRI/+3qkR6RwKfi95GsHe3KOKb6mBZk= X-Google-Smtp-Source: AGHT+IGwooQkYy2AVKxxGWJ/UmMqU1c8HUOmH0THD75YgHQ9unO0DSfqMIRjUoFP0QJ6FuBL1nQhVr7bkHmWc8lqg7M= X-Received: by 2002:a4a:d750:0:b0:581:dc8d:cc73 with SMTP id h16-20020a4ad750000000b00581dc8dcc73mr5992947oot.1.1699280133211; Mon, 06 Nov 2023 06:15:33 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 6 Nov 2023 15:15:22 +0100 Message-ID: To: David Gebler Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [Discussion] Variable Type Declaration Before Usage From: landers.robert@gmail.com (Robert Landers) On Mon, Nov 6, 2023 at 3:08=E2=80=AFAM David Gebler = wrote: > > On Sun, Nov 5, 2023 at 1:37=E2=80=AFPM Oladoyinbo Vincent > wrote: > > > Hello Internals, > > > > I was wondering if php could introduce this feature or if any experienc= ed C > > dev here can work on the implementation of this feature. > > > > > I think this is a much bigger issue than bikeshedding over syntax. The id= ea > of typed variables has been discussed a few times in recent years but the > roadblocks have been efficiency of any possible implementation, BC in > respect of places type hinting can already be used and the overall > usefulness / desirability of the feature. It's one of those things that's > been filled in reasonably well by third party static analysis tools. Tbh > I'd be more interested in an official static analyzer than more type chec= ks > at runtime. It's also worth adding that many times, certain functions cannot be chained elegantly or the nesting level gets out of hand, making reusing variables a way to handle that: $name =3D implode(' ', array_map(ucfirst(...), $name)); might be more readable to write as: $name =3D array_map(ucfirst(...), $name); $name =3D implode(' ', $name); In this case, $name turns from an array to a string. Having to come up with unique enough variable names just to satisfy type-checking would be rather annoying (and it is in other languages).