Skip to content

Commit 85c0730

Browse files
Allow values of other types than array to be passed to assertIsList()
1 parent a511e72 commit 85c0730

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

ChangeLog-10.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

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

5+
## [10.0.12] - 2023-MM-DD
6+
7+
### Changed
8+
9+
* Values of other types than `array` may now be passed to `assertIsList()`
10+
511
## [10.0.11] - 2023-02-20
612

713
### Fixed
@@ -210,6 +216,7 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
210216
* PHP 7.3, PHP 7.4, and PHP 8.0 are no longer supported
211217
* `phpunit/php-code-coverage` [no longer supports PHPDBG and Xdebug 2](https://github.com/sebastianbergmann/php-code-coverage/blob/10.0.0/ChangeLog.md#1000---2023-02-03)
212218

219+
[10.0.12]: https://github.com/sebastianbergmann/phpunit/compare/10.0.11...10.0
213220
[10.0.11]: https://github.com/sebastianbergmann/phpunit/compare/10.0.10...10.0.11
214221
[10.0.10]: https://github.com/sebastianbergmann/phpunit/compare/10.0.9...10.0.10
215222
[10.0.9]: https://github.com/sebastianbergmann/phpunit/compare/10.0.8...10.0.9

src/Framework/Assert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ final public static function assertArrayNotHasKey(int|string $key, array|ArrayAc
103103
/**
104104
* @throws ExpectationFailedException
105105
*/
106-
final public static function assertIsList(array $array, string $message = ''): void
106+
final public static function assertIsList(mixed $array, string $message = ''): void
107107
{
108108
static::assertThat(
109109
$array,

src/Framework/Assert/Functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string
111111
*
112112
* @see Assert::assertIsList
113113
*/
114-
function assertIsList(array $array, string $message = ''): void
114+
function assertIsList(mixed $array, string $message = ''): void
115115
{
116116
Assert::assertIsList(...func_get_args());
117117
}

tests/unit/Framework/AssertTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ public function testAssertIsListFailsWithStringKeys(): void
251251
$this->assertIsList(['string' => 0]);
252252
}
253253

254+
public function testAssertIsListFailsForTypesOtherThanArray(): void
255+
{
256+
$this->expectException(AssertionFailedError::class);
257+
258+
$this->assertIsList(null);
259+
}
260+
254261
public function testAssertArrayContainsOnlyIntegers(): void
255262
{
256263
$this->assertContainsOnly('integer', [1, 2, 3]);

0 commit comments

Comments
 (0)