Skip to content

fix: preserve null values in Validation::getValidated()#10101

Open
michalsn wants to merge 1 commit intocodeigniter4:developfrom
michalsn:fix/dot-array-filter
Open

fix: preserve null values in Validation::getValidated()#10101
michalsn wants to merge 1 commit intocodeigniter4:developfrom
michalsn:fix/dot-array-filter

Conversation

@michalsn
Copy link
Copy Markdown
Member

Description
This PR fixes a validation bug where Validation::getValidated() could drop fields whose validated value was explicitly null.

The issue came from DotArrayFilter, which treated null like a missing key when building the validated data array. With this change, explicit null values are preserved, so validated output stays consistent with the original validated input, including cases such as permit_empty.

Checklist:

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

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 10, 2026
Copy link
Copy Markdown
Contributor

@neznaika0 neznaika0 left a comment

Choose a reason for hiding this comment

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

I hope that no one disrupts their work.

@michalsn michalsn force-pushed the fix/dot-array-filter branch from f639fac to 0bbff2f Compare April 12, 2026 07:41
@neznaika0
Copy link
Copy Markdown
Contributor

Did cs-fixer get new rules?

@michalsn
Copy link
Copy Markdown
Member Author

@neznaika0 I guess a new version of cs-fix was released.

@paulbalandan Is that okay, or do we want to fix this another way?

@neznaika0
Copy link
Copy Markdown
Contributor

Why did I ask, if you changed it manually, we decided that the prefix for @phpstan-* is not needed. Since this is an automatic update, we'll leave it for later.

@michalsn
Copy link
Copy Markdown
Member Author

if you changed it manually

I did not change anything. The error popped up after rebase.

@paulbalandan
Copy link
Copy Markdown
Member

php-cs-fixer has a new release with few new fixers and options. I think we should fix this separately. for psalm, I'm thinking of instead of separate phpstan-type and psalm-type, can we just type those in the @var directly instead of having separate phpstan-var and psalm-var?

@michalsn michalsn force-pushed the fix/dot-array-filter branch from 0cc9d84 to 5fff035 Compare April 12, 2026 10:32
@neznaika0
Copy link
Copy Markdown
Contributor

@paulbalandan As I said, we discussed it in PR with you and came to the conclusion that we are so strongly attached to phpstan that we don't need to use prefixes. For psalm, I do not know if it has annotation differences.

@paulbalandan
Copy link
Copy Markdown
Member

Yes, that's what I'm proposing here. I'll make a PR for the cs fixes and for psalm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants