Skip to content

Commit ee7d436

Browse files
authored
PHPStan Level 4 Compliance (#219)
* PHPStan Level 4 * Solves Property WPMN_Loader::$admin_bar is never read, only written. * Solves Unreachable statement - code above always terminates. * Solves Strict comparison using === between true and int|null will always evaluate to false.
1 parent c367f0d commit ee7d436

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 3
2+
level: 4
33
paths:
44
- wp-multi-network/includes
55
- wpmn-loader.php

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ public function create( $args, $assoc_args ) {
8686

8787
if ( ! empty( $clone_network ) && ! get_network( $clone_network ) ) {
8888
WP_CLI::error( sprintf( "Clone network %s doesn't exist.", $clone_network ) );
89-
90-
if ( ! empty( $assoc_args['options_to_clone'] ) ) {
91-
$options_to_clone = explode( ',', $assoc_args['options_to_clone'] );
92-
}
9389
}
9490

9591
$network_id = add_network(

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717
class WP_MS_Networks_Admin_Bar {
1818

1919
/**
20-
* Constructor.
20+
* Registers WordPress hooks for the plugin.
2121
*
22-
* Hooks in the necessary methods.
22+
* Adds actions to:
23+
* - Modify the admin bar menu
24+
* - Add custom styles to the admin area
25+
* - Add custom styles to the front-end
2326
*
24-
* @since 2.2.0
27+
* @return void
2528
*/
26-
public function __construct() {
29+
public function add_hooks(): void {
2730
add_action( 'admin_bar_menu', array( $this, 'admin_bar' ), 20 );
28-
2931
add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
3032
add_action( 'wp_print_styles', array( $this, 'admin_print_styles' ) );
3133
}

wp-multi-network/includes/compat.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function wp_sanitize_site_path( $path = '' ) {
5656
* @param string $domain Site domain.
5757
* @param string $path Site path.
5858
* @param string $site_id Optional. Site ID, if an existing site. Default 0.
59+
*
5960
* @return bool True if the site URL is valid, false otherwise.
6061
*/
6162
function wp_validate_site_url( $domain, $path, $site_id = '0' ) {
@@ -66,7 +67,8 @@ function wp_validate_site_url( $domain, $path, $site_id = '0' ) {
6667
if ( (int) $exists === (int) $site_id ) {
6768
return true;
6869
}
69-
if ( true === $exists ) {
70+
71+
if ( true === (bool) $exists ) {
7072
return false;
7173
}
7274

wpmn-loader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ private function includes() {
165165
$this->capabilities->add_hooks();
166166

167167
$this->admin_bar = new WP_MS_Networks_Admin_Bar();
168+
$this->admin_bar->add_hooks();
168169

169170
if ( defined( 'WPMN_DEPRECATED' ) && ( true === WPMN_DEPRECATED ) ) {
170171
require $this->plugin_dir . 'includes/deprecated.php';

0 commit comments

Comments
 (0)