diff --git a/ChangeLog-11.5.md b/ChangeLog-11.5.md index 25a5d82f633..7b48ff1bef9 100644 --- a/ChangeLog-11.5.md +++ b/ChangeLog-11.5.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 11.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [11.5.2] - 2024-MM-DD + +### Fixed + +* [#6082](https://github.com/sebastianbergmann/phpunit/issues/6082): `assertArrayHasKey()`, `assertArrayNotHasKey()`, `arrayHasKey()`, and `ArrayHasKey::__construct()` do not support all possible key types + ## [11.5.1] - 2024-12-11 ### Added @@ -37,5 +43,6 @@ All notable changes of the PHPUnit 11.5 release series are documented in this fi * [#6055](https://github.com/sebastianbergmann/phpunit/issues/6055): `assertNotContainsOnly()` (use `assertContainsNotOnlyArray()`, `assertContainsNotOnlyBool()`, `assertContainsNotOnlyCallable()`, `assertContainsNotOnlyFloat()`, `assertContainsNotOnlyInt()`, `assertContainsNotOnlyIterable()`, `assertContainsNotOnlyNumeric()`, `assertContainsNotOnlyObject()`, `assertContainsNotOnlyResource()`, `assertContainsNotOnlyClosedResource()`, `assertContainsNotOnlyScalar()`, or `assertContainsNotOnlyString()` instead) * [#6059](https://github.com/sebastianbergmann/phpunit/issues/6059): `containsOnly()` (use `containsOnlyArray()`, `containsOnlyBool()`, `containsOnlyCallable()`, `containsOnlyFloat()`, `containsOnlyInt()`, `containsOnlyIterable()`, `containsOnlyNumeric()`, `containsOnlyObject()`, `containsOnlyResource()`, `containsOnlyClosedResource()`, `containsOnlyScalar()`, or `containsOnlyString()` instead) +[11.5.2]: https://github.com/sebastianbergmann/phpunit/compare/11.5.1...11.5 [11.5.1]: https://github.com/sebastianbergmann/phpunit/compare/11.5.0...11.5.1 [11.5.0]: https://github.com/sebastianbergmann/phpunit/compare/11.4.4...11.5.0 diff --git a/src/Framework/Assert.php b/src/Framework/Assert.php index 056a1bd0ee8..37ee4a8f719 100644 --- a/src/Framework/Assert.php +++ b/src/Framework/Assert.php @@ -170,7 +170,7 @@ final public static function assertArrayIsIdenticalToArrayIgnoringListOfKeys(arr * @throws Exception * @throws ExpectationFailedException */ - final public static function assertArrayHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void + final public static function assertArrayHasKey(mixed $key, array|ArrayAccess $array, string $message = ''): void { $constraint = new ArrayHasKey($key); @@ -185,7 +185,7 @@ final public static function assertArrayHasKey(int|string $key, array|ArrayAcces * @throws Exception * @throws ExpectationFailedException */ - final public static function assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void + final public static function assertArrayNotHasKey(mixed $key, array|ArrayAccess $array, string $message = ''): void { $constraint = new LogicalNot( new ArrayHasKey($key), @@ -2865,7 +2865,7 @@ final public static function containsOnlyInstancesOf(string $className): Travers return new TraversableContainsOnly($className, false); } - final public static function arrayHasKey(int|string $key): ArrayHasKey + final public static function arrayHasKey(mixed $key): ArrayHasKey { return new ArrayHasKey($key); } diff --git a/src/Framework/Assert/Functions.php b/src/Framework/Assert/Functions.php index 0f66023c59c..cfe2557e300 100644 --- a/src/Framework/Assert/Functions.php +++ b/src/Framework/Assert/Functions.php @@ -166,7 +166,7 @@ function assertArrayIsIdenticalToArrayIgnoringListOfKeys(array $expected, array * * @see Assert::assertArrayHasKey */ - function assertArrayHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void + function assertArrayHasKey(mixed $key, array|ArrayAccess $array, string $message = ''): void { Assert::assertArrayHasKey(...func_get_args()); } @@ -185,7 +185,7 @@ function assertArrayHasKey(int|string $key, array|ArrayAccess $array, string $me * * @see Assert::assertArrayNotHasKey */ - function assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void + function assertArrayNotHasKey(mixed $key, array|ArrayAccess $array, string $message = ''): void { Assert::assertArrayNotHasKey(...func_get_args()); } @@ -3093,7 +3093,7 @@ function containsOnlyInstancesOf(string $className): TraversableContainsOnly } if (!function_exists('PHPUnit\Framework\arrayHasKey')) { - function arrayHasKey(int|string $key): ArrayHasKey + function arrayHasKey(mixed $key): ArrayHasKey { return Assert::arrayHasKey(...func_get_args()); } diff --git a/src/Framework/Constraint/Traversable/ArrayHasKey.php b/src/Framework/Constraint/Traversable/ArrayHasKey.php index cc2482b313a..fa8d2744111 100644 --- a/src/Framework/Constraint/Traversable/ArrayHasKey.php +++ b/src/Framework/Constraint/Traversable/ArrayHasKey.php @@ -19,9 +19,9 @@ */ final class ArrayHasKey extends Constraint { - private readonly int|string $key; + private readonly mixed $key; - public function __construct(int|string $key) + public function __construct(mixed $key) { $this->key = $key; }