Skip to content

Use guard clauses in cmd->addHistoryValue - #3400

Merged
Salvialf merged 3 commits into
developfrom
refactor/add-history-value
Jun 27, 2026
Merged

Use guard clauses in cmd->addHistoryValue#3400
Salvialf merged 3 commits into
developfrom
refactor/add-history-value

Conversation

@Salvialf

@Salvialf Salvialf commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the single large if block in addHistoryValue with early return guard clauses
  • Extract null, empty, and out-of-range value checks into dedicated guards
  • Remove unused return on history::save() (returns void)
  • Fix $_unite_conversion PHPDoc type from array<string, int|string> to array<string, array<int|string>>

Motivation

The original method wrapped its entire body in one deeply nested condition, making it hard to follow the validation logic. The guard clause pattern makes each rejection reason explicit and reduces indentation throughout the method body.

This refactor is also preparatory for an upcoming history retention feature that will add logic between the guards and the history save.

Behaviour

No functional change. history::save() already rejects null values internally (early return on line 1012), so dropping the null pass-through from the outer condition has no observable effect.

@Salvialf Salvialf added the changelog-other Use to generate release notes label Jun 26, 2026
@Salvialf
Salvialf merged commit c3f7077 into develop Jun 27, 2026
9 checks passed
@Salvialf
Salvialf deleted the refactor/add-history-value branch June 27, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-other Use to generate release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants