Arelancelot
Arelancelot

Reputation: 501

Declaration of Child method should be compatible to Parent Method

got this error on Yii2. I dont know what exactly the problem is. I just migrate my source code from Windows to Mac OS. I tried cloning my whole project still the error appears.

Declaration of common\models\Product::getAttributes() should be compatible with yii\base\Model::getAttributes($names = NULL, $except = Array)

These are the things i tried:

  1. Clone the whole project to Mac OS. - error above exists.
  2. Clone the whole project to another windows machine.-the project is running well.

I am using yii2 in this project.

Upvotes: 0

Views: 552

Answers (2)

visualex
visualex

Reputation: 756

Your method must accept the same parameters ($names = NULL, $except = Array)

Upvotes: 0

arogachev
arogachev

Reputation: 33548

As you can see from the error message, you overrided yii\base\Model getAttributes() method. common\models\Product is extended from yii\db\ActiveRecord and ActiveRecord is extended from yii\base\Model.

If you really want to override this method, list all parameters (see here), it's easier to do with help of IDE. And by the way this is PHP feature and has nothing to do with OS or Yii2.

If it is your custom method for another purposes, you need to rename it in order to resolve conflict.

Upvotes: 2

Related Questions