Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126441 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 8E8261A00BC for ; Tue, 18 Feb 2025 11:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739878058; bh=wyzFaPteTQo2FUKWT/9mYuYoQMYgIDfJ1yv2yLTdCFA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fXt/KpgUE+G8Ph+zwiUOA6s3hz6rIcq6ROdsnMKchwXIk2S6xqQiIbhsg+YPl54Tu 9FfKU4Xf0weUa5uxmxeh2QGzPtkdVlzffLGgwS5dfUvs5XpcJfn9Md3IpOLKzpFu2Z M9ZGWZThbU98aAnIwqQZ4ftV/wYBkdTrNquY5t/wVVr8AO3m4TgxQG4YjBqEKFg3G3 v+BT+4zgYaOyzkSV1wecef+zuSLR2gDcdfxDczn5EXoD8Ua8Rp4YbgUjsrzWoLm7Ov y/n9oNoRoS0ro1Rd3TgtcbYcjcJJMt5p6cbxefitVKpdp5FGdfR8Fc1moyRhm5sgNe V5DbIlCmmgI8A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9A4D918006D for ; Tue, 18 Feb 2025 11:27:37 +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.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Tue, 18 Feb 2025 11:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1739878216; bh=s7lFVTVbmwln2FJleShk4BN3lY2nCEulqxNK3Diqc0E=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=S00sXxS+GqWAE+kqrTW6mJVFjkOaO/Mk39+netIJhGN4CSJDEoQhR6hgaxp9BFZyi Dm4GczMAGjUGXVN9PJtObiphDElZMP2NmQPdxYvSjcshRalAHVgBKADAcjTmCidYxs XZJ8VFcpnQxe8IP6pY03PoFet8jZJHmIynIWH/omgUiakhTo/GMYNbU4+6ehtJNgbK lkXZHqHm3EtTDEGL/42Bj9R18VIRbZ4ctrsVkkBYxhlEBZCGvZL+YTAJJB3BIjaF0I 2zOTTjpH5toA64O6HnjYwwFro4VZ6HIDNp0ze7x5oKw06veEuh2GC5LVO3ZhQs1tmc 6j7esThHbQgcw== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 18 Feb 2025 12:30:16 +0100 To: Jordi Boggiano Cc: Internals Subject: Re: [PHP-DEV] [RFC] Modern Compression (zstd, brotli) In-Reply-To: <528e16e1-1fb3-448a-b187-7cc84e1bcc4a@seld.be> References: <528e16e1-1fb3-448a-b187-7cc84e1bcc4a@seld.be> Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-02-18 11:19, schrieb Jordi Boggiano: > Thanks for your consideration, we're looking forward to hearing your > feedback! The RFC specifies that: > The zstd implementation includes a few global functions as well as > namespaced ones My question is: Why? Please also have a look at: https://github.com/php/policies/blob/main/coding-standards-and-naming.rst#namespaces. Instead of creating a top-level namespace for both Brotli and Zstd it would probably make sense to create a new “Compression” extension that could also include a new and improved gzip (and bz2) API as a follow-up. The new ext/random could probably serve as an API example. > function compress_add( resource $context, […] Please do not add new resources. It would probably also make sense to consider making this a proper OO API instead of resource objects that are processed by free-standing functions. ----- Both parts combined could then result in something like: ``` namespace Compression\Zstd; class Compressor implements \Compression\Compressor { } $file = fopen('file.txt', 'r'); $file2 = fopen('file.txt.zstd', 'w'); $decompressor = new Decompressor(); while (!feof($file)) { fwrite($file2, $decompressor->push(fread($file))); } ``` Best regards Tim Düsterhus