Skip to content

Commit

Permalink
Apply rector to php 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Condo committed Aug 21, 2024
1 parent 69834f7 commit 96e00a6
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withPhpSets(php80: true)
->withPhpSets(php81: true)
->withImportNames(importShortClasses: false)
->withTypeCoverageLevel(0);
2 changes: 1 addition & 1 deletion src/Analysis/Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/Builders/FacebookMetaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ public function process()
$tags = [];

if ($this->getTitle()) {
$tags[] = sprintf('<meta property="og:title" content="%s"/>', htmlentities($this->getTitle()));
$tags[] = sprintf('<meta property="og:title" content="%s"/>', htmlentities((string) $this->getTitle()));
}

if ($this->getDescription()) {
$tags[] = sprintf('<meta property="og:description" content="%s"/>', htmlentities($this->getDescription()));
$tags[] = sprintf('<meta property="og:description" content="%s"/>', htmlentities((string) $this->getDescription()));
}

if ($this->getType()) {
Expand Down Expand Up @@ -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'
);
Expand Down Expand Up @@ -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'
);
Expand Down
6 changes: 3 additions & 3 deletions src/Builders/TwitterMetaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public function process()

$tags[] = '<meta name="twitter:card" content="summary"/>';
if ($this->getTitle()) {
$tags[] = sprintf('<meta name="twitter:title" content="%s"/>', htmlentities($this->getTitle()));
$tags[] = sprintf('<meta name="twitter:title" content="%s"/>', htmlentities((string) $this->getTitle()));
}

if ($this->getDescription()) {
$tags[] = sprintf('<meta name="twitter:description" content="%s"/>', htmlentities($this->getDescription()));
$tags[] = sprintf('<meta name="twitter:description" content="%s"/>', htmlentities((string) $this->getDescription()));
}

if ($this->getImageUrl()) {
Expand Down Expand Up @@ -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'
);
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/PageSeoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions src/Forms/GoogleSearchPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '<strong>$0</strong>', strip_tags($haystack));
return preg_replace('/\b(' . $needle . ')\b/i', '<strong>$0</strong>', strip_tags((string) $haystack));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 96e00a6

Please sign in to comment.