This PHPStan extension provides type inference support and rules for CodeIgniter4.
To use this extension, require it in Composer:
composer require --dev codeigniter/phpstan-codeigniter
If you also install phpstan/extension-installer then you're all set!
Manual installation
If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:
includes:
- vendor/codeigniter/phpstan-codeigniter/extension.neonThis extension boots CodeIgniter during analysis so it can read your configuration, services, and database schema. Point PHPStan at a bootstrap file that loads the framework. CodeIgniter's own test bootstrap works out of the box:
parameters:
bootstrapFiles:
- vendor/codeigniter4/framework/system/Test/bootstrap.phpThe Model and Entity type inference additionally materializes your schema by running your migrations against
a temporary SQLite database, so the sqlite3 PHP extension is required (it is declared in this package's
composer.json). The schema is cached under the working directory's tmp folder by default. See the
type inference docs for how to point it at a specific namespace.
Any contributions are welcome.
If you want to see a new rule or extension specific to CodeIgniter, please open a feature request. If you can contribute the code yourself, please open a pull request instead.
Before reporting any bugs, please check if the bug occurs only if using this extension with PHPStan. If the bug is reproducible in PHPStan alone, please open a bug report there instead. Thank you!
PHPStan CodeIgniter is an open source library licensed under MIT.