Declaration of xxx should be compatible with yyy |
OK, I just migrated my web app from CI 2.1.4 to CI 3.0.0 and I am now getting a PHP Runtime Notice that shouldn't be related to the upgrade, but nonetheless it's there and I could use some help.
Quote:A PHP Error was encountered Here is the context. Three different times I am extending Person and on methods keeping the base variables, but adding to it. This means that the save function in Person cannot have the exact same declaration as the classes that extend it. I would prefer not to just suppress these warnings, but I could use some help getting to the bottom of how to declare these functions so that it doesn't generate the notice. Customer.php Code: class Customer extends Person Person.php Code: class Person extends CI_Model
You can't add parameters to an override method.
But you can use func_get_args().
ok, read up on this and it sounds like even though my code works, there is risk that php gets confused about which function I'm calling and that's why it's throwing the warning. Curious that it does not throw this warning in pre-CI 3.0.0.
It sounds like I have two options. Please correct me if I'm wrong. I can make the parent function signature include the extra arguments and just make those extra arguments optional arguments. OR I can use func_get_args() to pull the extra arguments. Question: If I go the func_get_args() does the signature have to have no arguments or can I do something like: Code: Class Foo I just couldn't seem to find an example where there were both arguments in the signature and func_get_arg() was used.
The notices have to do with a change to the error reporting levels in the index.php file. The errors were always there, but they were previously being suppressed.
The CI3 DB_driver actually does something similar to what you're looking for: PHP Code: public function call_function($function) From this, I would assume that your example would work as expected. |
Welcome Guest, Not a member yet? Register Sign In |