diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e3d1b60364c..31e79845f97 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -13,7 +13,7 @@ This serves two purposes: - for new features. ### Changed -- for changes in existing functionality. +- General compatible code quality improvements https://github.com/hydephp/develop/pull/1284 ### Deprecated - for soon-to-be removed features. diff --git a/packages/framework/src/Console/Commands/RouteListCommand.php b/packages/framework/src/Console/Commands/RouteListCommand.php index 1bf461b913a..1fe035c5cda 100644 --- a/packages/framework/src/Console/Commands/RouteListCommand.php +++ b/packages/framework/src/Console/Commands/RouteListCommand.php @@ -6,6 +6,7 @@ use Hyde\Console\Concerns\Command; use Hyde\Hyde; +use Hyde\Pages\InMemoryPage; use Hyde\Support\Models\Route; use Hyde\Support\Models\RouteList; use Hyde\Support\Models\RouteListItem; @@ -47,9 +48,10 @@ protected function stylePageType(string $class): string { $type = parent::stylePageType($class); - /** @experimental */ - if ($type === 'InMemoryPage' && $this->route->getPage()->hasMacro('typeLabel')) { - $type .= sprintf(' (%s)', $this->route->getPage()->typeLabel()); + $page = $this->route->getPage(); + /** @experimental The typeLabel macro is experimental */ + if ($page instanceof InMemoryPage && $page->hasMacro('typeLabel')) { + $type .= sprintf(' (%s)', $page->__call('typeLabel', [])); } return $type; diff --git a/packages/framework/src/Framework/Features/Metadata/MetadataBag.php b/packages/framework/src/Framework/Features/Metadata/MetadataBag.php index 1324e6f5223..29d3ef5090f 100644 --- a/packages/framework/src/Framework/Features/Metadata/MetadataBag.php +++ b/packages/framework/src/Framework/Features/Metadata/MetadataBag.php @@ -65,7 +65,7 @@ public function add(MetadataElementContract|string $element): static protected function addElement(string $type, MetadataElementContract $element): static { - $this->$type[$element->uniqueKey()] = $element; + $this->{$type}[$element->uniqueKey()] = $element; return $this; } diff --git a/packages/framework/src/Framework/Services/MarkdownService.php b/packages/framework/src/Framework/Services/MarkdownService.php index 151f2afe678..db03d7c133e 100644 --- a/packages/framework/src/Framework/Services/MarkdownService.php +++ b/packages/framework/src/Framework/Services/MarkdownService.php @@ -231,7 +231,7 @@ public static function normalizeIndentationLevel(string $string): string foreach ($lines as $lineNumber => $line) { if ($lineNumber >= $startNumber) { - $lines[$lineNumber] = substr($line, $indentationLevel); + $lines[$lineNumber] = substr((string) $line, $indentationLevel); } } @@ -247,9 +247,9 @@ protected static function getNormalizedLines(string $string): array protected static function findLineContentPositions(array $lines): array { foreach ($lines as $lineNumber => $line) { - if (filled(trim($line))) { - $lineLen = strlen($line); - $stripLen = strlen(ltrim($line)); // Length of the line without indentation lets us know its indentation level, and thus how much to strip from each line + if (filled(trim((string) $line))) { + $lineLen = strlen((string) $line); + $stripLen = strlen(ltrim((string) $line)); // Length of the line without indentation lets us know its indentation level, and thus how much to strip from each line if ($lineLen !== $stripLen) { return [$lineNumber, $lineLen - $stripLen]; diff --git a/packages/framework/src/Markdown/Processing/CodeblockFilepathProcessor.php b/packages/framework/src/Markdown/Processing/CodeblockFilepathProcessor.php index ce9b939e2a2..03df5102ee9 100644 --- a/packages/framework/src/Markdown/Processing/CodeblockFilepathProcessor.php +++ b/packages/framework/src/Markdown/Processing/CodeblockFilepathProcessor.php @@ -93,7 +93,7 @@ public static function postprocess(string $html): string protected static function lineMatchesPattern(string $line): bool { foreach (static::$patterns as $pattern) { - if (str_starts_with(strtolower($line), $pattern)) { + if (str_starts_with(strtolower($line), (string) $pattern)) { return true; } }