Skip to content

Commit c194863

Browse files
committedNov 25, 2021
Fixed more PHP 8.1 issues
1 parent 43cf2a3 commit c194863

29 files changed

+309
-166
lines changed
 

‎ArrayTraits/src/ArrayAccess.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
trait ArrayAccess
1313
{
1414
/**
15-
* Whether or not an offset exists.
15+
* Tests if an offset exists.
1616
*
17-
* @param string $offset An offset to check for.
17+
* @param string|int $offset An offset to check for.
1818
* @return bool Returns TRUE on success or FALSE on failure.
1919
*/
2020
#[\ReturnTypeWillChange]
@@ -26,7 +26,7 @@ public function offsetExists($offset)
2626
/**
2727
* Returns the value at specified offset.
2828
*
29-
* @param string $offset The offset to retrieve.
29+
* @param string|int $offset The offset to retrieve.
3030
* @return mixed Can return all value types.
3131
*/
3232
#[\ReturnTypeWillChange]
@@ -38,7 +38,7 @@ public function offsetGet($offset)
3838
/**
3939
* Assigns a value to the specified offset.
4040
*
41-
* @param string|null $offset The offset to assign the value to.
41+
* @param string|int|null $offset The offset to assign the value to.
4242
* @param mixed $value The value to set.
4343
* @return void
4444
*/
@@ -55,7 +55,7 @@ public function offsetSet($offset, $value)
5555
/**
5656
* Unsets an offset.
5757
*
58-
* @param string $offset The offset to unset.
58+
* @param string|int $offset The offset to unset.
5959
* @return void
6060
*/
6161
#[\ReturnTypeWillChange]

‎ArrayTraits/src/ArrayAccessWithGetters.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ trait ArrayAccessWithGetters
1616
/**
1717
* Magic setter method
1818
*
19-
* @param string $offset Asset name value
19+
* @param string|int $offset Asset name value
2020
* @param mixed $value Asset value
2121
* @return void
2222
*/
23+
#[\ReturnTypeWillChange]
2324
public function __set($offset, $value)
2425
{
2526
$this->offsetSet($offset, $value);
@@ -31,6 +32,7 @@ public function __set($offset, $value)
3132
* @param string $offset Asset name value
3233
* @return mixed Asset value
3334
*/
35+
#[\ReturnTypeWillChange]
3436
public function __get($offset)
3537
{
3638
return $this->offsetGet($offset);
@@ -42,6 +44,7 @@ public function __get($offset)
4244
* @param string $offset Asset name value
4345
* @return bool True if the value is set
4446
*/
47+
#[\ReturnTypeWillChange]
4548
public function __isset($offset)
4649
{
4750
return $this->offsetExists($offset);
@@ -53,6 +56,7 @@ public function __isset($offset)
5356
* @param string $offset The name value to unset
5457
* @return void
5558
*/
59+
#[\ReturnTypeWillChange]
5660
public function __unset($offset)
5761
{
5862
$this->offsetUnset($offset);

‎ArrayTraits/src/Countable.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace RocketTheme\Toolbox\ArrayTraits;
44

5+
use function count;
6+
57
/**
68
* Implements \Countable interface.
79
*
@@ -16,8 +18,9 @@ trait Countable
1618
*
1719
* @return int
1820
*/
21+
#[\ReturnTypeWillChange]
1922
public function count()
2023
{
21-
return \count($this->items);
24+
return count($this->items);
2225
}
2326
}

‎ArrayTraits/src/Export.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace RocketTheme\Toolbox\ArrayTraits;
44

5+
use RuntimeException;
56
use Symfony\Component\Yaml\Exception\DumpException;
67
use Symfony\Component\Yaml\Yaml;
78

@@ -46,7 +47,7 @@ public function toJson()
4647
{
4748
$string = json_encode($this->toArray());
4849
if (!\is_string($string)) {
49-
throw new \RuntimeException('Failed to encode array', 500);
50+
throw new RuntimeException('Failed to encode array', 500);
5051
}
5152

5253
return $string;

‎ArrayTraits/src/Iterator.php

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ trait Iterator
1919
*
2020
* @return mixed Can return any type.
2121
*/
22+
#[\ReturnTypeWillChange]
2223
public function current()
2324
{
2425
return current($this->items);
@@ -29,6 +30,7 @@ public function current()
2930
*
3031
* @return string|null Returns key on success, or NULL on failure.
3132
*/
33+
#[\ReturnTypeWillChange]
3234
public function key()
3335
{
3436
return (string)key($this->items);
@@ -39,6 +41,7 @@ public function key()
3941
*
4042
* @return void
4143
*/
44+
#[\ReturnTypeWillChange]
4245
public function next()
4346
{
4447
if ($this->iteratorUnset) {
@@ -54,6 +57,7 @@ public function next()
5457
*
5558
* @return void
5659
*/
60+
#[\ReturnTypeWillChange]
5761
public function rewind()
5862
{
5963
$this->iteratorUnset = false;
@@ -65,6 +69,7 @@ public function rewind()
6569
*
6670
* @return bool Returns TRUE on success or FALSE on failure.
6771
*/
72+
#[\ReturnTypeWillChange]
6873
public function valid()
6974
{
7075
return key($this->items) !== null;

‎ArrayTraits/src/NestedArrayAccess.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace RocketTheme\Toolbox\ArrayTraits;
44

5+
use function is_array;
6+
use function is_object;
7+
58
/**
69
* Implements nested ArrayAccess interface with dot notation.
710
*
@@ -30,9 +33,9 @@ public function get($name, $default = null, $separator = null)
3033
$current = $this->items;
3134

3235
foreach ($path as $field) {
33-
if (\is_object($current) && isset($current->{$field})) {
36+
if (is_object($current) && isset($current->{$field})) {
3437
$current = $current->{$field};
35-
} elseif (\is_array($current) && isset($current[$field])) {
38+
} elseif (is_array($current) && isset($current[$field])) {
3639
$current = $current[$field];
3740
} else {
3841
return $default;
@@ -58,15 +61,15 @@ public function set($name, $value, $separator = null)
5861
$current = &$this->items;
5962

6063
foreach ($path as $field) {
61-
if (\is_object($current)) {
64+
if (is_object($current)) {
6265
// Handle objects.
6366
if (!isset($current->{$field})) {
6467
$current->{$field} = [];
6568
}
6669
$current = &$current->{$field};
6770
} else {
6871
// Handle arrays and scalars.
69-
if (!\is_array($current)) {
72+
if (!is_array($current)) {
7073
$current = [$field => []];
7174
} elseif (!isset($current[$field])) {
7275
$current[$field] = [];
@@ -104,15 +107,15 @@ public function undef($name, $separator = null)
104107
$current = &$this->items;
105108

106109
foreach ($path as $field) {
107-
if (\is_object($current)) {
110+
if (is_object($current)) {
108111
// Handle objects.
109112
if (!isset($current->{$field})) {
110113
return $this;
111114
}
112115
$current = &$current->{$field};
113116
} else {
114117
// Handle arrays and scalars.
115-
if (!\is_array($current) || !isset($current[$field])) {
118+
if (!is_array($current) || !isset($current[$field])) {
116119
return $this;
117120
}
118121
$current = &$current[$field];

‎ArrayTraits/src/NestedArrayAccessWithGetters.php

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ trait NestedArrayAccessWithGetters
2020
* @param mixed $value Asset value
2121
* @return void
2222
*/
23+
#[\ReturnTypeWillChange]
2324
public function __set($offset, $value)
2425
{
2526
$this->offsetSet($offset, $value);
@@ -31,6 +32,7 @@ public function __set($offset, $value)
3132
* @param string $offset Asset name value
3233
* @return mixed Asset value
3334
*/
35+
#[\ReturnTypeWillChange]
3436
public function __get($offset)
3537
{
3638
return $this->offsetGet($offset);
@@ -42,6 +44,7 @@ public function __get($offset)
4244
* @param string $offset Asset name value
4345
* @return bool True if the value is set
4446
*/
47+
#[\ReturnTypeWillChange]
4548
public function __isset($offset)
4649
{
4750
return $this->offsetExists($offset);
@@ -53,6 +56,7 @@ public function __isset($offset)
5356
* @param string $offset The name value to unset
5457
* @return void
5558
*/
59+
#[\ReturnTypeWillChange]
5660
public function __unset($offset)
5761
{
5862
$this->offsetUnset($offset);

‎ArrayTraits/src/Serializable.php

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ trait Serializable
1616
*
1717
* @return string Returns the string representation of the object.
1818
*/
19+
#[\ReturnTypeWillChange]
1920
public function serialize()
2021
{
2122
return serialize($this->items);
@@ -27,6 +28,7 @@ public function serialize()
2728
* @param string $serialized The string representation of the object.
2829
* @return void
2930
*/
31+
#[\ReturnTypeWillChange]
3032
public function unserialize($serialized)
3133
{
3234
$this->items = unserialize($serialized);

0 commit comments

Comments
 (0)
Please sign in to comment.