Skip to content

Commit 308d0be

Browse files
authored
Enable explicit_indirect_variable (#4881)
1 parent 7b7d251 commit 308d0be

31 files changed

+82
-82
lines changed

system/BaseModel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,10 +1633,10 @@ protected function transformDataToArray($data, string $type): array
16331633
public function __get(string $name)
16341634
{
16351635
if (property_exists($this, $name)) {
1636-
return $this->$name;
1636+
return $this->{$name};
16371637
}
16381638

1639-
return $this->db->$name ?? null;
1639+
return $this->db->{$name} ?? null;
16401640
}
16411641

16421642
/**
@@ -1652,7 +1652,7 @@ public function __isset(string $name): bool
16521652
return true;
16531653
}
16541654

1655-
return isset($this->db->$name);
1655+
return isset($this->db->{$name});
16561656
}
16571657

16581658
/**

system/CLI/BaseCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function getPad(array $array, int $pad): int
230230
*/
231231
public function __get(string $key)
232232
{
233-
return $this->$key ?? null;
233+
return $this->{$key} ?? null;
234234
}
235235

236236
/**
@@ -242,6 +242,6 @@ public function __get(string $key)
242242
*/
243243
public function __isset(string $key): bool
244244
{
245-
return isset($this->$key);
245+
return isset($this->{$key});
246246
}
247247
}

system/Common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ function esc($data, string $context = 'html', string $encoding = null)
457457
$escaper = new Escaper($encoding);
458458
}
459459

460-
$data = $escaper->$method($data);
460+
$data = $escaper->{$method}($data);
461461
}
462462

463463
return $data;

system/Config/BaseConfig.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,15 @@ public function __construct()
6969
$shortPrefix = strtolower(substr($prefix, $slashAt === false ? 0 : $slashAt + 1));
7070

7171
foreach ($properties as $property) {
72-
$this->initEnvValue($this->$property, $property, $prefix, $shortPrefix);
72+
$this->initEnvValue($this->{$property}, $property, $prefix, $shortPrefix);
7373

7474
if ($this instanceof Encryption && $property === 'key') {
75-
// Handle hex2bin prefix
76-
if (strpos($this->$property, 'hex2bin:') === 0) {
77-
$this->$property = hex2bin(substr($this->$property, 8));
78-
}
79-
// Handle base64 prefix
80-
elseif (strpos($this->$property, 'base64:') === 0) {
81-
$this->$property = base64_decode(substr($this->$property, 7), true);
75+
if (strpos($this->{$property}, 'hex2bin:') === 0) {
76+
// Handle hex2bin prefix
77+
$this->{$property} = hex2bin(substr($this->{$property}, 8));
78+
} elseif (strpos($this->{$property}, 'base64:') === 0) {
79+
// Handle base64 prefix
80+
$this->{$property} = base64_decode(substr($this->{$property}, 7), true);
8281
}
8382
}
8483
}
@@ -188,10 +187,10 @@ protected function registerProperties()
188187
}
189188

190189
foreach ($properties as $property => $value) {
191-
if (isset($this->$property) && is_array($this->$property) && is_array($value)) {
192-
$this->$property = array_merge($this->$property, $value);
190+
if (isset($this->{$property}) && is_array($this->{$property}) && is_array($value)) {
191+
$this->{$property} = array_merge($this->{$property}, $value);
193192
} else {
194-
$this->$property = $value;
193+
$this->{$property} = $value;
195194
}
196195
}
197196
}

system/Config/Factories.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public static function getOptions(string $component): array
242242
// Handle Config as a special case to prevent logic loops
243243
? self::$configOptions
244244
// Load values from the best Factory configuration (will include Registrars)
245-
: config('Factory')->$component ?? [];
245+
: config('Factory')->{$component} ?? [];
246246

247247
return self::setOptions($component, $values);
248248
}

system/Controller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,17 @@ protected function validate($rules, array $messages = []): bool
162162

