diff --git a/composer.json b/composer.json index 752d16ef..f77b07ca 100644 --- a/composer.json +++ b/composer.json @@ -72,7 +72,7 @@ "phpcbf": "phpcbf --parallel=4", "phpcs": "phpcs --parallel=4", "phplint": "parallel-lint --exclude node_modules --exclude vendor --exclude dependencies .", - "phpstan": "phpstan analyze --memory-limit=-1", + "phpstan": "phpstan analyze --memory-limit=-1 -v", "generate-stubs": "generate-stubs --finder=compat/stub-finder.php --out=compat/stubs.php --force", "prefix-namespaces-dev": [ "strauss", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2d26364d..f30a1f9f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1580,11 +1580,6 @@ parameters: count: 1 path: src/Repository/MergeTag/Taxonomy/TermSlug.php - - - message: "#^Parameter \\#1 \\$url of function esc_url expects string, mixed given\\.$#" - count: 1 - path: src/Repository/MergeTag/UrlTag.php - - message: "#^Parameter \\#1 \\$triggerPropertyName of method BracketSpace\\\\Notification\\\\Repository\\\\MergeTag\\\\BaseMergeTag\\:\\:setTriggerProp\\(\\) expects string, mixed given\\.$#" count: 1 @@ -2015,21 +2010,6 @@ parameters: count: 1 path: src/Store/Trigger.php - - - message: "#^Cannot access offset 'host' on array\\{scheme\\?\\: string, host\\?\\: string, port\\?\\: int, user\\?\\: string, pass\\?\\: string, path\\?\\: string, query\\?\\: string, fragment\\?\\: string\\}\\|false\\.$#" - count: 1 - path: src/Utils/Settings.php - - - - message: "#^Cannot access offset 'path' on array\\{scheme\\?\\: string, host\\?\\: string, port\\?\\: int, user\\?\\: string, pass\\?\\: string, path\\?\\: string, query\\?\\: string, fragment\\?\\: string\\}\\|false\\.$#" - count: 3 - path: src/Utils/Settings.php - - - - message: "#^Cannot access offset 'scheme' on array\\{scheme\\?\\: string, host\\?\\: string, port\\?\\: int, user\\?\\: string, pass\\?\\: string, path\\?\\: string, query\\?\\: string, fragment\\?\\: string\\}\\|false\\.$#" - count: 1 - path: src/Utils/Settings.php - - message: "#^Cannot access offset mixed on mixed\\.$#" count: 2 diff --git a/src/Admin/Wizard.php b/src/Admin/Wizard.php index 6bffa0aa..b3afd76f 100644 --- a/src/Admin/Wizard.php +++ b/src/Admin/Wizard.php @@ -347,7 +347,7 @@ private function saveOptionToDismissWizard() if (get_option($this->dismissedOption) !== false) { update_option($this->dismissedOption, true); } else { - add_option($this->dismissedOption, true, '', 'no'); + add_option($this->dismissedOption, true, '', false); } } diff --git a/src/Repository/MergeTag/UrlTag.php b/src/Repository/MergeTag/UrlTag.php index f3f3d440..b7b66865 100644 --- a/src/Repository/MergeTag/UrlTag.php +++ b/src/Repository/MergeTag/UrlTag.php @@ -41,6 +41,6 @@ public function validate($value) */ public function sanitize($value) { - return esc_url_raw($value); + return is_string($value) ? esc_url_raw($value) : ''; } } diff --git a/src/Repository/Trigger/Post/PostTrigger.php b/src/Repository/Trigger/Post/PostTrigger.php index 6af9a672..fc2dc149 100644 --- a/src/Repository/Trigger/Post/PostTrigger.php +++ b/src/Repository/Trigger/Post/PostTrigger.php @@ -605,6 +605,7 @@ public function __get($property) if (in_array($property, array_keys($propertyMap), true)) { wp_trigger_error( + // @phpstan-ignore argument.type static::class, sprintf( 'Property `%s` is deprecated since 9.0.0, use `post` property instead.', diff --git a/src/Utils/Settings.php b/src/Utils/Settings.php index 20498e1a..a542a229 100644 --- a/src/Utils/Settings.php +++ b/src/Utils/Settings.php @@ -359,15 +359,21 @@ public function setVariables() // URI. $themeUrl = wp_parse_url(get_stylesheet_directory_uri()); - $themePos = strpos($this->path, $themeUrl['path']); + $themePos = strpos($this->path, $themeUrl['path'] ?? ''); if ($themePos !== false) { // loaded from theme. $pluginRelativeDir = str_replace( - $themeUrl['path'], + $themeUrl['path'] ?? '', '', substr($this->path, $themePos) ); - $this->uri = $themeUrl['scheme'] . '://' . $themeUrl['host'] . $themeUrl['path'] . $pluginRelativeDir; + $this->uri = sprintf( + '%s://%s%s%s', + $themeUrl['scheme'] ?? '', + $themeUrl['host'] ?? '', + $themeUrl['path'] ?? '', + $pluginRelativeDir + ); } else { // loaded from plugin. $this->uri = trailingslashit(plugins_url('', dirname(__FILE__))); }