Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85543 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29429 invoked from network); 30 Mar 2015 08:50:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2015 08:50:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.178 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.213.178 mail-ig0-f178.google.com Received: from [209.85.213.178] ([209.85.213.178:38272] helo=mail-ig0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EB/42-15027-D4E09155 for ; Mon, 30 Mar 2015 03:50:21 -0500 Received: by igbqf9 with SMTP id qf9so65568076igb.1 for ; Mon, 30 Mar 2015 01:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=W4rS41yj1q/7hpiEG+MFsuoEKP18gEtd9hxU5erfO/4=; b=fV5lBQ4jt7+TAF8aByVDkPsFHB1ccLkJCkvR66zOGY6mkIDaWwq/gob7dwQeskJC0l 25E7MzxOyYpX+yh7CHW4oYL11TkkUbqGhYCW1KEP14NJPS43S89YlO0nMmRp7JZYqnC+ ka2WdF2slTAZLpTvxpY2eb4QxZOiYSBkuyXC2y6K3FDmtMrDjAZARdxjrJYhY/pMV7Mq UoHmz1btzXU0MxZaLF7/eEelIvn4/cEFc9+pMsrRg+Brwnku6L7w4HYUrx5CSrWOyy+2 zMN5sIBc7AqRK1WQmN9Cf8gI0/VuilYfK+PWuasJjLUEbJBRcXR9AU9FUyO41HR323Ag kuXA== MIME-Version: 1.0 X-Received: by 10.107.135.212 with SMTP id r81mr48226282ioi.38.1427705418509; Mon, 30 Mar 2015 01:50:18 -0700 (PDT) Sender: jakub.php@gmail.com Received: by 10.107.39.18 with HTTP; Mon, 30 Mar 2015 01:50:18 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 Mar 2015 09:50:18 +0100 X-Google-Sender-Auth: NSmR5f3zMH-gw6sziJz6A-zA3U8 Message-ID: To: Yasuo Ohgaki Cc: Pierre Joye , PHP internals list Content-Type: multipart/alternative; boundary=001a113ec85a50718205127d92c9 Subject: Re: [PHP-DEV] JSON float number as string From: bukka@php.net (Jakub Zelenka) --001a113ec85a50718205127d92c9 Content-Type: text/plain; charset=UTF-8 On Mon, Mar 30, 2015 at 9:04 AM, Yasuo Ohgaki wrote: > Hi Pierre, > > On Mon, Mar 30, 2015 at 11:42 AM, Pierre Joye > wrote: > >> On Mon, Mar 30, 2015 at 9:14 AM, Yasuo Ohgaki wrote: >> > Hi Pierre, >> > >> > On Mon, Mar 30, 2015 at 10:54 AM, Pierre Joye >> wrote: >> >> >> >> Same effects but totally unrelated topics. All functions dealing with >> >> large external numbers had the same issues, since ever. It has nothing >> >> to do with STH. >> > >> > >> > Yes, it is. >> > Developers make casting mistakes like this even when they are used to >> strict >> > typing. >> >> I understand and this is why I said it is the same symptom. But JSON >> or any other external data decoding has nothing to do with STH. It >> would be nice to do not clutter this discussion with yet another STH >> argument :) > > > As you know, I'm an very unhappy person with the accepted RFC :) > Since Zeev closed the vote before the end date, I think we may have a > little > chance to improve weak mode scalar type hint. i.e. Use Zeev's RFC for weak > mode. > > Anyway, similar issue is not only external but also PHP internal. > For example, > > [yohgaki@dev php-src]$ ./php-bin -r > 'var_dump(["999999999999999999999"=>1, 999999999999999999999=>1]);' > array(2) { > ["999999999999999999999"]=> > int(1) > [3875820019684212736]=> > int(1) > } > > Library that deals with array should use "string" key data type to have > correct key for > any number even when library expects integer keys. i.e. The library must > have "string" type hint for integer key to achieve correct behavior. > > Database, JSON and array are good examples of confusions. Smart developers > will use "string" type hints for these, while less experienced developers > will use > "int/float" type hints for these. When users have to use both of them, > users are > forced to casting variable between "string" and "int/float". This makes > impossible > to write "correct" code. This JSON bug is a proof that this will happen. > > I just don't see the point to introduce new feature that makes impossible > to write > correct code while there is good solution. Fortunately, we still have time > to address > this. > > Regards, > > P.S. Does anyone have alternative ideas for this? > > Please can this be discussed in a new thread? This thread is just about adding a new option to json ext. Cheers Jakub --001a113ec85a50718205127d92c9--