From e740a7be13eb0be7621eff3e89ad7615851beee5 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 19:04:42 +0100 Subject: [PATCH 01/11] Fix PHPDoc comment --- .../framework/src/Framework/Concerns/RegistersFileLocations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Concerns/RegistersFileLocations.php b/packages/framework/src/Framework/Concerns/RegistersFileLocations.php index 8b03f21a0c6..e6b5c5ae0d2 100644 --- a/packages/framework/src/Framework/Concerns/RegistersFileLocations.php +++ b/packages/framework/src/Framework/Concerns/RegistersFileLocations.php @@ -36,7 +36,7 @@ protected function registerSourceDirectories(array $directoryMapping): void } } - /* + /** * Register the optional output directories. * Some HTML pages, like Blade and Markdown pages are stored right in the _site/ directory. * However, some pages, like docs and posts are in subdirectories of the _site/ directory. From c333905a8b2f49da27aad38176bb79ade29f234d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 19:04:56 +0100 Subject: [PATCH 02/11] Remove unnecessary return annotation --- .../framework/src/Framework/Concerns/RegistersFileLocations.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/framework/src/Framework/Concerns/RegistersFileLocations.php b/packages/framework/src/Framework/Concerns/RegistersFileLocations.php index e6b5c5ae0d2..3886eeef7aa 100644 --- a/packages/framework/src/Framework/Concerns/RegistersFileLocations.php +++ b/packages/framework/src/Framework/Concerns/RegistersFileLocations.php @@ -45,7 +45,6 @@ protected function registerSourceDirectories(array $directoryMapping): void * @example registerOutputDirectories([HydePage::class => 'docs']) * * @param array $directoryMapping{class: string, location: string} - * @return void */ protected function registerOutputDirectories(array $directoryMapping): void { From 84e19539bb7425c8f79137a97e736a5f9c100da9 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 19:08:13 +0100 Subject: [PATCH 03/11] Strongly type closure parameters --- .../src/Framework/Features/Metadata/Elements/LinkElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Metadata/Elements/LinkElement.php b/packages/framework/src/Framework/Features/Metadata/Elements/LinkElement.php index 0bffcc69575..e2763627e71 100644 --- a/packages/framework/src/Framework/Features/Metadata/Elements/LinkElement.php +++ b/packages/framework/src/Framework/Features/Metadata/Elements/LinkElement.php @@ -35,7 +35,7 @@ protected function formatOptionalAttributes(): string return ''; } - return sprintf(' %s', collect($this->attr)->map(function ($value, $key): string { + return sprintf(' %s', collect($this->attr)->map(function (string $value, string $key): string { return e($key).'="'.e($value).'"'; })->implode(' ')); } From 03a06bb67fca67175db9b788661b9b2744a3f147 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 19:11:39 +0100 Subject: [PATCH 04/11] Strongly type closure parameters --- .../framework/src/Markdown/Processing/BladeDownProcessor.php | 4 ++-- .../framework/src/Markdown/Processing/ShortcodeProcessor.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/framework/src/Markdown/Processing/BladeDownProcessor.php b/packages/framework/src/Markdown/Processing/BladeDownProcessor.php index 9332e9190fa..85d837745c7 100644 --- a/packages/framework/src/Markdown/Processing/BladeDownProcessor.php +++ b/packages/framework/src/Markdown/Processing/BladeDownProcessor.php @@ -34,7 +34,7 @@ public static function render(string $html, ?array $pageData = []): string public static function preprocess(string $markdown): string { - return implode("\n", array_map(function ($line): string { + return implode("\n", array_map(function (string $line): string { return str_starts_with(strtolower($line), strtolower('[Blade]:')) ? '' : $line; @@ -54,7 +54,7 @@ public function __construct(string $html, ?array $pageData = []) public function run(): static { - $this->output = implode("\n", array_map(function ($line): string { + $this->output = implode("\n", array_map(function (string $line): string { return $this->lineStartsWithDirective($line) ? $this->processLine($line) : $line; diff --git a/packages/framework/src/Markdown/Processing/ShortcodeProcessor.php b/packages/framework/src/Markdown/Processing/ShortcodeProcessor.php index 496cda08f9b..a130b52fe40 100644 --- a/packages/framework/src/Markdown/Processing/ShortcodeProcessor.php +++ b/packages/framework/src/Markdown/Processing/ShortcodeProcessor.php @@ -52,7 +52,7 @@ public function __construct(string $input) public function processInput(): static { - $this->output = implode("\n", array_map(function ($line): string { + $this->output = implode("\n", array_map(function (string $line): string { return $this->expandShortcode($line); }, explode("\n", $this->input))); From 4f7397d247fde8a3922124f7c2706852e87122b1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 19:11:59 +0100 Subject: [PATCH 05/11] Use e function instead of htmlentities --- .../framework/src/Markdown/Processing/BladeDownProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Markdown/Processing/BladeDownProcessor.php b/packages/framework/src/Markdown/Processing/BladeDownProcessor.php index 85d837745c7..4813bd83ba5 100644 --- a/packages/framework/src/Markdown/Processing/BladeDownProcessor.php +++ b/packages/framework/src/Markdown/Processing/BladeDownProcessor.php @@ -36,7 +36,7 @@ public static function preprocess(string $markdown): string { return implode("\n", array_map(function (string $line): string { return str_starts_with(strtolower($line), strtolower('[Blade]:')) - ? '' + ? '' : $line; }, explode("\n", $markdown))); } From a9b4dea301709432ebb669c1a1f82038c45e3b3d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 19:23:07 +0100 Subject: [PATCH 06/11] Strongly type the parameter type --- packages/framework/src/Support/Concerns/Serializable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Support/Concerns/Serializable.php b/packages/framework/src/Support/Concerns/Serializable.php index e7f3a2a12aa..d7ae70c5fa0 100644 --- a/packages/framework/src/Support/Concerns/Serializable.php +++ b/packages/framework/src/Support/Concerns/Serializable.php @@ -22,7 +22,7 @@ public function jsonSerialize(): array } /** @inheritDoc */ - public function toJson($options = 0): string + public function toJson(int $options = 0): string { return json_encode($this->jsonSerialize(), $options); } From cda2e9dd5c172e9b70befe1b76d27efafe2b0afb Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 19:27:02 +0100 Subject: [PATCH 07/11] Document array return type --- packages/framework/src/Framework/Services/DiscoveryService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/src/Framework/Services/DiscoveryService.php b/packages/framework/src/Framework/Services/DiscoveryService.php index 1f654435658..4f4a53ab830 100644 --- a/packages/framework/src/Framework/Services/DiscoveryService.php +++ b/packages/framework/src/Framework/Services/DiscoveryService.php @@ -62,6 +62,7 @@ public static function getDocumentationPageFiles(): array * Supply a model::class constant and get a list of all the existing source file base names. * * @param class-string<\Hyde\Pages\Concerns\HydePage> $model + * @return array * * @throws \Hyde\Framework\Exceptions\UnsupportedPageTypeException * From 1284141f1e0e95ed27801bea7cbbd493daed16cd Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 19:27:31 +0100 Subject: [PATCH 08/11] Remove false return type for method that never returns false --- packages/framework/src/Pages/Concerns/HydePage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Pages/Concerns/HydePage.php b/packages/framework/src/Pages/Concerns/HydePage.php index 2e2d22d14fa..792220eee35 100644 --- a/packages/framework/src/Pages/Concerns/HydePage.php +++ b/packages/framework/src/Pages/Concerns/HydePage.php @@ -104,9 +104,9 @@ public static function parse(string $identifier): HydePage * * Essentially an alias of DiscoveryService::getAbstractPageList(). * - * @return array|false + * @return array */ - public static function files(): array|false + public static function files(): array { return DiscoveryService::getSourceFileListForModel(static::class); } From df3efa68ce64e710b0e9dc27226c5d3bc4231a49 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sat, 21 Jan 2023 20:24:40 +0000 Subject: [PATCH 09/11] Apply fixes from StyleCI --- .../framework/src/Framework/Concerns/RegistersFileLocations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Concerns/RegistersFileLocations.php b/packages/framework/src/Framework/Concerns/RegistersFileLocations.php index 3886eeef7aa..65e3880c438 100644 --- a/packages/framework/src/Framework/Concerns/RegistersFileLocations.php +++ b/packages/framework/src/Framework/Concerns/RegistersFileLocations.php @@ -44,7 +44,7 @@ protected function registerSourceDirectories(array $directoryMapping): void * * @example registerOutputDirectories([HydePage::class => 'docs']) * - * @param array $directoryMapping{class: string, location: string} + * @param array $directoryMapping{class: string, location: string} */ protected function registerOutputDirectories(array $directoryMapping): void { From 3d8b8f929a5727a2178def46e7de5a05cbc94fb4 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 21:27:20 +0100 Subject: [PATCH 10/11] Revert "Strongly type the parameter type" This reverts commit a9b4dea301709432ebb669c1a1f82038c45e3b3d. --- packages/framework/src/Support/Concerns/Serializable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Support/Concerns/Serializable.php b/packages/framework/src/Support/Concerns/Serializable.php index d7ae70c5fa0..e7f3a2a12aa 100644 --- a/packages/framework/src/Support/Concerns/Serializable.php +++ b/packages/framework/src/Support/Concerns/Serializable.php @@ -22,7 +22,7 @@ public function jsonSerialize(): array } /** @inheritDoc */ - public function toJson(int $options = 0): string + public function toJson($options = 0): string { return json_encode($this->jsonSerialize(), $options); } From 592c3fd55f6bf786922ef5f743be597dc2d13651 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Jan 2023 21:28:30 +0100 Subject: [PATCH 11/11] Annotate the parameter type --- packages/framework/src/Support/Concerns/Serializable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Support/Concerns/Serializable.php b/packages/framework/src/Support/Concerns/Serializable.php index e7f3a2a12aa..a0eb88b3d20 100644 --- a/packages/framework/src/Support/Concerns/Serializable.php +++ b/packages/framework/src/Support/Concerns/Serializable.php @@ -21,7 +21,7 @@ public function jsonSerialize(): array return $this->toArray(); } - /** @inheritDoc */ + /** @param int $options */ public function toJson($options = 0): string { return json_encode($this->jsonSerialize(), $options);