Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Multiple exclusion strategy #44

Closed
wants to merge 2 commits into from

Conversation

Narretz
Copy link

@Narretz Narretz commented Feb 21, 2013

ChainExclusionStrategy, as first implemented by @adrienbrault in schmittjoh/JMSSerializerBundle#140 and recently brought up again in #39. Strategy must be set explicitly, otherwise the behavior stays the same as currently.

@schmittjoh
Copy link
Owner

I've just two remarks:

  • Could you rename the strategy to DisjunctExclusionStrategy (I don't have a less academic, yet precise name atm; maybe you have an idea?).
  • Could you revert all changes to the Serializer for now?

@schmittjoh
Copy link
Owner

Ah, and one more, please add a unit test instead of the functional tests. This is far easier here.

{
if (is_string($strategy)) {
unset($this->chain[$strategy]);
} elseif (false !== ($index = array_search($strategy, $this->chain, true))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of using array_search, you could simply check if $this->chain[get_class($strategy)] === $strategy, as you are using the class name as key currently

@Narretz
Copy link
Author

Narretz commented Feb 21, 2013

About the name, Disjunct is probably too academic. At least I couldn't immediately grasp it. What about "Multiple"?

@stof
Copy link
Contributor

stof commented Feb 21, 2013

@Narretz the issue is that there is 2 ways to implement the composed strategy: A->skip() || B->skip() (this implementation) and A->skip() && B->skip(). MultipleExclusionStrategy would not allow to distinguish them.

*/
class ChainExclusionStrategy implements ExclusionStrategyInterface
{
private $chain = array();
Copy link
Contributor

Choose a reason for hiding this comment

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

@schmittjoh should this use an array or do you prefer using a PhpCollection\SequenceInterface ?

@Narretz
Copy link
Author

Narretz commented Feb 22, 2013

Maybe we can borrow a term from Security component here. What about "MultipleAffirmative"? Other than that, Disjunct is fine, if the docs make it clear what it means.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants