diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..898fb625 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,13 @@ +parameters: + level: 9 + paths: + - src + - rewrite-command.php + scanDirectories: + - vendor/wp-cli/wp-cli/php + scanFiles: + - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php + treatPhpDocTypesAsCertain: false + ignoreErrors: + - identifier: missingType.parameter + - identifier: missingType.return diff --git a/src/Rewrite_Command.php b/src/Rewrite_Command.php index fe38105f..e662d6b7 100644 --- a/src/Rewrite_Command.php +++ b/src/Rewrite_Command.php @@ -126,11 +126,7 @@ public function structure( $args, $assoc_args ) { if ( ! empty( $permalink_structure ) ) { $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) ); - if ( $prefix && $blog_prefix ) { - $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure ); - } else { - $permalink_structure = $blog_prefix . $permalink_structure; - } + $permalink_structure = $blog_prefix . $permalink_structure; } $wp_rewrite->set_permalink_structure( $permalink_structure ); @@ -168,6 +164,9 @@ public function structure( $args, $assoc_args ) { } } + /** + * @var object{stdout: string, stderr: string, return_code: int} $process_run + */ $process_run = WP_CLI::runcommand( $cmd ); if ( ! empty( $process_run->stderr ) ) { // Strip "Warning: " @@ -222,6 +221,10 @@ public function list_( $args, $assoc_args ) { WP_CLI::warning( 'No rewrite rules.' ); } + /** + * @var array $rules + */ + self::check_skip_plugins_themes(); $defaults = [ @@ -333,6 +336,7 @@ private static function apache_modules() { // needed for get_home_path() and .htaccess location $_SERVER['SCRIPT_FILENAME'] = ABSPATH; + // @phpstan-ignore function.inner function apache_get_modules() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals return WP_CLI::get_config( 'apache_modules' ); }