10
10
use PHPUnit \Framework \Constraint \LogicalNot ;
11
11
use PHPUnit \Framework \Constraint \StringMatchesFormatDescription ;
12
12
use ReflectionClass ;
13
+ use ReflectionException ;
13
14
14
15
trait InheritedAsserts
15
16
{
@@ -49,7 +50,7 @@ protected function assertClassHasStaticAttribute(string $attributeName, string $
49
50
{
50
51
trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10 ' , E_USER_DEPRECATED );
51
52
52
- Assert::assertTrue ($ this -> hasStaticAttribute ($ attributeName , $ className ), $ message );
53
+ Assert::assertTrue (self :: hasStaticAttribute ($ attributeName , $ className ), $ message );
53
54
}
54
55
55
56
/**
@@ -69,7 +70,7 @@ protected function assertClassNotHasAttribute(string $attributeName, string $cla
69
70
protected function assertClassNotHasStaticAttribute (string $ attributeName , string $ className , string $ message = '' ): void
70
71
{
71
72
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 );
73
74
}
74
75
75
76
/**
@@ -1143,7 +1144,7 @@ protected function assertStringNotEqualsFileIgnoringCase(string $expectedFile, s
1143
1144
/**
1144
1145
* Asserts that a string does not match a given format string.
1145
1146
*/
1146
- protected function assertStringNotMatchesFormat (string $ format , string $ string , string $ message = '' )
1147
+ protected function assertStringNotMatchesFormat (string $ format , string $ string , string $ message = '' ): void
1147
1148
{
1148
1149
trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 12 ' , E_USER_DEPRECATED );
1149
1150
$ constraint = new LogicalNot (new StringMatchesFormatDescription ($ format ));
@@ -1153,15 +1154,14 @@ protected function assertStringNotMatchesFormat(string $format, string $string,
1153
1154
/**
1154
1155
* Asserts that a string does not match a given format string.
1155
1156
*/
1156
- protected function assertStringNotMatchesFormatFile (string $ formatFile , string $ string , string $ message = '' )
1157
+ protected function assertStringNotMatchesFormatFile (string $ formatFile , string $ string , string $ message = '' ): void
1157
1158
{
1158
1159
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 ));
1165
1165
Assert::assertThat ($ string , $ constraint , $ message );
1166
1166
}
1167
1167
@@ -1320,8 +1320,9 @@ protected function markTestSkipped(string $message = ''): never
1320
1320
1321
1321
/**
1322
1322
* @see https://github.com/sebastianbergmann/phpunit/blob/9.6/src/Framework/Constraint/Object/ClassHasStaticAttribute.php
1323
+ * @param class-string $className
1323
1324
*/
1324
- private static function hasStaticAttribute (string $ attributeName , string $ className )
1325
+ private static function hasStaticAttribute (string $ attributeName , string $ className ): bool
1325
1326
{
1326
1327
try {
1327
1328
$ class = new \ReflectionClass ($ className );
0 commit comments