@@ -51,7 +51,13 @@ protected function assertClassHasAttribute(string $attributeName, string $classN
5151 */
5252 protected function assertClassHasStaticAttribute (string $ attributeName , string $ className , string $ message = '' )
5353 {
54- Assert::assertClassHasStaticAttribute ($ attributeName , $ className , $ message );
54+ trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10 ' , E_USER_DEPRECATED );
55+
56+ if (method_exists (Assert::class, 'assertClassHasStaticAttribute ' )) {
57+ Assert::assertClassHasStaticAttribute ($ attributeName , $ className , $ message );
58+ } else {
59+ Assert::assertTrue (self ::hasStaticAttribute ($ attributeName , $ className ), $ message );
60+ }
5561 }
5662
5763 /**
@@ -75,7 +81,11 @@ protected function assertClassNotHasStaticAttribute(string $attributeName, strin
7581 {
7682 trigger_error (__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10 ' , E_USER_DEPRECATED );
7783
78- Assert::assertClassNotHasStaticAttribute ($ attributeName , $ className , $ message );
84+ if (method_exists (Assert::class, 'assertClassNotHasStaticAttribute ' )) {
85+ Assert::assertClassNotHasStaticAttribute ($ attributeName , $ className , $ message );
86+ } else {
87+ Assert::assertFalse (self ::hasStaticAttribute ($ attributeName , $ className ), $ message );
88+ }
7989 }
8090
8191 /**
@@ -1200,4 +1210,21 @@ protected function markTestSkipped(string $message = '')
12001210 {
12011211 Assert::markTestSkipped ($ message );
12021212 }
1213+
1214+ /**
1215+ * @see https://github.com/sebastianbergmann/phpunit/blob/9.6/src/Framework/Constraint/Object/ClassHasStaticAttribute.php
1216+ */
1217+ private static function hasStaticAttribute (string $ attributeName , string $ className )
1218+ {
1219+ try {
1220+ $ class = new \ReflectionClass ($ className );
1221+
1222+ if ($ class ->hasProperty ($ attributeName )) {
1223+ return $ class ->getProperty ($ attributeName )->isStatic ();
1224+ }
1225+ } catch (ReflectionException $ e ) {
1226+ }
1227+
1228+ return false ;
1229+ }
12031230}
0 commit comments