From 51ddb3984cea246bbed01388de091d4cd010df2f Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 20 Sep 2025 22:49:21 -0600 Subject: [PATCH] rector casting clarity Signed-off-by: Andy Miller --- system/rector.php | 22 ++++--------------- .../Common/Assets/Traits/AssetUtilsTrait.php | 4 ++-- system/src/Grav/Common/Data/Blueprint.php | 2 +- system/src/Grav/Common/Debugger.php | 3 +-- system/src/Grav/Common/File/CompiledFile.php | 2 +- system/src/Grav/Common/Form/FormFlash.php | 2 +- system/src/Grav/Common/GPM/GPM.php | 4 ++-- .../src/Grav/Common/GPM/Remote/GravCore.php | 2 +- system/src/Grav/Common/GPM/Remote/Package.php | 2 +- system/src/Grav/Common/Grav.php | 2 +- system/src/Grav/Common/Helpers/Truncator.php | 6 ++--- system/src/Grav/Common/Inflector.php | 2 +- system/src/Grav/Common/Page/Page.php | 2 +- system/src/Grav/Common/Page/Pages.php | 4 ++-- system/src/Grav/Common/Page/Types.php | 4 ++-- .../Common/Processors/InitializeProcessor.php | 10 ++++----- system/src/Grav/Common/Twig/Twig.php | 2 +- system/src/Grav/Common/Uri.php | 6 ++--- system/src/Grav/Common/Utils.php | 4 ++-- system/src/Grav/Console/Gpm/IndexCommand.php | 10 ++++----- system/src/Grav/Console/Gpm/InfoCommand.php | 8 +++---- system/src/Grav/Console/Gpm/UpdateCommand.php | 2 +- .../Grav/Console/Plugin/PluginListCommand.php | 2 +- system/src/Grav/Framework/Flex/FlexObject.php | 2 +- .../Flex/Pages/FlexPageCollection.php | 2 +- .../Flex/Pages/Traits/PageLegacyTrait.php | 2 +- system/src/Grav/Framework/Form/FormFlash.php | 2 +- 27 files changed, 50 insertions(+), 65 deletions(-) diff --git a/system/rector.php b/system/rector.php index 2de4caf68..c6263684f 100644 --- a/system/rector.php +++ b/system/rector.php @@ -1,30 +1,16 @@ withSkip([ __DIR__ . '/vendor', ]) ->withPaths([ - __DIR__, + __DIR__ ]) - // 8.x language upgrades — stack these once and move on - ->withSets([ - LevelSetList::UP_TO_PHP_84, // includes 8.2, 8.3, 8.4 language rules in one go [oai_citation:2‡DEV Community](https://dev.to/robertobutti/why-you-should-upgrade-to-php-84-or-at-least-php-8x-1ab0?utm_source=chatgpt.com) - CodeQualitySetList::UP_TO_CODE_QUALITY, // safe, general polish (early returns, etc.) [oai_citation:3‡Rector](https://getrector.com/documentation/levels?utm_source=chatgpt.com) - DeadCodeSetList::DEAD_CODE, // remove unused code - TypeDeclarationSetList::UP_TO_TYPE_DECLARATION, // add missing types where inferable - ]) - - // (Optional) Pin a few “important for 8.4” rules explicitly + ->withPhpSets(php82: true) + ->withPhpVersion(Rector\ValueObject\PhpVersion::PHP_84) ->withRules([ - Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector::class, // `?T` requirement for nullable params in 8.4 [oai_citation:4‡DEV Community](https://dev.to/gromnan/fix-php-84-deprecation-implicitly-marking-parameter-as-nullable-is-deprecated-the-explicit-nullable-type-must-be-used-instead-5gp3?utm_source=chatgpt.com) - Rector\Php84\Rector\FuncCall\AddEscapeArgumentRector::class, // add `escape` to CSV funcs in 8.4 [oai_citation:5‡Rector](https://getrector.com/find-rule?rectorSet=php-php-84&utm_source=chatgpt.com) - Rector\Php84\Rector\MethodCall\NewMethodCallWithoutParenthesesRector::class, // 8.4 new() parentheses tweak [oai_citation:6‡Rector](https://getrector.com/find-rule?rectorSet=php-php-84&utm_source=chatgpt.com) + Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector::class, ]); diff --git a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php index 589f7b35c..38f4ae92a 100644 --- a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php +++ b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php @@ -170,9 +170,9 @@ trait AssetUtilsTrait } if (in_array($key, $no_key, true)) { - $element = htmlentities($value, ENT_QUOTES, 'UTF-8', false); + $element = htmlentities((string) $value, ENT_QUOTES, 'UTF-8', false); } else { - $element = $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; + $element = $key . '="' . htmlentities((string) $value, ENT_QUOTES, 'UTF-8', false) . '"'; } $html .= ' ' . $element; diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index a1bff0fef..dc4d07deb 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -142,7 +142,7 @@ class Blueprint extends BlueprintForm { foreach ($this->dynamic as $key => $data) { // Locate field. - $path = explode('/', $key); + $path = explode('/', (string) $key); $current = &$this->items; foreach ($path as $field) { diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php index f97d6a739..c716ad503 100644 --- a/system/src/Grav/Common/Debugger.php +++ b/system/src/Grav/Common/Debugger.php @@ -623,7 +623,7 @@ class Debugger $table = []; foreach ($timings as $key => $timing) { - $parts = explode('==>', $key); + $parts = explode('==>', (string) $key); $method = $this->parseProfilerCall(array_pop($parts)); $context = $this->parseProfilerCall(array_pop($parts)); @@ -924,7 +924,6 @@ class Debugger if ($object instanceof TemplateWrapper) { $reflection = new ReflectionObject($object); $property = $reflection->getProperty('template'); - $property->setAccessible(true); $object = $property->getValue($object); } diff --git a/system/src/Grav/Common/File/CompiledFile.php b/system/src/Grav/Common/File/CompiledFile.php index fca85af6b..20f1be914 100644 --- a/system/src/Grav/Common/File/CompiledFile.php +++ b/system/src/Grav/Common/File/CompiledFile.php @@ -36,7 +36,7 @@ trait CompiledFile $filename = $this->filename; // If nothing has been loaded, attempt to get pre-compiled version of the file first. if ($var === null && $this->raw === null && $this->content === null) { - $key = md5($filename); + $key = md5((string) $filename); $file = PhpFile::instance(CACHE_DIR . "compiled/files/{$key}{$this->extension}.php"); $modified = $this->modified(); diff --git a/system/src/Grav/Common/Form/FormFlash.php b/system/src/Grav/Common/Form/FormFlash.php index 4f624ea9b..c22f5629e 100644 --- a/system/src/Grav/Common/Form/FormFlash.php +++ b/system/src/Grav/Common/Form/FormFlash.php @@ -28,7 +28,7 @@ class FormFlash extends FrameworkFormFlash { $fields = []; foreach ($this->files as $field => $files) { - if (strpos($field, '/')) { + if (strpos((string) $field, '/')) { continue; } foreach ($files as $file) { diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index bf727d660..346056ce4 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -119,7 +119,7 @@ class GPM extends Iterator if ($type_installed === false) { continue; } - $methodInstallableType = 'getInstalled' . ucfirst($type); + $methodInstallableType = 'getInstalled' . ucfirst((string) $type); $to_install = $this->$methodInstallableType(); $items[$type] = $to_install; $items['total'] += count($to_install); @@ -279,7 +279,7 @@ class GPM extends Iterator if ($type_updatable === false) { continue; } - $methodUpdatableType = 'getUpdatable' . ucfirst($type); + $methodUpdatableType = 'getUpdatable' . ucfirst((string) $type); $to_update = $this->$methodUpdatableType(); $items[$type] = $to_update; $items['total'] += count($to_update); diff --git a/system/src/Grav/Common/GPM/Remote/GravCore.php b/system/src/Grav/Common/GPM/Remote/GravCore.php index 398c12013..4a98c1cdb 100644 --- a/system/src/Grav/Common/GPM/Remote/GravCore.php +++ b/system/src/Grav/Common/GPM/Remote/GravCore.php @@ -82,7 +82,7 @@ class GravCore extends AbstractPackageCollection $diffLog = []; foreach ((array)$this->data['changelog'] as $version => $changelog) { - preg_match("/[\w\-\.]+/", $version, $cleanVersion); + preg_match("/[\w\-\.]+/", (string) $version, $cleanVersion); if (!$cleanVersion || version_compare($diff, $cleanVersion[0], '>=')) { continue; diff --git a/system/src/Grav/Common/GPM/Remote/Package.php b/system/src/Grav/Common/GPM/Remote/Package.php index 41db50ea5..cbf930161 100644 --- a/system/src/Grav/Common/GPM/Remote/Package.php +++ b/system/src/Grav/Common/GPM/Remote/Package.php @@ -52,7 +52,7 @@ class Package extends BasePackage implements \JsonSerializable $diffLog = []; foreach ((array)$this->data['changelog'] as $version => $changelog) { - preg_match("/[\w\-.]+/", $version, $cleanVersion); + preg_match("/[\w\-.]+/", (string) $version, $cleanVersion); if (!$cleanVersion || version_compare($diff, $cleanVersion[0], '>=')) { continue; diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index e0c0fd376..3aae05186 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -505,7 +505,7 @@ class Grav extends Container header("HTTP/{$response->getProtocolVersion()} {$response->getStatusCode()} {$response->getReasonPhrase()}"); foreach ($response->getHeaders() as $key => $values) { // Skip internal Grav headers. - if (str_starts_with($key, 'Grav-Internal-')) { + if (str_starts_with((string) $key, 'Grav-Internal-')) { continue; } foreach ($values as $i => $value) { diff --git a/system/src/Grav/Common/Helpers/Truncator.php b/system/src/Grav/Common/Helpers/Truncator.php index 061fdae04..0d235754b 100644 --- a/system/src/Grav/Common/Helpers/Truncator.php +++ b/system/src/Grav/Common/Helpers/Truncator.php @@ -60,7 +60,7 @@ class Truncator $words = $currentWordPosition[2]; $curNode->nodeValue = substr( - $curNode->nodeValue, + (string) $curNode->nodeValue, 0, $words[$offset][1] + strlen((string) $words[$offset][0]) ); @@ -110,7 +110,7 @@ class Truncator // If we have exceeded the limit, we want to delete the remainder of this document. if ($letters->key() >= $limit) { $currentText = $letters->currentTextPosition(); - $currentText[0]->nodeValue = mb_substr($currentText[0]->nodeValue, 0, $currentText[1] + 1); + $currentText[0]->nodeValue = mb_substr((string) $currentText[0]->nodeValue, 0, $currentText[1] + 1); self::removeProceedingNodes($currentText[0], $container); if (!empty($ellipsis)) { @@ -231,7 +231,7 @@ class Truncator } } else { // Append to current node - $domNode->nodeValue = rtrim($domNode->nodeValue) . $ellipsis; + $domNode->nodeValue = rtrim((string) $domNode->nodeValue) . $ellipsis; } } diff --git a/system/src/Grav/Common/Inflector.php b/system/src/Grav/Common/Inflector.php index dc9f6fd3f..338284936 100644 --- a/system/src/Grav/Common/Inflector.php +++ b/system/src/Grav/Common/Inflector.php @@ -126,7 +126,7 @@ class Inflector if (is_array(static::$irregular)) { foreach (static::$irregular as $_plural => $_singular) { if (preg_match('/(' . $_singular . ')$/i', $word, $arr)) { - return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word); + return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr((string) $_plural, 1), $word); } } } diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index fa95178e1..327b42c61 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1752,7 +1752,7 @@ class Page implements PageInterface // Build an array of meta objects.. foreach ((array)$metadata as $key => $value) { // Lowercase the key - $key = strtolower($key); + $key = strtolower((string) $key); // If this is a property type metadata: "og", "twitter", "facebook" etc // Backward compatibility for nested arrays in metas if (is_array($value)) { diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index a179f8312..e28dc758c 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -1009,7 +1009,7 @@ class Pages } else { // Use reverse order because of B/C (previously matched multiple and returned the last match). foreach (array_reverse($site_routes, true) as $pattern => $replace) { - $pattern = '#^' . str_replace('/', '\/', ltrim($pattern, '^')) . '#'; + $pattern = '#^' . str_replace('/', '\/', ltrim((string) $pattern, '^')) . '#'; try { $found = preg_replace($pattern, (string) $replace, $route); if ($found && $found !== $route) { @@ -1089,7 +1089,7 @@ class Pages $site_redirects = $config->get('site.redirects'); if (is_array($site_redirects)) { foreach ((array)$site_redirects as $pattern => $replace) { - $pattern = ltrim($pattern, '^'); + $pattern = ltrim((string) $pattern, '^'); $pattern = '#^' . str_replace('/', '\/', $pattern) . '#'; try { /** @var string $found */ diff --git a/system/src/Grav/Common/Page/Types.php b/system/src/Grav/Common/Page/Types.php index 2dd737b16..3c573a78e 100644 --- a/system/src/Grav/Common/Page/Types.php +++ b/system/src/Grav/Common/Page/Types.php @@ -125,7 +125,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable { $list = []; foreach ($this->items as $name => $file) { - if (strpos($name, '/')) { + if (strpos((string) $name, '/')) { continue; } $list[$name] = ucfirst(str_replace('_', ' ', $name)); @@ -142,7 +142,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable { $list = []; foreach ($this->items as $name => $file) { - if (!str_starts_with($name, 'modular/')) { + if (!str_starts_with((string) $name, 'modular/')) { continue; } $list[$name] = ucfirst(trim(str_replace('_', ' ', Utils::basename($name)))); diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index caa9e3768..5103adc96 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -205,14 +205,14 @@ class InitializeProcessor extends ProcessorBase $keys = $aliases = []; $env = $_ENV + $_SERVER; foreach ($env as $key => $value) { - if (!str_starts_with($key, $prefix)) { + if (!str_starts_with((string) $key, $prefix)) { continue; } - if (str_starts_with($key, $cPrefix)) { - $key = str_replace('__', '.', substr($key, $cLen)); + if (str_starts_with((string) $key, $cPrefix)) { + $key = str_replace('__', '.', substr((string) $key, $cLen)); $keys[$key] = $value; - } elseif (str_starts_with($key, $aPrefix)) { - $key = substr($key, $aLen); + } elseif (str_starts_with((string) $key, $aPrefix)) { + $key = substr((string) $key, $aLen); $aliases[$key] = $value; } } diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 75b0cf38c..ca286f721 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -154,7 +154,7 @@ class Twig $twig_paths = array_merge($twig_paths, $locator->findResources('theme://'.$prefix.'templates')); - $namespace = trim($prefix, '/'); + $namespace = trim((string) $prefix, '/'); $this->loader->setPaths($twig_paths, $namespace); } diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 9ebea9cd0..533645fa1 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -970,7 +970,7 @@ class Uri implements \Stringable } foreach ($parts as $name => $value) { - $parts[$name] = rawurldecode($value); + $parts[$name] = rawurldecode((string) $value); } if (!isset($parts['path'])) { @@ -1453,8 +1453,8 @@ class Uri implements \Stringable if (!function_exists('getallheaders')) { $headers = []; foreach ($_SERVER as $name => $value) { - if (str_starts_with($name, 'HTTP_')) { - $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; + if (str_starts_with((string) $name, 'HTTP_')) { + $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr((string) $name, 5)))))] = $value; } } return $headers; diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 7b02bd387..ee1e9e0cb 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -1264,7 +1264,7 @@ abstract class Utils { $newArray = []; foreach ($array as $key => $value) { - $dots = explode($separator, $key); + $dots = explode($separator, (string) $key); if (count($dots) > 1) { $last = &$newArray[$dots[0]]; foreach ($dots as $k => $dot) { @@ -1834,7 +1834,7 @@ abstract class Utils } foreach ($parts as $name => $value) { - $parts[$name] = urldecode($value); + $parts[$name] = urldecode((string) $value); } return $parts; diff --git a/system/src/Grav/Console/Gpm/IndexCommand.php b/system/src/Grav/Console/Gpm/IndexCommand.php index 2f8f8dad7..d655ac5f8 100644 --- a/system/src/Grav/Console/Gpm/IndexCommand.php +++ b/system/src/Grav/Console/Gpm/IndexCommand.php @@ -181,7 +181,7 @@ class IndexCommand extends GpmCommand { $list = $this->gpm->{'getUpdatable' . ucfirst($package->package_type)}(); $package = $list[$package->slug] ?? $package; - $type = ucfirst(preg_replace('/s$/', '', $package->package_type)); + $type = ucfirst(preg_replace('/s$/', '', (string) $package->package_type)); $updatable = $this->gpm->{'is' . $type . 'Updatable'}($package->slug); $installed = $this->gpm->{'is' . $type . 'Installed'}($package->slug); $local = $this->gpm->{'getInstalled' . $type}($package->slug); @@ -266,21 +266,21 @@ class IndexCommand extends GpmCommand // Filtering updatables only if ($filter && ($this->options['installed-only'] || $this->options['enabled'] || $this->options['disabled'])) { - $method = ucfirst(preg_replace('/s$/', '', $package->package_type)); + $method = ucfirst(preg_replace('/s$/', '', (string) $package->package_type)); $function = 'is' . $method . 'Installed'; $filter = $this->gpm->{$function}($package->slug); } // Filtering updatables only if ($filter && $this->options['updates-only']) { - $method = ucfirst(preg_replace('/s$/', '', $package->package_type)); + $method = ucfirst(preg_replace('/s$/', '', (string) $package->package_type)); $function = 'is' . $method . 'Updatable'; $filter = $this->gpm->{$function}($package->slug); } // Filtering enabled only if ($filter && $this->options['enabled']) { - $method = ucfirst(preg_replace('/s$/', '', $package->package_type)); + $method = ucfirst(preg_replace('/s$/', '', (string) $package->package_type)); // Check if packaged is enabled. $function = 'is' . $method . 'Enabled'; @@ -289,7 +289,7 @@ class IndexCommand extends GpmCommand // Filtering disabled only if ($filter && $this->options['disabled']) { - $method = ucfirst(preg_replace('/s$/', '', $package->package_type)); + $method = ucfirst(preg_replace('/s$/', '', (string) $package->package_type)); // Check if package is disabled. $function = 'is' . $method . 'Enabled'; diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php index 4aae54eb3..bf440eaec 100644 --- a/system/src/Grav/Console/Gpm/InfoCommand.php +++ b/system/src/Grav/Console/Gpm/InfoCommand.php @@ -83,11 +83,11 @@ class InfoCommand extends GpmCommand return 1; } - $io->writeln("Found package '{$input->getArgument('package')}' under the '" . ucfirst($foundPackage->package_type) . "' section"); + $io->writeln("Found package '{$input->getArgument('package')}' under the '" . ucfirst((string) $foundPackage->package_type) . "' section"); $io->newLine(); $io->writeln("{$foundPackage->name} [{$foundPackage->slug}]"); - $io->writeln(str_repeat('-', strlen($foundPackage->name) + strlen($foundPackage->slug) + 3)); - $io->writeln('' . strip_tags($foundPackage->description_plain) . ''); + $io->writeln(str_repeat('-', strlen($foundPackage->name) + strlen((string) $foundPackage->slug) + 3)); + $io->writeln('' . strip_tags((string) $foundPackage->description_plain) . ''); $io->newLine(); $packageURL = ''; @@ -131,7 +131,7 @@ class InfoCommand extends GpmCommand } } - $type = rtrim($foundPackage->package_type, 's'); + $type = rtrim((string) $foundPackage->package_type, 's'); $updatable = $this->gpm->{'is' . $type . 'Updatable'}($foundPackage->slug); $installed = $this->gpm->{'is' . $type . 'Installed'}($foundPackage->slug); diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php index 6e20c9391..4404e5fb3 100644 --- a/system/src/Grav/Console/Gpm/UpdateCommand.php +++ b/system/src/Grav/Console/Gpm/UpdateCommand.php @@ -191,7 +191,7 @@ class UpdateCommand extends GpmCommand // index str_pad((string)$index++, 2, '0', STR_PAD_LEFT) . '. ' . // name - '' . str_pad($package->name, 15) . ' ' . + '' . str_pad((string) $package->name, 15) . ' ' . // version "[v{$package->version} -> v{$package->available}]" ); diff --git a/system/src/Grav/Console/Plugin/PluginListCommand.php b/system/src/Grav/Console/Plugin/PluginListCommand.php index 705220193..36d8c51f9 100644 --- a/system/src/Grav/Console/Plugin/PluginListCommand.php +++ b/system/src/Grav/Console/Plugin/PluginListCommand.php @@ -61,7 +61,7 @@ class PluginListCommand extends ConsoleCommand $index++; $num = str_pad((string)$index, 2, '0', STR_PAD_LEFT); - $io->writeln(' ' . $num . '. ' . str_pad($name, 15) . " {$bin} {$name} list"); + $io->writeln(' ' . $num . '. ' . str_pad((string) $name, 15) . " {$bin} {$name} list"); } return 0; diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index 3de23178a..be74f2772 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -233,7 +233,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface, \String // Inject back elements which are missing in the filesystem. $data = $this->getBlueprint()->flattenData($current); foreach ($data as $property => $value) { - if (!str_contains($property, '.')) { + if (!str_contains((string) $property, '.')) { $this->defProperty($property, $value); } else { $this->defNestedProperty($property, $value); diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php index fff436b24..c14a41115 100644 --- a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php +++ b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php @@ -195,7 +195,7 @@ class FlexPageCollection extends FlexCollection $last = null; $order = 0; foreach ($keys as $folder => $key) { - preg_match(FlexPageIndex::ORDER_PREFIX_REGEX, $folder, $test); + preg_match(FlexPageIndex::ORDER_PREFIX_REGEX, (string) $folder, $test); $test = $test[0] ?? null; if ($test && $test > $order) { $order = $test; diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php index ab3004a48..dd9ce1513 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php @@ -635,7 +635,7 @@ trait PageLegacyTrait // Build an array of meta objects.. foreach ($metadata as $key => $value) { // Lowercase the key - $key = strtolower($key); + $key = strtolower((string) $key); // If this is a property type metadata: "og", "twitter", "facebook" etc // Backward compatibility for nested arrays in metas diff --git a/system/src/Grav/Framework/Form/FormFlash.php b/system/src/Grav/Framework/Form/FormFlash.php index 1dcff8e8f..bb0e049cb 100644 --- a/system/src/Grav/Framework/Form/FormFlash.php +++ b/system/src/Grav/Framework/Form/FormFlash.php @@ -306,7 +306,7 @@ class FormFlash implements FormFlashInterface { $list = []; foreach ($this->files as $field => $values) { - if (!$includeOriginal && strpos($field, '/')) { + if (!$includeOriginal && strpos((string) $field, '/')) { continue; } $list[$field] = $this->getFilesByField($field);