From bb5751bacfac6076b96255f8e79b0419cc7c934f Mon Sep 17 00:00:00 2001 From: Utkarsh Patel Date: Fri, 24 Jul 2026 16:23:06 +0530 Subject: [PATCH] Bump PHPStan to level 5 and fix type/annotation issues --- php/class-admin.php | 4 ++-- php/class-connect.php | 4 ++-- php/class-deactivation.php | 6 +++--- php/class-delivery.php | 8 ++++---- php/class-media-library.php | 2 +- php/class-media.php | 20 ++++++++++---------- php/class-plugin.php | 9 +++++++-- php/class-sync.php | 6 +++--- php/connect/class-api.php | 18 +++++++++--------- php/cron/class-lock-file.php | 14 +++++++------- php/cron/class-lock-object.php | 2 +- php/delivery/class-lazy-load.php | 4 ++-- php/integrations/class-wpml.php | 2 +- php/media/class-filter.php | 2 +- php/media/class-global-transformations.php | 4 ++-- php/media/class-upgrade.php | 2 +- php/media/class-video.php | 4 ++-- php/sync/class-sync-queue.php | 6 +++--- php/traits/trait-cli.php | 4 ++-- php/ui/class-component.php | 2 +- php/ui/component/class-asset-preview.php | 6 +++--- php/ui/component/class-plan-details.php | 2 +- php/ui/component/class-plan-status.php | 2 +- php/ui/component/class-plan.php | 2 +- phpstan.neon.dist | 2 +- 25 files changed, 71 insertions(+), 66 deletions(-) diff --git a/php/class-admin.php b/php/class-admin.php index 2b602787e..4481d5db9 100644 --- a/php/class-admin.php +++ b/php/class-admin.php @@ -153,7 +153,7 @@ public function rest_save_settings( WP_REST_Request $request ) { $data = array_filter( $data, function ( $key ) use ( $settings ) { - return $settings->get_setting( $key, false ); + return (bool) $settings->get_setting( $key, false ); }, ARRAY_FILTER_USE_KEY ); @@ -210,7 +210,7 @@ public function register_admin( $page ) { $page['slug'], '', $page['icon'], - '81.5' + 81.5 ); $connected = $this->settings->get_param( 'connected' ); // Setup the Child page handles. diff --git a/php/class-connect.php b/php/class-connect.php index 3d7345e2e..19e214b77 100644 --- a/php/class-connect.php +++ b/php/class-connect.php @@ -456,7 +456,7 @@ function ( $a ) { $cname_str = $this->extract_cname( $test ); $cname_valid = $this->validate_domain( $cname_str ); - if ( $cname_str && ( ! substr_count( $cname_valid, '.' ) || false === $cname_valid ) ) { + if ( $cname_str && ( false === $cname_valid || ! substr_count( $cname_valid, '.' ) ) ) { $result['type'] = 'invalid_cname'; $result['message'] = __( 'CNAME is not a valid domain name.', 'cloudinary' ); @@ -632,7 +632,7 @@ protected function extract_cname( $parsed_url ) { * * @param string $domain The domain. * - * @return bool + * @return string|false */ protected function validate_domain( $domain ) { $is_valid = false; diff --git a/php/class-deactivation.php b/php/class-deactivation.php index 07a8cd726..e7655abba 100644 --- a/php/class-deactivation.php +++ b/php/class-deactivation.php @@ -185,7 +185,7 @@ public function render_connected() { $is_cloudinary_only = 'cld' === $this->plugin->settings->get_value( 'offload' ); ?> -
+