Skip to content

Commit

Permalink
Closes #6082
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 12, 2024
1 parent 4e89eff commit 54ae58f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-10.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes of the PHPUnit 10.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.

## [10.5.40] - 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

## [10.5.39] - 2024-12-11

### Added
Expand Down Expand Up @@ -356,6 +362,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi

* [#5563](https://github.com/sebastianbergmann/phpunit/issues/5563): `createMockForIntersectionOfInterfaces()` does not automatically register mock object for expectation verification

[10.5.40]: https://github.com/sebastianbergmann/phpunit/compare/10.5.39...10.5
[10.5.39]: https://github.com/sebastianbergmann/phpunit/compare/10.5.38...10.5.39
[10.5.38]: https://github.com/sebastianbergmann/phpunit/compare/10.5.37...10.5.38
[10.5.37]: https://github.com/sebastianbergmann/phpunit/compare/10.5.36...10.5.37
Expand Down
6 changes: 3 additions & 3 deletions src/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ abstract class Assert
* @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);

Expand All @@ -91,7 +91,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),
Expand Down Expand Up @@ -2120,7 +2120,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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Framework/Assert/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
*
* @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());
}
Expand All @@ -97,7 +97,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());
}
Expand Down Expand Up @@ -2379,7 +2379,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());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Framework/Constraint/Traversable/ArrayHasKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 54ae58f

Please sign in to comment.