Skip to content

Commit 8ad9cb7

Browse files
committed
Revert "Increase PHPStan checks to level 9"
This reverts commit 47de47f.
1 parent fe995c9 commit 8ad9cb7

52 files changed

Lines changed: 141 additions & 178 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

classes/actions/class-content-scan.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function update_stats() {
105105
// Calculate the total pages to scan.
106106
$total_pages = $this->get_total_pages();
107107
// Get the last scanned page.
108-
$last_page = (int) \progress_planner()->get_settings()->get( static::LAST_SCANNED_PAGE_OPTION, 0 ); // @phpstan-ignore-line cast.int
108+
$last_page = (int) \progress_planner()->get_settings()->get( static::LAST_SCANNED_PAGE_OPTION, 0 );
109109
// The current page to scan.
110110
$current_page = $last_page + 1;
111111

classes/activities/class-content-helpers.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ public function get_post_types_names() {
2626
}
2727
$default = [ 'post', 'page' ];
2828
$include_post_types = \array_filter(
29-
(array) \progress_planner()->get_settings()->get( [ 'include_post_types' ], $default ),
29+
\progress_planner()->get_settings()->get( [ 'include_post_types' ], $default ),
3030
function ( $post_type ) {
31-
return $post_type
32-
&& \is_string( $post_type )
33-
&& \post_type_exists( $post_type )
34-
&& \is_post_type_viewable( $post_type );
31+
return $post_type && \post_type_exists( $post_type ) && \is_post_type_viewable( $post_type );
3532
}
3633
);
3734
return empty( $include_post_types ) ? $default : \array_values( $include_post_types );

classes/activities/class-query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ protected function get_activity_class_name( $category ) {
450450
* @return void
451451
*/
452452
private function maybe_upgrade() {
453-
$db_version = (int) \get_option( 'progress_planner_db_version', 0 ); // @phpstan-ignore-line cast.int
453+
$db_version = (int) \get_option( 'progress_planner_db_version', 0 );
454454
$available_upgrades = [];
455455
// Get an array of methods that are prefixed with "upgrade_".
456456
$methods = \get_class_methods( $this );

classes/admin/class-editor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function enqueue_editor_script() {
2828
// Bail early when we're on the site-editor.php page.
2929
$request = \filter_input( INPUT_SERVER, 'REQUEST_URI' );
3030
if ( ! $request && isset( $_SERVER['REQUEST_URI'] ) ) {
31-
$request = \sanitize_text_field( \wp_unslash( $_SERVER['REQUEST_URI'] ) ); // @phpstan-ignore-line argument.type
31+
$request = \sanitize_text_field( \wp_unslash( $_SERVER['REQUEST_URI'] ) );
3232
}
3333
if ( $request && \str_contains( $request, 'site-editor.php' ) ) {
3434
return;
@@ -38,7 +38,7 @@ public function enqueue_editor_script() {
3838

3939
// Check if the page-type is set in the URL (user is coming from the Settings page).
4040
if ( isset( $_GET['prpl_page_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
41-
$prpl_pt = \sanitize_text_field( \wp_unslash( $_GET['prpl_page_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, @phpstan-ignore-line argument.type
41+
$prpl_pt = \sanitize_text_field( \wp_unslash( $_GET['prpl_page_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
4242

4343
foreach ( $page_types as $page_type ) {
4444
if ( $page_type['slug'] === $prpl_pt ) {

classes/admin/class-page-settings.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,9 @@ public function store_settings_form_options() {
132132
\check_admin_referer( 'progress_planner' );
133133

134134
if ( isset( $_POST['pages'] ) ) {
135-
$pages = (array) \wp_unslash( $_POST['pages'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
136-
foreach ( $pages as $type => $page_args ) {
137-
$page_args = (array) $page_args;
138-
$need_page = isset( $page_args['have_page'] )
139-
? \sanitize_text_field( \wp_unslash( $page_args['have_page'] ) ) // @phpstan-ignore-line argument.type
140-
: 'not-applicable';
135+
foreach ( \wp_unslash( $_POST['pages'] ) as $type => $page_args ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
136+
137+
$need_page = \sanitize_text_field( \wp_unslash( $page_args['have_page'] ) );
141138

142139
\progress_planner()->get_page_types()->set_no_page_needed(
143140
$type,
@@ -168,7 +165,7 @@ public function store_settings_form_options() {
168165

169166
if ( 'no' !== $page_args['have_page'] ) {
170167
// Add the term to the `progress_planner_page_types` taxonomy.
171-
\progress_planner()->get_page_types()->set_page_type_by_id( (int) $page_args['id'], $type ); // @phpstan-ignore-line cast.int
168+
\progress_planner()->get_page_types()->set_page_type_by_id( (int) $page_args['id'], $type );
172169
}
173170
}
174171
}
@@ -191,7 +188,7 @@ public function save_settings() {
191188
\check_admin_referer( 'progress_planner' );
192189

193190
$redirect_on_login = isset( $_POST['prpl-redirect-on-login'] )
194-
? \sanitize_text_field( \wp_unslash( $_POST['prpl-redirect-on-login'] ) ) // @phpstan-ignore-line argument.type
191+
? \sanitize_text_field( \wp_unslash( $_POST['prpl-redirect-on-login'] ) )
195192
: false;
196193

197194
\update_user_meta( \get_current_user_id(), 'prpl_redirect_on_login', (bool) $redirect_on_login );
@@ -207,7 +204,7 @@ public function save_post_types() {
207204
\check_admin_referer( 'progress_planner' );
208205

209206
$include_post_types = isset( $_POST['prpl-post-types-include'] )
210-
? \array_map( 'sanitize_text_field', \wp_unslash( $_POST['prpl-post-types-include'] ) ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized @phpstan-ignore-line argument.type
207+
? \array_map( 'sanitize_text_field', \wp_unslash( $_POST['prpl-post-types-include'] ) ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
211208
// If no post types are selected, use the default post types (post and page can be deregistered).
212209
: \array_intersect( [ 'post', 'page' ], \progress_planner()->get_settings()->get_public_post_types() );
213210

classes/admin/widgets/class-activity-scores.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function personal_record_callback() {
184184
'priority' => 'low',
185185
'evaluate' => function ( $goal_object ) {
186186
// Get the cached activities.
187-
$cached_activities = (array) \progress_planner()->get_settings()->get( $this->cache_key, [] );
187+
$cached_activities = \progress_planner()->get_settings()->get( $this->cache_key, [] );
188188

189189
// Get the weekly cache key.
190190
$weekly_cache_key = $goal_object->get_details()['start_date']->format( 'Y-m-d' ) . '_' . $goal_object->get_details()['end_date']->format( 'Y-m-d' );

classes/admin/widgets/class-challenge.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public function get_challenge() {
3434
'feed' => [],
3535
'expires' => 0,
3636
];
37-
} else {
38-
$feed_data = (array) $feed_data;
3937
}
4038

4139
// Transient expired, fetch new feed.

classes/admin/widgets/class-whats-new.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ final class Whats_New extends Widget {
3636
public function get_blog_feed() {
3737
$feed_data = \progress_planner()->get_utils__cache()->get( self::CACHE_KEY );
3838

39+
// Migrate old feed to new format.
40+
if ( \is_array( $feed_data ) && ! isset( $feed_data['expires'] ) && ! isset( $feed_data['feed'] ) ) {
41+
$feed_data = [
42+
'feed' => $feed_data,
43+
'expires' => \get_option( '_transient_timeout_' . Cache::CACHE_PREFIX . self::CACHE_KEY, 0 ),
44+
];
45+
}
46+
3947
// Transient not set.
4048
if ( false === $feed_data ) {
4149
$feed_data = [
4250
'feed' => [],
4351
'expires' => 0,
4452
];
45-
} elseif ( \is_array( $feed_data ) && ! isset( $feed_data['expires'] ) && ! isset( $feed_data['feed'] ) ) {
46-
// Migrate old feed to new format.
47-
$feed_data = [
48-
'feed' => $feed_data,
49-
'expires' => \get_option( '_transient_timeout_' . Cache::CACHE_PREFIX . self::CACHE_KEY, 0 ),
50-
];
51-
} else {
52-
$feed_data = (array) $feed_data;
5353
}
5454

5555
// Transient expired, fetch new feed.
@@ -61,15 +61,11 @@ public function get_blog_feed() {
6161
// If we cant fetch the feed, we will try again later.
6262
$feed_data['expires'] = \time() + 5 * MINUTE_IN_SECONDS;
6363
} else {
64-
$feed = (array) \json_decode( \wp_remote_retrieve_body( $response ), true );
64+
$feed = \json_decode( \wp_remote_retrieve_body( $response ), true );
6565

6666
foreach ( $feed as $key => $post ) {
67-
if ( ! \is_array( $post ) ) {
68-
continue;
69-
}
70-
7167
// Get the featured media.
72-
$featured_media_id = (int) $post['featured_media']; // @phpstan-ignore-line cast.int
68+
$featured_media_id = $post['featured_media'];
7369
if ( $featured_media_id ) {
7470
$response = \wp_remote_get( \progress_planner()->get_remote_server_root_url() . '/wp-json/wp/v2/media/' . $featured_media_id );
7571
if ( ! \is_wp_error( $response ) ) {

classes/admin/widgets/class-widget.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function get_range() {
6161
// phpcs:ignore WordPress.Security.NonceVerification
6262
return isset( $_GET['range'] )
6363
// phpcs:ignore WordPress.Security.NonceVerification
64-
? \sanitize_text_field( \wp_unslash( $_GET['range'] ) ) // @phpstan-ignore-line argument.type
64+
? \sanitize_text_field( \wp_unslash( $_GET['range'] ) )
6565
: '-6 months';
6666
}
6767

@@ -74,7 +74,7 @@ public function get_frequency() {
7474
// phpcs:ignore WordPress.Security.NonceVerification
7575
return isset( $_GET['frequency'] )
7676
// phpcs:ignore WordPress.Security.NonceVerification
77-
? \sanitize_text_field( \wp_unslash( $_GET['frequency'] ) ) // @phpstan-ignore-line argument.type
77+
? \sanitize_text_field( \wp_unslash( $_GET['frequency'] ) )
7878
: 'monthly';
7979
}
8080

classes/badges/class-badge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ abstract public function progress_callback( $args = [] );
7171
* @return array
7272
*/
7373
protected function get_saved() {
74-
return (array) \progress_planner()->get_settings()->get( [ 'badges', $this->id ], [] );
74+
return \progress_planner()->get_settings()->get( [ 'badges', $this->id ], [] );
7575
}
7676

7777
/**

0 commit comments

Comments
 (0)