From 87e4c530ce7d4e3e1c63cff0dbfa5bec22d21016 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sat, 29 Aug 2026 07:57:07 +0000 Subject: [PATCH] Fix PHPStan errors with WordPress 7.1 stubs `WP_Filesystem_Base::abspath()` is now typed as `string|false`, so bail out with an error instead of building a bogus `.maintenance` path. --- src/MaintenanceModeCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MaintenanceModeCommand.php b/src/MaintenanceModeCommand.php index 58910a2..af16ecd 100644 --- a/src/MaintenanceModeCommand.php +++ b/src/MaintenanceModeCommand.php @@ -132,7 +132,13 @@ public function is_active() { private function get_maintenance_mode_status() { $wp_filesystem = $this->init_wp_filesystem(); - $maintenance_file = trailingslashit( $wp_filesystem->abspath() ) . '.maintenance'; + $abspath = $wp_filesystem->abspath(); + + if ( false === $abspath ) { + WP_CLI::error( 'Could not determine the WordPress root directory.' ); + } + + $maintenance_file = trailingslashit( $abspath ) . '.maintenance'; if ( ! $wp_filesystem->exists( $maintenance_file ) ) { return false;