So, as far as i understand, php 5.whatever we're currently on supports type hinting in classes when you're dealing either with arrays or objects. But, it doesn't allow us to declare variable types of methods which accept strings, ints, booleans, and these basic types.
I read somewhere that there is a debate over whether or not they should include this in php 6. What do you all think?
Personally, I think it would be nice to have the option of writing classes this way just because I think it makes the code more self documenting and easier to deal with for future developers or my future self who might have no idea what i was doing when i wrote something.
I think a part of PHP's beauty is that it does not have strong typing, or a distinction between types of objects and primitives.
Doing Java development shows the contrast between the two ideologies. In one, you can document things easily and do many things quickly and dynamically. In the other, you have the assurance that what you specify is what is (usually).
Type Hinting is enough for most purposes, and simple naming convention with mixed type checking should be enough for primitives.
I agree that its very nice not to be forced to declare variable types in PHP, and this feature is definitely an asset.
That being said, I think the option to declare them in class methods would be beneficial, so that I don't have to manually check its type later. I think its cleaner too, than naming variables like $intMyVar.
I do agree though that PHP's flexibility with variables is a beautiful thing about it