Copied from Yii2 Main repo