You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve noticed something in PHP that could really improve the language if added as a feature.
Imagine this scenario:
You have an abstract class with a method called funcA(param1), and there are 40 subclasses that implement this method.
Now, suppose you want to add a second parameter, so funcA becomes funcA(param1, param2). Updating all 40 subclasses manually becomes tedious and error-prone.
It would be incredibly helpful if you could just update the method signature in the abstract class, and have all subclasses inherit the change automatically — without needing to modify each one individually.
This would make code much more maintainable and extensible.
The text was updated successfully, but these errors were encountered:
Hi @mohammadMghi. Treating missing parameters as compatible also means child implementations that call the parent will silently break by not handling the new parameter, because parent::funcA($param1); needs to be updated to parent::funcA($param1, $param2);. I highly suspect this is not a tradeoff internals are willing to accept, but feel free to try your lock on the internals mailing list.
Description
I’ve noticed something in PHP that could really improve the language if added as a feature.
Imagine this scenario:
You have an abstract class with a method called funcA(param1), and there are 40 subclasses that implement this method.
Now, suppose you want to add a second parameter, so funcA becomes funcA(param1, param2). Updating all 40 subclasses manually becomes tedious and error-prone.
It would be incredibly helpful if you could just update the method signature in the abstract class, and have all subclasses inherit the change automatically — without needing to modify each one individually.
This would make code much more maintainable and extensible.
The text was updated successfully, but these errors were encountered: