Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118417 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77748 invoked from network); 11 Aug 2022 16:49:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Aug 2022 16:49:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A00301804BA for ; Thu, 11 Aug 2022 11:51:21 -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,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, 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-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 ; Thu, 11 Aug 2022 11:51:20 -0700 (PDT) Received: by mail-ej1-f46.google.com with SMTP id kb8so35059124ejc.4 for ; Thu, 11 Aug 2022 11:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc; bh=C1/FzrYFD7slKxvUBcsoLNLudKt6d8mcYhTfdolFTfY=; b=oXn1TeT+HOvWu0mrDJSGGFnd972ddP6oNnh40gNi56Wchz30qd8pPiVahYIqf74hFu erRLXMDCOyDwcd0Lt4XpVqXjtuC0Ho2sHDyAymy1Ab74qs9GzmgGyCYDhFGFtHQlsIhG uKimPEF3OMham38zDr1msCgVPnF5+t3Y+jOfDgSjHlZXLe62aRcx+GSXRDhxrsFdDKKB tHAlBRPlrKTPeOxZ3Pi9R8m58xr5FEPSTWgI/zxmhAH+tr5mUPEqqp/x18qfTx53vePi m9Ug6RJwQc8F8l184L9/7XzLWx5JlMvm5UtUzj61YHUMykK3FR3tPjsLUC50nAy6Uqdt x3Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc; bh=C1/FzrYFD7slKxvUBcsoLNLudKt6d8mcYhTfdolFTfY=; b=nrbkxZeUtM1XVqrqzCQeGx3Va5UaDFLAcCRuXHDC6K4xwtM1c3KdeqbajfK1l3h4d9 ENFMpAKHK2kDxyupJXXfABrUm81gWscdwX5cG3ONM550Z+s5RfcefJRGKbWtnFAKySig XoUHGVS144dwcCRk0F4ZRomNA4aH6a5KQamGYi+wDgbn9NFczAZuMHpwSFcmhFqla16v WLokFvCY7Vt6iFeplKrGAFWSJgluHCeVqHEDBLfvu1vSwxl/06+Gc+p54BkKWVM5RIB9 6oWzqZeLnAEFcPT7K/VTWTtL8e23n5vxhyPR8lsYQ3h0iLUDpkyg7P6vZYwQHy33d9ed uOUQ== X-Gm-Message-State: ACgBeo3ejGow/nBxDzgtd+AqurBngcEozLvR9COwZVgF1hkqfvoGu2z4 Nfl8vEP2HhzaAiAcUZErGd12Y+gTp0+VH6m+ X-Google-Smtp-Source: AA6agR52kciK3tlReWW2B1lKlZY8QhtIaHv2Wbt1NwWI3yGwbRzZeSYEs8Fr/iFJKYyji9QQnmcAYQ== X-Received: by 2002:a17:906:58d1:b0:733:f:a0ee with SMTP id e17-20020a17090658d100b00733000fa0eemr297511ejs.368.1660243879657; Thu, 11 Aug 2022 11:51:19 -0700 (PDT) Received: from smtpclient.apple ([93.175.202.231]) by smtp.gmail.com with ESMTPSA id 8-20020a170906318800b00730223dc5c0sm3747947ejy.206.2022.08.11.11.51.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Aug 2022 11:51:17 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) In-Reply-To: <69767A9B-B336-49AC-8932-C895DB3B373D@cschneid.com> Date: Thu, 11 Aug 2022 21:51:16 +0300 Cc: PHP Developers Mailing List Content-Transfer-Encoding: quoted-printable Message-ID: <6717F20F-D27A-4BF7-8C59-71126B1D1F50@gmail.com> References: <62f48769.250a0220.37387.53b5SMTPIN_ADDED_MISSING@mx.google.com> <01D4987C-FD37-4BD2-A1AC-DD10F808F248@gmail.com> <69767A9B-B336-49AC-8932-C895DB3B373D@cschneid.com> To: Christian Schneider X-Mailer: Apple Mail (2.3696.100.31) Subject: Re: [PHP-DEV] [Concept] Extension methods From: autaut03@gmail.com (Alex Wells) > On 11 Aug 2022, at 17:25, Christian Schneider = wrote: >=20 > Am 11.08.2022 um 11:03 schrieb Alex Wells : >> That=E2=80=99s just a concept. I=E2=80=99d love to bring a lot more = examples in an RFC if there=E2=80=99s more positive than negative = feedback. Again, I=E2=80=99m more looking for feedback than trying to = convince someone, but I=E2=80=99ll showcase a couple real comparisons = for some context: >>=20 >> Compere these (copied from real world project/public composer = packages): >> ```php >> $className =3D Str::studly(implode('_', array_slice(explode('_', = $file->getName()), 4))); >> // vs >> $className =3D = $file->getName()->explode(=E2=80=98_=E2=80=99)->slice(4)->implode(=E2=80=98= _=E2=80=99)->studly(); >=20 > This reminds me of the proposed (but declined) pipe operator > https://wiki.php.net/rfc/pipe-operator-v2 > but I'd still prefer to have it as a generic operator instead of using = a pseudo-OO approach for this. > I say pseudo-OO because not everything in PHP is an object plus using = the -> syntax IMHO muddies the water. >=20 > Regards, > - Chris >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >=20 The pipe operator RFC has actually been mentioned before; the short = takeway is: pipe operator works and has a benefit of using existing = functions. The downside is that those are still functions, not methods, = meaning you=E2=80=99ll still be left with `[your_type]_` prefixes for = all function names, unlike extension methods, where you can have = multiple methods with the same name (for different types). Regarding the `->` syntax, I agree it looks confusing at first. This is = the way it looks in the aforementioned languages (all of which use dot = as member access operator): ``` =E2=80=9C42=E2=80=9D.toInt() // kotlin =E2=80=9942=E2=80=99.parseInt() // dart =E2=80=9C42=E2=80=9D.ParseInt() // c# ```=