diff --git a/src/Foundation/Concerns/BaseFoundationCollection.php b/src/Foundation/Concerns/BaseFoundationCollection.php index c11dbe9c..0b97b626 100644 --- a/src/Foundation/Concerns/BaseFoundationCollection.php +++ b/src/Foundation/Concerns/BaseFoundationCollection.php @@ -13,6 +13,11 @@ /** * Base class for the kernel auto-discovery collections. * + * @template TKey of array-key + * @template TValue + * + * @extends \Illuminate\Support\Collection + * * These collections are the heart of the discovery process. * * They are responsible for discovering the files, pages, and routes, diff --git a/src/Foundation/Concerns/HandlesFoundationCollections.php b/src/Foundation/Concerns/HandlesFoundationCollections.php index 3192ee0c..58b137ed 100644 --- a/src/Foundation/Concerns/HandlesFoundationCollections.php +++ b/src/Foundation/Concerns/HandlesFoundationCollections.php @@ -15,7 +15,6 @@ */ trait HandlesFoundationCollections { - /** @return \Hyde\Foundation\Kernel\FileCollection */ public function files(): FileCollection { $this->needsToBeBooted(); @@ -23,7 +22,6 @@ public function files(): FileCollection return $this->files; } - /** @return \Hyde\Foundation\Kernel\PageCollection */ public function pages(): PageCollection { $this->needsToBeBooted(); @@ -31,7 +29,6 @@ public function pages(): PageCollection return $this->pages; } - /** @return \Hyde\Foundation\Kernel\RouteCollection */ public function routes(): RouteCollection { $this->needsToBeBooted(); diff --git a/src/Foundation/Facades/Files.php b/src/Foundation/Facades/Files.php index 79d2acdc..65e78467 100644 --- a/src/Foundation/Facades/Files.php +++ b/src/Foundation/Facades/Files.php @@ -13,7 +13,6 @@ */ class Files extends Facade { - /** @return \Hyde\Foundation\Kernel\FileCollection */ public static function getFacadeRoot(): FileCollection { return HydeKernel::getInstance()->files(); diff --git a/src/Foundation/Facades/Pages.php b/src/Foundation/Facades/Pages.php index a06577b7..42b37c66 100644 --- a/src/Foundation/Facades/Pages.php +++ b/src/Foundation/Facades/Pages.php @@ -13,7 +13,6 @@ */ class Pages extends Facade { - /** @return \Hyde\Foundation\Kernel\PageCollection */ public static function getFacadeRoot(): PageCollection { return HydeKernel::getInstance()->pages(); diff --git a/src/Foundation/Facades/Routes.php b/src/Foundation/Facades/Routes.php index 1a211480..f82acc26 100644 --- a/src/Foundation/Facades/Routes.php +++ b/src/Foundation/Facades/Routes.php @@ -19,7 +19,6 @@ */ class Routes extends Facade { - /** @return \Hyde\Foundation\Kernel\RouteCollection */ public static function getFacadeRoot(): RouteCollection { return HydeKernel::getInstance()->routes(); @@ -41,7 +40,6 @@ public static function getOrFail(string $routeKey): Route return static::getFacadeRoot()->getRoute($routeKey); } - /** @return \Hyde\Foundation\Kernel\RouteCollection<\Hyde\Support\Models\Route> */ public static function all(): RouteCollection { return static::getFacadeRoot()->getRoutes(); diff --git a/src/Foundation/Internal/LoadYamlConfiguration.php b/src/Foundation/Internal/LoadYamlConfiguration.php index d5d75acc..aae50195 100644 --- a/src/Foundation/Internal/LoadYamlConfiguration.php +++ b/src/Foundation/Internal/LoadYamlConfiguration.php @@ -26,6 +26,8 @@ class LoadYamlConfiguration { protected YamlConfigurationRepository $yaml; + + /** @var array> */ protected array $config; public function bootstrap(Application $app): void @@ -33,7 +35,10 @@ public function bootstrap(Application $app): void $this->yaml = $app->make(YamlConfigurationRepository::class); if ($this->yaml->hasYamlConfigFile()) { - tap($app->make('config'), function (Repository $config): void { + /** @var Repository $config */ + $config = $app->make('config'); + + tap($config, function (Repository $config): void { $this->config = $config->all(); $this->mergeParsedConfiguration(); })->set($this->config); diff --git a/src/Foundation/Kernel/FileCollection.php b/src/Foundation/Kernel/FileCollection.php index 063d04b0..9013be74 100644 --- a/src/Foundation/Kernel/FileCollection.php +++ b/src/Foundation/Kernel/FileCollection.php @@ -18,7 +18,7 @@ * * @template T of \Hyde\Support\Filesystem\SourceFile * - * @template-extends \Hyde\Foundation\Concerns\BaseFoundationCollection + * @extends \Hyde\Foundation\Concerns\BaseFoundationCollection * * @property array $items The files in the collection. * @@ -71,10 +71,7 @@ public function getFile(string $path): SourceFile return $this->get($path) ?? throw new FileNotFoundException($path); } - /** - * @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass - * @return \Hyde\Foundation\Kernel\FileCollection - */ + /** @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass */ public function getFiles(?string $pageClass = null): FileCollection { return $pageClass ? $this->filter(function (SourceFile $file) use ($pageClass): bool { diff --git a/src/Foundation/Kernel/PageCollection.php b/src/Foundation/Kernel/PageCollection.php index 4739a177..4cc4d85e 100644 --- a/src/Foundation/Kernel/PageCollection.php +++ b/src/Foundation/Kernel/PageCollection.php @@ -14,7 +14,7 @@ * * @template T of \Hyde\Pages\Concerns\HydePage * - * @template-extends \Hyde\Foundation\Concerns\BaseFoundationCollection + * @extends \Hyde\Foundation\Concerns\BaseFoundationCollection * * @property array $items The pages in the collection. * @@ -59,10 +59,7 @@ public function getPage(string $sourcePath): HydePage return $this->get($sourcePath) ?? throw new FileNotFoundException($sourcePath); } - /** - * @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass - * @return \Hyde\Foundation\Kernel\PageCollection - */ + /** @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass */ public function getPages(?string $pageClass = null): PageCollection { return $pageClass ? $this->filter(function (HydePage $page) use ($pageClass): bool { diff --git a/src/Foundation/Kernel/RouteCollection.php b/src/Foundation/Kernel/RouteCollection.php index a93b8eab..fe71995a 100644 --- a/src/Foundation/Kernel/RouteCollection.php +++ b/src/Foundation/Kernel/RouteCollection.php @@ -15,7 +15,7 @@ * * @template T of \Hyde\Support\Models\Route * - * @template-extends \Hyde\Foundation\Concerns\BaseFoundationCollection + * @extends \Hyde\Foundation\Concerns\BaseFoundationCollection * * @property array $items The routes in the collection. * @@ -53,10 +53,7 @@ public function getRoute(string $routeKey): Route return $this->get($routeKey) ?? throw new RouteNotFoundException($routeKey); } - /** - * @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass - * @return \Hyde\Foundation\Kernel\RouteCollection - */ + /** @param class-string<\Hyde\Pages\Concerns\HydePage>|null $pageClass */ public function getRoutes(?string $pageClass = null): RouteCollection { return $pageClass ? $this->filter(function (Route $route) use ($pageClass): bool { diff --git a/src/Framework/Features/Metadata/MetadataBag.php b/src/Framework/Features/Metadata/MetadataBag.php index ff8a036d..51e55491 100644 --- a/src/Framework/Features/Metadata/MetadataBag.php +++ b/src/Framework/Features/Metadata/MetadataBag.php @@ -54,26 +54,19 @@ public function get(): array public function add(MetadataElementContract|string $element): static { - return match (true) { - $element instanceof LinkElement => $this->addElement('links', $element), - $element instanceof MetadataElement => $this->addElement('metadata', $element), - $element instanceof OpenGraphElement => $this->addElement('properties', $element), + match (true) { + $element instanceof LinkElement => $this->links[$element->uniqueKey()] = $element, + $element instanceof MetadataElement => $this->metadata[$element->uniqueKey()] = $element, + $element instanceof OpenGraphElement => $this->properties[$element->uniqueKey()] = $element, default => $this->addGenericElement((string) $element), }; - } - - protected function addElement(string $type, MetadataElementContract $element): static - { - $this->{$type}[$element->uniqueKey()] = $element; return $this; } - protected function addGenericElement(string $element): static + protected function addGenericElement(string $element): void { $this->generics[] = $element; - - return $this; } /** @return array */ diff --git a/src/Hyde.php b/src/Hyde.php index 01167b10..860bd77c 100644 --- a/src/Hyde.php +++ b/src/Hyde.php @@ -13,7 +13,6 @@ use Hyde\Foundation\Kernel\RouteCollection; use Hyde\Pages\Concerns\HydePage; use Hyde\Support\Models\Route; -use Hyde\Support\Filesystem\SourceFile; use Illuminate\Support\Facades\Facade; use Illuminate\Support\HtmlString; use JetBrains\PhpStorm\Pure; @@ -53,9 +52,9 @@ * @method static string getMediaDirectory() * @method static string getMediaOutputDirectory() * @method static Features features() - * @method static FileCollection files() - * @method static PageCollection pages() - * @method static RouteCollection routes() + * @method static FileCollection files() + * @method static PageCollection pages() + * @method static RouteCollection routes() * @method static Route|null currentRoute() * @method static HydeKernel getInstance() * @method static Filesystem filesystem()