diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fcc843b472..6e027d3e20 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -40,6 +40,16 @@ parameters: count: 1 path: inc/Engine/Admin/Deactivation/DeactivationIntent.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Admin/Deactivation/DeactivationIntent.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 4 + path: inc/Engine/Admin/DomainChange/Subscriber.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 2 @@ -55,6 +65,11 @@ parameters: count: 12 path: inc/Engine/Admin/Settings/Page.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/Engine/Admin/Settings/Page.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 2 @@ -80,16 +95,41 @@ parameters: count: 6 path: inc/Engine/CDN/CDN.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 3 + path: inc/Engine/CDN/RocketCDN/APIClient.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 path: inc/Engine/CDN/RocketCDN/AdminPageSubscriber.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/CDN/RocketCDN/AdminPageSubscriber.php + + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/CDN/RocketCDN/CDNOptionsManager.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 path: inc/Engine/CDN/RocketCDN/DataManagerSubscriber.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 3 + path: inc/Engine/CDN/RocketCDN/DataManagerSubscriber.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/Engine/CDN/RocketCDN/DataManagerSubscriber.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 3 @@ -100,6 +140,11 @@ parameters: count: 2 path: inc/Engine/CDN/RocketCDN/NoticesSubscriber.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/Engine/CDN/RocketCDN/NoticesSubscriber.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -125,6 +170,11 @@ parameters: count: 1 path: inc/Engine/Cache/PurgeExpired/PurgeExpiredCache.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Cache/PurgeExpired/PurgeExpiredCache.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -145,6 +195,11 @@ parameters: count: 1 path: inc/Engine/Common/Clock/WPRClock.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Common/Database/Tables/AbstractTable.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -160,6 +215,11 @@ parameters: count: 1 path: inc/Engine/Common/JobManager/APIHandler/APIClient.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Common/PerformanceHints/Database/Table/AbstractTable.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 2 @@ -180,6 +240,11 @@ parameters: count: 1 path: inc/Engine/CriticalPath/Admin/Admin.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/CriticalPath/Admin/Settings.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 2 @@ -190,11 +255,21 @@ parameters: count: 5 path: inc/Engine/CriticalPath/CriticalCSS.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 4 + path: inc/Engine/CriticalPath/CriticalCSS.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 2 path: inc/Engine/CriticalPath/CriticalCSSSubscriber.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/Engine/CriticalPath/CriticalCSSSubscriber.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 5 @@ -210,11 +285,21 @@ parameters: count: 1 path: inc/Engine/Heartbeat/HeartbeatSubscriber.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/License/Renewal.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 3 path: inc/Engine/Media/AboveTheFold/AJAX/Controller.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Media/AboveTheFold/Context/Context.php + - message: "#^Hooks should not be used in ORM classes\\: WP_Rocket\\\\Engine\\\\Media\\\\AboveTheFold\\\\Database\\\\Queries\\\\AboveTheFold\\:\\:apply_filters$#" count: 1 @@ -285,6 +370,11 @@ parameters: count: 3 path: inc/Engine/Optimization/DeferJS/DeferJS.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Optimization/DeferJS/DeferJS.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -296,14 +386,14 @@ parameters: path: inc/Engine/Optimization/DelayJS/Admin/SiteList.php - - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" - count: 1 + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 path: inc/Engine/Optimization/DelayJS/Admin/SiteList.php - - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" + message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 - path: inc/Engine/Optimization/DelayJS/HTML.php + path: inc/Engine/Optimization/DelayJS/Admin/SiteList.php - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" @@ -320,6 +410,11 @@ parameters: count: 1 path: inc/Engine/Optimization/LazyRenderContent/AJAX/Controller.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Optimization/LazyRenderContent/Context/Context.php + - message: "#^Hooks should not be used in ORM classes\\: WP_Rocket\\\\Engine\\\\Optimization\\\\LazyRenderContent\\\\Database\\\\Queries\\\\LazyRenderContent\\:\\:apply_filters$#" count: 1 @@ -365,14 +460,29 @@ parameters: count: 1 path: inc/Engine/Optimization/Minify/JS/Subscriber.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Optimization/RUCSS/Admin/Database.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/Engine/Optimization/RUCSS/Admin/Settings.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 2 path: inc/Engine/Optimization/RUCSS/Admin/Settings.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Optimization/RUCSS/Admin/Subscriber.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" - count: 2 + count: 1 path: inc/Engine/Optimization/RUCSS/Controller/Filesystem.php - @@ -410,6 +520,11 @@ parameters: count: 5 path: inc/Engine/Preload/Controller/LoadInitialSitemap.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Preload/Controller/LoadInitialSitemap.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 8 @@ -430,6 +545,11 @@ parameters: count: 4 path: inc/Engine/Preload/Database/Queries/Cache.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Preload/Database/Tables/Cache.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 2 @@ -445,41 +565,131 @@ parameters: count: 2 path: inc/Engine/Preload/Subscriber.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Preload/Subscriber.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/Engine/Saas/Admin/Notices.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: inc/ThirdParty/Hostings/Godaddy.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/ThirdParty/Hostings/OneCom.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Hostings/ProIsp.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/Ads/Adthrive.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: inc/ThirdParty/Plugins/Ads/Adthrive.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 5 + path: inc/ThirdParty/Plugins/CDN/Cloudflare.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 path: inc/ThirdParty/Plugins/ContactForm7.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/Cookie/Termly.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 13 + path: inc/ThirdParty/Plugins/Ecommerce/BigCommerce.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 3 path: inc/ThirdParty/Plugins/Ecommerce/WooCommerceSubscriber.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 3 + path: inc/ThirdParty/Plugins/Ecommerce/WooCommerceSubscriber.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/I18n/WPML.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 path: inc/ThirdParty/Plugins/ModPagespeed.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/ThirdParty/Plugins/Optimization/AMP.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 5 + path: inc/ThirdParty/Plugins/Optimization/Autoptimize.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/Optimization/Perfmatters.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/Optimization/RapidLoad.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/Optimization/WPMeteor.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: inc/ThirdParty/Plugins/Optimization/WPMeteor.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/PageBuilder/Elementor.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 2 path: inc/ThirdParty/Plugins/SEO/AllInOneSEOPack.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/SEO/AllInOneSEOPack.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/ThirdParty/Plugins/SEO/Yoast.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -490,16 +700,41 @@ parameters: count: 6 path: inc/ThirdParty/Plugins/SimpleCustomCss.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/SimpleCustomCss.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: inc/ThirdParty/Plugins/ThirstyAffiliates.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 path: inc/ThirdParty/Plugins/WPGeotargeting.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/WPGeotargeting.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Plugins/WPGeotargeting.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: inc/ThirdParty/Plugins/WPGeotargeting.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: inc/ThirdParty/Themes/Avada.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -600,6 +835,11 @@ parameters: count: 1 path: tests/Integration/inc/Addon/Cloudflare/Subscriber/addCdnHelperMessage.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Addon/Cloudflare/Subscriber/deactivateDevMode.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -640,11 +880,26 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Admin/Deactivation/DeactivationIntent/activateSafeMode.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Admin/Deactivation/DeactivationIntent/activateSafeMode.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 path: tests/Integration/inc/Engine/Admin/Deactivation/Subscriber/addDataAttribute.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Admin/Deactivation/Subscriber/addModalAssets.php + + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Admin/Deactivation/Subscriber/insertDeactivationIntentForm.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -660,11 +915,21 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Admin/Settings/Subscriber/asyncWistiaScript.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/Admin/Settings/Subscriber/enableMobileCache.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: tests/Integration/inc/Engine/Admin/Settings/Subscriber/enableMobileCache.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/Admin/Settings/Subscriber/enableSeparateCacheFilesMobile.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -680,26 +945,56 @@ parameters: count: 1 path: tests/Integration/inc/Engine/CDN/RocketCDN/AdminPageSubscriber/preserveAuthorizationToken.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CDN/RocketCDN/AdminPageSubscriber/preserveAuthorizationToken.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 path: tests/Integration/inc/Engine/CDN/RocketCDN/AdminPageSubscriber/rocketcdnField.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CDN/RocketCDN/CDNOptionsManager/TestCase.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/CDN/RocketCDN/CDNOptionsManager/TestCase.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: tests/Integration/inc/Engine/CDN/RocketCDN/CDNOptionsManager/TestCase.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CDN/RocketCDN/CDNOptionsManager/disable.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: tests/Integration/inc/Engine/CDN/RocketCDN/NoticesSubscriber/displayRocketcdnCta.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CDN/RocketCDN/RESTSubscriber/disable.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: tests/Integration/inc/Engine/CDN/RocketCDN/RESTSubscriber/disable.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CDN/RocketCDN/RESTSubscriber/enable.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -760,6 +1055,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Cache/Config/ConfigSubscriber/changeCacheRejectUriWithPermalink.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Cache/PurgeActionsSubscriber/purgeCacheOnPublicSettingChange.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 2 @@ -775,6 +1075,11 @@ parameters: count: 2 path: tests/Integration/inc/Engine/Cache/PurgeExpired/Subscriber/scheduleEvent.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/Cache/PurgeExpired/Subscriber/updateLifespanOptionOnUpdate.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -835,6 +1140,16 @@ parameters: count: 1 path: tests/Integration/inc/Engine/CriticalPath/Admin/Subscriber/addHiddenAsyncCssMobile.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/CriticalPath/Admin/Subscriber/enableMobileCpcss.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CriticalPath/Admin/Subscriber/setAsyncCssMobileDefaultValue.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -845,6 +1160,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/CriticalPath/CriticalCSS/getCriticalCssContent.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CriticalPath/CriticalCSS/getCriticalCssContent.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -855,6 +1175,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/CriticalPath/CriticalCSS/getCurrentPageCriticalCss.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CriticalPath/CriticalCSSSubscriber/deleteCpcss.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -875,6 +1200,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/CriticalPath/CriticalCSSSubscriber/insertCriticalCssBuffer.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CriticalPath/CriticalCSSSubscriber/insertCriticalCssBuffer.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 2 @@ -890,6 +1220,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/CriticalPath/CriticalCSSSubscriber/stopCpcssProcess.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/CriticalPath/CriticalCSSSubscriber/stopCpcssProcess.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1045,6 +1380,16 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Optimization/DeferJS/AdminSubscriber/addDeferJsOption.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/DeferJS/AdminSubscriber/excludeJqueryDefer.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/Optimization/DeferJS/AdminSubscriber/excludeJqueryDefer.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1055,6 +1400,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Optimization/DeferJS/Subscriber/deferInlineJs.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/DeferJS/Subscriber/deferInlineJs.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1065,6 +1415,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Optimization/DeferJS/Subscriber/deferJs.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/DeferJS/Subscriber/deferJs.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1075,6 +1430,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Optimization/DeferJS/Subscriber/excludeJqueryCombine.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/DeferJS/Subscriber/excludeJqueryCombine.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1095,6 +1455,11 @@ parameters: count: 2 path: tests/Integration/inc/Engine/Optimization/DelayJS/Admin/Subscriber/sanitizeOptions.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/DelayJS/Admin/Subscriber/setOptionOnUpdate.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1105,6 +1470,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Optimization/DelayJS/Subscriber/delayJs.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/DelayJS/Subscriber/delayJs.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1160,6 +1530,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Optimization/DynamicLists/Subscriber/updateLists.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/Optimization/GoogleFonts/Admin/Subscriber/enableGoogleFonts.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1190,6 +1565,11 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes_when_allowed.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/Minify/CSS/AdminSubscriber/regenerateMinifyCssKey.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1250,16 +1630,36 @@ parameters: count: 1 path: tests/Integration/inc/Engine/Optimization/RUCSS/Admin/Subscriber/truncateUsedCss.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/RUCSS/Admin/Subscriber/updateSafelistItems.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 path: tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/maybeDisablePreloadFonts.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/maybeDisablePreloadFonts.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 path: tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/maybeDisablePreloadFonts.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/onUpdate.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/onUpdate.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1290,6 +1690,16 @@ parameters: count: 1 path: tests/Integration/inc/Engine/WPRocketUninstall/uninstall.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/WPRocketUninstall/uninstall.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/Engine/WPRocketUninstall/uninstall.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1410,6 +1820,11 @@ parameters: count: 1 path: tests/Integration/inc/ThirdParty/Hostings/WPXCloud/varnishIP.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/Ads/Adthrive/addDelayJsExclusion.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1465,6 +1880,16 @@ parameters: count: 1 path: tests/Integration/inc/ThirdParty/Plugins/Jetpack/addJetpackSitemap.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/Optimization/AMP/disableOptionsOnAmp.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/Optimization/AMP/disableOptionsOnAmp.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1475,6 +1900,16 @@ parameters: count: 1 path: tests/Integration/inc/ThirdParty/Plugins/Optimization/AMP/isAmpCompatibleCallback.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/Optimization/AMP/isAmpCompatibleCallback.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/Optimization/AMP/isAmpCompatibleCallback.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 3 @@ -1495,6 +1930,11 @@ parameters: count: 1 path: tests/Integration/inc/ThirdParty/Plugins/Optimization/Ezoic/addExplanations.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/Optimization/Hummingbird/warningNotice.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1515,6 +1955,11 @@ parameters: count: 1 path: tests/Integration/inc/ThirdParty/Plugins/Optimization/RocketLazyLoad/excludeRocketLazyLoadScript.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/Optimization/WPMeteor/disableDelayJs.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1540,6 +1985,11 @@ parameters: count: 1 path: tests/Integration/inc/ThirdParty/Plugins/PageBuilder/Elementor/addFixAnimationsScript.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/PageBuilder/Elementor/clearCache.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1550,6 +2000,11 @@ parameters: count: 1 path: tests/Integration/inc/ThirdParty/Plugins/PageBuilder/Elementor/excludePostCss.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Plugins/PageBuilder/Elementor/excludePostCss.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1585,6 +2040,11 @@ parameters: count: 1 path: tests/Integration/inc/ThirdParty/Plugins/Smush/SmushSubscriberTestCase.php + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/ThirdParty/Plugins/Smush/maybeDeactivateRocketLazyload.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 1 @@ -1630,6 +2090,11 @@ parameters: count: 2 path: tests/Integration/inc/ThirdParty/Themes/Bridge/maybeClearCache.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 1 + path: tests/Integration/inc/ThirdParty/Themes/Bridge/maybeClearCache.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 1 @@ -1700,6 +2165,16 @@ parameters: count: 1 path: tests/Integration/inc/admin/rocketAfterSaveOptions.php + - + message: "#^Usage of delete_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 2 + path: tests/Integration/inc/admin/rocketFirstInstall.php + + - + message: "#^Usage of get_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" + count: 3 + path: tests/Integration/inc/admin/rocketFirstInstall.php + - message: "#^Usage of update_option\\(\\) is discouraged\\. Use the Option object instead\\.$#" count: 2 @@ -1710,6 +2185,11 @@ parameters: count: 1 path: tests/Integration/inc/functions/rocketIsPluginActive.php + - + message: "#^Path in include_once\\(\\) \"vfs\\://public/wp\\-content/plugins/wp\\-rocket/inc/classes/dependencies/mobiledetect/mobiledetectlib/Mobile_Detect\\.php\" is not a file or it does not exist\\.$#" + count: 1 + path: tests/Integration/vfs:/public/wp-content/advanced-cache.php + - message: "#^Usage of apply_filters\\(\\) is discouraged\\. Use wpm_apply_filters_typed\\(\\) instead\\.$#" count: 5 diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 7d2c7a5a48..9b33f10fba 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -55,7 +55,7 @@ parameters: - %currentWorkingDirectory%/inc/classes/subscriber/third-party/ - %currentWorkingDirectory%/inc/3rd-party/ rules: - - WP_Rocket\Tests\phpstan\Rules\DiscourageUpdateOptionUsage + - WP_Rocket\Tests\phpstan\Rules\DiscourageWPOptionUsage - WP_Rocket\Tests\phpstan\Rules\DiscourageApplyFilters - WP_Rocket\Tests\phpstan\Rules\EnsureCallbackMethodsExistsInSubscribedEvents - WP_Rocket\Tests\phpstan\Rules\NoHooksInORM diff --git a/tests/phpstan/Rules/DiscourageUpdateOptionUsage.php b/tests/phpstan/Rules/DiscourageUpdateOptionUsage.php deleted file mode 100644 index d9050debc0..0000000000 --- a/tests/phpstan/Rules/DiscourageUpdateOptionUsage.php +++ /dev/null @@ -1,34 +0,0 @@ -name instanceof Node\Name && $node->name->toString() === 'update_option' ) { - return [ - RuleErrorBuilder::message( 'Usage of update_option() is discouraged. Use the Option object instead.' ) - ->identifier( 'custom.rules.discourageApplyFilters' ) - ->build(), - ]; - } - - return []; - } -} diff --git a/tests/phpstan/Rules/DiscourageWPOptionUsage.php b/tests/phpstan/Rules/DiscourageWPOptionUsage.php new file mode 100644 index 0000000000..97888c9c4e --- /dev/null +++ b/tests/phpstan/Rules/DiscourageWPOptionUsage.php @@ -0,0 +1,39 @@ +name instanceof Node\Name ? $node->name->toString() : ''; + + $discouragedFunctions = [ + 'update_option' => true, + 'get_option' => true, + 'delete_option' => true, + ]; + + if ( isset( $discouragedFunctions[ $functionName ] ) ) { + return [ + RuleErrorBuilder::message( sprintf( 'Usage of %1$s() is discouraged. Use the Option object instead.', $functionName ) ) + ->identifier('custom.rules.discourageOptionUsage') + ->build(), + ]; + } + + return []; + } +} diff --git a/tests/phpstan/tests/Rules/DiscourageUpdateOptionUsageTest.php b/tests/phpstan/tests/Rules/DiscourageUpdateOptionUsageTest.php deleted file mode 100644 index 3ec1fa2425..0000000000 --- a/tests/phpstan/tests/Rules/DiscourageUpdateOptionUsageTest.php +++ /dev/null @@ -1,28 +0,0 @@ -analyse([__DIR__ . '/../data/DiscourageUpdateOptionUsageTest/valid.php'], [ - ]); - } - - public function testShouldGetError() { - $this->analyse([__DIR__ . '/../data/DiscourageUpdateOptionUsageTest/not-valid.php'], [ - [ - "Usage of update_option() is discouraged. Use the Option object instead.", - 38 - ] - ]); - } -} diff --git a/tests/phpstan/tests/Rules/DiscourageWPOptionUsageTest.php b/tests/phpstan/tests/Rules/DiscourageWPOptionUsageTest.php new file mode 100644 index 0000000000..c9e205679f --- /dev/null +++ b/tests/phpstan/tests/Rules/DiscourageWPOptionUsageTest.php @@ -0,0 +1,46 @@ +analyse([__DIR__ . '/../data/DiscourageWPOptionUsageTest/valid.php'], [ + ]); + } + + public function testShouldHaveErrorWithDeleteOption() { + $this->analyse([__DIR__ . '/../data/DiscourageWPOptionUsageTest/use-delete-option.php'], [ + [ + "Usage of delete_option() is discouraged. Use the Option object instead.", + 19 + ] + ]); + } + + public function testShouldHaveErrorWithGetOption() { + $this->analyse([__DIR__ . '/../data/DiscourageWPOptionUsageTest/use-get-option.php'], [ + [ + "Usage of get_option() is discouraged. Use the Option object instead.", + 19 + ] + ]); + } + + public function testShouldHaveErrorWithUpdateOption() { + $this->analyse([__DIR__ . '/../data/DiscourageWPOptionUsageTest/use-update-option.php'], [ + [ + "Usage of update_option() is discouraged. Use the Option object instead.", + 19 + ] + ]); + } +} diff --git a/tests/phpstan/tests/data/DiscourageUpdateOptionUsageTest/not-valid.php b/tests/phpstan/tests/data/DiscourageUpdateOptionUsageTest/not-valid.php deleted file mode 100644 index 61561563ee..0000000000 --- a/tests/phpstan/tests/data/DiscourageUpdateOptionUsageTest/not-valid.php +++ /dev/null @@ -1,45 +0,0 @@ - 'return_false', - 'action_scheduler_extra_action_counts' => [ - ['hide_pastdue_status_filter'], - ['hide_pastdue_status_filter', 10, 3], - ], - ]; - } - - /** - * Hide past-due from status filter in Action Scheduler tools page. - * - * @param array $extra_actions Array with format action_count_identifier => action count. - * - * @return array - */ - public function hide_pastdue_status_filter( array $extra_actions ) { - if ( ! isset( $extra_actions['past-due'] ) ) { - return $extra_actions; - } - update_option( 'test_option', $extra_actions['past-due'] ); - - unset( $extra_actions['past-due'] ); - - - return $extra_actions; - } -} diff --git a/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-delete-option.php b/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-delete-option.php new file mode 100644 index 0000000000..570e08c0ad --- /dev/null +++ b/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-delete-option.php @@ -0,0 +1,21 @@ + 'callback', + ]; + } + + public function callback() { + return delete_option('test_option' ); + } +} diff --git a/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-get-option.php b/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-get-option.php new file mode 100644 index 0000000000..96c405cce6 --- /dev/null +++ b/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-get-option.php @@ -0,0 +1,21 @@ + 'callback', + ]; + } + + public function callback() { + return get_option('test_option', false ); + } +} diff --git a/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-update-option.php b/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-update-option.php new file mode 100644 index 0000000000..36448603db --- /dev/null +++ b/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/use-update-option.php @@ -0,0 +1,22 @@ + 'callback', + ]; + } + + public function callback() { + update_option('test_option', false ); + return true; + } +} diff --git a/tests/phpstan/tests/data/DiscourageUpdateOptionUsageTest/valid.php b/tests/phpstan/tests/data/DiscourageWPOptionUsageTest/valid.php similarity index 100% rename from tests/phpstan/tests/data/DiscourageUpdateOptionUsageTest/valid.php rename to tests/phpstan/tests/data/DiscourageWPOptionUsageTest/valid.php