eliashaeussler / phpstan-config
My personal configuration for PHPStan
Installs: 260 994
Dependents: 13
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 4
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- phpstan/phpstan: ^1.9
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-strict-rules: ^1.4
Requires (Dev)
- armin/editorconfig-cli: ^1.8 || ^2.0
- eliashaeussler/php-cs-fixer-config: ^2.0
- eliashaeussler/rector-config: ^3.0
- ergebnis/composer-normalize: ^2.29
- phpunit/phpunit: ^10.1 || ^11.0
This package is auto-updated.
Last update: 2024-11-23 05:28:52 UTC
README
PHPStan config
This package contains basic PHPStan config for use in my personal projects. It is not meant to be used anywhere else. I won't provide support and don't accept pull requests for this repo.
🔥 Installation
composer require eliashaeussler/phpstan-config
⚡ Usage
With extension installer
If you have the phpstan/extension-installer
package installed, there's nothing more to do. The base configuration
is automatically included.
Manual include
Create a phpstan.neon
file and include the
phpstan.neon.dist
file:
# phpstan.neon includes: - %rootDir%/../../eliashaeussler/phpstan-config/phpstan.neon.dist
PHP API
The package provides a PHP configuration API for PHPStan. Add this
to your phpstan.php
file:
# phpstan.php use EliasHaeussler\PHPStanConfig; $config = PHPStanConfig\Config\Config::create(__DIR__)->in( 'src', 'tests', ); // Exclude specific paths $config->not( 'src/lib/*', 'tests/test-application/vendor/*', ); // Configure rule level $config->level(9); $config->maxLevel(); // Enable bleeding edge $config->withBleedingEdge(); // Include baseline file $config->withBaseline(); // Include additional config files $config->with( 'phpstan-custom-rules.neon', 'vendor/foo/baz/optional-phpstan-rules.neon', ); // Define bootstrap files $config->bootstrapFiles( 'tests/build/phpstan-bootstrap.php', ); // Define stub files $config->stubFiles( 'tests/stubs/ThirdPartyClass.stub', 'tests/stubs/AnotherStubFile.stub', ); // Override cache path $config->useCacheDir('var/cache/phpstan'); // Ignore errors $config->ignoreError('Access to constant EXTENSIONS on an unknown class PHPStan\ExtensionInstaller\GeneratedConfig.'); $config->ignoreError('#^Access to constant EXTENSIONS on an unknown class .+\\.$#'); // Configure unmatched error reporting $config->reportUnmatchedIgnoredErrors(false); // Define error formatter $config->formatAs(PHPStanConfig\Enums\ErrorFormat::Json); // Treat phpdoc types as certain $config->treatPhpDocTypesAsCertain(); // Include Doctrine set $doctrineSet = PHPStanConfig\Set\DoctrineSet::create() ->withObjectManagerLoader('tests/object-manager.php') ->withOrmRepositoryClass(\MyApp\Doctrine\BetterEntityRepository::class) ->withOdmRepositoryClass(\MyApp\Doctrine\BetterDocumentRepository::class) $config->withSets($doctrineSet); // Include Symfony set $symfonySet = PHPStanConfig\Set\SymfonySet::create() ->withConsoleApplicationLoader('tests/build/console-application.php') ->withContainerXmlPath('var/cache/test-container.xml') ->disableConstantHassers(); $config->withSets($symfonySet); // Include TYPO3 set $typo3Set = PHPStanConfig\Set\TYPO3Set::create() ->withCustomAspect('myCustomAspect', \FlowdGmbh\MyProject\Context\MyCustomAspect::class) ->withCustomRequestAttribute('myAttribute', \FlowdGmbh\MyProject\Http\MyAttribute::class) ->withCustomSiteAttribute('myArrayAttribute', 'array'); $config->withSets($typo3Set); // Set custom parameters $config->parameters->set('tipsOfTheDay', false); return $config->toArray();
⭐ License
This project is licensed under GNU General Public License 3.0 (or later).