Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97783 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91263 invoked from network); 16 Jan 2017 10:11:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2017 10:11:28 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.218 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.218 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.218] ([81.169.146.218:23748] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/57-00729-D4C9C785 for ; Mon, 16 Jan 2017 05:11:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1484561482; l=4270; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=r+fVxBasWdsYyjdah4xRu3+EoAhq0CZXAMfMqwLcWx4=; b=otWwgguRhSFBknbzS+3cBr7ttPnyHmmzvH40GuSUpeophvglMhFcfB1HVPyx53IcQi DYembpHVaNk+A/9d1ZYuQiAA8t1u0gqVAraC3Yh1ogbhN91FPf5ftQby/krl4hg2bCbW xj3SsEPpd8y9tADsldHrEBZbbqoJPNTZ1iuN8= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLDup6E67mzuoNJBqD/tRU= X-RZG-CLASS-ID: mo00 Received: from mail-qt0-f175.google.com ([209.85.216.175]) by smtp.strato.de (RZmta 39.11 AUTH) with ESMTPSA id f065a6t0GABMT8P (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Mon, 16 Jan 2017 11:11:22 +0100 (CET) Received: by mail-qt0-f175.google.com with SMTP id l7so99988684qtd.1 for ; Mon, 16 Jan 2017 02:11:22 -0800 (PST) X-Gm-Message-State: AIkVDXIJekERxOuRiL7k24u8l27Cwg4UNVBzoshYPn2ctdsmot0NAUFadnAEay6A4QXLeQ3NSBsFP9K6yjr+5g== X-Received: by 10.237.32.70 with SMTP id 64mr8735733qta.163.1484561481901; Mon, 16 Jan 2017 02:11:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.144.132 with HTTP; Mon, 16 Jan 2017 02:11:21 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Jan 2017 11:11:21 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Jani Ollikainen Cc: Jakub Zelenka , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=94eb2c0c98c8c6b1c605463367e9 Subject: Re: [PHP-DEV] Exposing jsonSerialize's depth From: me@kelunik.com (Niklas Keller) --94eb2c0c98c8c6b1c605463367e9 Content-Type: text/plain; charset=UTF-8 2017-01-16 9:19 GMT+01:00 Jani Ollikainen : > 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. > That BC break: https://3v4l.org/L1u7q Regards, Niklas > 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] ) > Parameters: > depth > Depth of the current json_encode -call. > > New interface would also be good, but as you said it, it doesn't seem to > be worth the trouble. > > Well, and what do you think how much does going pre-processing slow the > code versus without need for pre-processing? That really doesn't sound > option to me. > > --94eb2c0c98c8c6b1c605463367e9--