Browse Source

Style fixes

master
J. King 1 year ago
parent
commit
02b655f5f6
  1. 5
      .php-cs-fixer.dist.php
  2. 11
      lib/Parser.php
  3. 3
      lib/Url.php

5
.php-cs-fixer.dist.php

@ -57,7 +57,10 @@ $rules = [
// PSR standard to apply // PSR standard to apply
'@PSR12' => true, '@PSR12' => true,
// house exceptions to PSR rules // house exceptions to PSR rules
'braces' => ['position_after_functions_and_oop_constructs' => "same"], 'curly_braces_position' => [
'functions_opening_brace' => "same_line",
'classes_opening_brace' => "same_line",
],
'function_declaration' => ['closure_function_spacing' => "none"], 'function_declaration' => ['closure_function_spacing' => "none"],
'new_with_braces' => false, // no option to specify absence of braces 'new_with_braces' => false, // no option to specify absence of braces
]; ];

11
lib/Parser.php

@ -106,7 +106,7 @@ class Parser {
'author' => ['h-entry' => ["u", "author", [], null, true]], 'author' => ['h-entry' => ["u", "author", [], null, true]],
]; ];
/** @var array The list of (global) attributes which contain URLs and apply to any element */ /** @var array The list of (global) attributes which contain URLs and apply to any element */
protected const URL_ATTRS_GLOBAL= ["itemid", "itemprop", "itemtype"]; protected const URL_ATTRS_GLOBAL = ["itemid", "itemprop", "itemtype"];
/** @var array The list of (non-global) attributes which contain URLs and their host elements */ /** @var array The list of (non-global) attributes which contain URLs and their host elements */
protected const URL_ATTRS = [ protected const URL_ATTRS = [
'a' => ["href", "ping"], 'a' => ["href", "ping"],
@ -663,10 +663,9 @@ class Parser {
} elseif (in_array($node->localName, ["img", "area"]) && $node->hasAttribute("alt")) { } elseif (in_array($node->localName, ["img", "area"]) && $node->hasAttribute("alt")) {
# else if img.p-x[alt] or area.p-x[alt], then return the alt attribute # else if img.p-x[alt] or area.p-x[alt], then return the alt attribute
return $node->getAttribute("alt"); return $node->getAttribute("alt");
} else {
# else return the textContent of the element after [cleaning]
return $this->getCleanText($node, $prefix);
} }
# else return the textContent of the element after [cleaning]
return $this->getCleanText($node, $prefix);
case "u": case "u":
# To parse an element for a u-x property value (whether explicit u-* or backcompat equivalent): # To parse an element for a u-x property value (whether explicit u-* or backcompat equivalent):
if (in_array($node->localName, ["a", "area", "link"]) && $node->hasAttribute("href")) { if (in_array($node->localName, ["a", "area", "link"]) && $node->hasAttribute("href")) {
@ -745,7 +744,7 @@ class Parser {
} }
// return the result // return the result
return [ return [
'html' => trim(Serializer::serializeInner($copy)), 'html' => trim(Serializer::serializeInner($copy)),
'value' => $this->getCleanText($node, $prefix), 'value' => $this->getCleanText($node, $prefix),
]; ];
default: default:
@ -870,7 +869,7 @@ class Parser {
]; ];
} }
foreach (self::ZONE_INPUT_FORMATS as $zf => $zp) { foreach (self::ZONE_INPUT_FORMATS as $zf => $zp) {
if ($out = $this->testDate($input, "!$df $tf$zf", "!$df\T$tf$zf","!$df $tf $zf", "!$df\T$tf $zf")) { if ($out = $this->testDate($input, "!$df $tf$zf", "!$df\T$tf$zf", "!$df $tf $zf", "!$df\T$tf $zf")) {
return [ return [
'date' => $out->format(self::DATE_OUTPUT_FORMATS[$dp]), 'date' => $out->format(self::DATE_OUTPUT_FORMATS[$dp]),
'time' => $out->format(self::DATE_OUTPUT_FORMATS[$tp]), 'time' => $out->format(self::DATE_OUTPUT_FORMATS[$tp]),

3
lib/Url.php

@ -4,6 +4,7 @@
* See LICENSE and AUTHORS files for details */ * See LICENSE and AUTHORS files for details */
declare(strict_types=1); declare(strict_types=1);
namespace MensBeam\Microformats; namespace MensBeam\Microformats;
use Psr\Http\Message\UriInterface; use Psr\Http\Message\UriInterface;
@ -44,7 +45,7 @@ class Url implements UriInterface {
(\#.*)? # fragment part (\#.*)? # fragment part
$>six $>six
PCRE; PCRE;
protected const STRICT_URI_PATTERN = <<<'PCRE' protected const STRICT_URI_PATTERN = <<<'PCRE'
<^ <^
(?: (?:
(?: (?:

Loading…
Cancel
Save