An open API service indexing awesome lists of open source software.

https://github.com/shipmonk-rnd/phpstan-dev

Smooth tests for PHPStan rules: inplace fixture asserts and autofix!
https://github.com/shipmonk-rnd/phpstan-dev

assert fixture inplace phpstan rule static-analysis

Last synced: 3 months ago
JSON representation

Smooth tests for PHPStan rules: inplace fixture asserts and autofix!

Awesome Lists containing this project

README

          

# PHPStan Rules Development Utilities

Inplace fixture asserts and autofix for PHPStan rules.
No more manual line adjustments in tests when new code is added to rule fixtures.

## Installation

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

## Usage

```php

*/
class YourRuleTest extends \ShipMonk\PHPStanDev\RuleTestCase
{
public function testRule(): void
{
$this->analyzeFiles([__DIR__ . '/Data/code.php']);
}
}
```

Create test fixture at `code.php`:

```php
analyzeFiles([...], autofix: true);
}
```

**⚠️ Important**: Remove `autofix: true` before committing - tests will fail if autofix is enabled.

## Contributing
- Check your code by `composer check`
- Autofix coding-style by `composer fix:cs`
- All functionality must be tested

## License

MIT