Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125363 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 0F9CE1A00BD for ; Fri, 30 Aug 2024 14:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1725029393; bh=0MIgUbmZZA3a3x59vcdRyhNBQmsruR7gOds/A5XT/mU=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=B3o1fPRqcuwrjLWg6wGyHnIxP83ktCDBPEkuPtoDLFTeBfqGOSoGAcFZEMJRtZToi dpyXMIdRo+b/g4twRGG/Ukv0hUAxLzfYUtcX8sI4E+XnTYByXtBImO2gkc2ruzTY7b lP/BDcV5FuEQyE/C4n8ao2EpGoCFerWPVDUdQ6YQrWhZDETtxdY9uU0DHOrZJ0c0EG bG0zUfA58pMrmS0/j2MBSTJ29oGZxq2nlEj+XC4OikB0l7W9fMzcW9wJoQohqY7xHh PgE2N5/qT2e98YX7N/wT3W1SOahZgkXO/2PpKTR90KOV93m2F83FwZ6e4fJdXiYJ0b vQzYONsr9qbVw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2A504180032 for ; Fri, 30 Aug 2024 14:49:53 +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, 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-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 14:49:52 +0000 (UTC) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2f3f0bdbcd9so22488201fa.1 for ; Fri, 30 Aug 2024 07:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725029276; x=1725634076; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0MIgUbmZZA3a3x59vcdRyhNBQmsruR7gOds/A5XT/mU=; b=TQwb9ZVfNRlXdh5B2w/KxtUJPjvHn4A/3yBudG3draD4Q8Mv76r5BzdPcWunPtGWsI CWgjNjnuvBSxE7w1ILcrrHP/lbdLkKkiPztn1GD7ZkujFk/gkZ35zIU+VA1L+L4vB3W7 FF1Ld6xUnDg5nY137J3mXrfGOOOMngEvHUhMLD/qqcXmFUdR5KcvCDlZ4VM7qrUk66XH PIkZkEKMJ6+3k0yV537BeU2iti9R6J1YCd4p9T/B9oUKuaxi9qWCMUaiqadVpZ2W3og0 voXCfmhkdNloaCbw2aPPz8Kr0GJsbNKVJMssnNHt0sXwRgiWkFkI82CaMPmIDZ0L1NbC bGPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725029276; x=1725634076; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0MIgUbmZZA3a3x59vcdRyhNBQmsruR7gOds/A5XT/mU=; b=asiedJA4QW4UOL/HoL3RYJjGW315w5QWym4acra/2V+q4TFH5W32hxzTkoxFJV+6nN nyWNZyaUc6X2EgZqG6cQx9kYYgR9wHUMSnjcRTsNBNboDKSkZ8+APf3cJ7KRhrdZfHiW C2HLnWN8klpHI3PN5lRK9wOgSGhWoR7yYnhwpAjcVCuk79wFXXiamuW+RSvmVzKkntVq eZyYBVu6yq1TjlEvPzzTVtI9ZFOnmZ2QXjl1p++qPyDxCspcTRC0hokrEZpWl1cufifq XAdMZEHM/VnwMXs+MFYUUhue4XemLnBtEk0tA1oXkg/w8/HTKoRawgfWFqod1LQZhz4B DDpw== X-Gm-Message-State: AOJu0Yzz/DBA7noQp4OwFBnrLRncWBRA3ubPLUnnhuJl5un8KQJqArBB en5As45scxXsaZ2SPX1kQf9tk5CnP9ZGCsGeLh7EQ0XNXEm2otYhcS7rMQ== X-Google-Smtp-Source: AGHT+IEmmtmbDhkhnUMw7Qu7wxiJSyTTXcQRDFDsV5xfGRkooGZLdLMeXkjxBjPy0lNFadnSZydJgw== X-Received: by 2002:a05:651c:95:b0:2ef:2ef5:ae98 with SMTP id 38308e7fff4ca-2f6104cec7emr37030451fa.34.1725029275421; Fri, 30 Aug 2024 07:47:55 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c226c6a3c2sm2001769a12.9.2024.08.30.07.47.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Aug 2024 07:47:54 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: [PHP-DEV] json_encode() and Generators / RFC Karma In-Reply-To: Date: Fri, 30 Aug 2024 16:47:43 +0200 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <783E4F90-4823-4224-B45C-E9D6EFC4479F@gmail.com> References: To: Philip Hofstetter X-Mailer: Apple Mail (2.3776.700.51) From: claude.pache@gmail.com (Claude Pache) > Le 30 ao=C3=BBt 2024 =C3=A0 09:36, Philip Hofstetter = a =C3=A9crit : >=20 > Hello, >=20 > 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: >=20 > It silently encodes generators as {}. >=20 > I would like to write an RFC to first deprecating and later = disallowing to json_encode Generators. >=20 Hi, Note that the issue is not limited to Generators. For instance a Closure = object is also json-encodable but not serialisable. IMO, every internal class (not just Generator) that is marked as = non-serialisable, should also be non-json-encodable. =E2=80=94Claude