163163
// If the rule wasn't found in the \Config\Validation, we
164164
// should throw an exception so the developer can find it.
165-
if (! isset($validation->$rules)) {
165+
if (! isset($validation->{$rules})) {
166166
throw ValidationException::forRuleNotFound($rules);
167167
}
168168

169169
// If no error message is defined, use the error message in the Config\Validation file
170170
if (! $messages) {
171171
$errorName = $rules . '_errors';
172-
$messages = $validation->$errorName ?? [];
172+
$messages = $validation->{$errorName} ?? [];
173173
}
174174

175-
$rules = $validation->$rules;
175+
$rules = $validation->{$rules};
176176
}
177177

178178
return $this->validator->withRequest($this->request)->setRules($rules, $messages)->run();

system/Database/BaseBuilder.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function __construct($tableName, ConnectionInterface &$db, array $options
272272
if (! empty($options)) {
273273
foreach ($options as $key => $value) {
274274
if (property_exists($this, $key)) {
275-
$this->$key = $value;
275+
$this->{$key} = $value;
276276
}
277277
}
278278
}
@@ -754,7 +754,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type
754754
}
755755

756756
foreach ($key as $k => $v) {
757-
$prefix = empty($this->$qbKey) ? $this->groupGetType('') : $this->groupGetType($type);
757+
$prefix = empty($this->{$qbKey}) ? $this->groupGetType('') : $this->groupGetType($type);
758758

759759
if ($v !== null) {
760760
$op = $this->getOperator($k, true);
@@ -1013,7 +1013,7 @@ protected function _whereIn(string $key = null, $values = null, bool $not = fals
10131013
$ok = $this->setBind($ok, $whereIn, $escape);
10141014
}
10151015

1016-
$prefix = empty($this->$clause) ? $this->groupGetType('') : $this->groupGetType($type);
1016+
$prefix = empty($this->{$clause}) ? $this->groupGetType('') : $this->groupGetType($type);
10171017

10181018
$whereIn = [
10191019
'condition' => $prefix . $key . $not . ($values instanceof Closure ? " IN ({$ok})" : " IN :{$ok}:"),
@@ -1230,7 +1230,7 @@ protected function _like($field, string $match = '', string $type = 'AND ', stri
12301230
$v = strtolower($v);
12311231
}
12321232

1233-
$prefix = empty($this->$clause) ? $this->groupGetType('') : $this->groupGetType($type);
1233+
$prefix = empty($this->{$clause}) ? $this->groupGetType('') : $this->groupGetType($type);
12341234

12351235
if ($side === 'none') {
12361236
$bind = $this->setBind($k, $v, $escape);
@@ -1416,7 +1416,7 @@ protected function groupStartPrepare(string $not = '', string $type = 'AND ', st
14161416
$type = $this->groupGetType($type);
14171417

14181418
$this->QBWhereGroupStarted = true;
1419-
$prefix = empty($this->$clause) ? '' : $type;
1419+
$prefix = empty($this->{$clause}) ? '' : $type;
14201420
$where = [
14211421
'condition' => $prefix . $not . str_repeat(' ', ++$this->QBWhereGroupCount) . ' (',
14221422
'escape' => false,
@@ -2917,8 +2917,8 @@ protected function compileIgnore(string $statement)
29172917
*/
29182918
protected function compileWhereHaving(string $qbKey): string
29192919
{
2920-
if (! empty($this->$qbKey)) {
2921-
foreach ($this->$qbKey as &$qbkey) {
2920+
if (! empty($this->{$qbKey})) {
2921+
foreach ($this->{$qbKey} as &$qbkey) {
29222922
// Is this condition already compiled?
29232923
if (is_string($qbkey)) {
29242924
continue;
@@ -2974,7 +2974,7 @@ protected function compileWhereHaving(string $qbKey): string
29742974
}
29752975

29762976
return ($qbKey === 'QBHaving' ? "\nHAVING " : "\nWHERE ")
2977-
. implode("\n", $this->$qbKey);
2977+
. implode("\n", $this->{$qbKey});
29782978
}
29792979

29802980
return '';
@@ -3172,7 +3172,7 @@ public function resetQuery()
31723172
protected function resetRun(array $qbResetItems)
31733173
{
31743174
foreach ($qbResetItems as $item => $defaultValue) {
3175-
$this->$item = $defaultValue;
3175+
$this->{$item} = $defaultValue;
31763176
}
31773177
}
31783178

system/Database/BaseConnection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ abstract class BaseConnection implements ConnectionInterface
307307
public function __construct(array $params)
308308
{
309309
foreach ($params as $key => $value) {
310-
$this->$key = $value;
310+
$this->{$key} = $value;
311311
}
312312

313313
$queryClass = str_replace('Connection', 'Query', static::class);
@@ -360,7 +360,7 @@ public function initialize()
360360
// Replace the current settings with those of the failover
361361
foreach ($failover as $key => $val) {
362362
if (property_exists($this, $key)) {
363-
$this->$key = $val;
363+
$this->{$key} = $val;
364364
}
365365
}
366366

@@ -1783,7 +1783,7 @@ abstract protected function _foreignKeyData(string $table): array;
17831783
public function __get(string $key)
17841784
{
17851785
if (property_exists($this, $key)) {
1786-
return $this->$key;
1786+
return $this->{$key};
17871787
}
17881788

17891789
return null;

system/Database/BaseResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function getCustomResultObject(string $className)
144144
$this->customResultObject[$className][$i] = new $className();
145145

146146
foreach ($this->{$_data}[$i] as $key => $value) {
147-
$this->customResultObject[$className][$i]->$key = $value;
147+
$this->customResultObject[$className][$i]->{$key} = $value;
148148
}
149149
}
150150

system/Database/Config.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function connect($group = null, bool $getShared = true)
6464
$group = ENVIRONMENT === 'testing' ? 'tests' : $config->defaultGroup;
6565
}
6666

67-
if (is_string($group) && ! isset($config->$group) && strpos($group, 'custom-') !== 0) {
67+
if (is_string($group) && ! isset($config->{$group}) && strpos($group, 'custom-') !== 0) {
6868
throw new InvalidArgumentException($group . ' is not a valid database connection group.');
6969
}
7070

@@ -74,8 +74,8 @@ public static function connect($group = null, bool $getShared = true)
7474

7575
static::ensureFactory();
7676

77-
if (isset($config->$group)) {
78-
$config = $config->$group;
77+
if (isset($config->{$group})) {
78+
$config = $config->{$group};
7979
}
8080

8181
$connection = static::$factory->load($config, $group);

system/Database/SQLSRV/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type
621621
}
622622

623623
foreach ($key as $k => $v) {
624-
$prefix = empty($this->$qbKey) ? $this->groupGetType('') : $this->groupGetType($type);
624+
$prefix = empty($this->{$qbKey}) ? $this->groupGetType('') : $this->groupGetType($type);
625625

626626
if ($v !== null) {
627627
$op = $this->getOperator($k, true);

system/Database/SQLite3/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function fetchObject(string $className = 'stdClass')
164164
}
165165

166166
$classSet = Closure::bind(function ($key, $value) {
167-
$this->$key = $value;
167+
$this->{$key} = $value;
168168
}, $classObj, $className);
169169

170170
foreach (array_keys($row) as $key) {

system/Debug/Exceptions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ protected function maskSensitiveData(&$trace, array $keysToMask, string $path =
313313
if (strpos(strrev($path . '/' . $index), strrev($keyToMask)) === 0) {
314314
if (is_array($trace) && array_key_exists($index, $trace)) {
315315
$trace[$index] = '******************';
316-
} elseif (is_object($trace) && property_exists($trace, $index) && isset($trace->$index)) {
317-
$trace->$index = '******************';
316+
} elseif (is_object($trace) && property_exists($trace, $index) && isset($trace->{$index})) {
317+
$trace->{$index} = '******************';
318318
}
319319
}
320320
}

system/Email/Email.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,9 @@ public function initialize($config)
420420
$method = 'set' . ucfirst($key);
421421

422422
if (method_exists($this, $method)) {
423-
$this->$method($config[$key]);
423+
$this->{$method}($config[$key]);
424424
} else {
425-
$this->$key = $config[$key];
425+
$this->{$key} = $config[$key];
426426
}
427427
}
428428
}
@@ -1741,7 +1741,7 @@ protected function spoolEmail()
17411741
$method = 'sendWith' . ucfirst($protocol);
17421742

17431743
try {
1744-
$success = $this->$method();
1744+
$success = $this->{$method}();
17451745
} catch (ErrorException $e) {
17461746
$success = false;
17471747
log_message('error', 'Email: ' . $method . ' throwed ' . $e->getMessage());

system/Entity/Entity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public function __set(string $key, $value = null)
477477
$method = 'set' . str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $key)));
478478

479479
if (method_exists($this, $method)) {
480-
$this->$method($value);
480+
$this->{$method}($value);
481481

482482
return $this;
483483
}
@@ -517,7 +517,7 @@ public function __get(string $key)
517517
// if a set* method exists for this key,
518518
// use that method to insert this value.
519519
if (method_exists($this, $method)) {
520-
$result = $this->$method();
520+
$result = $this->{$method}();
521521
}
522522

523523
// Otherwise return the protected property

system/HTTP/ResponseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ public function setCookie(
573573
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
574574
foreach (['samesite', 'value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name'] as $item) {
575575
if (isset($name[$item])) {
576-
$$item = $name[$item];
576+
${$item} = $name[$item];
577577
}
578578
}
579579
}

system/HTTP/UserAgent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ protected function compileData()
333333
$this->setPlatform();
334334

335335
foreach (['setRobot', 'setBrowser', 'setMobile'] as $function) {
336-
if ($this->$function() === true) {
336+
if ($this->{$function}() === true) {
337337
break;
338338
}
339339
}

system/Helpers/array_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function array_sort_by_multiple_keys(array &$array, array $sortColumns): bool
169169
if (is_object(reset($carry))) {
170170
// Extract the object attribute
171171
foreach ($carry as $index => $object) {
172-
$carry[$index] = $object->$keySegment;
172+
$carry[$index] = $object->{$keySegment};
173173
}
174174

175175
continue;

system/I18n/Time.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ protected function setValue(string $name, $value)
778778
{
779779
[$year, $month, $day, $hour, $minute, $second] = explode('-', $this->format('Y-n-j-G-i-s'));
780780

781-
$$name = $value;
781+
${$name} = $value;
782782

783783
return Time::create(
784784
(int) $year,
@@ -1352,7 +1352,7 @@ public function __get($name)
13521352
$method = 'get' . ucfirst($name);
13531353

13541354
if (method_exists($this, $method)) {
1355-
return $this->$method();
1355+
return $this->{$method}();
13561356
}
13571357

13581358
return null;

system/Images/Handlers/BaseHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ abstract protected function process(string $action);
812812
public function __call(string $name, array $args = [])
813813
{
814814
if (method_exists($this->image(), $name)) {
815-
return $this->image()->$name(...$args);
815+
return $this->image()->{$name}(...$args);
816816
}
817817
}
818818

system/Model.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,8 @@ public function __get(string $name)
710710
return parent::__get($name);
711711
}
712712

713-
if (isset($this->builder()->$name)) {
714-
return $this->builder()->$name;
713+
if (isset($this->builder()->{$name})) {
714+
return $this->builder()->{$name};
715715
}
716716

717717
return null;
@@ -730,7 +730,7 @@ public function __isset(string $name): bool
730730
return true;
731731
}
732732

733-
return isset($this->builder()->$name);
733+
return isset($this->builder()->{$name});
734734
}
735735

736736
/**

0 commit comments

Comments
 (0)