1 | <?php |
||
20 | class Plugin_Storage { |
||
21 | |||
22 | /** |
||
23 | * Connected plugins. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | private static $plugins = array(); |
||
28 | |||
29 | /** |
||
30 | * Whether the plugins were configured. |
||
31 | * To make sure we don't call the configuration process again and again. |
||
32 | * |
||
33 | * @var bool |
||
34 | */ |
||
35 | private static $plugins_configuration_finished = false; |
||
36 | |||
37 | /** |
||
38 | * Add or update the plugin information in the storage. |
||
39 | * |
||
40 | * @param string $slug Plugin slug. |
||
41 | * @param array $args Plugin arguments, optional. |
||
42 | * |
||
43 | * @return bool |
||
44 | */ |
||
45 | public static function upsert( $slug, array $args = array() ) { |
||
50 | |||
51 | /** |
||
52 | * Retrieve the plugin information by slug. |
||
53 | * WARNING: the method cannot be called until Jetpack Config has been run (`plugins_loaded`, priority 2). |
||
54 | * Even if you don't use Jetpack Config, it may be introduced later by other plugins, |
||
55 | * so please make sure not to run the method too early in the code. |
||
56 | * |
||
57 | * @param string $slug The plugin slug. |
||
58 | * |
||
59 | * @return array|null|WP_Error |
||
60 | */ |
||
61 | public static function get_one( $slug ) { |
||
70 | |||
71 | /** |
||
72 | * Retrieve info for all plugins that use the connection. |
||
73 | * WARNING: the method cannot be called until Jetpack Config has been run (`plugins_loaded`, priority 2). |
||
74 | * Even if you don't use Jetpack Config, it may be introduced later by other plugins, |
||
75 | * so please make sure not to run the method too early in the code. |
||
76 | * |
||
77 | * @return array|WP_Error |
||
78 | */ |
||
79 | public static function get_all() { |
||
88 | |||
89 | /** |
||
90 | * Remove the plugin connection info from Jetpack. |
||
91 | * WARNING: the method cannot be called until Jetpack Config has been run (`plugins_loaded`, priority 2). |
||
92 | * Even if you don't use Jetpack Config, it may be introduced later by other plugins, |
||
93 | * so please make sure not to run the method too early in the code. |
||
94 | * |
||
95 | * @param string $slug The plugin slug. |
||
96 | * |
||
97 | * @return bool|WP_Error |
||
98 | */ |
||
99 | public static function delete( $slug ) { |
||
112 | |||
113 | /** |
||
114 | * The method makes sure that `Jetpack\Config` has finished, and it's now safe to retrieve the list of plugins. |
||
115 | * |
||
116 | * @return bool|WP_Error |
||
117 | */ |
||
118 | private static function ensure_configured() { |
||
125 | |||
126 | } |
||
127 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.