Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86209 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23106 invoked from network); 14 May 2015 07:17:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 May 2015 07:17:20 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:32991] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/F2-31470-FFB44555 for ; Thu, 14 May 2015 03:17:19 -0400 Received: by obblk2 with SMTP id lk2so47399088obb.0 for ; Thu, 14 May 2015 00:17:16 -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:from:date:message-id :subject:to:cc:content-type; bh=0yjSIQufKoOsfiy71NYLTc9ibN7Ztbx6Pnk6Wj/fS7k=; b=P0t2uWytgT7AWxxBhvhnpCBHVelxlT9Lf2+R8aRggny5PfZwILMYaDCeHEA/1o45gH lvuZ+a2uaDpCaoGBBZof4aslJgs2xq8PS60mpnN1AJEd1OoGJ+5n2MCrm5mGg0LZmOjc VUtA/xYnefhuRgj8h9nfDrFZ1RQqrhYBTkSs7g8LP+kXUeyGy5M151LDmZOjdhPKhq+U 6lgKRyKV6KhjXgZrbfVT6Jv1LqKCdH2+8qHNvGcnblj2Qq3WbKXWH3917XqLf5lCqVlw xCV5hHID9hGYoRSb3cPdejiX3gbhlVX3XLJyuOMFnxJ8Zj1R4OfHAKKWLBe2N2rITa1Q peRA== X-Received: by 10.182.111.231 with SMTP id il7mr2354519obb.15.1431587836886; Thu, 14 May 2015 00:17:16 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.202.104.196 with HTTP; Thu, 14 May 2015 00:16:36 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 May 2015 16:16:36 +0900 X-Google-Sender-Auth: uDz1cyB8m7637YPTWrCWNb0SAG0 Message-ID: To: Walter Parker Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e015368627b83b405160584ad Subject: Re: [PHP-DEV] is_digits() and digits type From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e015368627b83b405160584ad Content-Type: text/plain; charset=UTF-8 Hi Walter, On Tue, May 12, 2015 at 11:25 AM, Walter Parker wrote: > You know, given how worried you seem to be about this issue, could you > booby trap your so that if the developers use the wrong type (int vs. > string) the program throws fatal errors with nasty error messages that > explain how much trouble the developer is in at the userland code level? > > While I like the of protecting idiot developers from themselves, I'm still > not sure that this isn't a half solutions that just hide the pieces of the > problem that it doesn't solve. > > I don't think we can solve the problem of developers not writing code > correctly or QA would mostly be out of job (instead of being a growth > segment). > > How about a full type system that would make Java programmer scream? I'm > sure with a bit of thought we can make one heavier than Java. > Java is not PHP. Java does not have 32 bit int on 32 bit machines, 64 bit int on 64 bit machine. Java has concrete byte, short, int, long type. It's whole different story. BTW, I noticed that mt_rand() behavior has changed to raise E_WARNING for too large numbers. This is good change because PHP is known to generate very weak random number with invalid min/max. [yohgaki@dev ~]$ php-5.6 -r "var_dump(mt_rand(222, '99999999999999999999999'));" int(115282844144104926) [yohgaki@dev ~]$ php-7.0 -r "var_dump(mt_rand(222, '99999999999999999999999'));" Warning: mt_rand() expects parameter 2 to be integer, string given in Command line code on line 1 NULL This behavior is much better. I mean E_WARNING and return NULL from function is much easier than dealing with E_RECOVERBLE_ERROR. Strict mode may stay as it is, but shouldn't we have consistent behavior? Internal function raises E_WARNING for too large int while user function raises E_RECOVERBLE_ERROR does not make much sense. Regards, P.S. With strict_types=1, mt_rand() gives Fatal error: mt_rand() expects parameter 2 to be integer, string given in /home/yohgaki/t.php on line 3 -- Yasuo Ohgaki yohgaki@ohgaki.net --089e015368627b83b405160584ad--