Error executing Yii2 application - Cannot use 'Object' as class name as it is reserved
772
I am presenting the following problem and it is that when opening my Yii2 application, I get the following error Cannot use 'Object' as class name as it is reserved
It tells you that the Object class no longer exists and to use BaseObject instead.
At the time I downgraded back to version 7.1 because I had read that there were problems with certain things in yii2 framework due to certain php changes (now object is a reserved word of the language → https://www.yiiframework.com/doc /api/2.0/yii-base-object )
You'll need to manually fix all classes that inherit from yii\base\Objectand should now inherit from yii\base\BaseObject.
It tells you that the Object class no longer exists and to use BaseObject instead.
At the time I downgraded back to version 7.1 because I had read that there were problems with certain things in yii2 framework due to certain php changes (now object is a reserved word of the language → https://www.yiiframework.com/doc /api/2.0/yii-base-object )
You'll need to manually fix all classes that inherit from
yii\base\Object
and should now inherit fromyii\base\BaseObject
.Ideally, for this process you should follow the official update notes: https://github.com/yiisoft/yii2/blob/2.0.13/framework/UPGRADE.md#upgrade-from-yii-2012
Since in php version 7.2.3 Object is a reserved word, you need to rename the file and the classes that extend that file.
mv vendor/yiisoft/yii2/base/Object.php vendor/yiisoft/yii2/base/BaseObject.php
. to rename the file.find ./vendor/yiisoft/ -type f -exec sed -i 's/class Object/class BaseObject/g' {} +
. to rename the class.find ./vendor/yiisoft/ -type f -exec sed -i 's/extends Object/extends BaseObject/g' {} +
. to rename it in classes that extend from it.find ./vendor/yiisoft/ -type f -exec sed -i 's/yii\\base\\Object/yii\\base\\BaseObject/g' {} +
. modify the routes associated with the class.find ./vendor/yiisoft/ -type f -exec sed -i 's/\/base\/Object.php/\/base\/BaseObject.php/g' {} +i
. edit the path to the file in the classes.php file