Download the PHP package nijidigital/phpstan-rules without Composer
On this page you can find all versions of the php package nijidigital/phpstan-rules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nijidigital/phpstan-rules
More information about nijidigital/phpstan-rules
Files in nijidigital/phpstan-rules
Package phpstan-rules
Short Description custom phpstan rules created by dsf-niji
License MIT
Homepage https://github.com/NijiDigital/phpstan-rules
Informations about the package phpstan-rules
nijidigital/phpstan-rules
Custom PhpStan rules made with ❤️ by Niji.
Installation
To use this extension, require it in Composer:
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:Existing rules
NoRelativeDatetime
Prevents usage of relative date/time strings and empty constructors in DateTime and DateTimeImmutable to ensure consistent and testable date handling.
Examples
❌ Invalid:
✅ Valid alternatives:
DoctrineMigrationsSafeMigration
Detects potentially unsafe database migration operations that could break backward compatibility in Doctrine migrations. Operations can be marked as safe using PHPStan's standard @phpstan-ignore comment.
Examples
❌ Invalid:
✅ Valid alternatives:
Configuration
You can customize the behavior of this rule using the parameters section in your phpstan.neon configuration:
Available options:
blacklistedQueries: Array of regex patterns (as keys) with their corresponding error messages (as values). If not specified, uses default patterns for common unsafe operations.
DoctrineMigrationsDescription
Ensures that Doctrine migration classes provide meaningful descriptions by validating the return value of the getDescription() method against a configurable pattern.
Examples
❌ Invalid:
✅ Valid:
Configuration
By default, the rule accepts any non-empty string. You can customize the accepted pattern using the parameters section in your phpstan.neon configuration:
Available options:
acceptedPattern: A regex pattern that migration descriptions must match. Defaults to/.+/im(any non-empty string).