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

Api improvement for isSearch. #164

Merged
merged 2 commits into from Apr 29, 2017
Merged

Api improvement for isSearch. #164

merged 2 commits into from Apr 29, 2017

Conversation

dereuromark
Copy link
Member

After be just bumped the major, I think this should also land in that new version.
It is BC - and improves the API by clearly returning a bool result on process() to indicated if a search filter has been actually applied.
It also simplifies the code since skip() doesnt need to be invoked twice.

@codecov
Copy link

codecov bot commented Apr 28, 2017

Codecov Report

Merging #164 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #164      +/-   ##
============================================
- Coverage     99.41%   99.41%   -0.01%     
+ Complexity      151      146       -5     
============================================
  Files            11       11              
  Lines           344      340       -4     
============================================
- Hits            342      338       -4     
  Misses            2        2
Impacted Files Coverage Δ Complexity Δ
src/Model/Filter/Base.php 98.48% <ø> (ø) 35 <0> (ø) ⬇️
src/Model/Behavior/SearchBehavior.php 100% <100%> (ø) 18 <0> (+1) ⬆️
src/Model/Filter/Compare.php 100% <100%> (ø) 4 <0> (-1) ⬇️
src/Model/Filter/Callback.php 100% <100%> (ø) 1 <0> (-1) ⬇️
src/Model/Filter/Like.php 100% <100%> (ø) 23 <0> (-1) ⬇️
src/Model/Filter/Finder.php 100% <100%> (ø) 3 <0> (-1) ⬇️
src/Model/Filter/Value.php 100% <100%> (ø) 8 <0> (-1) ⬇️
src/Model/Filter/Boolean.php 100% <100%> (ø) 7 <0> (-1) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2dc574c...851f671. Read the comment docs.

continue;
}
$result = $filter->process();
if ($result !== false) {
Copy link
Member

Choose a reason for hiding this comment

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

Explicit check for false will cause problems with existing custom filters people have which don't return anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did this on purpose. All current would Return null and behave Like true.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is already the current behavior. So it only Got better now, Not worse.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right it checks for not false. This is why i dislike negations in general, easy to misread :) Valid use here.

Copy link
Member Author

Choose a reason for hiding this comment

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

:) All good.

@dereuromark
Copy link
Member Author

I rebased and resolved the conflict.

@dereuromark
Copy link
Member Author

I suggest the following release notes for the tag 3.0.1:

### Improvements

Filters
- All filters should now return a boolean result on whether they modified the query. This allows for a more correct isSearch value.

@josegonzalez
Copy link
Member

Why all the test removals?

@dereuromark
Copy link
Member Author

Because they are obsolete with this improvement. You don't have to check for the skip being called.

@dereuromark
Copy link
Member Author

I rebased it - should be clear now.

@josegonzalez
Copy link
Member

Not bc as it changes the signature of a method. I think this is okay to go into 3.1.0 though.

@dereuromark
Copy link
Member Author

The idea was to release a 3.0.1 for it all after the release of 3.0.0 was just the other day.

@dereuromark
Copy link
Member Author

But both is fine.

@dereuromark
Copy link
Member Author

@josegonzalez Strictly speaking it is BC, the method signature only changes on the semantic level.
All custom filters would behave the same old way - false positive report.
So it enhanced it by adding a more accurate report - that's all. Not a BC break as I see it.

if (!empty($expressions)) {
$this->getQuery()->andWhere([$this->config('mode') => $expressions]);
}
$this->getQuery()->andWhere([$this->config('mode') => $expressions]);
Copy link
Member Author

Choose a reason for hiding this comment

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

Did I rebase wrongly?

Copy link
Member

Choose a reason for hiding this comment

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

We removed the empty check in favor of validation expressions.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thx.

@josegonzalez
Copy link
Member

Strictly speaking, void is not bool.

@dereuromark
Copy link
Member Author

dereuromark commented Apr 29, 2017

We both know what strictly means in a PHP world pre-7.1 - where we do not typehint anything scalar right now.
We do not need to fight about semantic meanings here - as it bears no relevance to the functional BC I was talking about ;)

@dereuromark
Copy link
Member Author

dereuromark commented Apr 29, 2017

And just to be clear: A change to bool (or anything non-void) is always BC from void - not the other way around.
So you just made the point for me: A BC enhancement, not a BC break.

@josegonzalez
Copy link
Member

Sorry, I think we'll agree to disagree.

In any case, this is good to go.

@josegonzalez josegonzalez merged commit 737fd36 into master Apr 29, 2017
@josegonzalez josegonzalez deleted the master-api branch April 29, 2017 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants