@@ -29,6 +29,26 @@ final protected function invokeMethod(object $object, string $method_name, ...$a
2929 return false ;
3030 }
3131
32+ /**
33+ * Invoke the static method on class.
34+ *
35+ * @param class-string $class
36+ * @param string $method_name
37+ * @param mixed ...$args
38+ *
39+ * @return bool TRUE if the method exists and invoked, FALSE otherwise.
40+ */
41+ final protected function invokeStaticMethod (string $ class , string $ method_name , ...$ args ): bool
42+ {
43+ if (\method_exists ($ class , $ method_name )) {
44+ $ class ::{$ method_name }(...$ args );
45+
46+ return true ;
47+ }
48+
49+ return false ;
50+ }
51+
3252 /**
3353 * Change object property value (even protected or private). Black magic is used.
3454 *
@@ -55,4 +75,37 @@ final protected function setProperty(object $object, string $property_name, $val
5575
5676 return $ changed ;
5777 }
78+
79+ /**
80+ * Change static object property value (even protected or private). Black magic is used.
81+ *
82+ * @param class-string $class
83+ * @param string $property_name
84+ * @param mixed $value
85+ *
86+ * @return bool TRUE if the property exists and changed, FALSE otherwise.
87+ */
88+ final protected function setStaticProperty (string $ class , string $ property_name , $ value ): bool
89+ {
90+ $ changed = false ;
91+
92+ try {
93+ $ instance = (new \ReflectionClass ($ class ))->newInstanceWithoutConstructor ();
94+
95+ $ closure = function () use ($ value , $ property_name , &$ changed ): void {
96+ if (\property_exists ($ this , $ property_name ) && static ::$ {$ property_name } !== null ) {
97+ static ::$ {$ property_name } = $ value ;
98+
99+ $ changed = true ;
100+ }
101+ };
102+
103+ $ reset = $ closure ->bindTo ($ instance , $ instance );
104+ $ reset ();
105+ } catch (\ReflectionException $ e ) {
106+ return false ;
107+ }
108+
109+ return $ changed ;
110+ }
58111}
0 commit comments