Skip to content

Commit d32478f

Browse files
authored
PHPStan Level 1 (#215)
* Fixes 'Variable might not be defined.' * Fixes 'Variable in empty() always exists and is not falsy.' (array_filter has been applied) * Ignores 'Constant WP_CONTENT_URL not found.' * Fixes sniff-php issues
1 parent c3e3b4a commit d32478f

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

phpstan.neon.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 0
2+
level: 1
33
paths:
44
- wp-multi-network/includes
55
- wpmn-loader.php
@@ -9,5 +9,5 @@ parameters:
99
#- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-i18n-stubs.php
1010
#- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-tools-stubs.php
1111
ignoreErrors:
12-
- '/^Call to static method encode\(\) on an unknown class Requests_IDNAEncoder.$/'
13-
12+
- '/^Call to static method encode\(\) on an unknown class Requests_IDNAEncoder\.$/'
13+
- '/^Constant WP_CONTENT_URL not found\.$/'

wp-multi-network/includes/classes/class-wp-ms-network-command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function delete( $args, $assoc_args ) {
194194
* @param array $args Positional CLI arguments.
195195
* @param array $assoc_args Associative CLI arguments.
196196
*/
197-
public function move_site( $args, $assoc_args ) {
197+
public function move_site( $args, $assoc_args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
198198
list( $site_id, $new_network_id ) = $args;
199199

200200
$network_id = move_site( $site_id, $new_network_id );
@@ -261,7 +261,7 @@ public function list_( $args, $assoc_args ) {
261261
*/
262262
public function plugin( $args, $assoc_args ) {
263263
$fetchers_plugin = new \WP_CLI\Fetchers\Plugin();
264-
$action = array_shift( $args );
264+
$action = array_shift( $args );
265265
if ( ! in_array( $action, array( 'activate', 'deactivate' ), true ) ) {
266266
WP_CLI::error( sprintf( '%s is not a supported action.', $action ) );
267267
}

wp-multi-network/includes/classes/class-wp-ms-networks-admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ public function page_my_networks() {
792792
}
793793
$num_rows = ceil( $num / $cols );
794794
$split = 0;
795+
$rows = array();
795796
for ( $i = 1; $i <= $num_rows; $i++ ) {
796797
$rows[] = array_slice( $my_networks, $split, $cols );
797798
$split = $split + $cols;

wp-multi-network/includes/compat.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ function wp_validate_site_url( $domain, $path, $site_id = 0 ) {
8686
$domains = substr_count( $domain, '.' ) > 1 ? (array) substr( $domain, 0, strpos( $domain, '.' ) ) : array();
8787
$pieces = array_filter( array_merge( $domains, $paths ) );
8888
foreach ( $pieces as $slug ) {
89-
90-
// Bail if empty.
91-
if ( empty( $slug ) ) {
92-
return false;
93-
}
94-
9589
// Bail if not lowercase or numbers.
9690
if ( preg_match( '/[^a-z0-9]+/', $slug ) ) {
9791
return false;

0 commit comments

Comments
 (0)