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

Correctly treat class names as case insensitive #571

Merged
merged 1 commit into from Sep 13, 2019

Conversation

morrisonlevi
Copy link
Collaborator

@morrisonlevi morrisonlevi commented Sep 13, 2019

Description

In PHP, class and method names are case insensitive. We already handled method names correctly. This PR adds support for case insensitive class names too.

Readiness checklist

  • Tests added for this feature/bug.

Reviewer checklist

  • Appropriate labels assigned.
  • Milestone is set.
  • Changelog has been added to the appropriate release draft.

@morrisonlevi morrisonlevi added 🐛 bug Something isn't working 💔 breaking-change c-extension Apply this label to issues and prs related to the C-extension and removed 💔 breaking-change labels Sep 13, 2019
@morrisonlevi morrisonlevi added this to the 0.31.0 milestone Sep 13, 2019
Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

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

Added an early question

class_name = class->name;
class_name_length = class->name_length;
size_t class_name_length = class->name_length;
char *class_name = zend_str_tolower_dup(class->name, class_name_length);
Copy link
Member

Choose a reason for hiding this comment

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

Should we measure the impact of lowering every call? What do you think? Will it be noticeable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's just a guess, but I think it will be okay. I'm not sure we can really avoid it -- the case insensitivity is PHP's behavior, which I'm sure we'll need to obey. In cases like CodeIgniter they definitely use the insensitivity as a feature, which is how I discovered this bug.

@morrisonlevi morrisonlevi marked this pull request as ready for review September 13, 2019 22:57
Copy link
Contributor

@SammyK SammyK left a comment

Choose a reason for hiding this comment

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

Nice find and fix @morrisonlevi! :)

@morrisonlevi morrisonlevi merged commit a315d73 into master Sep 13, 2019
@morrisonlevi morrisonlevi deleted the levi/case-insensitive-classes branch April 29, 2020 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working c-extension Apply this label to issues and prs related to the C-extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants