From 717c33f4714207e3bbf80b10f1666be3df7a1f96 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Sat, 6 Jan 2018 20:05:39 +0100 Subject: [PATCH] Fix implicit array-to-boolean convertion Scrutinizer: The expression $result of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements. --- lib/SimpleSAML/XML/Parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php index fb05d51bf..b8dda8522 100644 --- a/lib/SimpleSAML/XML/Parser.php +++ b/lib/SimpleSAML/XML/Parser.php @@ -50,7 +50,7 @@ class Parser public function getValue($xpath, $required = false) { $result = $this->simplexml->xpath($xpath); - if (!($result || !is_array($result))) { + if (!is_array($result) || empty($result)) { if ($required) { throw new \Exception('Could not get value from XML document using the following XPath expression: ' . $xpath); } else { -- GitLab