Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync 1.4.x and 1.x #383

Open
wants to merge 8 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 39 additions & 30 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
{
"name": "psalm/plugin-laravel",
"description": "A Laravel plugin for Psalm",
"description": "Psalm plugin for Laravel",
"license": "MIT",
"type": "psalm-plugin",
"authors": [
{
"name": "Matthew Brown",
"email": "[email protected]"
}
],
"require": {
"php": "^7.3|^8",
"php": "^7.3 || ^8",
"ext-simplexml": "*",
"barryvdh/laravel-ide-helper": ">=2.8.0 <2.9.2",
"illuminate/container": "^6.0 || ^7.0 || ^8.0",
"illuminate/contracts": "^6.0 || ^7.0 || ^8.0",
"illuminate/database": "^6.0 || ^7.0 || ^8.0",
"illuminate/http": "^6.0 || ^7.0 || ^8.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0",
"vimeo/psalm": "^4.8.1",
"orchestra/testbench": "^3.8 || ^4.0 || ^5.0 || ^6.0",
"barryvdh/laravel-ide-helper": ">=2.8.0 <2.9.2"
"vimeo/psalm": "^4.8.1"
},
"license": "MIT",
"authors": [
{
"name": "Matthew Brown",
"email": "[email protected]"
}
],
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"psalm": {
"pluginClass": "Psalm\\LaravelPlugin\\Plugin"
}
"require-dev": {
"codeception/codeception": "^4.1.6",
"codeception/module-asserts": "^1.0.0",
"codeception/module-phpbrowser": "^1.0.0",
"slevomat/coding-standard": "^6.2",
"squizlabs/php_codesniffer": "*",
"weirdan/codeception-psalm-module": "^0.13.1"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Psalm\\LaravelPlugin\\": "src"
Expand All @@ -39,24 +41,31 @@
"Tests\\Psalm\\LaravelPlugin\\": "tests"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
},
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"psalm": {
"pluginClass": "Psalm\\LaravelPlugin\\Plugin"
}
},
"scripts": {
"analyze": "@psalm",
"check": [
"@analyze",
"@lint",
"@test"
],
"analyze": "psalm",
"lint": "phpcs -n",
"lint": "phpcs --report-full --report-summary --colors -n -s",
"lint-fix": "phpcbf -n",
"psalm": "psalm --find-unused-psalm-suppress --long-progress",
"psalm-set-baseline": "psalm --set-baseline=psalm-baseline.xml",
"test": "codecept run --skip-group skip"
},
"require-dev": {
"codeception/codeception": "^4.1.6",
"codeception/module-phpbrowser": "^1.0.0",
"codeception/module-asserts": "^1.0.0",
"weirdan/codeception-psalm-module": "^0.13.1",
"squizlabs/php_codesniffer": "*",
"slevomat/coding-standard": "^6.2"
},
"minimum-stability": "dev"
}
}
16 changes: 15 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@b07de1fefde4714f29bca0b56c632bd82855fc64">
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<file src="src/Handlers/Eloquent/ModelMethodHandler.php">
<DeprecatedInterface occurrences="1">
<code>ModelMethodHandler</code>
Expand All @@ -15,6 +15,15 @@
<code>RelationsMethodHandler</code>
</DeprecatedInterface>
</file>
<file src="src/Handlers/Eloquent/Schema/SchemaAggregator.php">
<UndefinedPropertyFetch occurrences="5">
<code>$call-&gt;args[0]-&gt;value</code>
<code>$call-&gt;args[0]-&gt;value</code>
<code>$call-&gt;args[0]-&gt;value</code>
<code>$call-&gt;args[1]-&gt;value</code>
<code>$call-&gt;args[1]-&gt;value</code>
</UndefinedPropertyFetch>
</file>
<file src="src/Handlers/Helpers/PathHandler.php">
<DeprecatedInterface occurrences="1">
<code>PathHandler</code>
Expand All @@ -40,4 +49,9 @@
<code>ViewHandler</code>
</DeprecatedInterface>
</file>
<file src="src/Providers/ApplicationProvider.php">
<MissingFile occurrences="1">
<code>require $applicationPath</code>
</MissingFile>
</file>
</files>
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config"
Expand Down
35 changes: 21 additions & 14 deletions src/Fakes/FakeModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@
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;
use function is_string;
use function is_a;
use function array_merge;

class FakeModelsCommand extends \Barryvdh\LaravelIdeHelper\Console\ModelsCommand
{
Expand All @@ -41,7 +35,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
4 changes: 1 addition & 3 deletions src/Util/ContainerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

namespace Psalm\LaravelPlugin\Util;

use Illuminate\Contracts\Container\BindingResolutionException;
use Psalm\LaravelPlugin\Providers\ApplicationProvider;
use Psalm\NodeTypeProvider;
use Psalm\Type\Atomic\TLiteralString;
use Psalm\Type\Atomic\TNamedObject;
use Psalm\Type\Union;
use ReflectionException;
use function array_key_exists;
use function get_class;
use function count;
Expand Down Expand Up @@ -38,7 +36,7 @@ private static function resolveFromApplicationContainer(string $abstract): ?stri
// dynamic analysis to resolve the actual type from the container
try {
$concrete = ApplicationProvider::getApp()->make($abstract);
} catch (BindingResolutionException | ReflectionException $e) {
} catch (\Throwable $e) {
return null;
}

Expand Down
Loading