From a47dfb6dc2b57356022637b88bec4cc3016cb37f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Aug 2022 15:06:24 +0000 Subject: [PATCH 1/5] chore(deps-dev): update rector/rector requirement from 0.13.9 to 0.13.10 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.13.9...0.13.10) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ae0d7b86410d..d12d7148e38a 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "phpstan/phpstan": "^1.7.1", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1 || ^2.0", - "rector/rector": "0.13.9" + "rector/rector": "0.13.10" }, "suggest": { "ext-fileinfo": "Improves mime type detection for files" From c638e0f2b0b47e3358b5b3e9a9453606334ee2a6 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 3 Aug 2022 22:45:18 +0700 Subject: [PATCH 2/5] re-run rector with enable RemoveDeadZeroAndOneOperationRector --- rector.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rector.php b/rector.php index bdda1e466b71..f88e1e717258 100644 --- a/rector.php +++ b/rector.php @@ -32,7 +32,6 @@ use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector; use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector; use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector; -use Rector\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; @@ -134,9 +133,6 @@ // buggy on read based on @var on property RemoveAlwaysTrueIfConditionRector::class, - - // buggy on string * int - RemoveDeadZeroAndOneOperationRector::class, ]); // auto import fully qualified class names From 0e598d1cc35d6e8a76ab3d7da83566e5b4e955f2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 3 Aug 2022 22:53:38 +0700 Subject: [PATCH 3/5] re-run rector with enable RemoveAlwaysTrueIfConditionRector with skip only in trait --- phpstan-baseline.neon.dist | 10 ---------- rector.php | 7 +++++-- system/Autoloader/Autoloader.php | 4 +--- system/Cache/Handlers/MemcachedHandler.php | 4 +--- system/Cache/Handlers/RedisHandler.php | 4 +--- system/Database/Forge.php | 8 +++----- system/Helpers/form_helper.php | 6 ++---- 7 files changed, 13 insertions(+), 30 deletions(-) diff --git a/phpstan-baseline.neon.dist b/phpstan-baseline.neon.dist index da08082b3e08..448b76044915 100644 --- a/phpstan-baseline.neon.dist +++ b/phpstan-baseline.neon.dist @@ -70,11 +70,6 @@ parameters: count: 1 path: system/Cache/Handlers/MemcachedHandler.php - - - message: "#^Variable \\$config in empty\\(\\) always exists and is not falsy\\.$#" - count: 1 - path: system/Cache/Handlers/MemcachedHandler.php - - message: "#^Variable \\$data might not be defined\\.$#" count: 1 @@ -90,11 +85,6 @@ parameters: count: 1 path: system/Cache/Handlers/RedisHandler.php - - - message: "#^Variable \\$config in empty\\(\\) always exists and is not falsy\\.$#" - count: 1 - path: system/Cache/Handlers/RedisHandler.php - - message: "#^Call to an undefined method CodeIgniter\\\\HTTP\\\\Request\\:\\:getPost\\(\\)\\.$#" count: 1 diff --git a/rector.php b/rector.php index f88e1e717258..ce607ae53b5f 100644 --- a/rector.php +++ b/rector.php @@ -131,8 +131,11 @@ __DIR__ . '/tests/system/Email/EmailTest.php', ], - // buggy on read based on @var on property - RemoveAlwaysTrueIfConditionRector::class, + // buggy on read based on @var on property on Trait + RemoveAlwaysTrueIfConditionRector::class => [ + '**Trait.php', + __DIR__ . '/system/Test/ControllerTester.php', + ], ]); // auto import fully qualified class names diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 311428fe4165..f87e4485c6a7 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -141,9 +141,7 @@ public function register() // Load our non-class files foreach ($this->files as $file) { - if (is_string($file)) { - $this->includeFile($file); - } + $this->includeFile($file); } } diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php index b317652dd99e..6b6f60e0a6b7 100644 --- a/system/Cache/Handlers/MemcachedHandler.php +++ b/system/Cache/Handlers/MemcachedHandler.php @@ -45,9 +45,7 @@ public function __construct(Cache $config) { $this->prefix = $config->prefix; - if (! empty($config)) { - $this->config = array_merge($this->config, $config->memcached); - } + $this->config = array_merge($this->config, $config->memcached); } /** diff --git a/system/Cache/Handlers/RedisHandler.php b/system/Cache/Handlers/RedisHandler.php index 553825f615e8..df179e7455e6 100644 --- a/system/Cache/Handlers/RedisHandler.php +++ b/system/Cache/Handlers/RedisHandler.php @@ -45,9 +45,7 @@ public function __construct(Cache $config) { $this->prefix = $config->prefix; - if (! empty($config)) { - $this->config = array_merge($this->config, $config->redis); - } + $this->config = array_merge($this->config, $config->redis); } /** diff --git a/system/Database/Forge.php b/system/Database/Forge.php index 5fd92843e926..f26ac6255b8d 100644 --- a/system/Database/Forge.php +++ b/system/Database/Forge.php @@ -764,11 +764,9 @@ public function modifyColumn(string $table, $field): bool return false; } - if ($sqls !== null) { - foreach ($sqls as $sql) { - if ($this->db->query($sql) === false) { - return false; - } + foreach ($sqls as $sql) { + if ($this->db->query($sql) === false) { + return false; } } diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index 2466900d0d3e..aaab2a46e0be 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -63,10 +63,8 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s $form .= csrf_field($csrfId ?? null); } - if (is_array($hidden)) { - foreach ($hidden as $name => $value) { - $form .= form_hidden($name, $value); - } + foreach ($hidden as $name => $value) { + $form .= form_hidden($name, $value); } return $form; From d8c7a4b7f1c4a497649800e93f14f2698097f2bf Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 3 Aug 2022 23:00:57 +0700 Subject: [PATCH 4/5] use array check --- system/Database/Forge.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/system/Database/Forge.php b/system/Database/Forge.php index f26ac6255b8d..037612cffc80 100644 --- a/system/Database/Forge.php +++ b/system/Database/Forge.php @@ -704,9 +704,11 @@ public function addColumn(string $table, $field): bool return false; } - foreach ($sqls as $sql) { - if ($this->db->query($sql) === false) { - return false; + if (is_array($sqls)) { + foreach ($sqls as $sql) { + if ($this->db->query($sql) === false) { + return false; + } } } From 3b39f2679568886c83b6c02d81e9430c15735206 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 3 Aug 2022 23:03:18 +0700 Subject: [PATCH 5/5] use array check --- system/Database/Forge.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/system/Database/Forge.php b/system/Database/Forge.php index 037612cffc80..d46dfdfde498 100644 --- a/system/Database/Forge.php +++ b/system/Database/Forge.php @@ -704,11 +704,9 @@ public function addColumn(string $table, $field): bool return false; } - if (is_array($sqls)) { - foreach ($sqls as $sql) { - if ($this->db->query($sql) === false) { - return false; - } + foreach ($sqls as $sql) { + if ($this->db->query($sql) === false) { + return false; } } @@ -766,9 +764,11 @@ public function modifyColumn(string $table, $field): bool return false; } - foreach ($sqls as $sql) { - if ($this->db->query($sql) === false) { - return false; + if (is_array($sqls)) { + foreach ($sqls as $sql) { + if ($this->db->query($sql) === false) { + return false; + } } }