Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127541 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 79DD01A00BC for ; Mon, 2 Jun 2025 20:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748896793; bh=qJwGZ62CoufQStBvSVMwDAB8j8uURmcteyExoJn20NM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=bYV6hCsPJTQLyIxeK4ZpvjeBJ4pEou9oLWHRbp+Ub9SqtGS6DTJaaALHzj5FxMPKo M+s6vlIiJu0JTiCzdSPjuh5EhkveOfdGZNlIUo7qVF4JTzQRBDg+07y4PJRalvv3EV WOy31zZ6T5R0DU8KAbn4Vf1MmVYG5B64bfat8RxFn1dO1FKlCr7HoEEWvQfR0TLj0o z4VNGGsM70MXclnRfiAj67qM05ez63M44mi+UhiXDrfruFJ3/x/G7NKjPrzCQRZEsC a+GJIMEPLf9OsnDtMk055pYolj1186KuHU1J/3r4ZOBGOboU4siMn82ytqluzkbBZ1 Y//7YM/bdYOOA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0F3C018006C for ; Mon, 2 Jun 2025 20:39:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 ; Mon, 2 Jun 2025 20:39:52 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-b26f7d2c1f1so4603629a12.0 for ; Mon, 02 Jun 2025 13:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748896916; x=1749501716; 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=P4358xDFOQWhDtk9Nbj3gYtoS0WF842o2a7V5LXeekA=; b=P1jzmgBHtZe22+JpMIIYFq9pTL0vsApbkFMXvTIkkDsUBSwXnXVbG0EALpvS6TovN7 ilRN8GeLWXHCu6rxH3c7A596RfeUfLvsGEMVwBobptlDJ7LIgp+Op+zlBhtRdFgbbwGD e1OsOjQ51b2Tch6fMLP3GFixZrYmrYtjnwYWAIt2u9VUxbXray5kBq77zCVxEk/+wboT 8ZAU/hb5C9Qf2qqGDcamLTQ7iJ1gAdER9OjwDqX8/5RVlxt2/H1gCDvz0VTLNy7x6eFj MrN8aoV/mCu+S21LmqQLCerMLIK+K2FxIgwHF8FUWNiw+60XzbK1ACpAMhotiiZ8SNyB ohGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748896916; x=1749501716; 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=P4358xDFOQWhDtk9Nbj3gYtoS0WF842o2a7V5LXeekA=; b=kC7RIZ257RHsMKMURrUWH29fb+F6L6qVI09uEvFEhFnKzmO+pIYbKqSMUlNkcNI2cT GoqiJNMzN8XVzAeKN5y5pByfDl17TMuOzyHHbSGyJTxxFNarWGPLHf1WblFeKFZlqinv GwsgmrKgUAT8CkAn/CG9FcvUUpXT4LrYZ1qFeTEh/n58g+cmCNE5d6ysnI+n9bWM9S7W MnaTfZR5lhCO39xrq/uXgWaFAMM4F4ahsECrKXq9noOComT37SaMgVPGc1rxUAWhUx+K LggPewZ8NSCoj2WJNYWWPJ1+mZ1OGpd/Kq4euELUUVQhYS34itSG5KrPj8DZZhQqYEwb n/ww== X-Gm-Message-State: AOJu0YwlaVAD9DBKXm95iaqJO0vyhPx85km4xAdmihZyPWLT+/8Raetd a+IPQ/LRuY9eSuD0EAEU9JoH1NkeSZWC58/tc7FM6eAk/oKVrPc2Guz0kQ8Pofeb6Rd1PqTfyhw bkN1e2SPSwAt6qEAJ3jC2u+UoKfMJmsQqXDGR5q0= X-Gm-Gg: ASbGnctNuSOsenea6+zAuQ+mUeokEN1YExbNR2S44V65H4mqcB2xbONJyZbWkGKKhLC LnnI7J33hDsCW7K9wAyt7frsXSlyysmKpH7vLghBWgjJTM2OaFGagTUPuWA7kCsb2DtDlSTR/Bc 2PCD9Wi55PzkwpOcw7p9o9t8v5CJ8teHV25Q== X-Google-Smtp-Source: AGHT+IH0BKrB+IWeLPl5OMtW2gQ0LZFQj0IVH+/F16H3wcbml+ZejqLa5mgnu6DuOfRT/fojYDoYd4fSTjhTWFS88rM= X-Received: by 2002:a17:90a:d450:b0:311:ffe8:20e6 with SMTP id 98e67ed59e1d1-31250344809mr17781003a91.3.1748896916039; Mon, 02 Jun 2025 13:41:56 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 2 Jun 2025 23:41:44 +0300 X-Gm-Features: AX0GCFs8jJnsAadRySDum0Xx_s86NOhxrm4u6yj6DhNlxlb0ahJkDR8B8M3YIas Message-ID: Subject: Re: [PHP-DEV] [RFC] Pipe Operator (again) To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000006dedc906369ccbba" From: xepozzd@gmail.com (Dmitry Derepko) --0000000000006dedc906369ccbba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Larry! It's been a long, long way to get this feature, awesome work. Have you considered adding a compose function that does the same thing but in the classic PHP function style? There's not much difference between the new style: $processor =3D fn ($data) =3D> htmlentities($data) |> str_split(...), |> fn($x) =3D> array_map(strtoupper(...), $x), |> fn($x) =3D> array_filter($x, fn($v) =3D> $v !=3D 'O=E2=80=99); and the old one: $processor =3D compose( htmlentities(...), str_split(...), fn ($x) =3D> array_map(strtoupper(...), $x), fn ($x) =3D> array_filter($x, fn ($v) =3D> $v !=3D 'O'), ); But the classic looks better when you create real pipes. I=E2=80=99ve created examples with comparison. https://3v4l.org/jY0Vg https://3v4l.org/87Sj2 https://3v4l.org/4EE6b New syntax just makes code shorter, but the compose function still have benefits: - it will be able to add a polyfill for older versions - it will be possible to write the first function without passing the first argument ($data in the "fn ($data) =3D> htmlentities($data)=E2=80=9D) - it will be possible to re-use the compose function along with the new operator $data |> compose(=E2=80=A6$functions) ---------- Best regards, Dmitrii Derepko. @xepozz --0000000000006dedc906369ccbba Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi La= rry!


