Skip to content

Commit

Permalink
UPGRADE notes for Object -> BaseObject for PHP 7.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cebe committed Jul 19, 2017
1 parent 0001925 commit d4e584f
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions framework/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,48 @@ if you want to upgrade from version A to version C and there is
version B between A and C, you need to follow the instructions
for both A and B.

Upgrade from Yii 2.0.12
-----------------------

* For compatibiliy with PHP 7.2 which does not allow classes to be named `Object` anymore, we needed to rename
`yii\base\Object` to `yii\base\BaseObject`.

`yii\base\Object` still exists for backwards compatibility and will be loaded if needed in projects that are
running on PHP <7.2. The compatibility class `yii\base\Object` extends from `yii\base\BaseObject` so if you
have classes that extend from `yii\base\Object` these would still work.
What does not work however will be code that relies on `instanceof` checks or `is_subclass_of()` calls
for `yii\base\Object` on framework classes as these do not extend `yii\base\Object` anymore but only
extend from `yii\base\BaseObject`. In general such a check is not needed as there is a `yii\base\Configurable`
interface you should check against instead.

Here is a visualisation of the change (`a < b` means "b extends a"):

```
Before:
yii\base\Object < Framework Classes
yii\base\Object < Application Classes
After Upgrade:
yii\base\BaseObject < Framework Classes
yii\base\BaseObject < yii\base\Object < Application Classes
```

If you want to upgrade PHP to version 7.2 in your project you need to remove all cases that extend `yii\base\Object`
and extend from `yii\base\BaseObject` instead:

```
yii\base\BaseObject < Framework Classes
yii\base\BaseObject < Application Classes
```

For extensions that have classes extending from `yii\base\Object`, to be compatible with PHP 7.2, you need to
require `"yiisoft/yii2": "~2.0.13"` in composer.json and change affected classes to extend from `yii\base\BaseObject`
instead. It is not possible to allow Yii versions `<2.0.13` and be compatible with PHP 7.2 or higher.


Upgrade from Yii 2.0.11
-----------------------

Expand Down

0 comments on commit d4e584f

Please sign in to comment.