Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103852 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85897 invoked from network); 27 Jan 2019 19:58:41 -0000 Received: from unknown (HELO mail-oi1-f169.google.com) (209.85.167.169) by pb1.pair.com with SMTP; 27 Jan 2019 19:58:41 -0000 Received: by mail-oi1-f169.google.com with SMTP id u18so11169365oie.10 for ; Sun, 27 Jan 2019 08:37:36 -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=dErvc0pq0zx0YsrOjNxpfc2TOCO5QsjECnfdxxhOELY=; b=nh5Ilpr0VhO//UT0E+PyriqgyJcgJbpINp8nqDp2GV+ppy3mWMvsS4dntAkYG0U/o8 tmhDr+qVoEVQ7dqqaNv9C6t7trctha+aLpon9XSs/N6b5I6bNIu/0gGeXaN13ACi2LHC LB3t9A+q2LLjNvLJcUdwmH1z44hx9gobgHVOI4IvXmj9N96KP05Xn1ppz3zWii7hhUMF HzOgFRfQ0SxP2k9cKAQ2MZ4JxOA+c9INXGHM7ItISNol1yv8++EGtexQ+F/BGX3Qv7OI ZDjONNCV977ZFXB4QXWZbTksjncjAZgrk/C5VT+G3Mc8O+YT7YCRgotaaJprT08Bj+Dk M4uw== 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=dErvc0pq0zx0YsrOjNxpfc2TOCO5QsjECnfdxxhOELY=; b=ZNp8Fbf7TvxClViMN4HWr5OrCFCyMYIoCxxLXyJlozx+xnTR2O+CJhXb+KypqR6dFc Sb9R13Q+KzG6cgdQQIPmLasu/klZTRFGtqkKfjVItMi8lEieCE/6PUBHQbI1/DdAPIg2 YHqZyqMi6ib0h2g/HoujL2U2lVBBNXaXkorjfH2UrBebtsBdcKdup3t1lyzQ9Rkgz4XK KbKNgnLMnJiPcIhHnl1Rlzj4TuIfMkAntFdFVeU6MNVTXFyiGhfwEaNBH3r1sfHw9T2Y Rz5qEagw/Ru2NYz+lXfAEfpI8rOaY9Vluwd59PANcOxOYjsFs0fS4AJzN6LYrLS8nSZX DS+g== X-Gm-Message-State: AJcUukcP1zw5IgsWAiW1aL77v5QJoF5YxcHfkmPbxjRb1RL1EqTo7vRX OV6Rzj5J94+2/qQlBUcCAs7W0aKg4zsNZ3/wCa0= X-Google-Smtp-Source: AHgI3IY8lMde1cq+nsFE6JzGnBy0jXCweCcQAQO4piwtRxMOnyRHTSPNiv2rfJno0+WpI88zo+Aio0/o1WJ5vuXByVs= X-Received: by 2002:aca:d804:: with SMTP id p4mr3908506oig.304.1548607055678; Sun, 27 Jan 2019 08:37:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 27 Jan 2019 17:37:23 +0100 Message-ID: To: Sebastian Bergmann Cc: PHP Internals List Content-Type: multipart/alternative; boundary="0000000000007353830580732de4" Subject: Re: [PHP-DEV] [RFC] New custom object serialization mechanism From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --0000000000007353830580732de4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le jeu. 24 janv. 2019 =C3=A0 15:18, Sebastian Bergmann = a =C3=A9crit : > Am 24.01.2019 um 15:09 schrieb Marco Pivetta: > > Not really fussed about having another implicit interface for > serialization > > (via magic methods). > > I second that emotion. > The more I think about it, the more I'm convinced we should *not* add an interface for that. An interface defines a semantics - something that an API tpoa domain and that ppl can type-hint for to get a specific implementation of that API.Here, both aspects are not desired: we don't want ppl to type-hint for e.g. Serializable - and too bad it exists because I've already seen ppl think: "hey, I'll type-hint or extend it to express I want a serializable thing". BUT that's *not* the contract of Serializable or any variant of it because: 1. *any* PHP object is serializable 2. Serializable it well allowed to throw an exception to exactly *forbid* an object from being serialized. From this reasoning, I conclude that we really want magic methods here because what we need is a *behavior*. We want to hook into the engine to benefit from some special features it provides. That's what all magic methods are about and hooking into serialize()/unserialize() is not different. The parallel with the Symfony Serializer is interesting but it stop here: we don't need any help from core to build it. We should not seek for that goal IMHO as it blur the lines of what we're needing: a core primitive to build more useful things. Magic methods would just provide that, without polluting the semantics space. My 2cts, Nicolas --0000000000007353830580732de4--