i'd imagine typehinting is php's way of being flexible to allow somewhat static typing in the code in function signatures.Originally Posted by BerislavLopac
i don't see it as bad, especially when you want to enforce passing an object that might be of Type C/or interface x because you need to make sure that object has a certain method or property. So you can have class G inherit from class C and it should still be able to pass the type hint, or you use interface x as a type hint, you should be able to pass any object that uses that interface.
And type hinting failures should be found during the development and testing process. Now, if you were using an IDE that picked up typehints, it should display it as an error before you ever run the script.
In a framework like prado or something to that nature, it has it's uses.





)


Bookmarks