Re: [RFC] Scalar Type Hints
| From: | Marco Pivetta | Date: | Fri, 02 Jan 2015 14:06:46 +0000 |
| Subject: | Re: [RFC] Scalar Type Hints | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80096@lists.php.net to get a copy of this message | ||
On 2 January 2015 at 15:01, Jordi Boggiano <j.boggiano@seld.be> wrote:
> Looking at it from an OSS maintainer perspective, introducing strict hints
> in code would be a huge BC break as I don't know how people use my code,
> nor if they validate/coerce their user input early or not. If I suddenly
> declare something as int and someone used to pass '5', they get an error.
> That would make adoption quite hard in OSS IMO if you don't want to bother
> people.
>
Regardless if this RFC gets through or not, changing the signature of a
method IS a BC break in any case, so you shouldn't just move your
int
declaration from the docblocks into the method signature.
That'd be a simple lib to write, it barely adds more code to your
> functions, and you get strict typing. But I hardly see anyone do this, and
> I would argue it's because it sounds appealing in theory but it's not worth
> it in practice.
>
I'm actually already using https://github.com/beberlei/assert for that, and
I'd like to get rid of it for simpler types.
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/