improve typing in ViewRenderer

This commit is contained in:
Leon Stafford 2023-01-01 22:45:15 +11:00
parent 4ec7b22d67
commit 58d43185bb
2 changed files with 16 additions and 15 deletions

View file

@ -25,7 +25,7 @@ parameters:
count: 25
- message: '#^In method "WP2Static\\\S+::\S+", you should not use the \$_(GET|POST) superglobal#'
path: src/ViewRenderer.php
count: 18
count: 10
- message: "#^Cannot access property \\$value on mixed\\.$#"
path: views/options-page.php
count: 4

View file

@ -151,12 +151,12 @@ class ViewRenderer {
$paths = ProcessedSite::getPaths();
// Apply search
if ( ! empty( $_GET['s'] ) ) {
$s = $_GET['s'];
$search_term = strval( filter_input( INPUT_GET, 's' ) );
if ( $search_term !== '' ) {
$paths = array_filter(
$paths,
function ( $path ) use ( $s ) {
return stripos( $path, $s ) !== false;
function ( $path ) use ( $search_term ) {
return stripos( $path, $search_term ) !== false;
}
);
}
@ -184,12 +184,12 @@ class ViewRenderer {
$paths = StaticSite::getPaths();
// Apply search
if ( ! empty( $_GET['s'] ) ) {
$s = $_GET['s'];
$search_term = strval( filter_input( INPUT_GET, 's' ) );
if ( $search_term !== '' ) {
$paths = array_filter(
$paths,
function ( $path ) use ( $s ) {
return stripos( $path, $s ) !== false;
function ( $path ) use ( $search_term ) {
return stripos( $path, $search_term ) !== false;
}
);
}
@ -214,17 +214,18 @@ class ViewRenderer {
die( 'Forbidden' );
}
$paths = isset( $_GET['deploy_namespace'] )
? DeployCache::getPaths( $_GET['deploy_namespace'] )
$deploy_namespace = strval( filter_input( INPUT_GET, 'deploy_namespace' ) );
$paths = $deploy_namespace !== ''
? DeployCache::getPaths( $deploy_namespace )
: DeployCache::getPaths();
// Apply search
if ( ! empty( $_GET['s'] ) ) {
$s = $_GET['s'];
$search_term = strval( filter_input( INPUT_GET, 's' ) );
if ( $search_term !== '' ) {
$paths = array_filter(
$paths,
function ( $path ) use ( $s ) {
return stripos( $path, $s ) !== false;
function ( $path ) use ( $search_term ) {
return stripos( $path, $search_term ) !== false;
}
);
}