Re: Adding "numeric" type hint

From: Date: Wed, 29 Apr 2015 23:24:57 +0000
Subject: Re: Adding "numeric" type hint
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-86041@lists.php.net to get a copy of this message
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

« previous php.internals (#86041) next »