Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type coverage #850

Merged
merged 18 commits into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function runPreBuildActions(): void
if ($this->option('no-api')) {
$this->info('Disabling external API calls');
$this->newLine();
$config = config('hyde.features');
$config = (array) config('hyde.features');
unset($config[array_search('torchlight', $config)]);
Config::set(['hyde.features' => $config]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract class InvokableAction
{
abstract public function __invoke();

public static function call(...$args): mixed
public static function call(mixed ...$args): mixed
{
return (new static(...$args))->__invoke();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function makeCanonicalUrl(): ?string
return $this->getCanonicalUrl();
}

protected function makeNavigation(): ?NavigationData
protected function makeNavigation(): NavigationData
{
return NavigationData::make((new NavigationDataFactory($this->pageData, $this->title))->toArray());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function makeGroup(): ?string
return $this->searchForGroupInFrontMatter() ?? $this->defaultGroup();
}

protected function makeHidden(): ?bool
protected function makeHidden(): bool
{
return $this->isInstanceOf(MarkdownPost::class)
|| $this->searchForHiddenInFrontMatter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function renderFooter(): HtmlString
return new HtmlString($this->footer);
}

protected function process(): self
protected function process(): static
{
$this->tokenize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public function add(MetadataElementContract|string $element): static
return $this->addGenericElement($element);
}

protected function addElement(string $type, MetadataElementContract $element): MetadataBag
protected function addElement(string $type, MetadataElementContract $element): static
{
($this->$type)[$element->uniqueKey()] = $element;

return $this;
}

protected function addGenericElement(string $element): MetadataBag
protected function addGenericElement(string $element): static
{
$this->generics[] = $element;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

class SessionServiceProvider extends ServiceProvider
{
public function register()
public function register(): void
{
$this->app->singleton(Session::class, Session::class);
}

public function boot()
public function boot(): void
{
//
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ protected function getImageType(MarkdownPost $post): string
return str_ends_with($post->image->getSource(), '.png') ? 'image/png' : 'image/jpeg';
}

/** @return numeric-string */
protected function getImageLength(MarkdownPost $post): string
{
/** @todo We might want to add a build warning if the length is zero */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ protected function getPriority(string $pageClass, string $slug): string
return (string) $priority;
}

/** @return numeric-string */
protected function getFormattedProcessingTime(): string
{
return (string) round((microtime(true) - $this->timeStart) * 1000, 2);
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/src/Framework/HydeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function boot(): void
HydeKernel::getInstance()->readyToBoot();
}

protected function initializeConfiguration()
protected function initializeConfiguration(): void
{
if (YamlConfigurationService::hasFile()) {
YamlConfigurationService::boot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function getPostBuildTasks(): array
);
}

/**
* @deprecated Public usage of this method is deprecated as the method will be made protected.
*/
public static function findTasksInAppDirectory(): array
{
$tasks = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ protected static function getClassNameFromSignature(string $signature): string
return str_replace('>', '', $signature);
}

/**
* @return array (ColoredBlockquotes)[]
*/
/** @return ColoredBlockquotes[] */
public static function get(): array
{
return [
Expand Down
1 change: 1 addition & 0 deletions packages/framework/src/Support/Facades/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
class Render extends Facade
{
/** @return class-string */
protected static function getFacadeAccessor(): string
{
return \Hyde\Support\Models\Render::class;
Expand Down
1 change: 1 addition & 0 deletions packages/framework/src/Support/Models/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function getPage(): HydePage
return $this->page;
}

/** @return class-string<HydePage> */
public function getPageClass(): string
{
return $this->page::class;
Expand Down
20 changes: 11 additions & 9 deletions packages/framework/tests/Feature/MarkdownServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,18 @@ public function test_stripIndentation_method_with_trailing_newline()
$this->assertSame("foo\nbar\nbaz\n", $service->normalizeIndentationLevel($markdown));
}

protected function makeService(): MarkdownService
protected function makeService(): MarkdownServiceTestClass
{
return new class extends MarkdownService
{
public array $features = [];
return new MarkdownServiceTestClass();
}
}

public function __construct(string $markdown = '', ?string $sourceModel = null)
{
parent::__construct($markdown, $sourceModel);
}
};
class MarkdownServiceTestClass extends MarkdownService
{
public array $features = [];

public function __construct(string $markdown = '', ?string $sourceModel = null)
{
parent::__construct($markdown, $sourceModel);
}
}