Making a Check
If you followed the recommended setup, your Checks will be located in ./phecks/Checks
.
To make a new Pheck, run:
This command will generate the base of a Check for you.
Checks must implement the interface Juampi92\Phecks\Domain\Contracts\Check.
This is an example of a Pheck:
Installing the Check
Now add your check to the array checks
in your config file:
Remember to clear the config cache to see your changes. php artisan config:clear
Building the Violation
Violations are what describe the error, so it's important they are as descriptive as possible.
If the name itself can't be clear enough, consider using a ->setUrl($url)
and point that link to an internal Wiki page that documents the error and how to properly fix it.
By default, the violations are assigned to the $file
of the Match. Sources will remember the file (and sometimes line) where the match was found, and it will be included in the report whenever is possible.
You can change the file match by using setFile
on the ViolationBuilder:
In the previous example, the ReflectionMethod class is aware of the file and the start line, so you can rely on it instead of the original file match.
Last updated