Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[Feat] Added support for Laravel attribute setters in Laravel preset #154
This PR adds support for the Laravel set attribute syntax without showing it as an error.
This has been implemented by creating a custom Sniff for setters which replaces the one we used from a package. This new sniff has support for filtering methods based on a regex.
In the Laravel Preset the regex for Laravel attribute setters has been added in as methods which to ignore.
@nunomaduro I like the idea of adding that in to ignore errors in a more broad way. However for it to work good enough to replace this sniff, it has to be specific enough to I can ignore an error based on the naming of a method with a regex.
This PR still disallows setters in models, but just ignores them if they are laravel setters. The Sniff itself just has support for ignoring methods based on a regex.
My opinion would be to first merge this in, as we are going to need custom sniff in some cases and fixing an issue like this is pretty important as a lot of users are using laravel mutators.
Very good job! Thanks for this @olivernybroe. Fell free to perform the next release: https://github.com/nunomaduro/phpinsights/blob/master/RELEASE.md. Please ask me if you have any questions.