Skip to content

Commit

Permalink
#346 #244 Fix performance issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alies-dev committed Mar 17, 2024
1 parent f7119e6 commit c9b7b70
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/Fakes/FakeModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,14 @@
namespace Psalm\LaravelPlugin\Fakes;

use Composer\Autoload\ClassMapGenerator;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use Psalm\LaravelPlugin\Handlers\Eloquent\Schema\SchemaAggregator;
use ReflectionClass;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use Barryvdh\Reflection\DocBlock;
use Barryvdh\Reflection\DocBlock\Context;
use Barryvdh\Reflection\DocBlock\Tag;
use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
use function get_class;
use function in_array;
use function config;
use function get_class;
use function implode;
use function in_array;

class FakeModelsCommand extends \Barryvdh\LaravelIdeHelper\Console\ModelsCommand
{
Expand All @@ -41,7 +32,20 @@ public function __construct(Filesystem $files, SchemaAggregator $schema)
/** @return array<class-string> */
public function getModels()
{
return $this->model_classes + $this->loadModels();
if ($this->dirs === []) {
throw new \LogicException('Directories to scan models are not set.');
}

$models = [];

// Bypass an issue https://github.com/barryvdh/laravel-ide-helper/issues/1414
foreach ($this->loadModels() as $probably_model_fqcn) {
if (is_string($probably_model_fqcn) && is_a($probably_model_fqcn, Model::class, true)) {
$models[] = $probably_model_fqcn;
}
}

return array_merge($this->model_classes, $models);
}

/**
Expand Down

0 comments on commit c9b7b70

Please sign in to comment.