Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -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
14 changes: 9 additions & 5 deletions src/Rewrite_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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: "
Expand Down Expand Up @@ -222,6 +221,10 @@ public function list_( $args, $assoc_args ) {
WP_CLI::warning( 'No rewrite rules.' );
}

/**
* @var array<string, string> $rules
*/

self::check_skip_plugins_themes();

$defaults = [
Expand Down Expand Up @@ -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' );
}
Expand Down