Re: What do we need strict scalar type hints for?

From: Date: Wed, 04 Feb 2015 05:24:59 +0000
Subject: Re: What do we need strict scalar type hints for?
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-81759@lists.php.net to get a copy of this message
On Tue, Feb 3, 2015 at 7:14 PM, Andrea Faulds <ajf@ajf.me> wrote: > Hi Dmitry, > > > On 3 Feb 2015, at 04:07, Dmitry Stogov <dmitry@zend.com> wrote: > > > > I have similar opinion. Strict typing looks foreign for PHP. > > It is in a way, yes. PHP has traditionally been “weakly-typed” everywhere. > > That being said, we’re not always weakly-typed (there are strict type > checks in some places), and userland code has sometimes done strict type > checks anyway. > > > I see, strict type hints may be useful. > > Aspecially for testing and error detection, but anyaway, I'm not sure if > and how it should be enabled. Declare() is a working solution, but it's not > excelent. > > It’s not a perfect solution, but I haven’t seen anything that seems to be > much better. The best bit about declare() is that it would make strict > types completely optional, so people who don’t like them wouldn’t have to > use them, even if they call code which does. > I agree. It's probably the best solution that we saw. But it's still not good enough, It would be great to make the obvious part of the proposal accepted first. I would suggest to make two separate voting questions. 1) Enable scalar type hinting with standard rules. 2) In addition enable strict type hinting triggered by declare(). Thanks. Dmitry. > > -- > Andrea Faulds > http://ajf.me/ > > > > >

« previous php.internals (#81759) next »