@@ -1252,7 +1252,7 @@ public static function assertNan($actual, string $message = ''): void
1252
1252
*/
1253
1253
public static function assertClassHasAttribute (string $ attributeName , string $ className , string $ message = '' ): void
1254
1254
{
1255
- if (!self ::isValidAttributeName ($ attributeName )) {
1255
+ if (!self ::isValidClassAttributeName ($ attributeName )) {
1256
1256
throw InvalidArgumentHelper::factory (1 , 'valid attribute name ' );
1257
1257
}
1258
1258
@@ -1271,7 +1271,7 @@ public static function assertClassHasAttribute(string $attributeName, string $cl
1271
1271
*/
1272
1272
public static function assertClassNotHasAttribute (string $ attributeName , string $ className , string $ message = '' ): void
1273
1273
{
1274
- if (!self ::isValidAttributeName ($ attributeName )) {
1274
+ if (!self ::isValidClassAttributeName ($ attributeName )) {
1275
1275
throw InvalidArgumentHelper::factory (1 , 'valid attribute name ' );
1276
1276
}
1277
1277
@@ -1296,7 +1296,7 @@ public static function assertClassNotHasAttribute(string $attributeName, string
1296
1296
*/
1297
1297
public static function assertClassHasStaticAttribute (string $ attributeName , string $ className , string $ message = '' ): void
1298
1298
{
1299
- if (!self ::isValidAttributeName ($ attributeName )) {
1299
+ if (!self ::isValidClassAttributeName ($ attributeName )) {
1300
1300
throw InvalidArgumentHelper::factory (1 , 'valid attribute name ' );
1301
1301
}
1302
1302
@@ -1319,7 +1319,7 @@ public static function assertClassHasStaticAttribute(string $attributeName, stri
1319
1319
*/
1320
1320
public static function assertClassNotHasStaticAttribute (string $ attributeName , string $ className , string $ message = '' ): void
1321
1321
{
1322
- if (!self ::isValidAttributeName ($ attributeName )) {
1322
+ if (!self ::isValidClassAttributeName ($ attributeName )) {
1323
1323
throw InvalidArgumentHelper::factory (1 , 'valid attribute name ' );
1324
1324
}
1325
1325
@@ -1346,7 +1346,7 @@ public static function assertClassNotHasStaticAttribute(string $attributeName, s
1346
1346
*/
1347
1347
public static function assertObjectHasAttribute (string $ attributeName , $ object , string $ message = '' ): void
1348
1348
{
1349
- if (!self ::isValidAttributeName ($ attributeName )) {
1349
+ if (!self ::isValidObjectAttributeName ($ attributeName )) {
1350
1350
throw InvalidArgumentHelper::factory (1 , 'valid attribute name ' );
1351
1351
}
1352
1352
@@ -1371,7 +1371,7 @@ public static function assertObjectHasAttribute(string $attributeName, $object,
1371
1371
*/
1372
1372
public static function assertObjectNotHasAttribute (string $ attributeName , $ object , string $ message = '' ): void
1373
1373
{
1374
- if (!self ::isValidAttributeName ($ attributeName )) {
1374
+ if (!self ::isValidObjectAttributeName ($ attributeName )) {
1375
1375
throw InvalidArgumentHelper::factory (1 , 'valid attribute name ' );
1376
1376
}
1377
1377
@@ -2717,7 +2717,7 @@ public static function fail(string $message = ''): void
2717
2717
*/
2718
2718
public static function readAttribute ($ classOrObject , string $ attributeName )
2719
2719
{
2720
- if (!self ::isValidAttributeName ($ attributeName )) {
2720
+ if (!self ::isValidClassAttributeName ($ attributeName )) {
2721
2721
throw InvalidArgumentHelper::factory (2 , 'valid attribute name ' );
2722
2722
}
2723
2723
@@ -2763,7 +2763,7 @@ public static function getStaticAttribute(string $className, string $attributeNa
2763
2763
throw InvalidArgumentHelper::factory (1 , 'class name ' );
2764
2764
}
2765
2765
2766
- if (!self ::isValidAttributeName ($ attributeName )) {
2766
+ if (!self ::isValidClassAttributeName ($ attributeName )) {
2767
2767
throw InvalidArgumentHelper::factory (2 , 'valid attribute name ' );
2768
2768
}
2769
2769
@@ -2803,7 +2803,7 @@ public static function getObjectAttribute($object, string $attributeName)
2803
2803
throw InvalidArgumentHelper::factory (1 , 'object ' );
2804
2804
}
2805
2805
2806
- if (!self ::isValidAttributeName ($ attributeName )) {
2806
+ if (!self ::isValidClassAttributeName ($ attributeName )) {
2807
2807
throw InvalidArgumentHelper::factory (2 , 'valid attribute name ' );
2808
2808
}
2809
2809
@@ -2873,7 +2873,12 @@ public static function resetCount(): void
2873
2873
self ::$ count = 0 ;
2874
2874
}
2875
2875
2876
- private static function isValidAttributeName (string $ attributeName ): bool
2876
+ private static function isValidObjectAttributeName (string $ attributeName ): bool
2877
+ {
2878
+ return \preg_match ('/[^\x00-\x1f\x7f-\x9f]+/ ' , $ attributeName );
2879
+ }
2880
+
2881
+ private static function isValidClassAttributeName (string $ attributeName ): bool
2877
2882
{
2878
2883
return \preg_match ('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/ ' , $ attributeName );
2879
2884
}
0 commit comments