In Yii 2 we’re seeing a lot of shell classes that do nothing besides extend a base class. For example:
Yii is an empty class that extends yii\BaseYii
yii\helpers\Json is an empty class that extends yii\helpers\BaseJson
yii\helpers\Html is an empty class that extends yii\helpers\BaseHtml
Does anyone know the reason for this design pattern? Why not just define the yii\BaseYii implementation directly in Yii, the yii\helpers\BaseJson implementation directly in yii\helpers\Json, etc.?
Took me a minute to wrap my head around this, so to clarify: This allows you to helper classes at the framework level - in other words so you can modify the behavior of helper functions that Yii itself is calling (e.g. when Yii’s own classes call yii\helpers\ArrayHelper::merge()).
Previously this would have required a core file hack. This is much nicer!