Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122150 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23938 invoked from network); 13 Jan 2024 16:04:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Jan 2024 16:04:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1705161921; bh=mtiUv5lYLRlKwVsQ3CqaSW8DK0MBNayrURmBzX7S/lo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DwTKHaAO0xZP7t3b4qWaQGE9PqwQFgDH7/BQLJLC3ksvmrdOSsZSh/71REWfIT3yC xt4GaYch3jexUHzDkrOTpCX2w+zSzwxsbYH8gp8veQQGTZ47aQwEXWPcYnjSe7Qp2c dkc2l2ZCeLMi3Z7mBIReYlHJ5bs/IlNOpKJdQt/Q1VSzILEpxnvUDSqJxBFjZCDl0d FuroShS9+jSuyxE7mJAa8fUJfAAEcbUVcpEByofL0aNEM3y5CMl+SiXbfAGFV5CA2q KwrghprfGQ8IOW3sK3LFgUdHepMrDlsgBVT7bo236UbpqHy1xTh3s2dPHLhlD1nmcM IhjvA+ie5bvAQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4DB2E180058 for ; Sat, 13 Jan 2024 08:05:20 -0800 (PST) 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.9 required=5.0 tests=BAYES_00,DMARC_MISSING, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 ; Sat, 13 Jan 2024 08:05:19 -0800 (PST) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-555f581aed9so8545762a12.3 for ; Sat, 13 Jan 2024 08:04:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705161881; x=1705766681; 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=mtiUv5lYLRlKwVsQ3CqaSW8DK0MBNayrURmBzX7S/lo=; b=NfnokNRd3Nat6uClqHUOwOkzBu1LEyc3tVBHNObOKvR/agDi754XLOqoPrKlXZHWgl maM6P3jSThhDt5BJyrKiAu3uA1kOXg4QGqjBKSbn9jjYDAdwZYoZuhPz4nQA3DGrght0 Ecpk/MiydkAwy+jCGaVVEd5gzeHiIyy9qbKEYv9H+QLtdZeqP8rayXi88T7Y5c+4Oj3w DMX2bTS6bPLXtfJ+CmKURgOm9rmOo8yint4J4Mx2arpez8bM7S0souBhZoZ8RINWuIqf TRuMvM6hhz2Ubltpi9da+kfYBckHm8+G9HbZQg7kQKh0WfCP6lcz7kD6XPAwBLP6dIat mjzw== X-Gm-Message-State: AOJu0Yy1i0zy/oGC7zURQSw8iCs6FUQ608lMbHmlqT8DwGsNS0MfDZIE umUZA4lYIjf+LoyicyNumtkDDPCtAIi7BIOZaHk= X-Google-Smtp-Source: AGHT+IHwbjLoIMKbputyQZeWjrV1Vet8xYqA5JmLx1jvjvJUIGUjjlvL4VEv9C/IACUjsW5AgI3Xoe8v9NCK7cp/KEA= X-Received: by 2002:aa7:d390:0:b0:553:e3f2:3c74 with SMTP id x16-20020aa7d390000000b00553e3f23c74mr1630782edq.38.1705161880987; Sat, 13 Jan 2024 08:04:40 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 13 Jan 2024 16:04:29 +0000 Message-ID: To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000336c17060ed5f0fa" Subject: Re: [PHP-DEV] Dedicated StreamBucket class From: bukka@php.net (Jakub Zelenka) --000000000000336c17060ed5f0fa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Sat, Jan 13, 2024 at 9:29=E2=80=AFAM M=C3=A1t=C3=A9 Kocsis wrote: > Hi Everyone, > > Recently, I realized that the stream_bucket_new() and > stream_bucket_make_writeable() functions > create stdClass instances by dynamically adding a "bucket", a "data" and = a > "datalen" property to it. > > A few days ago, I submitted a PR which makes the above mentioned function= s > return a dedicated StreamBucket class which has these parameters properly > declared (https://github.com/php/php-src/pull/13111/). Furthermore, > stream_bucket_prepend() and stream_bucket_append() would accept objects o= f > this class as their second parameter from now on. Before, they accepted a= ny > kind of objects as long as they had a "bucket" property containing a vali= d > stream. > > I just submitted feedback to the PR but will also mention it here as it's probably more an API thing. The problem that I see is that it combines two distinct things and create quite ugly self reference inside the proposed StreamBucket object. I would prefer we split it and introduce StreamBucketHandle opaque object that will completely replace the current use of bucket resource. The actual StreamBucket could be introduced later (ideally in PHP 9 as it's a sort of breaking change - change of class). > As far as I see, my changes are backward compatible as long as people use > the stream bucket API properly (i.e. create stream buckets via > stream_bucket_new() and stream_bucket_make_writeable()). If they manually > construct such objects (i.e. $bucket =3D new stdClass(); $bucket->bucket = =3D > ....) then obviously, they would start to face type errors. > I think it's more typing issue if someone passes this object for further processing and type hint stdClass. Possibly the pattern above could be used for copying but seems quite unlikely. Still I would see this as a BC break and it is not really related to resource to object migration. > > So my question is whether anyone has any use-case/preexisting code which > falls into the second case? If no one knows about the invalid usage > pattern, my next question would be whether I have to create an RFC for th= is > change? > > If you want to change the API and replace stdClass with StreamBucket, then I think it should have a separate RFC. If you just introduce StreamBucketHandle as suggested, then I think it's already covered by other RFC as it's just a simple resource to object migration. Regards Jakub --000000000000336c17060ed5f0fa--