Skip to content

Commit

Permalink
Update CS-Fixer
Browse files Browse the repository at this point in the history
Requiring by friendsofphp/php-cs-fixer v2.18.0
  • Loading branch information
j0k3r committed Jan 18, 2021
1 parent 07c7f19 commit f057b12
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/Extractor/ContentExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ function ($element, $currentEntity) {
$this->logger->info('Detecting body');
$this->body = $this->readability->getContent();

if (1 === $this->body->childNodes->length && XML_ELEMENT_NODE === $this->body->firstChild->nodeType) {
if (1 === $this->body->childNodes->length && \XML_ELEMENT_NODE === $this->body->firstChild->nodeType) {
$this->body = $this->body->firstChild;
}

Expand All @@ -551,11 +551,11 @@ function ($element, $currentEntity) {
if (isset($this->title) && '' !== $this->title && null !== $this->body->firstChild) {
$firstChild = $this->body->firstChild;

while (null !== $firstChild->nextSibling && $firstChild->nodeType && (XML_ELEMENT_NODE !== $firstChild->nodeType)) {
while (null !== $firstChild->nextSibling && $firstChild->nodeType && (\XML_ELEMENT_NODE !== $firstChild->nodeType)) {
$firstChild = $firstChild->nextSibling;
}

if (XML_ELEMENT_NODE === $firstChild->nodeType
if (\XML_ELEMENT_NODE === $firstChild->nodeType
&& \in_array(strtolower($firstChild->tagName), ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'], true)
&& (strtolower(trim($firstChild->textContent)) === strtolower(trim($this->title)))) {
$this->body->removeChild($firstChild);
Expand Down
10 changes: 5 additions & 5 deletions src/Extractor/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ private function cleanupUrl($url)

// convert fragment to actual query parameters
if ($fragmentPos = strpos($url, '#!')) {
$fragment = parse_url($url, PHP_URL_FRAGMENT);
$fragment = parse_url($url, \PHP_URL_FRAGMENT);
// strip '!'
$fragment = substr((string) $fragment, 1);
$query = ['_escaped_fragment_' => $fragment];

// url without fragment
$url = substr($url, 0, $fragmentPos);
$url .= parse_url($url, PHP_URL_QUERY) ? '&' : '?';
$url .= parse_url($url, \PHP_URL_QUERY) ? '&' : '?';
// needed for some sites
$url .= str_replace('%2F', '/', http_build_query($query));
}
Expand All @@ -328,7 +328,7 @@ private function cleanupUrl($url)
*/
private function possibleUnsupportedType($url)
{
$ext = strtolower(trim(pathinfo($url, PATHINFO_EXTENSION)));
$ext = strtolower(trim(pathinfo($url, \PATHINFO_EXTENSION)));

if (!$ext) {
return false;
Expand Down Expand Up @@ -357,7 +357,7 @@ private function getUserAgent($url, array $httpHeader = [])
return $httpHeader['user-agent'];
}

$host = parse_url($url, PHP_URL_HOST);
$host = parse_url($url, \PHP_URL_HOST);

if ('www.' === strtolower(substr((string) $host, 0, 4))) {
$host = substr((string) $host, 4);
Expand Down Expand Up @@ -567,7 +567,7 @@ private function getUglyURL($url, $html)
$query = ['_escaped_fragment_' => ''];

// add fragment to url
$url .= parse_url($url, PHP_URL_QUERY) ? '&' : '?';
$url .= parse_url($url, \PHP_URL_QUERY) ? '&' : '?';
// needed for some sites
$url .= str_replace('%2F', '/', http_build_query($query));

Expand Down
12 changes: 6 additions & 6 deletions src/Graby.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ public function cleanupHtml($contentBlock, $url)

// remove empty text nodes
foreach ($contentBlock->childNodes as $n) {
if (XML_TEXT_NODE === $n->nodeType && '' === trim($n->textContent)) {
if (\XML_TEXT_NODE === $n->nodeType && '' === trim($n->textContent)) {
$contentBlock->removeChild($n);
}
}

// remove nesting: <div><div><div><p>test</p></div></div></div> = <p>test</p>
while (1 === $contentBlock->childNodes->length && XML_ELEMENT_NODE === $contentBlock->firstChild->nodeType) {
while (1 === $contentBlock->childNodes->length && \XML_ELEMENT_NODE === $contentBlock->firstChild->nodeType) {
// only follow these tag names
if (!\in_array(strtolower($contentBlock->tagName), ['div', 'article', 'section', 'header', 'footer'], true)) {
break;
Expand Down Expand Up @@ -314,7 +314,7 @@ private function doFetchContent($url)
$html = preg_replace($re, '', (string) $htmlCleaned);

// in case html string is too long, keep the html uncleaned to avoid empty html
if (PREG_JIT_STACKLIMIT_ERROR === preg_last_error()) {
if (\PREG_JIT_STACKLIMIT_ERROR === preg_last_error()) {
$html = $htmlCleaned;
$this->logger->debug('Failed to properly clean HTML from empty nodes');
}
Expand Down Expand Up @@ -501,11 +501,11 @@ private function validateUrl($url)
// everything should be converted, rebuild the final url
$url = (string) $uri;

if (false === filter_var($url, FILTER_VALIDATE_URL)) {
if (false === filter_var($url, \FILTER_VALIDATE_URL)) {
throw new \InvalidArgumentException(sprintf('Url "%s" is not valid.', $url));
}

$url = filter_var($url, FILTER_SANITIZE_URL);
$url = filter_var($url, \FILTER_SANITIZE_URL);

if (false === $url) {
throw new \InvalidArgumentException(sprintf('Sanitizing url "%s" failed.', $url));
Expand Down Expand Up @@ -897,7 +897,7 @@ private function convert2Utf8($html, array $headers = [])
// remove strange things
$html = str_replace('</[>', '', $html);

if (empty($contentType) || !preg_match_all('/([^;]+)(?:;\s*charset=["\']?([^;"\'\n]*))?/im', $contentType, $match, PREG_SET_ORDER)) {
if (empty($contentType) || !preg_match_all('/([^;]+)(?:;\s*charset=["\']?([^;"\'\n]*))?/im', $contentType, $match, \PREG_SET_ORDER)) {
// error parsing the response
$this->logger->info('Could not find Content-Type header in HTTP response', ['headers' => $headers]);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Formatter/GrabyFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ protected function convertToString($data): string
*/
private function addRowWithLevel($level, $th, $td = ' ', $escapeTd = true)
{
$th = htmlspecialchars($th, ENT_NOQUOTES, 'UTF-8');
$th = htmlspecialchars($th, \ENT_NOQUOTES, 'UTF-8');
if ($escapeTd) {
$td = '<pre>' . htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8') . '</pre>';
$td = '<pre>' . htmlspecialchars($td, \ENT_NOQUOTES, 'UTF-8') . '</pre>';
}

return "<tr style=\"padding: 4px;spacing: 0;text-align: left;\">\n<th style=\"background:" . $this->logLevels[$level] . "\" width=\"100px\">$th:</th>\n<td style=\"padding: 4px;spacing: 0;text-align: left;background: #eeeeee\">" . $td . "</td>\n</tr>";
Expand Down
4 changes: 2 additions & 2 deletions src/SiteConfig/ConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function create()
public function buildFromUrl($url, $addToCache = true)
{
// extract host name
$host = parse_url($url, PHP_URL_HOST);
$host = parse_url($url, \PHP_URL_HOST);

return $this->buildForHost((string) $host, $addToCache);
}
Expand Down Expand Up @@ -247,7 +247,7 @@ public function loadSiteConfig($host, $exactHostMatch = false)
if (isset($this->configFiles[$host . '.txt'])) {
$this->logger->info('... found site config {host}', ['host' => $host . '.txt']);

$configLines = file($this->configFiles[$host . '.txt'], FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$configLines = file($this->configFiles[$host . '.txt'], \FILE_IGNORE_NEW_LINES | \FILE_SKIP_EMPTY_LINES);
// no lines ? we don't found config then
if (empty($configLines) || !\is_array($configLines)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/Extractor/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function testTimeout(): void
null,
null,
[
CURLOPT_TIMEOUT => 2,
\CURLOPT_TIMEOUT => 2,
]
);
} else {
Expand Down

0 comments on commit f057b12

Please sign in to comment.