Skip to content

Commit 9fed578

Browse files
authored
Merge pull request #396 from alies-dev/395-no-hint-path-defined-for-ide-helper
Fix "no hint path defined for ide helper" error
2 parents b1a37e9 + 5983d9f commit 9fed578

File tree

9 files changed

+45
-58
lines changed

9 files changed

+45
-58
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"require": {
1414
"php": "^8.1",
1515
"ext-simplexml": "*",
16-
"barryvdh/laravel-ide-helper": "^2.13 || ^3.0",
16+
"barryvdh/laravel-ide-helper": "~3.5.4",
1717
"illuminate/config": "^10.48 || ^11.0",
1818
"illuminate/container": "^10.48 || ^11.0",
1919
"illuminate/contracts": "^10.48 || ^11.0",

psalm-baseline.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="6.6.0@07e9a53713232e924da9acb4a6e47507461cd411">
2+
<files psalm-version="6.8.8@1361cd33008feb3ae2b4a93f1860e14e538ec8c2">
33
<file src="src/Fakes/FakeModelsCommand.php">
44
<ClassMustBeFinal>
55
<code><![CDATA[FakeModelsCommand]]></code>
66
</ClassMustBeFinal>
7-
<TooFewArguments>
8-
<code><![CDATA[parent::__construct($files)]]></code>
9-
<code><![CDATA[parent::__construct($files)]]></code>
10-
</TooFewArguments>
117
</file>
128
<file src="src/Handlers/Auth/AuthConfigAnalyzer.php">
139
<MixedArgument>
@@ -19,6 +15,10 @@
1915
</MixedReturnStatement>
2016
</file>
2117
<file src="src/Handlers/Auth/AuthHandler.php">
18+
<LessSpecificImplementedReturnType>
19+
<code><![CDATA[array]]></code>
20+
<code><![CDATA[array]]></code>
21+
</LessSpecificImplementedReturnType>
2222
<TypeDoesNotContainType>
2323
<code><![CDATA[null]]></code>
2424
</TypeDoesNotContainType>

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<psalm
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns="https://getpsalm.org/schema/config"
5-
xsi:schemaLocation="https://getpsalm.org/schema/config config.xsd"
5+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
66
errorLevel="1"
77
errorBaseline="psalm-baseline.xml"
88
findUnusedBaselineEntry="false"

src/Fakes/FakeModelsCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ class FakeModelsCommand extends ModelsCommand
2121
/** @var list<class-string<\Illuminate\Database\Eloquent\Model>> */
2222
private array $model_classes = [];
2323

24-
public function __construct(Filesystem $files, private SchemaAggregator $schema)
24+
private SchemaAggregator $schema;
25+
26+
/**
27+
* While the setter of a required property is an anti-pattern,
28+
* this is the only way to be less independent of changes in the parent ModelsCommand constructor.
29+
*/
30+
public function setSchemaAggregator(SchemaAggregator $schemaAggregator): void
2531
{
26-
parent::__construct($files);
32+
$this->schema = $schemaAggregator;
2733
}
2834

2935
/** @return list<class-string<\Illuminate\Database\Eloquent\Model>> */

src/Handlers/Auth/AuthHandler.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
namespace Psalm\LaravelPlugin\Handlers\Auth;
66

77
use Psalm\Plugin\EventHandler\Event\MethodReturnTypeProviderEvent;
8+
use Psalm\Plugin\EventHandler\Event\MethodParamsProviderEvent;
89
use Psalm\Plugin\EventHandler\MethodReturnTypeProviderInterface;
10+
use Psalm\Plugin\EventHandler\MethodParamsProviderInterface;
911
use Psalm\Type;
1012

1113
use function in_array;
@@ -28,7 +30,7 @@
2830
* @see \Illuminate\Support\Facades\Auth::setRequest()
2931
* @see \Illuminate\Support\Facades\Auth::forgetUser()
3032
*/
31-
final class AuthHandler implements MethodReturnTypeProviderInterface
33+
final class AuthHandler implements MethodReturnTypeProviderInterface, MethodParamsProviderInterface
3234
{
3335
/** @inheritDoc */
3436
public static function getClassLikeNames(): array
@@ -81,4 +83,18 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event)
8183
default => null,
8284
};
8385
}
86+
87+
#[\Override]
88+
public static function getMethodParams(MethodParamsProviderEvent $event): ?array
89+
{
90+
$method_name_lowercase = $event->getMethodNameLowercase();
91+
92+
if ($method_name_lowercase !== 'user') {
93+
return null;
94+
}
95+
96+
return match ($method_name_lowercase) {
97+
'user' => [], // Explicitly define that user() has no parameters
98+
};
99+
}
84100
}

src/Providers/FacadeStubProvider.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ public static function generateStubFile(): void
3131

3232
$fake_filesystem = new FakeFilesystem();
3333

34+
/**
35+
* @var \Illuminate\View\Factory $viewFactory
36+
*/
37+
$viewFactory = $app->make('view');
38+
3439
$stubs_generator_command = new GeneratorCommand(
3540
$config,
3641
$fake_filesystem,
37-
ViewFactoryProvider::get(),
42+
$viewFactory
3843
);
3944

4045
$stubs_generator_command->setLaravel($app);

src/Providers/ModelStubProvider.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ public static function generateStubFile(): void
4141

4242
$models_generator_command = new FakeModelsCommand(
4343
$fake_filesystem,
44-
$schema_aggregator
44+
$app->make(\Illuminate\Contracts\Config\Repository::class),
45+
$app->make(\Illuminate\View\Factory::class)
4546
);
46-
47+
$models_generator_command->setSchemaAggregator($schema_aggregator);
4748
$models_generator_command->setLaravel($app);
4849

4950
@unlink(self::getStubFileLocation());
@@ -66,9 +67,7 @@ public static function getStubFileLocation(): string
6667
return CacheDirectoryProvider::getCacheLocation() . '/models.stubphp';
6768
}
6869

69-
/**
70-
* @return list<class-string<\Illuminate\Database\Eloquent\Model>>
71-
*/
70+
/** @return list<class-string<\Illuminate\Database\Eloquent\Model>> */
7271
public static function getModelClasses(): array
7372
{
7473
return self::$model_classes;

src/Providers/ViewFactoryProvider.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

stubs/common/Database/Migrations/Migrator.stubphp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ class Migrator
77
/**
88
* Execute the given callback using the given connection as the default connection.
99
*
10-
* @template TCalbackReturn
10+
* @template TCallbackReturn
1111
* @param string $name
12-
* @param callable(): TCalbackReturn $callback
13-
* @return TCalbackReturn
12+
* @param callable(): TCallbackReturn $callback
13+
* @return TCallbackReturn
1414
*/
1515
public function usingConnection($name, callable $callback) {}
1616
}

0 commit comments

Comments
 (0)