Skip to content

Commit

Permalink
Readme: mention static analyses
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 13, 2024
1 parent da6944e commit facb1e5
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Integration of [Doctrine ORM](https://www.doctrine-project.org/projects/orm.html
- [Helper](#helper)
- [DBAL](#dbal)
- [Console](#console)
- [Static analyses](#static-analyses)
- [Troubleshooting](#troubleshooting)
- [Examples](#examples)

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

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

## Static analyses

You can use [PHPStan](https://github.com/phpstan) to analyze your code.

1. Install PHPStan and Doctrine extension.

```bash
composer require --dev phpstan/phpstan phpstan/phpstan-doctrine
```

2. Create ORM loader for PHPStan, e.q. `phpstan-doctrine.php`.

```php
<?php declare(strict_types = 1);

require __DIR__ . '/../vendor/autoload.php';

return App\Bootstrap::boot()
->createContainer()
->getByType(Doctrine\ORM\EntityManagerInterface::class);
```

3. Configure PHPStan in `phpstan.neon`.

```neon
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
parameters:
level: 9
phpVersion: 80200
tmpDir: %currentWorkingDirectory%/var/tmp/phpstan
fileExtensions:
- php
- phpt
paths:
- app
doctrine:
objectManagerLoader: phpstan-doctrine.php
```

4. And run PHPStan.

```bash
vendor/bin/phpstan analyse -c phpstan.neon
```

## Troubleshooting

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).
Expand Down

0 comments on commit facb1e5

Please sign in to comment.