Skip to content
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

Improve ArrayAccess implementation in yii\base\Model #18992

Merged
merged 1 commit into from
Nov 1, 2021
Merged
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
16 changes: 8 additions & 8 deletions framework/base/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ public function getIterator()
* Returns whether there is an element at the specified offset.
* This method is required by the SPL interface [[\ArrayAccess]].
* It is implicitly called when you use something like `isset($model[$offset])`.
* @param mixed $offset the offset to check on.
* @param string $offset the offset to check on.
* @return bool whether or not an offset exists.
*/
public function offsetExists($offset)
Expand All @@ -1018,7 +1018,7 @@ public function offsetExists($offset)
* Returns the element at the specified offset.
* This method is required by the SPL interface [[\ArrayAccess]].
* It is implicitly called when you use something like `$value = $model[$offset];`.
* @param mixed $offset the offset to retrieve element.
* @param string $offset the offset to retrieve element.
* @return mixed the element at the offset, null if no element is found at the offset
*/
public function offsetGet($offset)
Expand All @@ -1029,20 +1029,20 @@ public function offsetGet($offset)
/**
* Sets the element at the specified offset.
* This method is required by the SPL interface [[\ArrayAccess]].
* It is implicitly called when you use something like `$model[$offset] = $item;`.
* @param int $offset the offset to set element
* @param mixed $item the element value
* It is implicitly called when you use something like `$model[$offset] = $value;`.
* @param string $offset the offset to set element
* @param mixed $value the element value
*/
public function offsetSet($offset, $item)
public function offsetSet($offset, $value)
{
$this->$offset = $item;
$this->$offset = $value;
}

/**
* Sets the element value at the specified offset to null.
* This method is required by the SPL interface [[\ArrayAccess]].
* It is implicitly called when you use something like `unset($model[$offset])`.
* @param mixed $offset the offset to unset element
* @param string $offset the offset to unset element
*/
public function offsetUnset($offset)
{
Expand Down