1010use PHPUnit \Framework \Constraint \LogicalNot ;
1111use PHPUnit \Framework \Constraint \StringMatchesFormatDescription ;
1212use ReflectionClass ;
13+ use ReflectionException ;
1314
1415trait InheritedAsserts
1516{
@@ -49,7 +50,7 @@ protected function assertClassHasStaticAttribute(string $attributeName, string $
4950 {
5051 trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10 ' , E_USER_DEPRECATED );
5152
52- Assert::assertTrue ($ this -> hasStaticAttribute ($ attributeName , $ className ), $ message );
53+ Assert::assertTrue (self :: hasStaticAttribute ($ attributeName , $ className ), $ message );
5354 }
5455
5556 /**
@@ -69,7 +70,7 @@ protected function assertClassNotHasAttribute(string $attributeName, string $cla
6970 protected function assertClassNotHasStaticAttribute (string $ attributeName , string $ className , string $ message = '' ): void
7071 {
7172 trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10 ' , E_USER_DEPRECATED );
72- Assert::assertFalse ($ this -> hasStaticAttribute ($ attributeName , $ className ), $ message );
73+ Assert::assertFalse (self :: hasStaticAttribute ($ attributeName , $ className ), $ message );
7374 }
7475
7576 /**
@@ -401,8 +402,7 @@ protected function assertInstanceOf(string $expected, $actual, string $message =
401402 * Asserts that a variable is of type array.
402403 *
403404 * @param mixed $actual
404- *
405- * @phpstan-assert array $actual
405+ * @phpstan-assert array<mixed> $actual
406406 */
407407 protected function assertIsArray ($ actual , string $ message = '' ): void
408408 {
@@ -474,7 +474,7 @@ protected function assertIsInt($actual, string $message = ''): void
474474 *
475475 * @param mixed $actual
476476 *
477- * @phpstan-assert iterable $actual
477+ * @phpstan-assert iterable<mixed> $actual
478478 */
479479 protected function assertIsIterable ($ actual , string $ message = '' ): void
480480 {
@@ -486,7 +486,7 @@ protected function assertIsIterable($actual, string $message = ''): void
486486 *
487487 * @param mixed $actual
488488 *
489- * @phpstan-assert !array $actual
489+ * @phpstan-assert !array<mixed> $actual
490490 */
491491 protected function assertIsNotArray ($ actual , string $ message = '' ): void
492492 {
@@ -558,7 +558,7 @@ protected function assertIsNotInt($actual, string $message = ''): void
558558 *
559559 * @param mixed $actual
560560 *
561- * @phpstan-assert !iterable $actual
561+ * @phpstan-assert !iterable<mixed> $actual
562562 */
563563 protected function assertIsNotIterable ($ actual , string $ message = '' ): void
564564 {
@@ -1143,7 +1143,7 @@ protected function assertStringNotEqualsFileIgnoringCase(string $expectedFile, s
11431143 /**
11441144 * Asserts that a string does not match a given format string.
11451145 */
1146- protected function assertStringNotMatchesFormat (string $ format , string $ string , string $ message = '' )
1146+ protected function assertStringNotMatchesFormat (string $ format , string $ string , string $ message = '' ): void
11471147 {
11481148 trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 12 ' , E_USER_DEPRECATED );
11491149 $ constraint = new LogicalNot (new StringMatchesFormatDescription ($ format ));
@@ -1153,15 +1153,14 @@ protected function assertStringNotMatchesFormat(string $format, string $string,
11531153 /**
11541154 * Asserts that a string does not match a given format string.
11551155 */
1156- protected function assertStringNotMatchesFormatFile (string $ formatFile , string $ string , string $ message = '' )
1156+ protected function assertStringNotMatchesFormatFile (string $ formatFile , string $ string , string $ message = '' ): void
11571157 {
11581158 trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 12 ' , E_USER_DEPRECATED );
1159- Assert::assertFileExists ($ formatFile );
1160- $ constraint = new LogicalNot (
1161- new StringMatchesFormatDescription (
1162- file_get_contents ($ formatFile )
1163- )
1164- );
1159+ $ content = file_get_contents ($ formatFile );
1160+ if ($ content === false ) {
1161+ Assert::fail (sprintf ('Failed to read format file "%s" ' , $ formatFile ));
1162+ }
1163+ $ constraint = new LogicalNot (new StringMatchesFormatDescription ($ content ));
11651164 Assert::assertThat ($ string , $ constraint , $ message );
11661165 }
11671166
@@ -1320,8 +1319,9 @@ protected function markTestSkipped(string $message = ''): never
13201319
13211320 /**
13221321 * @see https://github.com/sebastianbergmann/phpunit/blob/9.6/src/Framework/Constraint/Object/ClassHasStaticAttribute.php
1322+ * @param class-string $className
13231323 */
1324- private static function hasStaticAttribute (string $ attributeName , string $ className )
1324+ private static function hasStaticAttribute (string $ attributeName , string $ className ): bool
13251325 {
13261326 try {
13271327 $ class = new \ReflectionClass ($ className );
0 commit comments