-
-
Notifications
You must be signed in to change notification settings - Fork 34
Fix deprecated PHP patterns for PHP 8.2–8.5+ compatibility #151
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
Changes from 5 commits
eb963d8
151eeb4
5f523a0
ab15e30
7da08a6
d48b02a
ce22716
f833480
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 |
|---|---|---|
|
|
@@ -274,9 +274,9 @@ | |
| ); | ||
| } | ||
|
|
||
| $this->internalSet($key, $value); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| return $this->append($value); | ||
|
|
@@ -322,7 +322,7 @@ | |
| $this->array[] = $value; | ||
| } | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -392,7 +392,7 @@ | |
|
|
||
| \asort($this->array, $sort_flags); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -419,7 +419,7 @@ | |
| */ | ||
| $that->asort($sort_flags); | ||
|
|
||
| return $that; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -473,7 +473,7 @@ | |
| return \iterator_count($this->generator); | ||
| } | ||
|
|
||
| return \count($this->toArray(), $mode); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -594,7 +594,7 @@ | |
|
|
||
| \ksort($this->array, $sort_flags); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -620,7 +620,7 @@ | |
| */ | ||
| $that->ksort($sort_flags); | ||
|
|
||
| return $that; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -638,7 +638,7 @@ | |
|
|
||
| \natcasesort($this->array); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -659,7 +659,7 @@ | |
| */ | ||
| $that->natcasesort(); | ||
|
|
||
| return $that; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1941,7 +1941,7 @@ | |
| * @phpstan-return static<int,string> | ||
| * @psalm-mutation-free | ||
| */ | ||
| public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self | ||
| public static function createFromString(string $str, ?string $delimiter = null, ?string $regEx = null): self | ||
| { | ||
| if ($regEx) { | ||
| \preg_match_all($regEx, $str, $array); | ||
|
|
@@ -2648,7 +2648,7 @@ | |
| public function filterBy( | ||
| string $property, | ||
| $value, | ||
| string $comparisonOp = null | ||
| ?string $comparisonOp = null | ||
| ): self { | ||
| if (!$comparisonOp) { | ||
| $comparisonOp = \is_array($value) ? 'contains' : 'eq'; | ||
|
|
@@ -2834,7 +2834,7 @@ | |
| * @phpstan-return static<TKey,T> | ||
| * @psalm-mutation-free | ||
| */ | ||
| public function firstsImmutable(int $number = null): self | ||
| public function firstsImmutable(?int $number = null): self | ||
| { | ||
| $arrayTmp = $this->toArray(); | ||
|
|
||
|
|
@@ -2863,7 +2863,7 @@ | |
| * @phpstan-return static<array-key,TKey> | ||
| * @psalm-mutation-free | ||
| */ | ||
| public function firstsKeys(int $number = null): self | ||
| public function firstsKeys(?int $number = null): self | ||
| { | ||
| $arrayTmp = $this->keys()->toArray(); | ||
|
|
||
|
|
@@ -2895,7 +2895,7 @@ | |
| * | ||
| * @phpstan-return ($number is null ? static<int,T> : static<TKey,T>) | ||
| */ | ||
| public function firstsMutable(int $number = null): self | ||
| public function firstsMutable(?int $number = null): self | ||
| { | ||
| $this->generatorToArray(); | ||
|
|
||
|
|
@@ -2972,7 +2972,7 @@ | |
| public function get( | ||
| $key = null, | ||
| $fallback = null, | ||
| array $array = null, | ||
| ?array $array = null, | ||
| bool $useByReference = false | ||
| ) { | ||
| if ($array === null && $key === null) { | ||
|
|
@@ -4265,7 +4265,7 @@ | |
| * @phpstan-return static<TKey,T> | ||
| * @psalm-mutation-free | ||
| */ | ||
| public function lastsImmutable(int $number = null): self | ||
| public function lastsImmutable(?int $number = null): self | ||
| { | ||
| if ($this->isEmpty()) { | ||
| return static::create( | ||
|
|
@@ -4310,7 +4310,7 @@ | |
| * | ||
| * @phpstan-return static<TKey,T> | ||
| */ | ||
| public function lastsMutable(int $number = null): self | ||
| public function lastsMutable(?int $number = null): self | ||
| { | ||
| if ($this->isEmpty()) { | ||
| return $this; | ||
|
|
@@ -4724,7 +4724,7 @@ | |
| * @phpstan-return static<array-key,T> | ||
| * @psalm-mutation-free | ||
| */ | ||
| public function mostUsedValues(int $number = null): self | ||
| public function mostUsedValues(?int $number = null): self | ||
| { | ||
| return $this->countValues()->arsortImmutable()->firstsKeys($number); | ||
| } | ||
|
|
@@ -5230,7 +5230,7 @@ | |
| * | ||
| * @phpstan-return static<array-key,T> | ||
| */ | ||
| public function randomImmutable(int $number = null): self | ||
| public function randomImmutable(?int $number = null): self | ||
| { | ||
| $this->generatorToArray(); | ||
|
|
||
|
|
@@ -5347,7 +5347,7 @@ | |
| * | ||
| * @phpstan-return static<TKey,T> | ||
| */ | ||
| public function randomMutable(int $number = null): self | ||
| public function randomMutable(?int $number = null): self | ||
| { | ||
| $this->generatorToArray(); | ||
|
|
||
|
|
@@ -5429,7 +5429,7 @@ | |
| * @phpstan-param array<(int&T)|(string&T),int> $array | ||
| * @phpstan-return static<array-key,T> | ||
| */ | ||
| public function randomWeighted(array $array, int $number = null): self | ||
| public function randomWeighted(array $array, ?int $number = null): self | ||
| { | ||
| // init | ||
| $options = []; | ||
|
|
@@ -6248,7 +6248,7 @@ | |
| * @phpstan-param array<TKey,T> $array | ||
| * @phpstan-return static<TKey,T> | ||
| */ | ||
| public function shuffle(bool $secure = false, array $array = null): self | ||
| public function shuffle(bool $secure = false, ?array $array = null): self | ||
| { | ||
| if ($array === null) { | ||
| $array = $this->toArray(false); | ||
|
|
@@ -6454,7 +6454,7 @@ | |
| * @phpstan-return static<array-key,T> | ||
| * @psalm-mutation-free | ||
| */ | ||
| public function slice(int $offset, int $length = null, bool $preserveKeys = false) | ||
| public function slice(int $offset, ?int $length = null, bool $preserveKeys = false) | ||
| { | ||
| return static::create( | ||
| \array_slice( | ||
|
|
@@ -6719,7 +6719,7 @@ | |
| * @phpstan-return static<TKey,T> | ||
| * @psalm-mutation-free | ||
| */ | ||
| public function splice(int $offset, int $length = null, $replacement = []): self | ||
| public function splice(int $offset, ?int $length = null, $replacement = []): self | ||
| { | ||
| $tmpArray = $this->toArray(); | ||
|
|
||
|
|
@@ -6967,7 +6967,7 @@ | |
| * | ||
| * @phpstan-return static<int, static<TKey,T>> | ||
| */ | ||
| public function toPermutation(array $items = null, array $helper = []): self | ||
| public function toPermutation(?array $items = null, array $helper = []): self | ||
| { | ||
| // init | ||
| $return = []; | ||
|
|
@@ -7891,7 +7891,7 @@ | |
| /** | ||
| * @psalm-suppress PossiblyInvalidArgument - the parameter is always some kind of array - false-positive from psalm? | ||
| */ | ||
| return \array_map(['static', 'objectToArray'], $object); | ||
| return \array_map(\Closure::fromCallable([static::class, 'objectToArray']), $object); | ||
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| namespace Arrayy; | ||
|
|
||
| #[\AllowDynamicProperties] | ||
| final class ArrayyMeta | ||
|
Comment on lines
+7
to
8
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. While |
||
| { | ||
| /** @noinspection MagicMethodsValidityInspection */ | ||
|
|
||
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.
Using
"*"as a version constraint forphpstan/phpstanis not recommended as it can pull in major versions with breaking changes, potentially causing your CI/builds to fail unexpectedly. It's better to use a more restrictive constraint, for example"^1.0", to ensure stability.