From 81a3b83995b47d5c16be260ed50fa7c778389ae5 Mon Sep 17 00:00:00 2001 From: rhertogh Date: Sun, 21 Nov 2021 22:43:53 +0100 Subject: [PATCH] Fix #19021: Fix return type in PhpDoc `yii\db\Migration` functions `up()`, `down()`, `safeUp()` and `safeDown()` * Fixed PhpDoc in Migration.php (revert #18886) Fixed the return type of `up()`, `down()`, `safeUp()` and `safeDown()` functions to match the described behavior. The current implementation checks for `false`, "all other return values mean the migration succeeds". This PR also reverts #18886 since it was a code fix for what was documentation error. Allow all possible values for `yii\db\Migration` functions `up()`, `down()`, `safeUp()` and `safeDown()` --- framework/CHANGELOG.md | 2 +- framework/db/Migration.php | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index ae03004..a10bc6b 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -20,7 +20,6 @@ Yii Framework 2 Change Log - Enh #18858: Reduce memory usage in `yii\base\View::afterRender` method (LeoOnTheEarth) - Bug #18880: Fix `yii\helpers\ArrayHelper::toArray()` for `DateTime` objects in PHP >= 7.4 (rhertogh) - Bug #18883: Fix `yii\web\HeaderCollection::fromArray()` now ensures lower case keys (rhertogh) -- Bug #18886: Fix default return of `yii\db\Migration::safeUp()` and `yii\db\Migration::safeDown()` (WinterSilence) - Enh #18899: Replace usages of `strpos` with `strncmp` and remove redundant usage of `array_merge` and `array_values` (AlexGx) - Bug #18898: Fix `yii\helpers\Inflector::camel2words()` to work with words ending with 0 (michaelarnauts) - Enh #18904: Improve Captcha client-side validation (hexkir) @@ -29,6 +28,7 @@ Yii Framework 2 Change Log - Bug #18955: Check `yiisoft/yii2-swiftmailer` before using as default mailer in `yii\base\Application` (WinterSilence) - Bug #18988: Fix default value of `yii\console\controllers\MessageController::$translator` (WinterSilence) - Bug #18993: Load defaults by `attributes()` in `yii\db\ActiveRecord::loadDefaultValues()` (WinterSilence) +- Bug #19021: Fix return type in PhpDoc `yii\db\Migration` functions `up()`, `down()`, `safeUp()` and `safeDown()` (WinterSilence, rhertogh) 2.0.43 August 09, 2021 diff --git a/framework/db/Migration.php b/framework/db/Migration.php index e1177d4..a8e2264 100644 --- a/framework/db/Migration.php +++ b/framework/db/Migration.php @@ -104,7 +104,7 @@ class Migration extends Component implements MigrationInterface /** * This method contains the logic to be executed when applying this migration. * Child classes may override this method to provide actual migration logic. - * @return bool return a false value to indicate the migration fails + * @return false|void|mixed return a false value to indicate the migration fails * and should not proceed further. All other return values mean the migration succeeds. */ public function up() @@ -133,7 +133,7 @@ class Migration extends Component implements MigrationInterface * This method contains the logic to be executed when removing this migration. * The default implementation throws an exception indicating the migration cannot be removed. * Child classes may override this method if the corresponding migrations can be removed. - * @return bool return a false value to indicate the migration fails + * @return false|void|mixed return a false value to indicate the migration fails * and should not proceed further. All other return values mean the migration succeeds. */ public function down() @@ -177,12 +177,11 @@ class Migration extends Component implements MigrationInterface * Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples, * please refer to [implicit commit](http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html). * - * @return bool return a false value to indicate the migration fails + * @return false|void|mixed return a false value to indicate the migration fails * and should not proceed further. All other return values mean the migration succeeds. */ public function safeUp() { - return true; } /** @@ -195,12 +194,11 @@ class Migration extends Component implements MigrationInterface * Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples, * please refer to [implicit commit](http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html). * - * @return bool return a false value to indicate the migration fails + * @return false|void|mixed return a false value to indicate the migration fails * and should not proceed further. All other return values mean the migration succeeds. */ public function safeDown() { - return true; } /**