Skip to content

Enable explicit_indirect_variable #4881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1633,10 +1633,10 @@ protected function transformDataToArray($data, string $type): array
public function __get(string $name)
{
if (property_exists($this, $name)) {
return $this->$name;
return $this->{$name};
}

return $this->db->$name ?? null;
return $this->db->{$name} ?? null;
}

/**
Expand All @@ -1652,7 +1652,7 @@ public function __isset(string $name): bool
return true;
}

return isset($this->db->$name);
return isset($this->db->{$name});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions system/CLI/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function getPad(array $array, int $pad): int
*/
public function __get(string $key)
{
return $this->$key ?? null;
return $this->{$key} ?? null;
}

/**
Expand All @@ -242,6 +242,6 @@ public function __get(string $key)
*/
public function __isset(string $key): bool
{
return isset($this->$key);
return isset($this->{$key});
}
}
2 changes: 1 addition & 1 deletion system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ function esc($data, string $context = 'html', string $encoding = null)
$escaper = new Escaper($encoding);
}

$data = $escaper->$method($data);
$data = $escaper->{$method}($data);
}

return $data;
Expand Down
21 changes: 10 additions & 11 deletions system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,15 @@ public function __construct()
$shortPrefix = strtolower(substr($prefix, $slashAt === false ? 0 : $slashAt + 1));

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

if ($this instanceof Encryption && $property === 'key') {
// Handle hex2bin prefix
if (strpos($this->$property, 'hex2bin:') === 0) {
$this->$property = hex2bin(substr($this->$property, 8));
}
// Handle base64 prefix
elseif (strpos($this->$property, 'base64:') === 0) {
$this->$property = base64_decode(substr($this->$property, 7), true);
if (strpos($this->{$property}, 'hex2bin:') === 0) {
// Handle hex2bin prefix
$this->{$property} = hex2bin(substr($this->{$property}, 8));
} elseif (strpos($this->{$property}, 'base64:') === 0) {
// Handle base64 prefix
$this->{$property} = base64_decode(substr($this->{$property}, 7), true);
}
}
}
Expand Down Expand Up @@ -188,10 +187,10 @@ protected function registerProperties()
}

