The title is a bit confusing, I know, but it's the best I could do. =P
Hopefully, someone will be able to help.
I'm using CodeIgniter and I have a method in a base class that has multiple parameters:
class MY_Base extends CI_Model {
function some_function($param1, $param2 ... $param8) {
// do stuff
}
}
What I want to do is basically this, in a child class:
class Child extends MY_Base {
function some_function($param1, $param2 ... $param8) {
parent::some_function($param1, $param2 ... $param8);
// call a methods found in this class only
$this->some_method();
}
function some_method() {
// do more stuff
}
}
I can't touch the base classes so I have to extend from it. Problem is, There are just too many parameters. And this happens in different methods as well and sometimes I forget one which makes the code fail.
So I was wondering, if there's a way to write it like this:
function some_function(__PARAMETERS__) {
parent::some_function(__PARAMETERS__)
}
I seem to vaguely recall that this is possible but I can't find it in Google. Probably because I'm searching the wrong keywords.
Any help would be appreciated.
EDIT:
And then, of course, I find func_get_args()
after posting this question.
This seems to do what I want, but I'll leave this question up for better ideas.
For PHP >=7.0 I use:
parent::{__FUNCTION__}(...func_get_args())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With