Skip to content

fix: Unicode support for NothingPersonalValidator - #1406

Open
neznaika0 wants to merge 1 commit into
codeigniter4:developfrom
neznaika0:test/personal-validator
Open

neznaika0 wants to merge 1 commit into
codeigniter4:developfrom
neznaika0:test/personal-validator

Conversation

@neznaika0

Copy link
Copy Markdown
Contributor

Description

  1. Tests are run for individual methods, instead of check(). Otherwise, it’s unclear at which stage the error occurs.
    There is a proposal to move mb_strtolower($password) inside for clarity.
  2. By allowing Unicode, the $trivial check now loses its relevance for other languages.
  • Unicode support has been added. User data may contain multibyte characters: in the email, username, lastname and other User properties.
  • The phpDoc has been slightly corrected
  • Tests for the case when User = null is passed
  • strip_explode() also understands Unicode
  • Checking a reversed Unicode username is impossible

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@neznaika0
neznaika0 force-pushed the test/personal-validator branch from fc43695 to 4eafdfe Compare November 13, 2026 16:01
public function check(string $password, ?User $user = null): Result
{
$password = strtolower($password);
$password = mb_strtolower($password);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The MBString mutation suggests the tests did not cover multibyte passwords, which this change is anchoring on.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I haven’t used Infection. Does this mean that my version of the tests works in both strtolower() variants?
Perhaps it will work if the exact strings are the same. But we understand that there is a difference:

$ php -r "var_dump(strtolower('ПёТр'), mb_strtolower('ПёТр')); ";
string(8) "ПёТр"
string(8) "пётр"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, your test passes in both variants. infection must see your test fails when it changes things to say you covered the mutant

This branch has not been deployed

No deployments
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