From 77b2587feebed4ec10bc5962df8248ebdbbcfffa Mon Sep 17 00:00:00 2001 From: George Steel Date: Thu, 25 Jan 2024 10:29:17 +0000 Subject: [PATCH 1/5] Fix `RiskyTruthyFalsyComparison` issues Signed-off-by: George Steel --- composer.json | 10 ++-- composer.lock | 60 +++++++++---------- src/Helper/Doctype.php | 4 +- src/Helper/Gravatar.php | 3 +- src/Helper/HeadLink.php | 2 +- src/Helper/HeadScript.php | 2 +- src/Helper/Navigation/PluginManager.php | 2 +- src/Helper/ServerUrl.php | 2 +- src/HelperPluginManager.php | 6 +- src/Model/FeedModel.php | 4 +- src/Renderer/FeedRenderer.php | 2 +- src/Renderer/PhpRenderer.php | 4 +- src/Resolver/AggregateResolver.php | 3 +- src/Resolver/PrefixPathStackResolver.php | 4 +- src/Resolver/RelativeFallbackResolver.php | 2 +- test/Helper/HtmlTagTest.php | 2 +- test/HelperPluginManagerCompatibilityTest.php | 4 +- 17 files changed, 60 insertions(+), 56 deletions(-) diff --git a/composer.json b/composer.json index 41e2e9fc5..cfd0fb51e 100644 --- a/composer.json +++ b/composer.json @@ -46,15 +46,15 @@ "laminas/laminas-modulemanager": "^2.15", "laminas/laminas-mvc": "^3.7.0", "laminas/laminas-mvc-i18n": "^1.8", - "laminas/laminas-mvc-plugin-flashmessenger": "^1.10", - "laminas/laminas-navigation": "^2.19.0", - "laminas/laminas-paginator": "^2.18", + "laminas/laminas-mvc-plugin-flashmessenger": "^1.10.1", + "laminas/laminas-navigation": "^2.19.1", + "laminas/laminas-paginator": "^2.18.1", "laminas/laminas-permissions-acl": "^2.16", "laminas/laminas-router": "^3.12.0", "laminas/laminas-uri": "^2.11", - "phpunit/phpunit": "^10.5.5", + "phpunit/phpunit": "^10.5.9", "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.18" + "vimeo/psalm": "^5.20" }, "conflict": { "container-interop/container-interop": "<1.2", diff --git a/composer.lock b/composer.lock index a68b7c52a..e66b091ac 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2d2ce4dd1a4c98f31574846b74249f6f", + "content-hash": "592dafb0d2f33db8a69049bf7183ec67", "packages": [ { "name": "laminas/laminas-escaper", @@ -289,16 +289,16 @@ }, { "name": "laminas/laminas-stdlib", - "version": "3.18.0", + "version": "3.19.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "e85b29076c6216e7fc98e72b42dbe1bbc3b95ecf" + "reference": "6a192dd0882b514e45506f533b833b623b78fff3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/e85b29076c6216e7fc98e72b42dbe1bbc3b95ecf", - "reference": "e85b29076c6216e7fc98e72b42dbe1bbc3b95ecf", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/6a192dd0882b514e45506f533b833b623b78fff3", + "reference": "6a192dd0882b514e45506f533b833b623b78fff3", "shasum": "" }, "require": { @@ -309,10 +309,10 @@ }, "require-dev": { "laminas/laminas-coding-standard": "^2.5", - "phpbench/phpbench": "^1.2.14", - "phpunit/phpunit": "^10.3.3", + "phpbench/phpbench": "^1.2.15", + "phpunit/phpunit": "^10.5.8", "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.15.0" + "vimeo/psalm": "^5.20.0" }, "type": "library", "autoload": { @@ -344,7 +344,7 @@ "type": "community_bridge" } ], - "time": "2023-09-19T10:15:21+00:00" + "time": "2024-01-19T12:39:49+00:00" }, { "name": "psr/container", @@ -1974,16 +1974,16 @@ }, { "name": "laminas/laminas-mvc-plugin-flashmessenger", - "version": "1.10.0", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-mvc-plugin-flashmessenger.git", - "reference": "e3e763d2a584b6fa5b1d09ec73e2f56fe45675b7" + "reference": "852d8c661dfb6492d4ea6d4ab238e72180e82387" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-mvc-plugin-flashmessenger/zipball/e3e763d2a584b6fa5b1d09ec73e2f56fe45675b7", - "reference": "e3e763d2a584b6fa5b1d09ec73e2f56fe45675b7", + "url": "https://api.github.com/repos/laminas/laminas-mvc-plugin-flashmessenger/zipball/852d8c661dfb6492d4ea6d4ab238e72180e82387", + "reference": "852d8c661dfb6492d4ea6d4ab238e72180e82387", "shasum": "" }, "require": { @@ -2039,7 +2039,7 @@ "type": "community_bridge" } ], - "time": "2023-11-14T09:56:52+00:00" + "time": "2024-01-18T15:07:28+00:00" }, { "name": "laminas/laminas-navigation", @@ -2477,16 +2477,16 @@ }, { "name": "laminas/laminas-validator", - "version": "2.46.0", + "version": "2.47.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-validator.git", - "reference": "98330256f8d8a1357a93f6f7f1a987036aff6329" + "reference": "5c3fc8c4f1263cda5c5f14aed874fdadd5b90bbd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/98330256f8d8a1357a93f6f7f1a987036aff6329", - "reference": "98330256f8d8a1357a93f6f7f1a987036aff6329", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/5c3fc8c4f1263cda5c5f14aed874fdadd5b90bbd", + "reference": "5c3fc8c4f1263cda5c5f14aed874fdadd5b90bbd", "shasum": "" }, "require": { @@ -2557,7 +2557,7 @@ "type": "community_bridge" } ], - "time": "2024-01-03T12:43:04+00:00" + "time": "2024-01-17T11:31:50+00:00" }, { "name": "myclabs/deep-copy", @@ -3368,16 +3368,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.7", + "version": "10.5.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e5c5b397a95cb0db013270a985726fcae93e61b8" + "reference": "0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e5c5b397a95cb0db013270a985726fcae93e61b8", - "reference": "e5c5b397a95cb0db013270a985726fcae93e61b8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe", + "reference": "0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe", "shasum": "" }, "require": { @@ -3449,7 +3449,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.7" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.9" }, "funding": [ { @@ -3465,7 +3465,7 @@ "type": "tidelift" } ], - "time": "2024-01-14T16:40:30+00:00" + "time": "2024-01-22T14:35:40+00:00" }, { "name": "psalm/plugin-phpunit", @@ -5523,16 +5523,16 @@ }, { "name": "vimeo/psalm", - "version": "5.19.0", + "version": "5.20.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "06b71be009a6bd6d81b9811855d6629b9fe90e1b" + "reference": "3f284e96c9d9be6fe6b15c79416e1d1903dcfef4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/06b71be009a6bd6d81b9811855d6629b9fe90e1b", - "reference": "06b71be009a6bd6d81b9811855d6629b9fe90e1b", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/3f284e96c9d9be6fe6b15c79416e1d1903dcfef4", + "reference": "3f284e96c9d9be6fe6b15c79416e1d1903dcfef4", "shasum": "" }, "require": { @@ -5629,7 +5629,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-01-09T21:02:43+00:00" + "time": "2024-01-18T12:15:06+00:00" }, { "name": "webimpress/coding-standard", diff --git a/src/Helper/Doctype.php b/src/Helper/Doctype.php index c805cfa5d..a7e3bf049 100644 --- a/src/Helper/Doctype.php +++ b/src/Helper/Doctype.php @@ -94,7 +94,7 @@ public function __invoke($doctype = null) if (0 !== strpos($doctype, 'isHtml5() || stristr($this->getDoctype(), 'rdfa'); + return $this->isHtml5() || stristr($this->getDoctype(), 'rdfa') !== false; } } diff --git a/src/Helper/Gravatar.php b/src/Helper/Gravatar.php index f06dedfce..07ab90892 100644 --- a/src/Helper/Gravatar.php +++ b/src/Helper/Gravatar.php @@ -6,6 +6,7 @@ use Laminas\View\Exception; +use function is_string; use function md5; use function method_exists; use function preg_match; @@ -104,7 +105,7 @@ class Gravatar extends AbstractHtmlElement */ public function __invoke($email = "", $options = [], $attributes = []) { - if (! empty($email)) { + if (is_string($email) && $email !== '') { $this->setEmail($email); } if (! empty($options)) { diff --git a/src/Helper/HeadLink.php b/src/Helper/HeadLink.php index bdbea923c..f89cc0aa6 100644 --- a/src/Helper/HeadLink.php +++ b/src/Helper/HeadLink.php @@ -182,7 +182,7 @@ public function __call($method, $args) $item = $this->$dataMethod($args); } - if ($item) { + if (is_object($item)) { if ('offsetSet' === $action) { $this->offsetSet($index, $item); } else { diff --git a/src/Helper/HeadScript.php b/src/Helper/HeadScript.php index bae22fe27..6add0494a 100644 --- a/src/Helper/HeadScript.php +++ b/src/Helper/HeadScript.php @@ -463,7 +463,7 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd) $type = $this->autoEscape ? $this->escapeAttribute($item->type) : $item->type; $html = '