Skip to content

Commit c79d75a

Browse files
committed
adjust typing for Controller
1 parent 26d4f57 commit c79d75a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

phpstan.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ parameters:
1919
# https://gist.github.com/nicolas-grekas/1028251#improving-native-php-interface
2020
- message: '#^In method "WP2Static\\\S+::\S+", you should not use the \$_(COOKIE|GET|POST) superglobal#'
2121
path: src/Controller.php
22-
count: 6
22+
count: 1
2323
- message: '#^In method "WP2Static\\\S+::\S+", you should not use the \$_(GET|POST) superglobal#'
2424
path: src/CoreOptions.php
2525
count: 16
@@ -47,4 +47,7 @@ parameters:
4747
- message: "#^Cannot access offset \\S+ on mixed\\.$#"
4848
path: src/SitemapParser.php
4949
count: 3
50+
- message: "#^Cannot access property \\S+ on mixed\\.$#"
51+
path: src/Controller.php
52+
count: 6
5053
- '/^Parameter #2 \$callable of static method WP_CLI::add_command\(\) expects callable\(\): mixed, \S+ given\.$/'

src/Controller.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,9 @@ public static function wp2staticProcessJobsQueue() : void {
364364
public static function wp2staticDeployCacheDelete() : void {
365365
check_admin_referer( 'wp2static-caches-page' );
366366

367-
if ( isset( $_POST['deploy_namespace'] ) ) {
368-
DeployCache::truncate( $_POST['deploy_namespace'] );
367+
$deploy_namespace = strval( filter_input( INPUT_POST, 'deploy_namespace' ) );
368+
if ( $deploy_namespace !== '' ) {
369+
DeployCache::truncate( $deploy_namespace );
369370
} else {
370371
DeployCache::truncate();
371372
}
@@ -377,11 +378,12 @@ public static function wp2staticDeployCacheDelete() : void {
377378
public static function wp2staticDeployCacheShow() : void {
378379
check_admin_referer( 'wp2static-caches-page' );
379380

380-
if ( isset( $_POST['deploy_namespace'] ) ) {
381+
$deploy_namespace = strval( filter_input( INPUT_POST, 'deploy_namespace' ) );
382+
if ( $deploy_namespace !== '' ) {
381383
wp_safe_redirect(
382384
admin_url(
383385
'admin.php?page=wp2static-deploy-cache&deploy_namespace=' .
384-
urlencode( $_POST['deploy_namespace'] )
386+
urlencode( $deploy_namespace )
385387
)
386388
);
387389
} else {
@@ -515,7 +517,7 @@ public static function wp2staticToggleAddon( string $addon_slug = null ) : void
515517
} else {
516518
check_admin_referer( 'wp2static-addons-page' );
517519

518-
$addon_slug = sanitize_text_field( $_POST['addon_slug'] );
520+
$addon_slug = sanitize_text_field( strval( filter_input( INPUT_POST, 'addon_slug' ) ) );
519521
}
520522

521523
global $wpdb;

0 commit comments

Comments
 (0)