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 /**
@@ -1143,7 +1144,7 @@ protected function assertStringNotEqualsFileIgnoringCase(string $expectedFile, s
11431144 /**
11441145 * Asserts that a string does not match a given format string.
11451146 */
1146- protected function assertStringNotMatchesFormat (string $ format , string $ string , string $ message = '' )
1147+ protected function assertStringNotMatchesFormat (string $ format , string $ string , string $ message = '' ): void
11471148 {
11481149 trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 12 ' , E_USER_DEPRECATED );
11491150 $ constraint = new LogicalNot (new StringMatchesFormatDescription ($ format ));
@@ -1153,15 +1154,14 @@ protected function assertStringNotMatchesFormat(string $format, string $string,
11531154 /**
11541155 * Asserts that a string does not match a given format string.
11551156 */
1156- protected function assertStringNotMatchesFormatFile (string $ formatFile , string $ string , string $ message = '' )
1157+ protected function assertStringNotMatchesFormatFile (string $ formatFile , string $ string , string $ message = '' ): void
11571158 {
11581159 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- );
1160+ $ content = file_get_contents ($ formatFile );
1161+ if ($ content === false ) {
1162+ Assert::fail (sprintf ('Failed to read format file "%s" ' , $ formatFile ));
1163+ }
1164+ $ constraint = new LogicalNot (new StringMatchesFormatDescription ($ content ));
11651165 Assert::assertThat ($ string , $ constraint , $ message );
11661166 }
11671167
@@ -1320,8 +1320,9 @@ protected function markTestSkipped(string $message = ''): never
13201320
13211321 /**
13221322 * @see https://github.com/sebastianbergmann/phpunit/blob/9.6/src/Framework/Constraint/Object/ClassHasStaticAttribute.php
1323+ * @param class-string $className
13231324 */
1324- private static function hasStaticAttribute (string $ attributeName , string $ className )
1325+ private static function hasStaticAttribute (string $ attributeName , string $ className ): bool
13251326 {
13261327 try {
13271328 $ class = new \ReflectionClass ($ className );
0 commit comments