It seems like you code against a specific sub-type and not the parent class CI_Migration as the method __construct() does only exist in the following sub-classes of CI_Migration: Migration_Auth_add_apikey, Migration_Favourites_Rework, Migration_Favourites_Rework_Revert, Migration_Install_ion_auth, Migration_Setup_Favourites, Migration_Setup_Notices, Migration_Setup_Rate_Limit, Migration_Setup_Sessions, Migration_Setup_Signup_Verification, Migration_Setup_Title_History, Migration_Setup_Tracker, Migration_Setup_User_History, Migration_Setup_User_Options, Migration_Tracker_Add_Active, Migration_Tracker_Add_Site_Custom, Migration_Tracker_Add_Site_Status, Migration_Tracker_Add_Title_Status, Migration_Tracker_add_category, Migration_Tracker_add_complete, Migration_Tracker_add_last_checked, Migration_Tracker_add_tags, Migration_Update_Sites_20170415. Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example:
abstractclassUser{/** @return string */abstractpublicfunctiongetPassword();}classMyUserextendsUser{publicfunctiongetPassword(){// return something}publicfunctiongetDisplayName(){// return some name.}}classAuthSystem{publicfunctionauthenticate(User$user){$this->logger->info(sprintf('Authenticating %s.',$user->getDisplayName()));// do something.}}
In the above example, the authenticate() method works fine as long as you just pass
instances of MyUser. However, if you now also want to pass a different sub-classes
of User which does not have a getDisplayName() method, the code will break.
classAuthSystem{publicfunctionauthenticate(User$user){if($userinstanceofMyUser){$this->logger->info(/** ... */);}// or alternativelyif(!$userinstanceofMyUser){thrownew\LogicException('$user must be an instance of MyUser, '.'other instances are not supported.');}}}
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: