Concept Flow - Type hinting with parent classes
Define Parent Class
Define Child Class extends Parent
Function with parameter type hinted as Parent
Call function with Parent instance
→Accept
Call function with Child instance
→Accept
Call function with unrelated class
→Error
The flow shows how a function expects a parameter of the parent class type, allowing instances of the parent or any child class to be passed safely.