-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from ronb-lendesk/support-newer-ide-helper
Add support for later versions of IDE helper
- Loading branch information
Showing
9 changed files
with
130 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Psalm\LaravelPlugin\Fakes; | ||
|
||
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Filesystem\Filesystem; | ||
use Psalm\LaravelPlugin\Handlers\Eloquent\Schema\SchemaAggregator; | ||
|
||
class FakeModelsCommand210 extends ModelsCommand | ||
{ | ||
use FakeModelsCommandLogic; | ||
|
||
/** @var SchemaAggregator */ | ||
private $schema; | ||
|
||
public function __construct(Filesystem $files, SchemaAggregator $schema) | ||
{ | ||
parent::__construct($files); | ||
$this->schema = $schema; | ||
} | ||
|
||
/** | ||
* Load the properties from the database table. | ||
* | ||
* @param Model $model | ||
*/ | ||
public function getPropertiesFromTable($model): void | ||
{ | ||
$this->getProperties($model); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Psalm\LaravelPlugin\Fakes; | ||
|
||
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Filesystem\Filesystem; | ||
use Psalm\LaravelPlugin\Handlers\Eloquent\Schema\SchemaAggregator; | ||
|
||
class FakeModelsCommand291 extends ModelsCommand | ||
{ | ||
use FakeModelsCommandLogic; | ||
|
||
/** @var SchemaAggregator */ | ||
private $schema; | ||
|
||
/** @var array<class-string> */ | ||
private $model_classes = []; | ||
|
||
public function __construct(Filesystem $files, SchemaAggregator $schema) | ||
{ | ||
parent::__construct($files); | ||
$this->schema = $schema; | ||
} | ||
|
||
/** | ||
* Load the properties from the database table. | ||
* | ||
* @param Model $model | ||
*/ | ||
protected function getPropertiesFromTable($model): void | ||
{ | ||
$this->getProperties($model); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Psalm\LaravelPlugin\Providers; | ||
|
||
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; | ||
use Composer\InstalledVersions; | ||
use Illuminate\Filesystem\Filesystem; | ||
use Psalm\LaravelPlugin\Fakes\FakeModelsCommand210; | ||
use Psalm\LaravelPlugin\Fakes\FakeModelsCommand291; | ||
use Psalm\LaravelPlugin\Handlers\Eloquent\Schema\SchemaAggregator; | ||
|
||
use function version_compare; | ||
use function assert; | ||
use function is_string; | ||
|
||
class FakeModelsCommandProvider | ||
{ | ||
public static function getCommand(Filesystem $filesystem, SchemaAggregator $schemaAggregator): ModelsCommand | ||
{ | ||
$ideHelperVersion = InstalledVersions::getVersion('barryvdh/laravel-ide-helper'); | ||
|
||
assert(is_string($ideHelperVersion)); | ||
|
||
// ide-helper released a breaking change in a non-major version. As a result, we need to monkey patch our code | ||
if (version_compare($ideHelperVersion, '2.9.2', '<')) { | ||
return new FakeModelsCommand291( | ||
$filesystem, | ||
$schemaAggregator | ||
); | ||
} | ||
|
||
return new FakeModelsCommand210( | ||
$filesystem, | ||
$schemaAggregator | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters