From fd4b80d8f673b1d6d67de6c0fd95a9bdb9b54d28 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Tue, 11 Jul 2023 18:38:15 -0400 Subject: [PATCH] Fix VCP comparison bug --- README.md | 2 +- lib/Microformats/Parser.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a7e9806..a014482 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A generic [Microformats](https://microformats.io/) parser for PHP. While it simi ## Usage -Functionality is provided for parsing from an HTTP URL, from a file, from a string, and from an HTML element (a `\DOMElement` object), as well as for serializing to JSON. A static method of the `MensBeam\Microformats` is provided for each task. +Functionality is provided for parsing from an HTTP URL, from a file, from a string, and from an HTML element (a `\DOMElement` object), as well as for serializing to JSON. A static method of the `MensBeam\Microformats` class is provided for each task. The parsing methods all return a Microformats structure as an array. The [Microformats wiki](https://microformats.org/wiki/microformats2) includes some sample structures in JSON format. diff --git a/lib/Microformats/Parser.php b/lib/Microformats/Parser.php index 72354fa..9c9024b 100644 --- a/lib/Microformats/Parser.php +++ b/lib/Microformats/Parser.php @@ -847,7 +847,7 @@ class Parser { switch ($prefix) { case "p": # To parse an element for a p-x property value (whether explicit p-* or backcompat equivalent): - if (!$isChild && $text = $this->getValueClassPattern($node, $prefix, $backcompatTypes)) { + if (!$isChild && ($text = $this->getValueClassPattern($node, $prefix, $backcompatTypes)) !== null) { # Parse the element for the Value Class Pattern. If a value is found, return it. return $text; } elseif (in_array($node->localName, ["abbr", "link"]) && $node->hasAttribute("title")) { @@ -890,7 +890,7 @@ class Parser { } elseif ($node->localName === "object" && $node->hasAttribute("data")) { # else if object.u-x[data], then get the data attribute $url = $node->getAttribute("data"); - } elseif (!$isChild && $url = $this->getValueClassPattern($node, $prefix, $backcompatTypes)) { + } elseif (!$isChild && ($url = $this->getValueClassPattern($node, $prefix, $backcompatTypes)) !== null) { # else parse the element for the Value Class Pattern. If a value is found, get it // Nothing to do in this branch } elseif ($node->localName === "abbr" && $node->hasAttribute("title")) { @@ -912,7 +912,7 @@ class Parser { case "dt": // NOTE: Because we perform implied date resolution we don't blindly return data from nodes; returning is done below after checks # To parse an element for a dt-x property value (whether explicit dt-* or backcompat equivalent): - if (!$isChild && $date = $this->getValueClassPattern($node, $prefix, $backcompatTypes, $impliedDate)) { + if (!$isChild && ($date = $this->getValueClassPattern($node, $prefix, $backcompatTypes, $impliedDate)) !== null) { # parse the element for the Value Class Pattern, including the date and time parsing rules. If a value is found, then return it. return $date; } elseif (in_array($node->localName, ["time", "ins", "del"]) && $node->hasAttribute("datetime")) {