File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,18 @@ Using [vim-plug](https://github.com/junegunn/vim-plug):
26
26
27
27
You can configure the level PHPStan uses. By default the level is 2.
28
28
29
- ` let g:phpstan_analyse_level = 4 ` in your ` .vimrc ` file to change the level to fit your needs.
29
+ ```
30
+ let g:phpstan_analyse_level = 4
31
+ ```
32
+
33
+ By default the plugin will look for PHPStan in ` ./vendor/bin/phpstan ` , then
34
+ ` ./bin/phpstan ` and fallback to the global ` phpstan ` global executable if it exists.
35
+
36
+ You can override the path with
37
+
38
+ ```
39
+ let g:phpstan_path = '/path//to/phpstan'
40
+ ```
30
41
31
42
# Assumptions
32
43
Original file line number Diff line number Diff line change 1
1
function ! phpstan#PHPStanAnalyse (... )
2
2
let paths = join (a: 000 , ' \ ' )
3
- let cmd = ' ./vendor/bin/phpstan analyse --errorFormat=raw --no-progress -l' . g: phpstan_analyse_level . ' ' . paths
3
+
4
+ let phpstan_path = phpstan#_resolvePhpstanPath ()
5
+
6
+ let cmd = phpstan_path . ' analyse --errorFormat=raw --no-progress -l' . g: phpstan_analyse_level . ' ' . paths
4
7
let result = system (cmd)
5
8
6
9
let list = []
@@ -12,3 +15,18 @@ function! phpstan#PHPStanAnalyse(...)
12
15
call setqflist (list )
13
16
execute ' :cwindow'
14
17
endfun
18
+
19
+ function ! phpstan#_resolvePhpstanPath ()
20
+ echo g: phpstan_paths
21
+ for phpstan_path in g: phpstan_paths
22
+ if filereadable (phpstan_path)
23
+ return phpstan_path
24
+ endif
25
+ endfor
26
+
27
+ if ! executable (' phpstan' )
28
+ throw ' PHPStan doesn' t seem to be globally installed or detected locally'
29
+ endif
30
+
31
+ return ' phpstan'
32
+ endfun
Original file line number Diff line number Diff line change @@ -2,8 +2,7 @@ if exists('g:phpstan_plugin_loaded') || &cp
2
2
finish
3
3
endif
4
4
let g: phpstan_plugin_loaded = 1
5
-
6
- let g: phpstan_plugin_path = expand (' <sfile>:p:h' )
5
+ let phpstan_paths = [ ' ./vendor/bin/phpstan' , ' ./bin/phpstan' ]
7
6
8
7
if ! exists (' g:phpstan_analyse_level' )
9
8
let g: phpstan_analyse_level = 2
You can’t perform that action at this time.
0 commit comments