1 | <?php |
||
15 | class Assets { |
||
16 | /** |
||
17 | * Holds all the scripts handles that should be loaded in an async fashion. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | private $async_script_handles = array(); |
||
22 | /** |
||
23 | * The singleton instance of this class. |
||
24 | * |
||
25 | * @var Assets |
||
26 | */ |
||
27 | protected static $instance; |
||
28 | |||
29 | /** |
||
30 | * Constructor. |
||
31 | * |
||
32 | * Static-only class, so nothing here. |
||
33 | */ |
||
34 | private function __construct() {} |
||
35 | |||
36 | /** |
||
37 | * Get the singleton instance of the class. |
||
38 | * |
||
39 | * @return Assets |
||
40 | */ |
||
41 | public static function instance() { |
||
49 | |||
50 | /** |
||
51 | * Initalize the hooks as needed. |
||
52 | */ |
||
53 | private function init_hooks() { |
||
59 | |||
60 | /** |
||
61 | * A public method for adding the async script. |
||
62 | * |
||
63 | * @param string $script_handle Script handle. |
||
64 | */ |
||
65 | public function add_async_script( $script_handle ) { |
||
68 | |||
69 | /** |
||
70 | * Add an async attribute to scripts that can be loaded asynchronously. |
||
71 | * https://www.w3schools.com/tags/att_script_async.asp |
||
72 | * |
||
73 | * @param string $tag The <script> tag for the enqueued script. |
||
74 | * @param string $handle The script's registered handle. |
||
75 | */ |
||
76 | public function script_add_async( $tag, $handle ) { |
||
87 | |||
88 | /** |
||
89 | * Given a minified path, and a non-minified path, will return |
||
90 | * a minified or non-minified file URL based on whether SCRIPT_DEBUG is set and truthy. |
||
91 | * |
||
92 | * Both `$min_base` and `$non_min_base` are expected to be relative to the |
||
93 | * root Jetpack directory. |
||
94 | * |
||
95 | * @since 5.6.0 |
||
96 | * |
||
97 | * @param string $min_path minified path. |
||
98 | * @param string $non_min_path non-minified path. |
||
99 | * @return string The URL to the file |
||
100 | */ |
||
101 | public static function get_file_url_for_environment( $min_path, $non_min_path ) { |
||
121 | |||
122 | /** |
||
123 | * A helper function that lets you enqueue scripts in an async fashion. |
||
124 | * |
||
125 | * @param string $handle Name of the script. Should be unique. |
||
126 | * @param string $min_path Minimized script path. |
||
127 | * @param string $non_min_path Full Script path. |
||
128 | * @param array $deps Array of script dependencies. |
||
129 | * @param bool $ver The script version. |
||
130 | * @param bool $in_footer Should the script be included in the footer. |
||
131 | */ |
||
132 | public static function enqueue_async_script( $handle, $min_path, $non_min_path, $deps = array(), $ver = false, $in_footer = true ) { |
||
137 | |||
138 | } |
||
139 |
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.