Cakeb DB post migration error Strict (2048): Declaration of BaseCompanyComponent:: initialize()

Asked 2 years ago, Updated 2 years ago, 48 views

Why did I get the following error when I migrated all the data to A server B server and also imported the database from A database server into B database?
Please let me know

Strict (2048): Declaration of BaseCompanyComponent:: initialize() should be compatible with Component:: initialize(Controller$controller) [APP/Controller/Component/BaseCompanyComponent.php,line999]

Strict (2048): Declaration of CaptureUtilityComponent:: initialize() should be compatible with Component:: initialize(Controller$controller) [APP/Controller/Component/CaptureUtilityComponent.php, line 66]
test CMS

php cakephp

2022-09-30 18:12

1 Answers

Beginning with PHP5, you must use declarations that are compatible with the parent class when inheriting classes and overwriting methods.Declaration of A::hoge() should be compatible with B::hoge(...) is "A inherits B, but the declaration of hoge() is incompatible."

PHP:class abstraction - Manual

The Component::initialize() in CakePHP 2.x is declared as follows:

public function initialize(Controller$controller){
}

Does the CaptureUtilityComponent::initialize() inherit this declaration?

//NG: Private should be less visible than parent class ->public
private initialize (Controller $controller) {
}

// NG: The model hint is missing -> Let's turn it on
public initialize($controller){
}

// NG—Required arguments are increasing ->Default value or make it a different method
public initialize(Controller$controller,$hoge){
}

In this case, both of them are PHP 5.x, so I think the error was not displayed because the error_reporting of php.ini did not include E_STRICT in the original server.

Compare the php.ini between the two servers, as other settings may be different.


2022-09-30 18:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.