Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/phpstan-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: PHPStan CI

on: [push]

jobs:
build-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
uses: php-actions/composer@v6
with:
php_version: '7.2'
- name: Run PHPStan
uses: php-actions/phpstan@v3
with:
version: 'composer'
php_version: '7.2'
memory_limit: 1G
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
},
"require-dev": {
"phpcompatibility/phpcompatibility-wp": "^2.1.0",
"szepeviktor/phpstan-wordpress": "^1.0",
"wp-coding-standards/wpcs": "^3.1.0",
"yoast/wp-test-utils": "^1.2"
},
"scripts": {
"phpstan": "phpstan analyse --memory-limit=1G"
},
"config": {
"allow-plugins": {
"composer/installers": true,
Expand Down
18 changes: 18 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
level: 0
paths:
- wp-multi-network/includes
- wpmn-loader.php
ignoreErrors:
- '/^Call to static method add_command\(\) on an unknown class WP_CLI.$/'
- '/^Call to static method encode\(\) on an unknown class Requests_IDNAEncoder.$/'
- '/^Call to static method error\(\) on an unknown class WP_CLI.$/'
- '/^Call to static method success\(\) on an unknown class WP_CLI.$/'
- '/^Call to static method warning\(\) on an unknown class WP_CLI.$/'
- '/^Function WP_CLI\\Utils\\get_flag_value not found.$/'
- '/^Function WP_CLI\\Utils\\get_plugin_name not found.$/'
- '/^Instantiated class WP_CLI\\Fetchers\\Plugin not found.$/'
- '/^Instantiated class WP_CLI\\Fetchers\\User not found.$/'
- '/^Instantiated class WP_CLI\\Formatter not found.$/'
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @since 1.3.0
*/
class WP_MS_Network_Command extends WP_CLI_Command {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Historically, WP-CLI provided a base WP_CLI_Command class to extend, however extending this class is not required and will not change how your command behaves.

https://make.wordpress.org/cli/handbook/guides/commands-cookbook/

class WP_MS_Network_Command {

/**
* Default fields to display for each object.
Expand Down Expand Up @@ -260,7 +260,7 @@ public function list_( $args, $assoc_args ) {
* @param array $assoc_args Associative CLI arguments.
*/
public function plugin( $args, $assoc_args ) {
$this->fetcher = new \WP_CLI\Fetchers\Plugin();
$fetchers_plugin = new \WP_CLI\Fetchers\Plugin();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this should be a var and not a class member (PHPStan also didn't like it :-))

$action = array_shift( $args );
if ( ! in_array( $action, array( 'activate', 'deactivate' ), true ) ) {
WP_CLI::error( sprintf( '%s is not a supported action.', $action ) );
Expand All @@ -284,7 +284,7 @@ function ( $file ) {
}, array_keys( get_plugins() )
);
}
foreach ( $this->fetcher->get_many( $args ) as $plugin ) {
foreach ( $fetchers_plugin->get_many( $args ) as $plugin ) {
$status = $this->get_status( $plugin->file );
if ( $all && in_array( $status, array( 'active', 'active-network' ), true ) ) {
--$needing_activation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ protected function handle_row_actions( $network, $column_name, $primary ) {
*
* @since 2.0.0
*
* @param array Action links as $slug => $link_markup pairs.
* @param int The current network ID.
* @param string The current network name.
* @param array $filtered_acions Action links as $slug => $link_markup pairs.
* @param int $network_id The current network ID.
* @param string $network_sitename The current network name.
*/
$actions = apply_filters( 'manage_networks_action_links', array_filter( $actions ), $network->id, $network->sitename );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,6 @@ public function update_item( $request ) {
}

if ( ! empty( $prepared_args ) ) {
if ( is_wp_error( $prepared_args ) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already sorted out at line 447.

return $prepared_args;
}

$domain = $prepared_args['domain'];
$path = $prepared_args['path'];

Expand Down
10 changes: 5 additions & 5 deletions wp-multi-network/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ function user_has_networks( $user_id = 0 ) {
*
* @since 2.0.0
*
* @param array|bool|null List of network IDs or false. Anything but null will short-circuit
* the process.
* @param int User ID for which the networks should be returned.
* @param array|bool|null $my_networks List of network IDs or false. Anything but null will short-circuit
* the process.
* @param int $user_id User ID for which the networks should be returned.
*/
$my_networks = apply_filters( 'networks_pre_user_is_network_admin', null, $user_id );
if ( null !== $my_networks ) {
Expand All @@ -89,8 +89,8 @@ function user_has_networks( $user_id = 0 ) {
*
* @since 2.0.0
*
* @param array|bool List of network IDs or false if no networks for the user.
* @param int User ID for which the networks should be returned.
* @param array|bool $my_networks List of network IDs or false if no networks for the user.
* @param int $user_id User ID for which the networks should be returned.
*/
return apply_filters( 'networks_user_is_network_admin', $my_networks, $user_id );
}
Expand Down
Loading