diff --git a/rector.php b/rector.php index 8e111bb..cb14d8a 100644 --- a/rector.php +++ b/rector.php @@ -9,6 +9,6 @@ __DIR__ . '/src', __DIR__ . '/tests', ]) - ->withPhpSets(php80: true) + ->withPhpSets(php81: true) ->withImportNames(importShortClasses: false) ->withTypeCoverageLevel(0); diff --git a/src/Analysis/Analysis.php b/src/Analysis/Analysis.php index e4c5df8..c34f30d 100644 --- a/src/Analysis/Analysis.php +++ b/src/Analysis/Analysis.php @@ -72,7 +72,7 @@ public function getContent() $parser = $this->getRenderedHtmlDomParser(); $output = []; foreach ($parser->find('p,h1,h2,h3,h4,h5') as $item) { - $output[] = strip_tags(html_entity_decode($item->innertext())); + $output[] = strip_tags(html_entity_decode((string) $item->innertext())); } $output = array_filter($output); diff --git a/src/Builders/FacebookMetaGenerator.php b/src/Builders/FacebookMetaGenerator.php index 33af790..5886495 100644 --- a/src/Builders/FacebookMetaGenerator.php +++ b/src/Builders/FacebookMetaGenerator.php @@ -105,11 +105,11 @@ public function process() $tags = []; if ($this->getTitle()) { - $tags[] = sprintf('', htmlentities($this->getTitle())); + $tags[] = sprintf('', htmlentities((string) $this->getTitle())); } if ($this->getDescription()) { - $tags[] = sprintf('', htmlentities($this->getDescription())); + $tags[] = sprintf('', htmlentities((string) $this->getDescription())); } if ($this->getType()) { @@ -174,7 +174,7 @@ public function setImageHeight($height) */ public function setImageUrl(mixed $imageUrl) { - if ($imageUrl && (str_starts_with($imageUrl, '/') || !str_starts_with($imageUrl, 'http'))) { + if ($imageUrl && (str_starts_with((string) $imageUrl, '/') || !str_starts_with((string) $imageUrl, 'http'))) { throw new \InvalidArgumentException( 'A relative or invalid URL was detected; you must provide the full absolute URL' ); @@ -228,7 +228,7 @@ public function setType(mixed $type) */ public function setUrl(mixed $url) { - if ($url && (str_starts_with($url, '/') || !str_starts_with($url, 'http'))) { + if ($url && (str_starts_with((string) $url, '/') || !str_starts_with((string) $url, 'http'))) { throw new \InvalidArgumentException( 'A relative URL was detected; you must provide the full absolute URL instead' ); diff --git a/src/Builders/TwitterMetaGenerator.php b/src/Builders/TwitterMetaGenerator.php index ac12865..ee07a8e 100644 --- a/src/Builders/TwitterMetaGenerator.php +++ b/src/Builders/TwitterMetaGenerator.php @@ -95,11 +95,11 @@ public function process() $tags[] = ''; if ($this->getTitle()) { - $tags[] = sprintf('', htmlentities($this->getTitle())); + $tags[] = sprintf('', htmlentities((string) $this->getTitle())); } if ($this->getDescription()) { - $tags[] = sprintf('', htmlentities($this->getDescription())); + $tags[] = sprintf('', htmlentities((string) $this->getDescription())); } if ($this->getImageUrl()) { @@ -143,7 +143,7 @@ public function setDescription(mixed $description) */ public function setImageUrl(mixed $imageUrl) { - if ($imageUrl && (str_starts_with($imageUrl, '/') || !str_starts_with($imageUrl, 'http'))) { + if ($imageUrl && (str_starts_with((string) $imageUrl, '/') || !str_starts_with((string) $imageUrl, 'http'))) { throw new \InvalidArgumentException( 'A relative or invalid URL was detected, your must provide the full absolute URL' ); diff --git a/src/Extensions/PageSeoExtension.php b/src/Extensions/PageSeoExtension.php index 4c10d89..5b030cc 100644 --- a/src/Extensions/PageSeoExtension.php +++ b/src/Extensions/PageSeoExtension.php @@ -80,7 +80,7 @@ class PageSeoExtension extends DataExtension */ public function MetaTags(&$tags) { - $tags = explode(PHP_EOL, $tags); + $tags = explode(PHP_EOL, (string) $tags); $tags = array_merge( $tags, Seo::getCanonicalUrlLink($this->getOwner()), diff --git a/src/Forms/GoogleSearchPreview.php b/src/Forms/GoogleSearchPreview.php index 2a9f605..60133be 100644 --- a/src/Forms/GoogleSearchPreview.php +++ b/src/Forms/GoogleSearchPreview.php @@ -92,10 +92,10 @@ public function limitDescriptionLength($text) { public function highlight($haystack, $needle) { if (!$needle) { - return strip_tags($haystack); + return strip_tags((string) $haystack); } - return preg_replace('/\b(' . $needle . ')\b/i', '$0', strip_tags($haystack)); + return preg_replace('/\b(' . $needle . ')\b/i', '$0', strip_tags((string) $haystack)); } /** diff --git a/src/Seo.php b/src/Seo.php index 825d8ff..bcfb654 100644 --- a/src/Seo.php +++ b/src/Seo.php @@ -144,7 +144,7 @@ public static function getPixels() $ours = array_keys(SiteConfigSettingsExtension::config()->get('db')); $db = SiteConfig::config()->get('db'); foreach ($db as $k => $v) { - if (strstr($k, 'Pixel') && in_array($k, $ours)) { + if (strstr((string) $k, 'Pixel') && in_array($k, $ours)) { if (is_null($siteConfig->{$k})) { continue; }