Skip to content

Commit c0820ed

Browse files
committed
README.md
1 parent 5849c23 commit c0820ed

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## 23. PHP 静态代码分析包 Larastan
2+
3+
`Larastan` 是对 [phpstan/phpstan](https://github.com/phpstan/phpstan) 的 Laravel 封装,主要是帮你查找代码中的错误,而无需实际的运行代码。它可以捕获所有类的 `bug` 。支持 `Laravel` 优美的魔术
4+
5+
![Larastan Example](https://static.oschina.net/uploads/img/201905/17104813_oSxA.png)
6+
7+
### 安装和使用
8+
9+
#### Requires:
10+
11+
- PHP 7.1.3+
12+
- Laravel 5.6+
13+
14+
你可以通过 `Composer` 来安装 `Larastan` 作为开发依赖到你的 `Laravel` 项目:
15+
16+
```
17+
composer require --dev nunomaduro/larastan
18+
```
19+
20+
在 Laravel 应用中使用
21+
可以使用如下命令来分析代码
22+
23+
```
24+
php artisan code:analyse
25+
```
26+
27+
定制配置
28+
如果你想提供你自己的配置,可以创建 `phpstan.neon` 或者 `phpstan.neon.dist` 文件在你应用的根目录中,如下所示:
29+
30+
```
31+
includes:
32+
- ./vendor/nunomaduro/larastan/extension.neon
33+
parameters:
34+
level: 5
35+
ignoreErrors:
36+
- '#Access to an undefined property App\\Demo\\[a-zA-Z0-9\\_]+::\$[a-zA-Z0-9\\_]+\.#'
37+
- '#Call to an undefined method App\\Http\\Resources\\DemoResource::DemoMethod\(\)\.#'
38+
excludes_analyse:
39+
- /*/*/FileToBeExcluded.php
40+
```
41+
42+
所有可用配置请阅读 [PHPStan documentation](https://github.com/phpstan/phpstan).

0 commit comments

Comments
 (0)