Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107914 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9431 invoked from network); 16 Dec 2019 11:28:17 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 16 Dec 2019 11:28:17 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 1442F2C7727 for ; Mon, 16 Dec 2019 01:27:55 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: No Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Mon, 16 Dec 2019 01:27:54 -0800 (PST) Received: by mail-lj1-x22c.google.com with SMTP id u17so6003387lja.4 for ; Mon, 16 Dec 2019 01:27:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ejQ+6xVD1iixbB4Py7WJsVt+c3W6a0OP5UgEwYZBX5Q=; b=TLQoPgyGYsHlp5L2npNJq4iHooNAKC6ZafN2+kNTGA0mLPDjrm+oktu9u9oUXppbsP 9UR00iwaNAo8vVieI0gIoGRxJYz5BcmG+CjsiHSvwLMscUxyhypTZtyXmSgRayQFCVoD UDOWVwOFN7ZKGQOLnG6r+zQg8vMg1RqKcOMpS3T2/29+PDqCTTJrysr7m4hW+63Vnw57 RnD0XQhjxlhjYsHi1lV0DN1YMM9j1sB/QgmnQK4C0RelNSQaqHcVBdMFD3C4YnR1Vgei 5LLHWJqb0HvGYZDSqovhIH1AbojJkuoiXUnAGTokOeSsoephd89u32G6pVqyfY1UyIHs ek0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ejQ+6xVD1iixbB4Py7WJsVt+c3W6a0OP5UgEwYZBX5Q=; b=CH25y83lrvrvrCIflA4ZZQOaKByAb0p7dQM/na7/0BhiKV0Jpgff6xzxwL7CYKWSWg CLeCmIgE+JVz9YFL8PVdTq2/7lZwsT7Gg0sgxUiYoNyaUlz0kPjooPYXn5RDQTD6MiKX FjJEiJbzUzolx1U5qEjpGMGXJisZKU6Y9G22EaDTwK6aUH8w+TMa7XYnqHpVUzYSh4Ye /kPicRHCjE9owW03aPJepCF1ZYcD+Q2FSY0b6Zvhb484D/yfijzCim2B7f9HDZM4b846 kMOHX8qZ6a6Xvdp/DWoO6lXLDryK4pqyFynmqQzBNPNHfqjkoaDDmzvOaZlbI/iWn5pt Gicg== X-Gm-Message-State: APjAAAWsZy/nTXCYEMpKXlPzLc0xVrbEojAvxRwAgAoS/bfLm9fdjtw2 2Y955BOk32C1DvXTyzPowgDgIkwq5vgoE8XjJ4I= X-Google-Smtp-Source: APXvYqyVQSwnaU59oYfH5n7++grILXTyoJIhwflzpJXwD4sRzM07cmWm3Nebiz7Ues9RrtWWJx13KYLh0Gp0/i2LTh0= X-Received: by 2002:a2e:9216:: with SMTP id k22mr18755155ljg.52.1576488472580; Mon, 16 Dec 2019 01:27:52 -0800 (PST) MIME-Version: 1.0 References: <1d2d5c23-3864-a202-92a8-34228798510d@birkholz.biz> In-Reply-To: Date: Mon, 16 Dec 2019 10:27:36 +0100 Message-ID: To: Dennis Birkholz Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000006698170599ced34d" X-Envelope-From: Subject: Re: [PHP-DEV] Re: [RFC] Add WeakMap From: nikita.ppv@gmail.com (Nikita Popov) --0000000000006698170599ced34d Content-Type: text/plain; charset="UTF-8" On Mon, Dec 16, 2019 at 10:19 AM Dennis Birkholz wrote: > On 12.12.19 18:13, Nikita Popov wrote: > > On Tue, Dec 10, 2019 at 12:03 PM Dennis Birkholz < > php@dennis.birkholz.biz> > > wrote: > >> But my just want to repeat my main concern: buildin > >> data structures that are not serializable are a real problem for users > >> that use serialization extensively. Maybe the solution to that problem > >> is a method to check whether a provided object graph can be serialized > >> (which may not be possible due to throwing an exception in __sleep() or > >> something like that), some way to ignore unserializable elements or some > >> way to register callback methods to handle unserializable elements. > >> > > > > I'm must be missing something obvious here: Isn't this a reliable way to > > detect whether an object graph is serializable? > > > > try { > > $serialized = serialize($value); > > } catch (\Throwable $e) { > > // not serializable > > } > > Checking whether the serialization process worked is different from > checking beforehand whether an object graph is serializable as it makes > it a lot easier to display a meaningful error message. Something like > the Serializable interface in Java. But that seems to not be the PHP way > so far, I will have to think about an RFC for a second parameter for > serialize() that accepts a callback that can "serialize" > objects/variables that fail to serialize themselves... > Could you please explain in more detail what the practical distinction between checking beforehand and catching an exception is? It seems like the exception should be sufficient to display a meaningful error message -- heck, it already contains an error message you can use. Nikita --0000000000006698170599ced34d--