mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-11-26 20:34:48 +01:00
Merge pull request #4 from psalm/resolve-ide-helper-dep
Resolving an issue in the plugin where it isn't always bootstrapped.
This commit is contained in:
commit
33850a7237
@ -3,7 +3,7 @@
|
||||
totallyTyped="false"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config file:///Users/matthewbrown/Desktop/vimeo/git/laravel-psalm-plugin/vendor/vimeo/psalm/config.xsd"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
|
@ -1,15 +1,14 @@
|
||||
<?php
|
||||
namespace Psalm\LaravelPlugin;
|
||||
|
||||
use Psalm\Plugin\PluginEntryPointInterface;
|
||||
use Psalm\Plugin\RegistrationInterface;
|
||||
use SimpleXMLElement;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\View\Engines\EngineResolver;
|
||||
use Illuminate\View\Engines\PhpEngine;
|
||||
use Illuminate\View\Factory;
|
||||
use Illuminate\View\FileViewFinder;
|
||||
use Orchestra\Testbench\Concerns\CreatesApplication;
|
||||
use Psalm\Plugin\PluginEntryPointInterface;
|
||||
use Psalm\Plugin\RegistrationInterface;
|
||||
use SimpleXMLElement;
|
||||
|
||||
class Plugin implements PluginEntryPointInterface
|
||||
{
|
||||
@ -20,19 +19,29 @@ class Plugin implements PluginEntryPointInterface
|
||||
*/
|
||||
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null)
|
||||
{
|
||||
$ide_helper_provider = \Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class;
|
||||
|
||||
if (file_exists($applicationPath = __DIR__.'/../../../../bootstrap/app.php')) { // Applications
|
||||
$app = require $applicationPath;
|
||||
} elseif (file_exists($applicationPath = getcwd().'/bootstrap/app.php')) { // Local Dev
|
||||
$app = require $applicationPath;
|
||||
} else { // Packages
|
||||
$app = (new self)->createApplication();
|
||||
$app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
||||
$app->register($ide_helper_provider);
|
||||
}
|
||||
|
||||
if ($app instanceof \Illuminate\Contracts\Foundation\Application) {
|
||||
/** @var \Illuminate\Contracts\Http\Kernel $kernel */
|
||||
$kernel = $app->make(\Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
// If we're running a Laravel container, let's see if we need to register the IDE helper if it isn't
|
||||
// already. If we don't do this, the plugin will crash out because the IDE helper doesn't have configs
|
||||
// it bootstraps present in the app container.
|
||||
|
||||
if (!$app->getProvider($ide_helper_provider)) {
|
||||
$app->register($ide_helper_provider);
|
||||
}
|
||||
}
|
||||
|
||||
$fake_filesystem = new FakeFilesystem();
|
||||
|
Loading…
Reference in New Issue
Block a user