Skip to content

Commit

Permalink
Rectorize to PHP 7.4
Browse files Browse the repository at this point in the history
Switches to short anonymous function syntax.
  • Loading branch information
jtojnar committed Mar 16, 2024
1 parent 0e824ad commit 027367b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 2 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

// Define what rule sets will be applied
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_72,
LevelSetList::UP_TO_PHP_74,
]);

// is your PHP version different from the one your refactor to?
$rectorConfig->phpVersion(PhpVersion::PHP_72);
$rectorConfig->phpVersion(PhpVersion::PHP_74);
};
12 changes: 3 additions & 9 deletions src/Readability.php
Original file line number Diff line number Diff line change
Expand Up @@ -1120,9 +1120,7 @@ protected function grabArticle(?\DOMElement $page = null)

$topCandidates = array_filter(
$topCandidates,
function ($v, $idx) {
return 0 === $idx || null !== $v;
},
fn ($v, $idx) => 0 === $idx || null !== $v,
\ARRAY_FILTER_USE_BOTH
);
$topCandidate = $topCandidates[0];
Expand Down Expand Up @@ -1471,9 +1469,7 @@ private function isPhrasingContent($node): bool
&& !\in_array(
false,
array_map(
function ($c) {
return $this->isPhrasingContent($c);
},
fn ($c) => $this->isPhrasingContent($c),
iterator_to_array($node->childNodes)
),
true
Expand All @@ -1489,9 +1485,7 @@ private function hasSingleTagInsideElement(\DOMElement $node, string $tag): bool

$a = array_filter(
iterator_to_array($node->childNodes),
function ($childNode) {
return $childNode instanceof \DOMText && preg_match($this->regexps['hasContent'], $this->getInnerText($childNode));
}
fn ($childNode) => $childNode instanceof \DOMText && preg_match($this->regexps['hasContent'], $this->getInnerText($childNode))
);

return 0 === \count($a);
Expand Down

0 comments on commit 027367b

Please sign in to comment.