From 89647a57db280f9f93c27271fea58babb77bb473 Mon Sep 17 00:00:00 2001
From: Nicolas Grekas <nicolas.grekas@gmail.com>
Date: Tue, 22 Oct 2024 12:26:52 +0200
Subject: [PATCH] Minor fixes around parse_url() checks

---
 AbstractUriElement.php | 2 +-
 Form.php               | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/AbstractUriElement.php b/AbstractUriElement.php
index f4b0e06..a119e53 100644
--- a/AbstractUriElement.php
+++ b/AbstractUriElement.php
@@ -46,7 +46,7 @@ public function __construct(\DOMElement $node, ?string $currentUri = null, ?stri
         $this->method = $method ? strtoupper($method) : null;
         $this->currentUri = $currentUri;
 
-        $elementUriIsRelative = null === parse_url(trim($this->getRawUri()), \PHP_URL_SCHEME);
+        $elementUriIsRelative = !parse_url(trim($this->getRawUri()), \PHP_URL_SCHEME);
         $baseUriIsAbsolute = null !== $this->currentUri && \in_array(strtolower(substr($this->currentUri, 0, 4)), ['http', 'file']);
         if ($elementUriIsRelative && !$baseUriIsAbsolute) {
             throw new \InvalidArgumentException(sprintf('The URL of the element is relative, so you must define its base URI passing an absolute URL to the constructor of the "%s" class ("%s" was passed).', __CLASS__, $this->currentUri));
diff --git a/Form.php b/Form.php
index 3b03b58..9e85a61 100644
--- a/Form.php
+++ b/Form.php
@@ -203,9 +203,8 @@ public function getUri()
         $uri = parent::getUri();
 
         if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) {
-            $query = parse_url($uri, \PHP_URL_QUERY);
             $currentParameters = [];
-            if ($query) {
+            if ($query = parse_url($uri, \PHP_URL_QUERY)) {
                 parse_str($query, $currentParameters);
             }