Skip to content

Commit

Permalink
Removed optimization for PHP predating v7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rhertogh committed Jul 26, 2023
1 parent c8c0ea9 commit 4d60974
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions framework/db/BaseActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ public function canSetProperty($name, $checkVars = true, $checkBehaviors = true)
*/
public function __get($name)
{
if (isset($this->_attributes[$name]) || array_key_exists($name, $this->_attributes)) {
if (array_key_exists($name, $this->_attributes)) {
return $this->_attributes[$name];
}

if ($this->hasAttribute($name)) {
return null;
}

if (isset($this->_related[$name]) || array_key_exists($name, $this->_related)) {
if (array_key_exists($name, $this->_related)) {
return $this->_related[$name];
}
$value = parent::__get($name);
Expand Down
6 changes: 2 additions & 4 deletions framework/helpers/BaseArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public static function setValue(&$array, $path, $value)
*/
public static function remove(&$array, $key, $default = null)
{
if (is_array($array) && (isset($array[$key]) || array_key_exists($key, $array))) {
if (is_array($array) && array_key_exists($key, $array)) {
$value = $array[$key];
unset($array[$key]);

Expand Down Expand Up @@ -616,9 +616,7 @@ public static function map($array, $from, $to, $group = null)
public static function keyExists($key, $array, $caseSensitive = true)
{
if ($caseSensitive) {
// Function `isset` checks key faster but skips `null`, `array_key_exists` handles this case
// https://www.php.net/manual/en/function.array-key-exists.php#107786
if (is_array($array) && (isset($array[$key]) || array_key_exists($key, $array))) {
if (is_array($array) && array_key_exists($key, $array)) {
return true;
}
// Cannot use `array_has_key` on Objects for PHP 7.4+, therefore we need to check using [[ArrayAccess::offsetExists()]]
Expand Down

0 comments on commit 4d60974

Please sign in to comment.