Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97787 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1394 invoked from network); 16 Jan 2017 12:01:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2017 12:01:17 -0000 Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.180 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.213.180 mail-yb0-f180.google.com Received: from [209.85.213.180] ([209.85.213.180:35867] helo=mail-yb0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/E8-00729-A06BC785 for ; Mon, 16 Jan 2017 07:01:15 -0500 Received: by mail-yb0-f180.google.com with SMTP id 123so33396638ybe.3 for ; Mon, 16 Jan 2017 04:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=8h8Dky+f5Wk0u11ObESdO/KrwaLd8sOvDU6gXQ7ogcw=; b=EvgItwPvoyiT0Nd0fCv9dQS+KmI+5UtZGskHCJYKEudeZB/kkn9TKr4Rb1GcO4/Nc3 a2DRFLI2X7bBWK/1t2027kryE0NznwOrFnC4ee2MT7In8YsEt/8yXucLh1vHAEgmAZnv XV76Zr5aUfnPhWP2b4H4YKcteTBj5lQ3w7V9iHIO/mMzSO0Exc9gEqHS6BzordhyPj5e zNhHhu6bnTPC+qudVWwMQrz2F+M2clUASatCYOxkJeIXqUqs87M9LL+POD6rAIgtCO/q TYQc3D6mTAklX/hNbXoCJGN9Z3nl/01nS26xZWRpLvDhD0cWcxX8bcKc3WfzglmI/DbC Wg2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=8h8Dky+f5Wk0u11ObESdO/KrwaLd8sOvDU6gXQ7ogcw=; b=qJ4I46+0O74EDYWk9WQHhJ7AsqngAPg7Y4jFg5xIxk/CeF4QFq8YNXfcfPbnoApUGo dyZxapdB/biV+ZWY4cSyGUGX9ba3vECAw861fSZZdiWUFiJPW0988ky4oUCfsvuJNoY2 Am9K76JOrWIMmtbzF6lgwppZsdAew9BVM1nXKNrt6ZRhESTemi+6f8h+zldemE6s18Vv MQWDr7vtbx8kVbztRaaJGWZWj9UNEpYltdMTB6T2FJHlC5u2TWEEIprFn3m0NSAyoANq oEJoanMTl9m3ljq0PoNPX5CYJ9/E8W7MQ8X8SF/OU+lUD5nkIuSi7ay/S8APduyy7YmU joZQ== X-Gm-Message-State: AIkVDXJWtpgfyqaLYclncbJWadDNP2trjxvmO7dfcr1c2rURibqHXXkoubD1spDFA2hZZpXbX8J8JvrScl9/iQ== X-Received: by 10.37.42.80 with SMTP id q77mr20322894ybq.102.1484568071821; Mon, 16 Jan 2017 04:01:11 -0800 (PST) MIME-Version: 1.0 Sender: jakub.php@gmail.com Received: by 10.129.72.73 with HTTP; Mon, 16 Jan 2017 04:01:11 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Jan 2017 12:01:11 +0000 X-Google-Sender-Auth: 4ZoCTjrPYl-J8URHDmQe8t_Rm_k Message-ID: To: Jani Ollikainen Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1144047e90dd05054634f084 Subject: Re: [PHP-DEV] Exposing jsonSerialize's depth From: bukka@php.net (Jakub Zelenka) --001a1144047e90dd05054634f084 Content-Type: text/plain; charset=UTF-8 On Mon, Jan 16, 2017 at 8:19 AM, Jani Ollikainen wrote: > Hi, > > > I don't really like this. The reason is that you don't actually modify > JsonSerializable interface for the obvious BC break that it would cause it. > It means that the > function just gets this parameter and it kind of raises > a question how we should document it? The solution would be to extend > JsonSerializable with some > > new interface. However I don't think it's worth it for such thing. Maybe > you should consider to pre-process your data before passing it to > json_encode... > > What BC break are you talking about? There is no need for using the > parameter in old codes. Even if we pass that depth to jsonSerialize doing > something like: > "public function jsonSerialize() {...}" will still work without any > problems. > > And how would you document it it? Like any other.. if there now is: > http://php.net/manual/en/jsonserializable.jsonserialize.php > abstract public mixed JsonSerializable::jsonSerialize ( void ) > This function has no parameters. > Then it would just be: > abstract public mixed JsonSerializable::jsonSerialize ( [integer $depth] ) > That's not what is implemented. You just call jsonSerialize with an extra parameter and basically create a contract that is not specified by the interface. As you can see from the example that Niklas sent, you can't just add an optional parameter to the interface method as it would be a BC break. Cheers Jakub --001a1144047e90dd05054634f084--