Skip to content

Commit

Permalink
Merge pull request #214 from JonasKraska/adding-php-8.2-support
Browse files Browse the repository at this point in the history
Adding php 8.2 support
  • Loading branch information
boesing authored Apr 14, 2023
2 parents 1dba6b6 + b6922ec commit b4bcbfa
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 113 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"description": "Hashmap and Collection",
"license": "MIT",
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"webmozart/assert": "^1.9"
},
"require-dev": {
"doctrine/coding-standard": "^11.1",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6",
"psalm/plugin-phpunit": "^0.18.4",
"symfony/polyfill-php80": "^1.22",
"vimeo/psalm": "^5.9"
Expand Down
49 changes: 25 additions & 24 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment"/>
<!-- Can be removed with dropping support for PHP 7.4 -->
<exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator.RequiredNullCoalesceEqualOperator"/>
<!-- Static callables are deprecated as of PHP 8.2 -->
<exclude name="SlevomatCodingStandard.Functions.StaticClosure.ClosureNotStatic"/>
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion src/Array_.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function count(): int
*/
protected function valueComparator(): callable
{
return static function ($a, $b): int {
return function ($a, $b): int {
if (! is_object($a) || ! is_object($b)) {
return $a <=> $b;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function diffKeys(MapInterface $other, ?callable $keyComparator = null):
*/
private function keyComparator(): callable
{
return static function (string $a, string $b): int {
return function (string $a, string $b): int {
return strcmp($a, $b);
};
}
Expand Down
18 changes: 8 additions & 10 deletions src/OrderedList.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function toMap(callable $keyGenerator): MapInterface
public function removeElement($element): OrderedListInterface
{
return $this->filter(
static function ($value) use ($element): bool {
function ($value) use ($element): bool {
return $value !== $element;
},
);
Expand Down Expand Up @@ -219,14 +219,12 @@ public function unify(
?callable $unificationIdentifierGenerator = null,
?callable $callback = null
): OrderedListInterface {
/** @psalm-suppress MissingClosureParamType */
/**
* @psalm-suppress MissingClosureParamType
* @psalm-var callable(mixed):non-empty-string $unificationIdentifierGenerator
*/
$unificationIdentifierGenerator = $unificationIdentifierGenerator
?? static function ($value): string {
$hash = hash('sha256', serialize($value));
Assert::stringNotEmpty($hash);

return $hash;
};
?? fn ($value): string => hash('sha256', serialize($value));

$instance = clone $this;

Expand Down Expand Up @@ -302,7 +300,7 @@ private function createListFilledWithValues(int $start, int $amount, $value): ar
* @psalm-suppress MissingClosureReturnType We have to assume that the value contains the fill value.
* @return TValue
*/
$callable = static fn () => $value;
$callable = fn () => $value;
}

for ($index = $start; $index < $amount; $index++) {
Expand Down Expand Up @@ -471,6 +469,6 @@ public function prepend($value): OrderedListInterface

public function removeAt(int $index): OrderedListInterface
{
return $this->filter(static fn ($_, int $i) => $i !== $index);
return $this->filter(fn ($_, int $i) => $i !== $index);
}
}
2 changes: 1 addition & 1 deletion tests/ForAllPromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ForAllPromiseTest extends TestCase
public function testWillNotExecuteTwiceDueToDestructionOfObject(): void
{
$executed = false;
$task = static function () use (&$executed): void {
$task = function () use (&$executed): void {
self::assertFalse($executed, 'Task was executed more than once!');
$executed = true;
};
Expand Down
Loading

0 comments on commit b4bcbfa

Please sign in to comment.