Skip to content

Commit 7e2f316

Browse files
Copilotpattonwebz
andcommitted
Add PHPStan bootstrap file and fix variable initialization issues
Co-authored-by: pattonwebz <3902039+pattonwebz@users.noreply.github.com>
1 parent e923332 commit 7e2f316

7 files changed

Lines changed: 324 additions & 3 deletions

File tree

admin/class-ajax.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ public function details() {
229229
}
230230

231231
$rules = edac_register_rules();
232+
233+
// Initialize arrays to prevent undefined variable warnings
234+
$passed_rules = [];
235+
$error_rules = [];
236+
$warning_rules = [];
237+
232238
if ( $rules ) {
233239

234240
// if ANWW is active remove link_blank for details meta box.
@@ -237,7 +243,6 @@ public function details() {
237243
}
238244

239245
// separate rule types.
240-
$passed_rules = [];
241246
$error_rules = edac_remove_element_with_value( $rules, 'rule_type', 'warning' );
242247
$warning_rules = edac_remove_element_with_value( $rules, 'rule_type', 'error' );
243248

@@ -354,6 +359,7 @@ function ( $a, $b ) {
354359
$html .= '<div id="edac-details-rule-records-' . $rule['slug'] . '" class="edac-details-rule-records">';
355360

356361
$fixes_for_item = [];
362+
$controls_id = '';
357363
if ( isset( $rule['fixes'] ) && current_user_can( apply_filters( 'edac_filter_settings_capability', 'manage_options' ) ) ) {
358364
foreach ( $rule['fixes'] as $fix_slug ) {
359365
$fixes_for_item[] = FixesManager::get_instance()->get_fix( $fix_slug );

includes/classes/Fixes/Fix/SkipLinkFix.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ public function run() {
130130
}
131131

132132
$targets_list = explode( ',', $targets_string );
133-
133+
134+
$targets = [];
134135
foreach ( $targets_list as $target ) {
135136
// trim whitespace and any leading '#'.
136137
$trimmed = ltrim( trim( $target ), '#' );

includes/classes/Fixes/FixesManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,6 @@ public function update_fix_settings( $request ) {
304304
}
305305
}
306306

307-
return rest_ensure_response( [ 'enabled' => $enabled ] );
307+
return rest_ensure_response( [ 'success' => true ] );
308308
}
309309
}

phpstan-after-bootstrap.txt

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
Note: Using configuration file /home/runner/work/accessibility-checker/accessibility-checker/phpstan.neon.
2+
0/124 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%
3+
124/124 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
4+
5+
::error file=admin/class-ajax.php,line=277,col=0::Variable $error_rules might not be defined.
6+
::error file=admin/class-ajax.php,line=286,col=0::Variable $warning_rules might not be defined.
7+
::error file=admin/class-ajax.php,line=295,col=0::Variable $passed_rules might not be defined.
8+
::error file=admin/class-ajax.php,line=519,col=0::Variable $controls_id might not be defined.
9+
::error file=admin/class-settings.php,line=70,col=0::Call to static method get_scannable_post_types() on an unknown class EqualizeDigital\AccessibilityCheckerPro\Admin\Settings.
10+
::error file=admin/class-settings.php,line=71,col=0::Call to static method get_scannable_post_types() on an unknown class EDACP\Settings.
11+
::error file=includes/classes/Fixes/Fix/SkipLinkFix.php,line=144,col=0::Variable $targets might not be defined.
12+
::error file=includes/classes/Fixes/FixesManager.php,line=307,col=0::Undefined variable: $enabled
13+
::error file=includes/classes/WPCLI/BootstrapCLI.php,line=36,col=0::Property EqualizeDigital\AccessibilityChecker\WPCLI\BootstrapCLI::$wp_cli has unknown class WP_CLI as its type.
14+
::error file=includes/classes/WPCLI/BootstrapCLI.php,line=59,col=0::Parameter $wp_cli of method EqualizeDigital\AccessibilityChecker\WPCLI\BootstrapCLI::__construct() has invalid type WP_CLI.
15+
::error file=includes/classes/WPCLI/BootstrapCLI.php,line=60,col=0::Instantiated class WP_CLI not found.
16+
::error file=includes/classes/WPCLI/Command/CleanupOrphanedIssues.php,line=35,col=0::Instantiated class WP_CLI not found.
17+
::error file=includes/classes/WPCLI/Command/DeleteStats.php,line=38,col=0::Instantiated class WP_CLI not found.
18+
::error file=includes/classes/WPCLI/Command/DeleteStats.php,line=79,col=0::PHPDoc tag @throws with type WP_CLI\ExitException is not subtype of Throwable
19+
::error file=includes/classes/WPCLI/Command/GetSiteStats.php,line=40,col=0::Instantiated class WP_CLI not found.
20+
::error file=includes/classes/WPCLI/Command/GetSiteStats.php,line=94,col=0::PHPDoc tag @throws with type WP_CLI\ExitException is not subtype of Throwable
21+
::error file=includes/classes/WPCLI/Command/GetStats.php,line=58,col=0::Instantiated class WP_CLI not found.
22+
::error file=includes/classes/WPCLI/Command/GetStats.php,line=117,col=0::PHPDoc tag @throws with type WP_CLI\ExitException is not subtype of Throwable
23+
::error file=includes/classes/class-rest-api.php,line=213,col=0::Parameter $request of method EDAC\Inc\REST_Api::clear_issues_for_post() has invalid type EDAC\Inc\WP_REST_Request.
24+
::error file=includes/classes/class-rest-api.php,line=219,col=0::Call to method get_json_params() on an unknown class EDAC\Inc\WP_REST_Request.
25+
::error file=includes/classes/class-rest-api.php,line=286,col=0::Parameter $request of method EDAC\Inc\REST_Api::set_post_scan_results() has invalid type EDAC\Inc\WP_REST_Request.
26+
::error file=includes/classes/class-rest-api.php,line=549,col=0::Parameter $request of method EDAC\Inc\REST_Api::get_scans_stats_by_post_type() has invalid type EDAC\Inc\WP_REST_Request.
27+
::error file=includes/classes/class-rest-api.php,line=590,col=0::Parameter $request of method EDAC\Inc\REST_Api::get_scans_stats_by_post_types() has invalid type EDAC\Inc\WP_REST_Request.
28+
::error file=includes/deprecated/class-issues-query.php,line=37,col=0::Property EDAC\Issues_Query::$instance has unknown class EDAC\class as its type.
29+
::error file=includes/deprecated/class-issues-query.php,line=62,col=0::Method EDAC\Issues_Query::__call() has invalid return type EDAC\function.
30+
::error file=includes/deprecated/class-issues-query.php,line=77,col=0::Method EDAC\Issues_Query::__callStatic() has invalid return type EDAC\function.
31+
::error file=includes/deprecated/class-issues-query.php,line=81,col=0::Static access to instance property EDAC\Issues_Query::$instance.
32+
::error file=includes/deprecated/class-issues-query.php,line=91,col=0::Method EDAC\Issues_Query::__get() has invalid return type EDAC\function.
33+
::error file=includes/deprecated/class-scans-stats.php,line=28,col=0::Property EDAC\Scans_Stats::$instance has unknown class EDAC\class as its type.
34+
::error file=includes/deprecated/class-scans-stats.php,line=51,col=0::Method EDAC\Scans_Stats::__call() has invalid return type EDAC\function.
35+
::error file=includes/deprecated/class-scans-stats.php,line=66,col=0::Method EDAC\Scans_Stats::__callStatic() has invalid return type EDAC\function.
36+
::error file=includes/deprecated/class-scans-stats.php,line=70,col=0::Static access to instance property EDAC\Scans_Stats::$instance.
37+
::error file=includes/deprecated/class-scans-stats.php,line=80,col=0::Method EDAC\Scans_Stats::__get() has invalid return type EDAC\function.
38+
::error file=includes/helper-functions.php,line=668,col=0::Function wc_get_page_id not found.
39+
------ -----------------------------------------------
40+
Line admin/class-ajax.php
41+
------ -----------------------------------------------
42+
277 Variable $error_rules might not be defined.
43+
286 Variable $warning_rules might not be defined.
44+
295 Variable $passed_rules might not be defined.
45+
519 Variable $controls_id might not be defined.
46+
------ -----------------------------------------------
47+
48+
------ --------------------------------------------------------------------------------------
49+
Line admin/class-settings.php
50+
------ --------------------------------------------------------------------------------------
51+
70 Call to static method get_scannable_post_types() on an unknown class
52+
EqualizeDigital\AccessibilityCheckerPro\Admin\Settings.
53+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
54+
71 Call to static method get_scannable_post_types() on an unknown class EDACP\Settings.
55+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
56+
------ --------------------------------------------------------------------------------------
57+
58+
------ --------------------------------------------
59+
Line includes/classes/Fixes/Fix/SkipLinkFix.php
60+
------ --------------------------------------------
61+
144 Variable $targets might not be defined.
62+
------ --------------------------------------------
63+
64+
------ -----------------------------------------
65+
Line includes/classes/Fixes/FixesManager.php
66+
------ -----------------------------------------
67+
307 Undefined variable: $enabled
68+
------ -----------------------------------------
69+
70+
------ -----------------------------------------------------------------------------------------------------------
71+
Line includes/classes/WPCLI/BootstrapCLI.php
72+
------ -----------------------------------------------------------------------------------------------------------
73+
36 Property EqualizeDigital\AccessibilityChecker\WPCLI\BootstrapCLI::$wp_cli has unknown class WP_CLI as its
74+
type.
75+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
76+
59 Parameter $wp_cli of method EqualizeDigital\AccessibilityChecker\WPCLI\BootstrapCLI::__construct() has
77+
invalid type WP_CLI.
78+
60 Instantiated class WP_CLI not found.
79+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
80+
------ -----------------------------------------------------------------------------------------------------------
81+
82+
------ ---------------------------------------------------------------------
83+
Line includes/classes/WPCLI/Command/CleanupOrphanedIssues.php
84+
------ ---------------------------------------------------------------------
85+
35 Instantiated class WP_CLI not found.
86+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
87+
------ ---------------------------------------------------------------------
88+
89+
------ -------------------------------------------------------------------------------
90+
Line includes/classes/WPCLI/Command/DeleteStats.php
91+
------ -------------------------------------------------------------------------------
92+
38 Instantiated class WP_CLI not found.
93+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
94+
79 PHPDoc tag @throws with type WP_CLI\ExitException is not subtype of Throwable
95+
------ -------------------------------------------------------------------------------
96+
97+
------ -------------------------------------------------------------------------------
98+
Line includes/classes/WPCLI/Command/GetSiteStats.php
99+
------ -------------------------------------------------------------------------------
100+
40 Instantiated class WP_CLI not found.
101+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
102+
94 PHPDoc tag @throws with type WP_CLI\ExitException is not subtype of Throwable
103+
------ -------------------------------------------------------------------------------
104+
105+
------ -------------------------------------------------------------------------------
106+
Line includes/classes/WPCLI/Command/GetStats.php
107+
------ -------------------------------------------------------------------------------
108+
58 Instantiated class WP_CLI not found.
109+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
110+
117 PHPDoc tag @throws with type WP_CLI\ExitException is not subtype of Throwable
111+
------ -------------------------------------------------------------------------------
112+
113+
------ --------------------------------------------------------------------------------------------------
114+
Line includes/classes/class-rest-api.php
115+
------ --------------------------------------------------------------------------------------------------
116+
213 Parameter $request of method EDAC\Inc\REST_Api::clear_issues_for_post() has invalid type
117+
EDAC\Inc\WP_REST_Request.
118+
219 Call to method get_json_params() on an unknown class EDAC\Inc\WP_REST_Request.
119+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
120+
286 Parameter $request of method EDAC\Inc\REST_Api::set_post_scan_results() has invalid type
121+
EDAC\Inc\WP_REST_Request.
122+
549 Parameter $request of method EDAC\Inc\REST_Api::get_scans_stats_by_post_type() has invalid type
123+
EDAC\Inc\WP_REST_Request.
124+
590 Parameter $request of method EDAC\Inc\REST_Api::get_scans_stats_by_post_types() has invalid type
125+
EDAC\Inc\WP_REST_Request.
126+
------ --------------------------------------------------------------------------------------------------
127+
128+
------ ---------------------------------------------------------------------------------
129+
Line includes/deprecated/class-issues-query.php
130+
------ ---------------------------------------------------------------------------------
131+
37 Property EDAC\Issues_Query::$instance has unknown class EDAC\class as its type.
132+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
133+
62 Method EDAC\Issues_Query::__call() has invalid return type EDAC\function.
134+
77 Method EDAC\Issues_Query::__callStatic() has invalid return type EDAC\function.
135+
81 Static access to instance property EDAC\Issues_Query::$instance.
136+
91 Method EDAC\Issues_Query::__get() has invalid return type EDAC\function.
137+
------ ---------------------------------------------------------------------------------
138+
139+
------ --------------------------------------------------------------------------------
140+
Line includes/deprecated/class-scans-stats.php
141+
------ --------------------------------------------------------------------------------
142+
28 Property EDAC\Scans_Stats::$instance has unknown class EDAC\class as its type.
143+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
144+
51 Method EDAC\Scans_Stats::__call() has invalid return type EDAC\function.
145+
66 Method EDAC\Scans_Stats::__callStatic() has invalid return type EDAC\function.
146+
70 Static access to instance property EDAC\Scans_Stats::$instance.
147+
80 Method EDAC\Scans_Stats::__get() has invalid return type EDAC\function.
148+
------ --------------------------------------------------------------------------------
149+
150+
------ ---------------------------------------------------------------------
151+
Line includes/helper-functions.php
152+
------ ---------------------------------------------------------------------
153+
668 Function wc_get_page_id not found.
154+
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
155+
------ ---------------------------------------------------------------------
156+
157+
[ERROR] Found 34 errors
158+

phpstan-bootstrap.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* PHPStan bootstrap file to define constants for static analysis
4+
*
5+
* @package EqualizeDigital\AccessibilityChecker
6+
*/
7+
8+
// PHPStan isn't able to resolve the constants defined in the plugin that aren't at root level so
9+
// we define them here to avoid notices about them in the results.
10+
define( 'EDAC_VERSION', '1.29.0' );
11+
define( 'EDAC_DB_VERSION', '1.0.4' );
12+
define( 'EDAC_PLUGIN_URL', '' );
13+
define( 'EDAC_PLUGIN_DIR', '' );
14+
define( 'EDAC_PLUGIN_FILE', '' );
15+
define( 'EDAC_SVG_IGNORE_ICON', '' );
16+
define( 'EDAC_KEY_VALID', false );
17+
define( 'EDAC_DEBUG', false );
18+
define( 'EDAC_ANWW_ACTIVE', false );
19+
define( 'EDAC_GAAD_NOTICE_START_DATE', '2025-05-13' );
20+
define( 'EDAC_GAAD_NOTICE_END_DATE', '2025-05-21' );
21+
22+
// Pro plugin constants.
23+
define( 'EDACAH_VERSION', '1.0.0' );

0 commit comments

Comments
 (0)