Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117331 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24354 invoked from network); 14 Mar 2022 19:55:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Mar 2022 19:55:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 252E6180506 for ; Mon, 14 Mar 2022 14:20:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 14 Mar 2022 14:20:27 -0700 (PDT) Received: by mail-oi1-f175.google.com with SMTP id n7so18832342oif.5 for ; Mon, 14 Mar 2022 14:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20210112.gappssmtp.com; s=20210112; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=mw8bGq0USy4yMuqbYlRSZr5WBjuXKigZBwxZJ1vO5LU=; b=HXe7XOp1/rbVI3Fbt9MKZ4jtBVTugc6YjXsXCzovPFUIivUzukmyfu/5JOs361d/nt Geh4uZAWA+s94LHJyt5O0SAHNzJeXraxI1PCPcqgu2ilzlXd7gzH0AklU9GZGFXI1Lcl R2v5MSGoGkxGbunTZjq5CfFWklfQKdPC7cVnmfdkedW4UCr+V37deSw67RP6kMVRVwW8 nB43hf0svzL5CeHBBHNP5KCtA8EvNx0hB7r6tq/++1SSbqUn/vh6gWnVkR6muMM8Pvie vYui6nbJugUcB7Rej+d4+5qfAKBM4SjlkE/C3FNVWVmOIxp+aTWFzrK23JBEiIA43Mpw 4clw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=mw8bGq0USy4yMuqbYlRSZr5WBjuXKigZBwxZJ1vO5LU=; b=SsFyyfW7p1Gxlc+MKaocQ68ZQlMho3spZyHZCgoX4F/pdyGfBPsSZvO74JNJLv9L4l xtOHkJF4iDSRZNosxIjBCz9agNM+6wdtlkIrpNMdE8pqzyiwMJAYIAwLCLlEN/bVJWcH uN5WuQYLsaDFJV7SnaK0Uy9wxiCwfcBnBkCh5v1ZlX8TEiIYO901XgXgSyPgMKm9STgC nOWi0c2Y+2TWV4sDSVHpEjX+26Bh7Y+iPlAgkySR+6Esa6GyDmopkY+iCDkgIUUGEJbb Yq5q8UKOgKMNFWkO93XDhq9vDdLVGLD+iHWi/alRsE75xacvHqIwLuA9WW950jNfHt+2 MCIA== X-Gm-Message-State: AOAM530r6bmg8N2YlJp+qN+jLC4aFDVrU565J5QO4VTgmHVH9x8hKYkN oZsXuOivZ+0qeZCkrdas8knM8g== X-Google-Smtp-Source: ABdhPJwwFXb+KAfnT9yWcUXPcm5t6ZCm+WzrePNHofPVVX9FW64V69qaCzqyb6i9SAYHDtd27nNeqg== X-Received: by 2002:a05:6808:1883:b0:2da:3ed2:68cf with SMTP id bi3-20020a056808188300b002da3ed268cfmr529478oib.204.1647292826946; Mon, 14 Mar 2022 14:20:26 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id g18-20020a9d6c52000000b005af7c7cb702sm7880204otq.34.2022.03.14.14.20.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Mar 2022 14:20:26 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_D1894B2D-5F73-4D26-8CA2-8124FB87738A" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Date: Mon, 14 Mar 2022 17:20:24 -0400 In-Reply-To: Cc: Kamil Tekiela , PHP internals To: Lynn References: <20220312031138.5e0669a4@platypus> <5E019DDC-43D8-4676-9AA6-FBEF36A92FEF@newclarity.net> X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [RFC][Under discussion] Deprecate ${} string interpolation From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_D1894B2D-5F73-4D26-8CA2-8124FB87738A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Mar 14, 2022, at 3:20 PM, Lynn wrote: >=20 > On Mon, Mar 14, 2022 at 8:04 PM Mike Schinkel > wrote: >=20 > Variable variables provide functionality[1] that if removed would = force major rewrites of PHP applications that were architected in a way = that depends on that functionality.=20 > And while probably between 90% and 99% of the time when someone uses = variable variables there are better alternatives, variable variables = make certain code possible that would be impossible without them.=20 > Do you have examples where this is the case?=20 Most of these things cannot be done without the functionality provided = by variable variables. However a few are examples could be handled = differently but would require significant rewrite to fix without a new = get_value_from_variable_name() function. Either way, these are just = from the first few pages of those 162.2k results on SourceGraph.com = : = https://github.com/microsoft/sql-server-samples/blob/master/samples/develo= pment-frameworks/laravel/vendor/jeremeamia/SuperClosure/src/SerializableCl= osure.php#L200-L208 = = https://github.com/mockery/mockery/blob/master/library/Mockery/Generator/S= tringManipulation/Pass/MethodDefinitionPass.php#L151 = = https://github.com/vlucas/phpdotenv/blob/master/tests/Dotenv/DotenvTest.ph= p#L251 = = https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/PSR= 12/Tests/Classes/ClassInstantiationUnitTest.inc#L34-L38 = https://github.com/kanaka/mal/blob/master/impls/php/interop.php#L19 = = https://github.com/moodle/moodle/blob/master/mod/data/tests/lib_test.php#L= 1293 = = https://github.com/moodle/moodle/blob/master/mod/data/tests/generator_test= .php?L105#L104 = = https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/tests/Fixer/Funct= ionNotation/StaticLambdaFixerTest.php#L236 = = https://github.com/phpipam/phpipam/blob/master/functions/PEAR/Net/Ping.php= #L284 = = https://github.com/api-platform/core/blob/main/src/Core/Annotation/ApiProp= erty.php#L154-L159 = = https://github.com/wp-cli/wp-cli/blob/master/php/WP_CLI/Runner.php#L1285-L= 1287 = = https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/classes/Dat= abase/Qbe.php#L878-L879 = = https://github.com/PrestaShop/PrestaShop/blob/develop/classes/SpecificPric= e.php#L474 = > Using arrays is a compatible replacement as far as I know, and I = highly doubt these kinds of hacks are necessary. "Necessary" is a judgement call. If you never do meta-programming in = PHP then these _techniques_ =E2=80=94 calling them "hacks" is a bit = incendiary =E2=80=94 would not ever seem necessary.=20 However if a developer does work on projects that by-requirement = leverage meta-programming then variable variables are a tool in one's = toolkit that one would be hobbled without. An area where I have seen them required is in theming where the CMS or = plugin vendor wants to make it easier on the themer by creating = dynamically-named variables in scope and then including a PHP file = intended to be used as a template, and the in other functions being able = to access those dynamically-named variables. Other areas are in developer tools written in PHP for PHP developers. That said, are you objecting to the "variable variable" syntax, or more = broadly to the ability to access the value of a variable given its name = (as a new function could provide)? -Mike P.S. BTW, I agree that if a developer can avoid variable variables there = would be doing themselves and future maintainers a big favor. I am only = commenting because in rare cases variable variables provide a capability = that you cannot achieved another way. But if PHP provides that other = way by way of a function then the only concern is BC breakage for those = who have used the technique. --Apple-Mail=_D1894B2D-5F73-4D26-8CA2-8124FB87738A--