Skip to content
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

feature: Add IsReadonly Expression #422

Merged
merged 6 commits into from
Jan 24, 2024

Conversation

helyakin
Copy link
Contributor

Hey there !

First of all I wanted to say how cool I find this package. It is very useful so thank you everyone !

I've started coding before reading the guidelines so maybe this will directly be closed.
Hopefully not 🙏🏻

So I'm with my project where I would like to enforce the classes to be readonly in a directory
And since I know using the reflection you directly have access to this value, so I figured it would not be that a big of a deal 🧠

I figured it should look like something like that:

$rules[] = Rule::allClasses()
        ->that(new ResideInOneOfTheseNamespaces('App\Domain\Event'))
        ->should(new IsReadonly())
        ->because('All event have to be readonly.')
    ;

I guess I should wait for your input before continuing in this way ?

Do you think this would be helpful for the community ?

Thank you for your time in any case and have a nice day !

@helyakin helyakin changed the title feature: Adding IsReadonly Expression feature: Add IsReadonly Expression Jan 17, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (e29c207) 94.35% compared to head (f16c7f9) 94.19%.
Report is 1 commits behind head on main.

Files Patch % Lines
src/Analyzer/ClassDescriptionBuilder.php 40.00% 3 Missing ⚠️
src/Analyzer/FileVisitor.php 50.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #422      +/-   ##
============================================
- Coverage     94.35%   94.19%   -0.16%     
- Complexity      573      582       +9     
============================================
  Files            67       69       +2     
  Lines          1505     1533      +28     
============================================
+ Hits           1420     1444      +24     
- Misses           85       89       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fain182
Copy link
Collaborator

fain182 commented Jan 19, 2024

Thank you for your contribution @helyakin !
I think this looks very good 🙂
If you could add the negative rule IsNotReadOnly, and a couple of lines in the README to show an example (like the other rules) and then we are ready for merging it!

@helyakin
Copy link
Contributor Author

Thanks for your quick review @fain182

I'm super thrilled that you find this contribution interesting and worth adding 🙏🏻

I've just added the requested changes.

@fain182
Copy link
Collaborator

fain182 commented Jan 24, 2024

great work, thanks!

@fain182 fain182 merged commit b78ecce into phparkitect:main Jan 24, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants