Skip to content

Conversation

@hgraca
Copy link
Contributor

@hgraca hgraca commented Aug 7, 2023

At some point this was correct and then changed into a bug.

I am reverting the change that introduced the bug.

@hgraca hgraca force-pushed the fix/fix_pattern_match branch from a7e3e5e to 7d7e9c1 Compare August 7, 2023 19:48
@fain182 fain182 self-assigned this Aug 22, 2023
@fain182
Copy link
Collaborator

fain182 commented Aug 26, 2023

Thanks for you contributions! As you can see from the broken tests this function is used in a lot of places, and reverting to an old behavior is not a valid solution...
Which is the exact behavior that you didn't expect? If you have an example would be great 🙂

@hgraca
Copy link
Contributor Author

hgraca commented Aug 26, 2023

@fain182

Reverting the changes and leaving the test as is, we can see that this assertion fails:

        $pattern = new PatternString('SoThisIsAnExample');
        $this->assertFalse($pattern->matches('*This'));

However, it shouldn't fail because it shouldn't match since there is no wildcard at the end of the string.

@hgraca
Copy link
Contributor Author

hgraca commented Aug 26, 2023

@fain182
I removed a duplicate assertion and added a few more to make sure all scenarios are covered.

@hgraca
Copy link
Contributor Author

hgraca commented Sep 5, 2023

@fain182 I believe I fixed the issues, can you check the last commits, please?

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.76%. Comparing base (92dad93) to head (f628a1b).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #404      +/-   ##
============================================
- Coverage     94.79%   94.76%   -0.04%     
+ Complexity      606      604       -2     
============================================
  Files            69       69              
  Lines          1614     1604      -10     
============================================
- Hits           1530     1520      -10     
  Misses           84       84              

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@d-cichon
Copy link

@hgraca i need this ;-;

Can we merge it?

@hgraca
Copy link
Contributor Author

hgraca commented Feb 27, 2025

@d-cichon as far as I'm concerned, yes. However, I'm not a maintainer, I can't merge anything.
Back when I opened these PRs I ended up making my own fork cozz I felt this project was abandoned, no one was merging anything.
Not sure how this is now, but u might need to do the same.

@hgraca hgraca force-pushed the fix/fix_pattern_match branch from 7f6ae0d to f628a1b Compare March 9, 2025 20:22
@hgraca
Copy link
Contributor Author

hgraca commented Mar 9, 2025

@d-cichon @fain182

I see there is work being merged, so I guess this is not abandoned as I thought.

Thus, I opened an issue for this PR, rebased, squashed and force pushed to this branch.

This PR resolves #457

@hgraca hgraca force-pushed the fix/fix_pattern_match branch from f628a1b to 0e965be Compare March 9, 2025 20:47
Copy link
Member

@AlessandroMinoccheri AlessandroMinoccheri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@AlessandroMinoccheri
Copy link
Member

@fain182 @micheleorselli it seems OK for me, any other opinions?

$resideInNamespace = false;
foreach ($this->namespaces as $namespace) {
if ($theClass->namespaceMatches($namespace)) {
if ($theClass->namespaceMatches($namespace.'*')) {
Copy link
Member

@micheleorselli micheleorselli Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just out of curiosity, why do we need to add this? cc @AlessandroMinoccheri

Copy link
Contributor Author

@hgraca hgraca Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its from a long time ago, but I guess it was because if a class is in a subnamespace is still in the given namespace.

However, looking at it now, it's out of scope fo this PR, and not having the * is a better option because we can match the namespace exactly or provide the namespace with a * which will match subnamespaces as well.

So, Im adding a fixup commit to remove this change.

The test ResideInOneOfTheseNamespacesTest::test_it_should_match_namespace_and_descendants will fail if this is not there, as it seems this expression has been designed to match the namespace or its descendants.

@hgraca hgraca force-pushed the fix/fix_pattern_match branch from 0e965be to 1d91538 Compare March 11, 2025 20:27
@hgraca
Copy link
Contributor Author

hgraca commented Mar 11, 2025

I rebased and force pushed

@micheleorselli micheleorselli merged commit 9aaafd8 into phparkitect:main Mar 13, 2025
16 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.

6 participants