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

Feat: Global segments #104

Merged
merged 7 commits into from
Aug 11, 2022
Merged

Feat: Global segments #104

merged 7 commits into from
Aug 11, 2022

Conversation

RikudouSage
Copy link
Collaborator

@RikudouSage RikudouSage commented Jul 7, 2022

Description

Global segments

Fixes #103

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Spec Tests

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@RikudouSage RikudouSage marked this pull request as ready for review August 5, 2022 11:21
$constraints = $strategy->getConstraints();
$segments = method_exists($strategy, 'getSegments') ? $strategy->getSegments() : [];
foreach ($segments as $segment) {
$constraints = [...$constraints, ...$segment->getConstraints()];
Copy link
Member

Choose a reason for hiding this comment

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

This looks to my very uninformed PHP eyes that this is unpacking each segment into the array in a loop. Is this an efficient way to do this? I'm mostly asking because we have folks that are wanting to use this feature to create very large segments and reuse them a lot

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, that could be a little inefficient, don't know what I was thinking. I redid it to use yield and also got rid of one null check that wasn't necessary in each iteration.

Copy link
Member

Choose a reason for hiding this comment

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

Hahaha, this is why we do code review, I do things like this all the time :)

Thank you! That looks great!


/**
* This class is only for triggering code that doesn't really make sense to test and is here to achieve 100% code coverage.
* The reason is to catch potential problems during transpilation to lower versions of php.
Copy link
Member

Choose a reason for hiding this comment

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

Nice, that's pretty clever!

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

This looks great I see all the spec test are passing, the code looks really nice, I'm happy to merge if you're happy here

@RikudouSage
Copy link
Collaborator Author

Yep, good to go, thanks!

@RikudouSage RikudouSage merged commit f4e841d into main Aug 11, 2022
@RikudouSage RikudouSage deleted the feat/global-segments branch August 11, 2022 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Feature: Global Segments
2 participants