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

Remove calls to Str::contains and Arr::get when not necessary #2571

Merged
merged 2 commits into from
Aug 23, 2023

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Aug 22, 2023

  • Str::contains is identical to str_contains but support array. This is not necessary in several places.
  • Arr::get is identical to $array[$key] ?? $default but accept dot notation for nested arrays. This is not necessary when the key does not contain a dot.

Replacing this method calls with native functions improve performance (less method calls) and simplifies step-by-step debugging.

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

LGTM.

Per our earlier conversation in GromNaN/laravel-mongodb#27 (comment), I created PHPORM-76 to propose adding an explicit PHP language requirement to this package's composer.json file.

@GromNaN
Copy link
Member Author

GromNaN commented Aug 22, 2023

I created PHPORM-76 to propose adding an explicit PHP language requirement to this package's composer.json file.

Done in #2574. I close the Jira as fixed.

@alcaeus alcaeus merged commit 7d3be9f into mongodb:master Aug 23, 2023
9 checks passed
@GromNaN GromNaN deleted the str-helper branch August 23, 2023 09:44
@GromNaN GromNaN added this to the 4.0.0 milestone Aug 30, 2023
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