Skip to content

fix: widen accepted values in set_value()'s $default - #10641

Merged
paulbalandan merged 2 commits into
codeigniter4:developfrom
paulbalandan:set-value-non-string-default
Oct 23, 2026
Merged

paulbalandan merged 2 commits into
codeigniter4:developfrom
paulbalandan:set-value-non-string-default

Conversation

@paulbalandan

Copy link
Copy Markdown
Member

Description
Ref: https://forum.codeigniter.com/showthread.php?tid=94539

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

@carson-codeigniter4 carson-codeigniter4 Bot added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 19, 2026
@paulbalandan
paulbalandan force-pushed the set-value-non-string-default branch from 240ed59 to 6f77131 Compare October 19, 2026 05:49

@neznaika0 neznaika0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any point in checking the array for valid values? I think it’s an unnecessary burden. But the topic starter on the forum mentions this.

@neznaika0

neznaika0 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Is it worth adding a note in changelog about strict types in #10521 ? Previously, this was not approved as BC and was pushed to the next branch.

@paulbalandan

Copy link
Copy Markdown
Member Author

Is it worth adding a note in changelog about strict types in #10521 ? Previously, this was not approved as BC and was pushed to the next branch.

#10521 didn't add strict_types. form_helper.php already declared it, and that PR added native return types. I checked every helper affected, and set_value() was the only one returning a caller-supplied value that could fall outside the new type. Overridden helpers are unaffected thanks to the function_exists() guards. The changelog entry here already records it as a v4.7.5 regression, so I don't think a separate note is needed.

@paulbalandan

Copy link
Copy Markdown
Member Author

Is there any point in checking the array for valid values? I think it’s an unnecessary burden. But the topic starter on the forum mentions this.

Hmm, yes, no need. With an array default, the array|string return type holds whatever the array contains, and esc() passes non-string elements through unchanged, so nothing can throw there.

@paulbalandan
paulbalandan force-pushed the set-value-non-string-default branch from 6f77131 to 9657352 Compare October 23, 2026 06:57
@paulbalandan
paulbalandan merged commit 6ddf104 into codeigniter4:develop Oct 23, 2026
59 checks passed
@paulbalandan
paulbalandan deleted the set-value-non-string-default branch October 23, 2026 09:06
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.

4 participants