@@ -27,10 +27,12 @@ public function __call( string $name, array $arguments ) {
27
27
$ should_throw = static ::check_access ( $ this , $ name );
28
28
29
29
if ( false !== $ should_throw ) {
30
- throw new \BadMethodCallException ( esc_html ( $ should_throw ) );
30
+ throw new \BadMethodCallException ( \ esc_html ( $ should_throw ) );
31
31
}
32
32
33
- return is_callable ( array ( 'parent ' , '__call ' ) ) ? parent ::__call ( $ name , $ arguments ) : ( $ this ->$ name )( ...$ arguments );
33
+ return \is_callable ( array ( 'parent ' , '__call ' ) )
34
+ ? parent ::__call ( $ name , $ arguments )
35
+ : $ this ->$ name ( ...$ arguments );
34
36
}
35
37
36
38
/**
@@ -46,7 +48,7 @@ public static function __callStatic( string $name, array $arguments ) {
46
48
$ should_throw = static ::check_access ( static ::class, $ name );
47
49
48
50
if ( false !== $ should_throw ) {
49
- throw new \BadMethodCallException ( esc_html ( $ should_throw ) );
51
+ throw new \BadMethodCallException ( \ esc_html ( $ should_throw ) );
50
52
}
51
53
52
54
return static ::$ name ( ...$ arguments );
@@ -60,11 +62,17 @@ public static function __callStatic( string $name, array $arguments ) {
60
62
* @return string|false
61
63
*/
62
64
private static function check_access ( string |object $ class_or_obj , string $ method ): string |false {
63
- $ classname = is_object ( $ class_or_obj ) ? $ class_or_obj ::class : $ class_or_obj ;
65
+ $ classname = \ is_object ( $ class_or_obj ) ? $ class_or_obj ::class : $ class_or_obj ;
64
66
65
67
return match ( true ) {
66
- ! method_exists ( $ class_or_obj , $ method ) => 'Call to undefined method ' . $ classname . ':: ' . $ method ,
67
- ! static ::is_valid_method ( $ classname , $ method ) => 'Call to private method ' . $ classname . ':: ' . $ method ,
68
+ ! \method_exists (
69
+ $ class_or_obj ,
70
+ $ method ,
71
+ ) => 'Call to undefined method ' . $ classname . ':: ' . $ method ,
72
+ ! static ::is_valid_method (
73
+ $ classname ,
74
+ $ method ,
75
+ ) => 'Call to private method ' . $ classname . ':: ' . $ method ,
68
76
default => false ,
69
77
};
70
78
}
@@ -77,10 +85,10 @@ private static function check_access( string|object $class_or_obj, string $metho
77
85
* @return bool
78
86
*/
79
87
private static function is_valid_method ( string $ classname , string $ method ): bool {
80
- return array_reduce (
88
+ return \ array_reduce (
81
89
static ::get_registered_hooks ( $ classname , $ method ),
82
- fn ( bool $ c , string $ hook ) => $ c || doing_action ( $ hook ) || doing_filter ( $ hook ),
83
- false
90
+ static fn ( bool $ c , string $ hook ) => $ c || \ doing_action ( $ hook ) || \ doing_filter ( $ hook ),
91
+ false ,
84
92
);
85
93
}
86
94
@@ -92,6 +100,6 @@ private static function is_valid_method( string $classname, string $method ): bo
92
100
* @return array
93
101
*/
94
102
private static function get_registered_hooks ( string $ classname , string $ method ): array {
95
- return array_unique ( wp_list_pluck ( Filter::$ registry [ $ classname ][ $ method ] ?? array (), 'tag ' ) );
103
+ return \ array_unique ( \ wp_list_pluck ( Filter::$ registry [ $ classname ][ $ method ] ?? array (), 'tag ' ) );
96
104
}
97
105
}
0 commit comments