Skip to content

Commit 526fb64

Browse files
authored
Merge pull request #1284 from hydephp/code-quality-improvements
Code quality improvements
2 parents 1a7d031 + 2e97221 commit 526fb64

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

RELEASE_NOTES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This serves two purposes:
1313
- for new features.
1414

1515
### Changed
16-
- for changes in existing functionality.
16+
- General compatible code quality improvements https://github.com/hydephp/develop/pull/1284
1717

1818
### Deprecated
1919
- for soon-to-be removed features.

packages/framework/src/Console/Commands/RouteListCommand.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Hyde\Console\Concerns\Command;
88
use Hyde\Hyde;
9+
use Hyde\Pages\InMemoryPage;
910
use Hyde\Support\Models\Route;
1011
use Hyde\Support\Models\RouteList;
1112
use Hyde\Support\Models\RouteListItem;
@@ -47,9 +48,10 @@ protected function stylePageType(string $class): string
4748
{
4849
$type = parent::stylePageType($class);
4950

50-
/** @experimental */
51-
if ($type === 'InMemoryPage' && $this->route->getPage()->hasMacro('typeLabel')) {
52-
$type .= sprintf(' <fg=gray>(%s)</>', $this->route->getPage()->typeLabel());
51+
$page = $this->route->getPage();
52+
/** @experimental The typeLabel macro is experimental */
53+
if ($page instanceof InMemoryPage && $page->hasMacro('typeLabel')) {
54+
$type .= sprintf(' <fg=gray>(%s)</>', $page->__call('typeLabel', []));
5355
}
5456

5557
return $type;

packages/framework/src/Framework/Features/Metadata/MetadataBag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function add(MetadataElementContract|string $element): static
6565

6666
protected function addElement(string $type, MetadataElementContract $element): static
6767
{
68-
$this->$type[$element->uniqueKey()] = $element;
68+
$this->{$type}[$element->uniqueKey()] = $element;
6969

7070
return $this;
7171
}

packages/framework/src/Framework/Services/MarkdownService.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public static function normalizeIndentationLevel(string $string): string
231231

232232
foreach ($lines as $lineNumber => $line) {
233233
if ($lineNumber >= $startNumber) {
234-
$lines[$lineNumber] = substr($line, $indentationLevel);
234+
$lines[$lineNumber] = substr((string) $line, $indentationLevel);
235235
}
236236
}
237237

@@ -247,9 +247,9 @@ protected static function getNormalizedLines(string $string): array
247247
protected static function findLineContentPositions(array $lines): array
248248
{
249249
foreach ($lines as $lineNumber => $line) {
250-
if (filled(trim($line))) {
251-
$lineLen = strlen($line);
252-
$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
250+
if (filled(trim((string) $line))) {
251+
$lineLen = strlen((string) $line);
252+
$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
253253

254254
if ($lineLen !== $stripLen) {
255255
return [$lineNumber, $lineLen - $stripLen];

packages/framework/src/Markdown/Processing/CodeblockFilepathProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static function postprocess(string $html): string
9393
protected static function lineMatchesPattern(string $line): bool
9494
{
9595
foreach (static::$patterns as $pattern) {
96-
if (str_starts_with(strtolower($line), $pattern)) {
96+
if (str_starts_with(strtolower($line), (string) $pattern)) {
9797
return true;
9898
}
9999
}

0 commit comments

Comments
 (0)