[Chore] Introduce psalm (#962)

* chore: introduce psalm

* chore: remove dead code

* chore: run psalm workflow

* chore: run psalm in grumphp

* normalize composer.json

* chore: analyse --> analyze

* chore: just remove psalm when running tests instead of worrying about dependency mismatch hell

Co-authored-by: mr-feek <[email protected]>
This commit is contained in:
feek
2020-06-22 20:28:59 +02:00
committed by GitHub
co-authored by mr-feek
parent 3381123e71
commit 545298c44d
9 changed files with 68 additions and 34 deletions
+20
View File
@@ -0,0 +1,20 @@
name: Run Static Analysis
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Analyze
run: composer analyze
+1 -1
View File
@@ -61,7 +61,7 @@ jobs:
- name: Install dependencies
run: |
composer remove phpro/grumphp --no-interaction --no-update --dev
composer remove phpro/grumphp vimeo/psalm --no-interaction --no-update --dev
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --no-progress
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
+3 -1
View File
@@ -35,7 +35,8 @@
"mockery/mockery": "^1.3",
"orchestra/testbench": "^3 || ^4 || ^5",
"phpro/grumphp": "^0.17.1",
"squizlabs/php_codesniffer": "^3.5"
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^3.12"
},
"extra": {
"branch-alias": {
@@ -58,6 +59,7 @@
}
},
"scripts": {
"analyze": "psalm",
"check-style": "phpcs -p --standard=PSR2 src/",
"fix-style": "phpcbf -p --standard=PSR2 src/",
"test": "phpunit"
+9
View File
@@ -16,3 +16,12 @@ parameters:
whitelist_patterns:
- /^src\/.*/
- /^config\/.*/
psalm:
config: psalm.xml
ignore_patterns: []
no_cache: false
report: null
output_format: null
threads: null
triggered_by: ['php']
show_info: false
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.12.0@d46283075d76ed244f7825b378eeb1cee246af73">
<file src="src/Generator.php">
<UndefinedClass occurrences="8">
<code>'\Laravel\Lumen\Application'</code>
<code>\Auth</code>
<code>\DB</code>
<code>\Cache</code>
<code>\Cache</code>
<code>\Queue</code>
<code>\SSH</code>
<code>\Storage</code>
</UndefinedClass>
</file>
</files>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
+2
View File
@@ -21,6 +21,7 @@ use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
class Alias
{
protected $alias;
/** @psalm-var class-string $facade */
protected $facade;
protected $extends = null;
protected $extendsClass = null;
@@ -43,6 +44,7 @@ class Alias
/**
* @param ConfigRepository $config
* @param string $alias
* @psalm-param class-string $facade
* @param string $facade
* @param array $magicMethods
* @param array $interfaces
+2 -2
View File
@@ -43,7 +43,7 @@ class MetaCommand extends Command
/** @var \Illuminate\Contracts\View\Factory */
protected $view;
/** @var \Illuminate\Contracts\Config */
/** @var \Illuminate\Contracts\Config\Repository */
protected $config;
protected $methods = [
@@ -61,7 +61,7 @@ class MetaCommand extends Command
*
* @param \Illuminate\Contracts\Filesystem\Filesystem $files
* @param \Illuminate\Contracts\View\Factory $view
* @param \Illuminate\Contracts\Config $config
* @param \Illuminate\Contracts\Config\Repository $config
*/
public function __construct($files, $view, $config)
{
-30
View File
@@ -283,36 +283,6 @@ class Generator
);
}
/**
* Get the driver/connection/store from the managers
*
* @param $alias
* @return array|bool|string
*/
public function getDriver($alias)
{
try {
if ($alias == "Auth") {
$driver = \Auth::driver();
} elseif ($alias == "DB") {
$driver = \DB::connection();
} elseif ($alias == "Cache") {
$driver = get_class(\Cache::driver());
$store = get_class(\Cache::getStore());
return array($driver, $store);
} elseif ($alias == "Queue") {
$driver = \Queue::connection();
} else {
return false;
}
return get_class($driver);
} catch (\Exception $e) {
$this->error("Could not determine driver/connection for $alias.");
return false;
}
}
/**
* Write a string as error output.
*