foreach ($properties as $property => $value) {
if (isset($this->$property) && is_array($this->$property) && is_array($value)) {
$this->$property = array_merge($this->$property, $value);
if (isset($this->{$property}) && is_array($this->{$property}) && is_array($value)) {
$this->{$property} = array_merge($this->{$property}, $value);
} else {
$this->$property = $value;
$this->{$property} = $value;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion system/Config/Factories.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static function getOptions(string $component): array
// Handle Config as a special case to prevent logic loops
? self::$configOptions
// Load values from the best Factory configuration (will include Registrars)
: config('Factory')->$component ?? [];
: config('Factory')->{$component} ?? [];

return self::setOptions($component, $values);
}
Expand Down
6 changes: 3 additions & 3 deletions system/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ protected function validate($rules, array $messages = []): bool

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

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

$rules = $validation->$rules;
$rules = $validation->{$rules};
}

return $this->validator->withRequest($this->request)->setRules($rules, $messages)->run();
Expand Down
18 changes: 9 additions & 9 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function __construct($tableName, ConnectionInterface &$db, array $options
if (! empty($options)) {
foreach ($options as $key => $value) {
if (property_exists($this, $key)) {
$this->$key = $value;
$this->{$key} = $value;
}
}
}
Expand Down Expand Up @@ -754,7 +754,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type
}

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

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

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

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

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

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

$this->QBWhereGroupStarted = true;
$prefix = empty($this->$clause) ? '' : $type;
$prefix = empty($this->{$clause}) ? '' : $type;
$where = [
'condition' => $prefix . $not . str_repeat(' ', ++$this->QBWhereGroupCount) . ' (',
'escape' => false,
Expand Down Expand Up @@ -2917,8 +2917,8 @@ protected function compileIgnore(string $statement)
*/
protected function compileWhereHaving(string $qbKey): string
{
if (! empty($this->$qbKey)) {
foreach ($this->$qbKey as &$qbkey) {
if (! empty($this->{$qbKey})) {
foreach ($this->{$qbKey} as &$qbkey) {
// Is this condition already compiled?
if (is_string($qbkey)) {
continue;
Expand Down Expand Up @@ -2974,7 +2974,7 @@ protected function compileWhereHaving(string $qbKey): string
}

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

return '';
Expand Down Expand Up @@ -3172,7 +3172,7 @@ public function resetQuery()
protected function resetRun(array $qbResetItems)
{
foreach ($qbResetItems as $item => $defaultValue) {
$this->$item = $defaultValue;
$this->{$item} = $defaultValue;
}
}

Expand Down
6 changes: 3 additions & 3 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ abstract class BaseConnection implements ConnectionInterface
public function __construct(array $params)
{
foreach ($params as $key => $value) {
$this->$key = $value;
$this->{$key} = $value;
}

$queryClass = str_replace('Connection', 'Query', static::class);
Expand Down Expand Up @@ -360,7 +360,7 @@ public function initialize()
// Replace the current settings with those of the failover
foreach ($failover as $key => $val) {
if (property_exists($this, $key)) {
$this->$key = $val;
$this->{$key} = $val;
}
}

Expand Down Expand Up @@ -1783,7 +1783,7 @@ abstract protected function _foreignKeyData(string $table): array;
public function __get(string $key)
{
if (property_exists($this, $key)) {
return $this->$key;
return $this->{$key};
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion system/Database/BaseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function getCustomResultObject(string $className)
$this->customResultObject[$className][$i] = new $className();

foreach ($this->{$_data}[$i] as $key => $value) {
$this->customResultObject[$className][$i]->$key = $value;
$this->customResultObject[$className][$i]->{$key} = $value;
}
}

Expand Down
6 changes: 3 additions & 3 deletions system/Database/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function connect($group = null, bool $getShared = true)
$group = ENVIRONMENT === 'testing' ? 'tests' : $config->defaultGroup;
}

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

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

static::ensureFactory();

if (isset($config->$group)) {
$config = $config->$group;
if (isset($config->{$group})) {
$config = $config->{$group};
}

$connection = static::$factory->load($config, $group);
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLSRV/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type
}

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

if ($v !== null) {
$op = $this->getOperator($k, true);
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLite3/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected function fetchObject(string $className = 'stdClass')
}

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

foreach (array_keys($row) as $key) {
Expand Down
4 changes: 2 additions & 2 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ protected function maskSensitiveData(&$trace, array $keysToMask, string $path =
if (strpos(strrev($path . '/' . $index), strrev($keyToMask)) === 0) {
if (is_array($trace) && array_key_exists($index, $trace)) {
$trace[$index] = '******************';
} elseif (is_object($trace) && property_exists($trace, $index) && isset($trace->$index)) {
$trace->$index = '******************';
} elseif (is_object($trace) && property_exists($trace, $index) && isset($trace->{$index})) {
$trace->{$index} = '******************';
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ public function initialize($config)
$method = 'set' . ucfirst($key);

if (method_exists($this, $method)) {
$this->$method($config[$key]);
$this->{$method}($config[$key]);
} else {
$this->$key = $config[$key];
$this->{$key} = $config[$key];
}
}
}
Expand Down Expand Up @@ -1741,7 +1741,7 @@ protected function spoolEmail()
$method = 'sendWith' . ucfirst($protocol);

try {
$success = $this->$method();
$success = $this->{$method}();
} catch (ErrorException $e) {
$success = false;
log_message('error', 'Email: ' . $method . ' throwed ' . $e->getMessage());
Expand Down
4 changes: 2 additions & 2 deletions system/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public function __set(string $key, $value = null)
$method = 'set' . str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $key)));

if (method_exists($this, $method)) {
$this->$method($value);
$this->{$method}($value);

return $this;
}
Expand Down Expand Up @@ -517,7 +517,7 @@ public function __get(string $key)
// if a set* method exists for this key,
// use that method to insert this value.
if (method_exists($this, $method)) {
$result = $this->$method();
$result = $this->{$method}();
}

// Otherwise return the protected property
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ public function setCookie(
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
foreach (['samesite', 'value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name'] as $item) {
if (isset($name[$item])) {
$$item = $name[$item];
${$item} = $name[$item];
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/UserAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ protected function compileData()
$this->setPlatform();

foreach (['setRobot', 'setBrowser', 'setMobile'] as $function) {
if ($this->$function() === true) {
if ($this->{$function}() === true) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion system/Helpers/array_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function array_sort_by_multiple_keys(array &$array, array $sortColumns): bool
if (is_object(reset($carry))) {
// Extract the object attribute
foreach ($carry as $index => $object) {
$carry[$index] = $object->$keySegment;
$carry[$index] = $object->{$keySegment};
}

continue;
Expand Down
4 changes: 2 additions & 2 deletions system/I18n/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ protected function setValue(string $name, $value)
{
[$year, $month, $day, $hour, $minute, $second] = explode('-', $this->format('Y-n-j-G-i-s'));

$$name = $value;
${$name} = $value;

return Time::create(
(int) $year,
Expand Down Expand Up @@ -1352,7 +1352,7 @@ public function __get($name)
$method = 'get' . ucfirst($name);

if (method_exists($this, $method)) {
return $this->$method();
return $this->{$method}();
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion system/Images/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ abstract protected function process(string $action);
public function __call(string $name, array $args = [])
{
if (method_exists($this->image(), $name)) {
return $this->image()->$name(...$args);
return $this->image()->{$name}(...$args);
}
}

Expand Down
6 changes: 3 additions & 3 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ public function __get(string $name)
return parent::__get($name);
}

if (isset($this->builder()->$name)) {
return $this->builder()->$name;
if (isset($this->builder()->{$name})) {
return $this->builder()->{$name};
}

return null;
Expand All @@ -730,7 +730,7 @@ public function __isset(string $name): bool
return true;
}

return isset($this->builder()->$name);
return isset($this->builder()->{$name});
}

/**
Expand Down
Loading