Skip to content

Commit

Permalink
chore: fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dartui committed Oct 22, 2024
1 parent 1e117c6 commit 7213c01
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 0 additions & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Repository/MergeTag/UrlTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) : '';
}
}
1 change: 1 addition & 0 deletions src/Repository/Trigger/Post/PostTrigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
12 changes: 9 additions & 3 deletions src/Utils/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__)));
}
Expand Down

0 comments on commit 7213c01

Please sign in to comment.