Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84973 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52549 invoked from network); 16 Mar 2015 02:49:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2015 02:49:57 -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.176 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.214.176 mail-ob0-f176.google.com Received: from [209.85.214.176] ([209.85.214.176:34371] helo=mail-ob0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/DE-06614-1D446055 for ; Sun, 15 Mar 2015 21:49:55 -0500 Received: by obbgg8 with SMTP id gg8so26218890obb.1 for ; Sun, 15 Mar 2015 19:49:51 -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:content-type; bh=qY+h5MQz63+9YP2U5VRGBLUt5BlAoOg7nuGrIcotwV8=; b=Wepxpfz2dhCflftyJwfnsDwrZZwtMu/zQuZx78ul9zZAJ6dAbLK7etPbtxYDTNUHw7 SVRRSJkLmtAseZ8BNss0T+5gcekv+ItKYxfAkMZYlibw4wyizfY9gCn1VXba2i78XK+L W5u6jQKSrXNs4Uk5QVIIOQk9Ad4GdWHZif7LLuemft08mC4e16Cywx6CQiU7eDxWiN8I Yj3BfdOOli2rYL5i03Rpr+70FUGGEUgheeWM1aTADkFdlzuw/R0CI4xjffV7Iwh1GNb2 bu4A1f17r6X58Kod1Y5hg/Pb4aO1rjBTiOnGPkRYhlN5MpmwVwcxRPAXCvfppGzrCgXY F2gg== X-Received: by 10.202.13.203 with SMTP id 194mr8545786oin.130.1426474191066; Sun, 15 Mar 2015 19:49:51 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.202.58.2 with HTTP; Sun, 15 Mar 2015 19:49:10 -0700 (PDT) In-Reply-To: <550641A7.7070809@birkholz.biz> References: <550641A7.7070809@birkholz.biz> Date: Mon, 16 Mar 2015 11:49:10 +0900 X-Google-Sender-Auth: WqnK5V0H2pF47h9ErFohHoQ1OxI Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113d149c709bc705115ee74c Subject: Re: [PHP-DEV] [RFC][Status] Scalar Type Declarations Voting Date Change From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a113d149c709bc705115ee74c Content-Type: text/plain; charset=UTF-8 Hi Dennies, On Mon, Mar 16, 2015 at 11:36 AM, Dennis Birkholz wrote: > Am 16.03.2015 um 03:16 schrieb Yasuo Ohgaki: > > This code is an example that I posted in other thread. > > > > e.g. > > > function check_num_range(int $num) { if ($num < 0 || $num > 100) > > trigger_error('Invalid range'); } > > // Somewhere far from function definition. > > $num = $GET['num']; > > // Somewhere far from $num definition. > > check_num_range($num); // Trying to check validity, int and range. > > echo 'You have '.$num. ' now
'; // But $num could have any string. > > // > > "check_num_range((int)$num)" wouldn't help also. > > > > Simple cast hides bugs, not eliminates type bugs. > > This is just an example and there are many cases that cast hides bugs in > > real world codes. > > please, if check_num_range() would be a build-in function, the outcome > would be exactly the same. > > If $num contains something like "100 dogs", you get a notice: > http://3v4l.org/fnuAc/rfc#tabs > > If $num contains rubbish, you get a catchable fatal error: > http://3v4l.org/UStfP/rfc#tabs > My point is "Coercive type" can find/detect invalid inputs, while both "Weak and Strict type" cannot. Writing solid code is upto users with respect to correct conversion handling. I'm not saying "Coercive type" is perfect, but much more helpful. Coercive type RFC helps to find very hard to detect/notice bugs, while "Weak and Strict type" cannot. This is very important difference to me because I saw many codes like this with source code security check, as well as buggy code with external resources like databases. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a113d149c709bc705115ee74c--