-
Notifications
You must be signed in to change notification settings - Fork 8
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
PHP 8.x Support #33
PHP 8.x Support #33
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
parameters: | ||
level: 1 | ||
paths: | ||
- src | ||
- config |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,9 @@ class MutatorProvider implements ArrayAccess | |
protected $mutators = []; | ||
|
||
/** | ||
* @param string $mutator | ||
* @param string $mutator | ||
* @return \Weebly\Mutate\Mutators\MutatorContract | ||
* | ||
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException | ||
*/ | ||
public function get($mutator) | ||
|
@@ -31,8 +32,8 @@ public function get($mutator) | |
} | ||
|
||
/** | ||
* @param string $name | ||
* @param mixed $mutator | ||
* @param string $name | ||
* @param mixed $mutator | ||
* @return $this | ||
*/ | ||
public function set($name, $mutator) | ||
|
@@ -43,7 +44,7 @@ public function set($name, $mutator) | |
} | ||
|
||
/** | ||
* @param string $mutator | ||
* @param string $mutator | ||
* @return bool | ||
*/ | ||
public function exists($mutator) | ||
|
@@ -52,7 +53,7 @@ public function exists($mutator) | |
} | ||
|
||
/** | ||
* @param array $mutators | ||
* @param array $mutators | ||
*/ | ||
public function registerMutators(array $mutators) | ||
{ | ||
|
@@ -63,45 +64,51 @@ public function registerMutators(array $mutators) | |
} | ||
|
||
/** | ||
* @param string $offset | ||
* @param string $offset | ||
* @return bool | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
public function offsetExists($offset) | ||
{ | ||
return $this->exists($offset); | ||
} | ||
|
||
/** | ||
* @param string $offset | ||
* @param string $offset | ||
* @return \Weebly\Mutate\Mutators\MutatorContract | ||
* | ||
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
public function offsetGet($offset) | ||
{ | ||
return $this->get($offset); | ||
} | ||
|
||
/** | ||
* @param string $offset | ||
* @param mixed $value | ||
* @param string $offset | ||
* @param mixed $value | ||
* @return \Weebly\Mutate\MutatorProvider | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
public function offsetSet($offset, $value) | ||
{ | ||
return $this->set($offset, $value); | ||
} | ||
|
||
/** | ||
* @param string $offset | ||
* @param string $offset | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What behavior are we driving from this? The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding this attribute is necessary to prevent these errors in PHPStan (also, PHP will throw an error when executing this code in PHP 8.1 if this attribute is not added or the return type is not set correctly.
In older PHP versions, since it is |
||
public function offsetUnset($offset) | ||
{ | ||
unset($this->mutators[$offset]); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @param string $name | ||
* @return \Weebly\Mutate\Mutators\MutatorContract | ||
* | ||
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException | ||
*/ | ||
public function __get($name) | ||
|
@@ -110,16 +117,16 @@ public function __get($name) | |
} | ||
|
||
/** | ||
* @param string $name | ||
* @param mixed $value | ||
* @param string $name | ||
* @param mixed $value | ||
*/ | ||
public function __set($name, $value) | ||
{ | ||
$this->set($name, $value); | ||
} | ||
|
||
/** | ||
* @param string $key | ||
* @param string $key | ||
* @return bool | ||
*/ | ||
public function __isset($key) | ||
|
@@ -128,7 +135,7 @@ public function __isset($key) | |
} | ||
|
||
/** | ||
* @param string $key | ||
* @param string $key | ||
* @return void | ||
*/ | ||
public function __unset($key) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
statement got added, but this doesn't seem to be used anywhere in the fileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually used here
laravel-mutate/src/Database/EloquentBuilder.php
Lines 69 to 72 in aab32b1
This is technically a bugfix ;)