Hi!

> The question here is how type strictness would benefit the language. 
> I agree with you on most parts. But still... if the class was declared
> like this:
> 
> class CancelOutdatedOrdersDTO {
>     public int $olderThan;
> }
> 
> Wouldn't that be solved entirely? Code would crash (through a

No of course not. The specific instance of error you had *this time* may
be solved. The problem won't be. You still have to deal with:
- How this object is initialized? How you ensure it *is* initialized and
that initialization is correct (0 is perfectly valid int)?
- How this object is unserialized and what if unserialized data has
non-integer or 0 or __wakeup has a bug?
- What if some code just writes 0 into $olderThan - you declared it as
public so anybody could mess with it?
- What if some code mixes signed and unsigned and you get negative
number instead of positive?
- What if this code runs on 32-bit but receives 64-bit value and
truncates it?

And so on, and so forth, I probably missed more possibilities than I
mentioned. Declaring a type does not magically free one from correct
design and testing, and typed programs have bugs as much as non-typed
ones (maybe slightly different ones). Actually, one of the harms relying
on it would be the same problem safe_mode had - it's full of holes, it's
not safe and it creates wrong expectations. If you just write "int" and
expect your problems to magically go away - you're in for big and bad
surprises.

-- 
Stas Malyshev
smalys...@gmail.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to