Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86041 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37760 invoked from network); 29 Apr 2015 23:25:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2015 23:25:24 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.174 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.174 mail-pd0-f174.google.com Received: from [209.85.192.174] ([209.85.192.174:35119] helo=mail-pd0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/C1-29050-36861455 for ; Wed, 29 Apr 2015 19:25:24 -0400 Received: by pdbqd1 with SMTP id qd1so42019919pdb.2 for ; Wed, 29 Apr 2015 16:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=fNqh3lEf3OFop/hLeQdzVZNe9Y4/E8SQvD+p/9ccf04=; b=y7npuRiOn96NWdSiRfwBrCuOT+VYOP2GbwqLqqgMzLyr8/nt3LYeAZYFNz35Lqsn6C CAmHjsiH/8nvXxBBVprAxXRiZMalgahYj0C32GgTiNYvBkUhxsTbHMivQwA6B5K5XCjQ JnK9xCkaein0TgUU/12GgIspwPINOK3sh8XaOXlD4mpcQngsnGrtb2hERBQ09LjTqDCw SGvr+fYENhMA9Gxho1Z92yfWRMFmliC8i7GNw1Vv9GUkyYco96MEnvYaNR9MRFwn6d+u w4lQT6grM3uFJ/QRStCp1UqeXyqwHJZjOpvp6QI19oLgg21EI6R9LivtvmLkCSTXU0e/ VBvw== X-Received: by 10.66.102.99 with SMTP id fn3mr2698423pab.118.1430349921233; Wed, 29 Apr 2015 16:25:21 -0700 (PDT) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id l5sm275233pbq.15.2015.04.29.16.25.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2015 16:25:20 -0700 (PDT) Message-ID: <55416849.9010808@gmail.com> Date: Wed, 29 Apr 2015 16:24:57 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Yasuo Ohgaki , Ryan Pallas CC: "internals@lists.php.net" References: <55401F31.9030703@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Adding "numeric" type hint From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > The objective to have type "hint" is to remove such checks by users, > isn't it? No, not really. The objective is to ensure type of the parameter. If you checks are not limited to types, then typing is not going to help, and I don't think inventing special built-in type for each narrow use case is a good way to go. > Do you really think all users will write such code for database/json/etc > values? No, I don't think all users need such checks. But those that do will have to write the code for it. > The issue is that weak mode type hint is *not* weak at all. It forces to > have > machine native type rather than it's data form. PHP types are not machine native types. But yes, it forces PHP type - that's why it is *type* check. > PHP apps are easily broken by too large value because PHP stops execution > by fatal error. i.e. DoS became easy. I will never write such code, but That is a different issue. If you don't want fatal error, a) we have proposal to make those exceptions, b) it is not fixed by introducing pseudo-types for narrow use cases, since it is a completely different issue. > I don't > want to check and fix library that I would like to use. I don't think I > can manage > programmers to do that even if they are under my control. You are saying type checking which produces fatal errors does not match your use case. OK, I can sympathize, but how introducing more pseudo-types helps? You just fix one narrow use case that you have right now while leaving the problem still in the same place. That's not a good way to address it. -- Stas Malyshev smalyshev@gmail.com