Skip to content

Commit 43d81fb

Browse files
authored
Merge pull request #7088 from samsonasik/rector-enable-add-default
[Rector] Enable AddDefaultValueForUndefinedVariableRector
2 parents 0391c3f + ee9abc7 commit 43d81fb

16 files changed

Lines changed: 23 additions & 32 deletions

File tree

phpstan-baseline.neon.dist

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ parameters:
195195
count: 1
196196
path: system/Helpers/number_helper.php
197197

198-
-
199-
message: "#^Variable \\$count might not be defined\\.$#"
200-
count: 1
201-
path: system/Helpers/url_helper.php
202-
203198
-
204199
message: "#^Property CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:\\$image \\(CodeIgniter\\\\Images\\\\Image\\) in empty\\(\\) is not falsy\\.$#"
205200
count: 1
@@ -225,21 +220,6 @@ parameters:
225220
count: 4
226221
path: system/Images/Handlers/ImageMagickHandler.php
227222

228-
-
229-
message: "#^Variable \\$gravity might not be defined\\.$#"
230-
count: 1
231-
path: system/Images/Handlers/ImageMagickHandler.php
232-
233-
-
234-
message: "#^Variable \\$xAxis might not be defined\\.$#"
235-
count: 1
236-
path: system/Images/Handlers/ImageMagickHandler.php
237-
238-
-
239-
message: "#^Variable \\$yAxis might not be defined\\.$#"
240-
count: 1
241-
path: system/Images/Handlers/ImageMagickHandler.php
242-
243223
-
244224
message: "#^Call to an undefined method CodeIgniter\\\\Router\\\\RouteCollectionInterface\\:\\:getDefaultNamespace\\(\\)\\.$#"
245225
count: 3

rector.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
3737
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
3838
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
39-
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
4039
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
4140
use Rector\Php71\Rector\FuncCall\CountOnNullRector;
4241
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
@@ -106,9 +105,6 @@
106105
// sometime too detail
107106
CountOnNullRector::class,
108107

109-
// may not be unitialized on purpose
110-
AddDefaultValueForUndefinedVariableRector::class,
111-
112108
// use mt_rand instead of random_int on purpose on non-cryptographically random
113109
RandomFunctionRector::class,
114110

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ public function initialize()
124124
*/
125125
public function get(string $key)
126126
{
127-
$key = static::validateKey($key, $this->prefix);
127+
$data = [];
128+
$key = static::validateKey($key, $this->prefix);
128129

129130
if ($this->memcached instanceof Memcached) {
130131
$data = $this->memcached->get($key);

system/Commands/Generators/MigrationGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function run(array $params)
9797
*/
9898
protected function prepare(string $class): string
9999
{
100+
$data = [];
100101
$data['session'] = false;
101102

102103
if ($this->getOption('session')) {

system/Commands/Generators/SessionMigrationGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function run(array $params)
8989
*/
9090
protected function prepare(string $class): string
9191
{
92+
$data = [];
9293
$data['session'] = true;
9394
$data['table'] = $this->getOption('t');
9495
$data['DBGroup'] = $this->getOption('g');

system/Commands/Utilities/FilterCheck.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class FilterCheck extends BaseCommand
7272
*/
7373
public function run(array $params)
7474
{
75+
$tbody = [];
7576
if (! isset($params[0], $params[1])) {
7677
CLI::error('You must specify a HTTP verb and a route.');
7778
CLI::write(' Usage: ' . $this->usage);

system/Database/BaseBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@ public function orHaving($key, $value = null, ?bool $escape = null)
14231423
*/
14241424
public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null)
14251425
{
1426+
$qbOrderBy = [];
14261427
if (empty($orderBy)) {
14271428
return $this;
14281429
}

system/Database/SQLSRV/Connection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ public function getPlatform(): string
529529
*/
530530
public function getVersion(): string
531531
{
532+
$info = [];
532533
if (isset($this->dataCache['version'])) {
533534
return $this->dataCache['version'];
534535
}

system/Debug/Toolbar.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function __construct(ToolbarConfig $config)
7676
*/
7777
public function run(float $startTime, float $totalTime, RequestInterface $request, ResponseInterface $response): string
7878
{
79+
$data = [];
7980
// Data items used within the view.
8081
$data['url'] = current_url();
8182
$data['method'] = strtoupper($request->getMethod());

system/Debug/Toolbar/Collectors/Database.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ protected function formatTimelineData(): array
140140
*/
141141
public function display(): array
142142
{
143+
$data = [];
143144
$data['queries'] = array_map(static function (array $query) {
144145
$isDuplicate = $query['duplicate'] === true;
145146

0 commit comments

Comments
 (0)