Skip to content

Commit 4dfe608

Browse files
authored
Merge pull request #1306 from hydephp/improve-type-support
Improve type and IDE support
2 parents 274e82c + 343fb43 commit 4dfe608

File tree

23 files changed

+76
-43
lines changed

23 files changed

+76
-43
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public function handle(): int
3838
$this->info('HydePHP Debug Screen');
3939

4040
$this->newLine();
41-
$this->comment('Git Version: '.app('git.version'));
41+
$this->comment('Git Version: '.(string) app('git.version'));
4242
$this->comment('Hyde Version: '.(InstalledVersions::getPrettyVersion('hyde/hyde') ?: 'unreleased'));
4343
$this->comment('Framework Version: '.(InstalledVersions::getPrettyVersion('hyde/framework') ?: 'unreleased'));
4444

4545
$this->newLine();
46-
$this->comment('App Env: '.app('env'));
46+
$this->comment('App Env: '.(string) app('env'));
4747

4848
$this->newLine();
4949
if ($this->getOutput()->isVerbose()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function stylePageType(string $class): string
4949
$page = $this->route->getPage();
5050
/** @experimental The typeLabel macro is experimental */
5151
if ($page instanceof InMemoryPage && $page->hasMacro('typeLabel')) {
52-
$type .= sprintf(' <fg=gray>(%s)</>', $page->__call('typeLabel', []));
52+
$type .= sprintf(' <fg=gray>(%s)</>', (string) $page->__call('typeLabel', []));
5353
}
5454

5555
return $type;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function handle(): void
3232

3333
// Rename the config group to be more helpful
3434
if (isset(ServiceProvider::$publishGroups['config'])) {
35-
ServiceProvider::$publishGroups['vendor-configs'] = ServiceProvider::$publishGroups['config'];
35+
ServiceProvider::$publishGroups['vendor-configs'] = (array) ServiceProvider::$publishGroups['config'];
3636
unset(ServiceProvider::$publishGroups['config']);
3737
}
3838

packages/framework/src/Foundation/ConsoleKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function bootstrappers(): array
2828
// the default LoadConfiguration bootstrapper class with our implementation.
2929
// We do this by swapping out the LoadConfiguration class with our own.
3030

31-
return array_values(tap(array_combine($bootstrappers, $bootstrappers), function (array &$array): void {
31+
return array_values((array) tap(array_combine($bootstrappers, $bootstrappers), function (array &$array): void {
3232
$array[\LaravelZero\Framework\Bootstrap\LoadConfiguration::class] = \Hyde\Foundation\Internal\LoadConfiguration::class;
3333
}));
3434
}

packages/framework/src/Foundation/Internal/LoadConfiguration.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LoadConfiguration extends BaseLoadConfiguration
2121
/** Get all the configuration files for the application. */
2222
protected function getConfigurationFiles(Application $app): array
2323
{
24-
return tap(parent::getConfigurationFiles($app), function (array &$files) use ($app): void {
24+
return (array) tap(parent::getConfigurationFiles($app), function (array &$files) use ($app): void {
2525
// Inject our custom config file which is stored in `app/config.php`.
2626
$files['app'] = $app->basePath().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'config.php';
2727

@@ -55,7 +55,7 @@ private function mergeConfigurationFile(RepositoryContract $repository, string $
5555
// if they're present, so we'll merge their changes here.
5656

5757
$repository->set($file, array_merge(
58-
require __DIR__."/../../../config/$file.php",
58+
(array) require __DIR__."/../../../config/$file.php",
5959
(array) $repository->get($file, [])
6060
));
6161
}
@@ -72,12 +72,13 @@ private static function providePharSupportIfNeeded(array &$files): void
7272
// If we're running in a Phar and no project config directory exists,
7373
// we need to adjust the path to use the bundled static Phar config file.
7474

75+
/** @var array{app: string} $files */
7576
if (Phar::running() && (! is_dir($files['app']))) {
7677
$files['app'] = dirname(__DIR__, 6).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
7778
}
7879
}
7980

80-
private function loadRuntimeConfiguration(Application $app, RepositoryContract $repository)
81+
private function loadRuntimeConfiguration(Application $app, RepositoryContract $repository): void
8182
{
8283
if ($app->runningInConsole() && isset($_SERVER['argv'])) {
8384
// Check if the `--pretty-urls` CLI argument is set, and if so, set the config value accordingly.

packages/framework/src/Foundation/Kernel/FileCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*
2323
* @property array<string, SourceFile> $items The files in the collection.
2424
*
25+
* @method SourceFile|null get(string $key, SourceFile $default = null)
26+
*
2527
* This class is stored as a singleton in the HydeKernel.
2628
* You would commonly access it via the facade or Hyde helper:
2729
*

packages/framework/src/Foundation/Kernel/PageCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
* @property array<string, HydePage> $items The pages in the collection.
2020
*
21+
* @method HydePage|null get(string $key, HydePage $default = null)
22+
*
2123
* This class is stored as a singleton in the HydeKernel.
2224
* You would commonly access it via the facade or Hyde helper:
2325
*

packages/framework/src/Foundation/Kernel/RouteCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
* @property array<string, Route> $items The routes in the collection.
2020
*
21+
* @method Route|null get(string $key, Route $default = null)
22+
*
2123
* This class is stored as a singleton in the HydeKernel.
2224
* You would commonly access it via the facade or Hyde helper:
2325
*

packages/framework/src/Framework/Actions/MarkdownFileParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function __construct(string $path)
4444
$document = YamlFrontMatter::markdownCompatibleParse($stream);
4545

4646
if ($document->matter()) {
47-
$this->matter = $document->matter();
47+
$this->matter = (array) $document->matter();
4848
}
4949

5050
if ($document->body()) {

packages/framework/src/Framework/Concerns/Internal/ForwardsIlluminateFilesystem.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ protected static function getParameterNames(string $name): array
8585
);
8686
}
8787

88+
/** @param string[] $parameterNames */
8889
protected static function qualifyArguments(array $parameterNames, array $arguments): Collection
8990
{
9091
return collect($arguments)->mapWithKeys(function (string|array|int|bool $argumentValue, int|string $key) use ($parameterNames): string|array|int|bool {

0 commit comments

Comments
 (0)