Skip to content

Matching class names case insensitive#2561

Closed
mamazu wants to merge 2 commits intophpactor:masterfrom
mamazu:case_insensitive
Closed

Matching class names case insensitive#2561
mamazu wants to merge 2 commits intophpactor:masterfrom
mamazu:case_insensitive

Conversation

@mamazu
Copy link
Contributor

@mamazu mamazu commented Feb 25, 2024

This only changes the behaviour of the ShortName search as searching with an FQN sould be case sensitive. Or what do you think?

}

return str_starts_with($record->shortName(), $this->name);
return str_starts_with(strtolower($record->shortName()), $this->name);
Copy link
Contributor

@przepompownia przepompownia Feb 25, 2024

Choose a reason for hiding this comment

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

This place is tempting to try (probably slow) fuzzy matching if str_starts_with didn't match:

Suggested change
return str_starts_with(strtolower($record->shortName()), $this->name);
if (str_starts_with(strtolower($record->shortName()), $this->name)) {
return true;
}
$regex = '#' . implode('.*', array_map(preg_quote(...), str_split($this->name))) . '#i';
return preg_match($regex, $record->shortName()) === 1;

image

@mamazu
Copy link
Contributor Author

mamazu commented Feb 26, 2024

Closed replaced by #2562

@mamazu mamazu closed this Feb 26, 2024
@przepompownia
Copy link
Contributor

On simple benchmark in #2563 I see that using a class compound of two Criteria class is significantly slower so closing this PR seems to be good idea in favor of single class implementation.

@mamazu mamazu deleted the case_insensitive branch March 1, 2024 16:21
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.

2 participants