It= 9;s been a long, long way to get this feature, awesome work.


Have = you considered adding a compose function that does the same thing but in th= e classic PHP function style?


There= 's not much difference between the new style:



$proc= essor =3D fn ($data) =3D> htmlentities($data)

=C2=A0 =C2=A0 |> str_split= (...),

=C2=A0 =C2=A0 =C2=A0 =C2=A0 |= > fn($x) =3D> array_map(strtoupper(...), $x),

=C2=A0 =C2=A0 =C2=A0 =C2=A0 |= > fn($x) =3D> array_filter($x, fn($v) =3D> $v !=3D 'O=E2=80=99= );


and t= he old one:


$proc= essor =3D compose(

=C2=A0 =C2=A0 htmlentities(..= .),

=C2=A0 =C2=A0 str_split(...),=

=C2=A0 =C2=A0 fn ($x) =3D>= array_map(strtoupper(...), $x),

=C2=A0 =C2=A0 fn ($x) =3D>= array_filter($x, fn ($v) =3D> $v !=3D 'O'),

);


But t= he classic looks better when you create real pipes.=C2=A0


I=E2= =80=99ve created examples with comparison.


https://3v4l.org/jY0Vg

https://3v4l.org/87Sj2

https://3v4l.org/4EE6b



New s= yntax just makes code shorter, but the compose function still have benefits= :

- it = will be able to add a polyfill for older versions

- it = will be possible to write the first function without passing the first argu= ment ($data in the "fn ($data) =3D> htmlentities($data)=E2=80=9D)

- it = will be possible to re-use the compose function along with the new operator= $data |> compose(=E2=80=A6$functions)


-----= -----


Best = regards,

Dmitr= ii Derepko.

@xepo= zz

--0000000000006dedc906369ccbba--