Skip to content

Commit facb1e5

Browse files
committed
Readme: mention static analyses
1 parent da6944e commit facb1e5

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.docs/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Integration of [Doctrine ORM](https://www.doctrine-project.org/projects/orm.html
1515
- [Helper](#helper)
1616
- [DBAL](#dbal)
1717
- [Console](#console)
18+
- [Static analyses](#static-analyses)
1819
- [Troubleshooting](#troubleshooting)
1920
- [Examples](#examples)
2021

@@ -386,6 +387,57 @@ Since this moment when you type `bin/console`, there'll be registered commands f
386387

387388
![Console Commands](https://raw.githubusercontent.com/nettrine/orm/master/.docs/assets/console.png)
388389

390+
## Static analyses
391+
392+
You can use [PHPStan](https://github.com/phpstan) to analyze your code.
393+
394+
1. Install PHPStan and Doctrine extension.
395+
396+
```bash
397+
composer require --dev phpstan/phpstan phpstan/phpstan-doctrine
398+
```
399+
400+
2. Create ORM loader for PHPStan, e.q. `phpstan-doctrine.php`.
401+
402+
```php
403+
<?php declare(strict_types = 1);
404+
405+
require __DIR__ . '/../vendor/autoload.php';
406+
407+
return App\Bootstrap::boot()
408+
->createContainer()
409+
->getByType(Doctrine\ORM\EntityManagerInterface::class);
410+
```
411+
412+
3. Configure PHPStan in `phpstan.neon`.
413+
414+
```neon
415+
includes:
416+
- vendor/phpstan/phpstan-doctrine/extension.neon
417+
418+
parameters:
419+
level: 9
420+
phpVersion: 80200
421+
422+
tmpDir: %currentWorkingDirectory%/var/tmp/phpstan
423+
424+
fileExtensions:
425+
- php
426+
- phpt
427+
428+
paths:
429+
- app
430+
431+
doctrine:
432+
objectManagerLoader: phpstan-doctrine.php
433+
```
434+
435+
4. And run PHPStan.
436+
437+
```bash
438+
vendor/bin/phpstan analyse -c phpstan.neon
439+
```
440+
389441
## Troubleshooting
390442

391443
1. Are you looking for custom types? You can register custom types in DBAL, see [Nettrine DBAL](https://github.com/contributte/doctrine-dbal/blob/master/.docs/README.md#types).

0 commit comments

Comments
 (0)