Hacker News new | past | comments | ask | show | jobs | submit login

PHP(.net) doesnt have strict typing ,but type hinting, which is not the same.



It does have strict typing with objects, but not literals.

If I make a function meow(MyClass $meow) { } it will throw errors if anything other than a MyClass is given to it, including NULL.


You are wrong , it has type hinting , not strict type checking. You can alias types, there is no hard types in PHP except for arrays. Your function signature check the name of the object in the namespace , not it's type.


function meow(MyClass $meow) { }

This will only accept an object that is_a MyClass. It can either implement an interface MyClass, extend an abstract MyClass, extend a regular class MyClass, or be the actual object MyClass.

Namespaces have nothing to do with this, other than you being able to use the "use" statement at the top to alias it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: