-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] Added support for Laravel attribute setters in Laravel preset #154
Conversation
@nunomaduro This PR also adds an example for testing that the Laravel Preset actually ignores attribute setters. It is not a bullet proof way, as it just checks if any errors are present in the |
…to laravel-setter # Conflicts: # src/Domain/Analyser.php
Sounds awesome, going to check this tonight. |
@olivernybroe Thanks for this pull request. Actually I think we can do better on this: A generic feature where on the configuration you can ignore errors globally or on specific classes. What do you think? |
@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. |
…to laravel-setter # Conflicts: # src/Application/Console/Style.php # src/Domain/Analyser.php # src/Domain/Contracts/Repositories/FilesRepository.php # src/Domain/Insights/InsightCollectionFactory.php # src/Domain/Insights/InsightFactory.php # src/Domain/Insights/Sniff.php # src/Domain/Reflection.php
@olivernybroe Alright! Can you just check why tests are not passing? |
…to laravel-setter # Conflicts: # src/Application/Console/Style.php # src/Domain/Analyser.php # src/Domain/Contracts/Repositories/FilesRepository.php # src/Domain/Insights/InsightCollectionFactory.php # src/Domain/Insights/InsightFactory.php # src/Domain/Insights/Sniff.php # src/Domain/Reflection.php
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. |
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.
resolves: #135