Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125355 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 6419F1A00BD for ; Fri, 30 Aug 2024 07:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1725003523; bh=ExiGFlJrtNYzRXAisFA38JhMKRrIme86LpH1s5Qe3Po=; h=From:Date:Subject:To:From; b=H0M8Goq6s103mWC6BENaIwgGGYFjjoBZdJ4RKUkX1wDhNPrft3EJ7VutquNOrC66O a2Lbpa/QcQ9R6STLc/Jmcm1WBARo6XtFmIPlp4cwWUjBtmQv25pxxOCLSqpFVuRycl 83jZYLcON6s6r3ALjmMDXBjNI4kCD7yWOz0MOf5vc98jzkHbosnn8C3TY1tj2/lFLy VCunrS/RV6JiCZk3zhsLnXuOiEM18oje6XRbr39F2gHbHalnSyIrUDRh+m4KxDaEpX 3m2Y2kTlzlfqgImAtV6wsYIyar/JPW8XihTfqA7IZYdkpMjPKtsdDOY9S249Sp8l4S eFF+62PTgrDag== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DCE8E180059 for ; Fri, 30 Aug 2024 07:38:42 +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_MISSING,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-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 ; Fri, 30 Aug 2024 07:38:42 +0000 (UTC) Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3df04cf5135so796577b6e.1 for ; Fri, 30 Aug 2024 00:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sensational.ch; s=google; t=1725003406; x=1725608206; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=ExiGFlJrtNYzRXAisFA38JhMKRrIme86LpH1s5Qe3Po=; b=Pvdq/okBNF5JEGBOY6vJQKTbUJAaOVg1NTecMmybeUoRSVpduRB8OuUSER2yO0PfzG 1shuZevoFI/Ct602L110QAmrg11jQahBUEwGQtWVIC9YJNkhXOdEmcmg94vaAVfud6P0 BdZTJzO3XMqhD1fR3es1Kdm6J1EO/ClzANj2G8MPjJpoiQm5xncSZcRruGKdgHwvY9se kEJWh+gyqULca+ASt+Q37/ixR5NYF1baoaz4vDCvnN4htL5zI3G0+jFSJiZn0kDvoE5G dTYrvycmk/h7PrC2eeaqFRasFzXAAr1e07yPna7wOgcsidOZauPSz7fSsBOcUcIqR387 /ByA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725003406; x=1725608206; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ExiGFlJrtNYzRXAisFA38JhMKRrIme86LpH1s5Qe3Po=; b=pc2XGqVJYprh3yh0rYzrWvH0MoHNIEwD0eQlcosHhmB7kJ3oA2FWXw2NOOPSZsXG1G PRCgoiug5MaEdqXdGNhRYXPuzgfCc1HKJC8Los239kJIrLLVz3rlBd5fqLVSYaHFpTRS Pi2b4qhkaWbS8eBtQzLd7wKP+8iyZAi0b4X/RYc6uUc+vEyNDIYazg8PYK3q1XjHLYPB kcxQmB2ZP1H2Jwol5pB30uyOzr47DZx9udIzlKBV+v/RLp6IR/h5ihdtMCHzX/GOZHZH jKyUHQxK/EDtyU/dxeRFrREj7KqDGutalI4BUyrbzo7sfr5zulQ4k5a/67DRoBDHc7Ap twMg== X-Gm-Message-State: AOJu0YzVTx3nv4MHWF448out40IaxvnNDIqwbQu+S2rJe5zXKA4caZHF P5V7oY5+sfaPucuOnFTvfcmHSvJ6CRsrwpjbAx0RCytXvSaj6JeolKwdK1DanHMQm5aWiM+6BuL jExlXJbCoMatTuWBcGKOKgfAzfKR/utwYceH/5bbal+fbJzgJ X-Google-Smtp-Source: AGHT+IGtemDQzdAEFx0INzjZW9Ag2oGnjs05vi0GwOQYcuO+Nd93yEkPNzxLyWwHX2fcecN4pgkFPhF3Pz0kMVkGHO8= X-Received: by 2002:a05:6808:1242:b0:3dd:32b3:75c5 with SMTP id 5614622812f47-3df05d8338cmr5448112b6e.25.1725003406603; Fri, 30 Aug 2024 00:36:46 -0700 (PDT) Received: from 1064022179695 named unknown by gmailapi.google.com with HTTPREST; Fri, 30 Aug 2024 00:36:45 -0700 Received: from 1064022179695 named unknown by gmailapi.google.com with HTTPREST; Fri, 30 Aug 2024 00:36:42 -0700 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 (Mimestream 1.3.8) Date: Fri, 30 Aug 2024 00:36:45 -0700 Message-ID: Subject: [PHP-DEV] json_encode() and Generators / RFC Karma To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000004994360620e1a7b8" From: phofstetter@sensational.ch (Philip Hofstetter) --0000000000004994360620e1a7b8 Content-Type: text/plain; charset="UTF-8" Hello, In the aftermath of an internal refactoring of an internal code-base to turn something eager into something more lazy using Generators, it occurred to me that while PHP refuses to serialize() a Generator, accidentally running json_encode() over a Generator produces the worst possible result: It silently encodes generators as {}. I would like to write an RFC to first deprecating and later disallowing to json_encode Generators. If you think this is a worthwhile thing to do an RFC for, I would kindly ask for somebody to grant me RFC karma, so I can start working on one. Regards Philip --0000000000004994360620e1a7b8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

In the aftermath of an internal refactoring of an internal code= -base to turn something eager into something more lazy using Generators, it= occurred to me that while PHP refuses to serialize() a Generator, accident= ally running json_encode() over a Generator produces the worst possible res= ult:

It silently encodes g= enerators as {}.

I would l= ike to write an RFC to first deprecating and later disallowing to json_enco= de Generators.

If you thin= k this is a worthwhile thing to do an RFC for, I would kindly ask for someb= ody to grant me RFC karma, so I can start working on one.

Regards

Philip
--0000000000004994360620e1a7b8--