Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124291 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 7822B1A009C for ; Mon, 8 Jul 2024 16:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720454698; bh=BVZbsNj3u62tZU1H72+t5lSXd8ceRzlInv9+kKPJK+Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=P9JmN6U+TiiFlg1MgAg16kkd9G8EDHvb8Bf/Z8LMP3g8rCxqw0dbp2e2QUevA/J8X 24oxV9v9gx0RXeH8zn0g6k6qPHDwZmuITiaDLwy01YvXSo3uySlPfaMCgFsKTaPWhV o3Z3cCPSXpX0WE3DuBv6ike0q8mM4Ih5REpvxf2POEagoPF0wRjsJAFQvdhklUNqiQ H6L/XnLYfDFUBWSlGh0FsGit+0eTboobbsoGpLPu/23a1Ip9BiHUQkJueUGrY2O0rp 6LV1huiCd22UCTbsGiF5S0skgq6IzkozKXWn6ZyXLANHin31uCZGh13ZfE5biaLgQS UTWIbvgK5hPBQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 72B1B1801ED for ; Mon, 8 Jul 2024 16:04:57 +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.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_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (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, 8 Jul 2024 16:04:57 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e02c4983bfaso4219877276.2 for ; Mon, 08 Jul 2024 09:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720454611; x=1721059411; 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=5iGlN+O2VNhSgKKQXrnZWFWNMe25oBGez08WgyoDeOQ=; b=OUFs61CgepD7ey8+FGQ3xOqIsM5l3e8ZDxYBKfCWGhRuunh+YWVrMEYLLKFc6TVVQz /LU95asj+IQy5vknMnsUhQ6J8WWuPWOW08576bEGsWq2iCscVPFXkoMFf0zNEAV9E6IM DSKp//PfV1GpS2FfSNcCMYBBfnpA+krL9GqQ7PdxO2rJQK/sCOvPUiFzW1vU/09BFXR/ AqpQRWXUZwIf48z0tv5at9sfSTqxj44xq24iH+jBVjRxJxTBn9IgQNHIS4jLVsYFZMV7 V97ZfYSrTGgYQEsBzPvVl7ZGr5eVW2iLt8pD5vJ286+l0Ni3UocFrkPj8b4dTwnYpVwr 29Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720454611; x=1721059411; 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=5iGlN+O2VNhSgKKQXrnZWFWNMe25oBGez08WgyoDeOQ=; b=bVaWtlayI9mQbtZf93JY95Tnf1jz+rfv1HfxVyQGxDnBMOV1PvEQpawaBgrmqaHsrO 4DH5K1nDwnljeI8le6ZDa4KiEKjLdiL2T8wYkD8H/0tbMNE+Wmx0DQbkJ9J1UvXizbAM XXyVW1TE6NYe2S6qDbeuZ0RaB96Io20oxFeuRHaB4Ll0D5LcUaIU+YJztezbdGTn/SwI fkS/iBXPf5MkNtE6Efm8YMBcoGEURXi9d8KlYwqL4iigTJqQ6FiVT3TJDCB4eW/tIrj2 Oiaroh7xZHELnr+AH1Cq4f1Quaeqt4gMP/0LZ2Q8F8CIY/1VIZSpS8sz3EBMj9d8EsJQ C8ag== X-Forwarded-Encrypted: i=1; AJvYcCXgKiTMAS+lG/XEFBAb44kHDjnujIN2RMT8eK7lzGwiNwHD99TgCJQ9DhX7TxgDDA1AiajKow0wqgd9OCUCg2FxHgTDPqxK3Q== X-Gm-Message-State: AOJu0Yzb9xgOae/TGlZoZt4PAl4zwR+qdG36HqFJ10jaXe+3cZufqGfx IzQwrtnjY+I2CUcxfFYQxmPiIBeU0y/00tCFEiql4/tSWodekqhICGR5sTbFVngrBEqZTzanALg a0jsO2nPUOtEvlpc+h0JsEIaW1e0= X-Google-Smtp-Source: AGHT+IEoEjJHRtDRRpW/MhPuflMtFa0ARvxSPReXNRH7OO1Ek33n6dm0HMNXAdCweSrKdWD7U1tpttb/M8k0nceZ5yw= X-Received: by 2002:a25:6911:0:b0:dfb:2ba4:91d with SMTP id 3f1490d57ef6-e041b0965c0mr184393276.17.1720454611544; Mon, 08 Jul 2024 09:03:31 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <76838718-E108-4A08-A88F-4965FB81E52C@gmail.com> In-Reply-To: Date: Mon, 8 Jul 2024 19:03:13 +0300 Message-ID: Subject: Re: [PHP-DEV] [RFC] Deprecations for PHP 8.4 To: Mike Schinkel Cc: Claude Pache , "Gina P. Banyard" , PHP internals Content-Type: multipart/alternative; boundary="000000000000f9324c061cbe8d4e" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000f9324c061cbe8d4e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jul 8, 2024 at 6:43=E2=80=AFPM Alexandru P=C4=83tr=C4=83nescu wrote: > > I'm hoping this can be simplified further, but to get to the point, I als= o > think we should have a userland replacement suggestion in the RFC. > > Managed to simplify it like this and I find it reasonable enough: function strtok2(string $string, ?string $token =3D null): string|false { static $tokenGenerator =3D null; if ($token) { $tokenGenerator =3D (function(string $characters) use ($string): \Generator { $pos =3D 0; while (true) { $pos +=3D \strspn($string, $characters, $pos); $len =3D \strcspn($string, $characters, $pos); if ($len =3D=3D=3D 0) return; $token =3D \substr($string, $pos, $len); $characters =3D yield $token; $pos +=3D $len; } })($token); return $tokenGenerator->current() ?? false; } return $tokenGenerator?->send($string) ?? false; } Alex --000000000000f9324c061cbe8d4e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Mon, Jul 8, 2024 at 6:43=E2=80=AFPM Al= exandru P=C4=83tr=C4=83nescu <drea= lecs@gmail.com> wrote:

I'm hoping this=C2=A0ca= n be simplified further, but to get to the point, I also think we should ha= ve a userland replacement suggestion in the RFC.


Managed to simplify it like this= and I find it reasonable enough:
function strtok2(strin=
g $string, ?string $tok=
en =3D null): string|=
false {
static $tokenGenerator =3D null;
if ($token) {
= $tokenGenerator =3D (function(string $characters) use ($string): \Generator {
$pos =3D 0<= /span>;
while (true
) {
$pos +=3D \strspn($string, $characters, $pos);
= $len =3D \= strcspn($string, $characters, $pos);
= if ($len =3D=3D=3D 0)
return;
$token =3D \substr($string, $pos<= /span>, $len);
= $characters =3D yield $token<= /span>;
$pos += =3D $len;
}
= })($token);
return
$tokenGenerator->current= () ?? false;
}
= return $tokenGenerator?->send($string) ?? false;
}
Alex=
--000000000000f9324c061cbe8d4e--