Skip to content

fix(helpers): Use UIAwesome/Helper package, remove related classes, and update tests accordingly.#113

Merged
terabytesoftw merged 1 commit into
mainfrom
fix_mini_81
Dec 17, 2025
Merged

fix(helpers): Use UIAwesome/Helper package, remove related classes, and update tests accordingly.#113
terabytesoftw merged 1 commit into
mainfrom
fix_mini_81

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

@terabytesoftw terabytesoftw commented Dec 17, 2025

Pull Request

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated dependencies to use the UIAwesome HTML helper package, consolidating internal utilities and improving code maintainability.
    • Added internal testing dependency for enhanced test isolation.
    • Removed redundant internal helper code in favor of external package implementations.

✏️ Tip: You can customize this high-level summary in your review settings.

@terabytesoftw terabytesoftw added the bug Something isn't working label Dec 17, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 17, 2025

Walkthrough

This PR migrates from internal helper implementations to the external UIAwesome Html-Helper package. It removes local helper classes (Attributes, CSSClass, Encode, Enum, Template, Validator), their base implementations, and corresponding test suites. Dependencies are updated, and all codebase imports are redirected from yii\ui\helpers\* to UIAwesome\Html\Helper\* namespaces.

Changes

Cohort / File(s) Summary
Dependencies
composer.json
Added ui-awesome/html-helper (^0.4) and xepozz/internal-mocker (^1.4).
Removed Helpers (Base Classes)
src/helpers/base/BaseAttributes.php, src/helpers/base/BaseCSSClass.php, src/helpers/base/BaseEncode.php, src/helpers/base/BaseEnum.php, src/helpers/base/BaseTemplate.php, src/helpers/base/BaseValidator.php
Removed abstract base helper classes for attribute rendering, CSS class manipulation, HTML encoding, enum normalization, template processing, and value validation.
Removed Helpers (Public Wrappers)
src/helpers/Attributes.php, src/helpers/CSSClass.php, src/helpers/Encode.php, src/helpers/Enum.php, src/helpers/Template.php, src/helpers/Validator.php
Removed thin wrapper classes that extended the base helpers.
Updated Attributes (Import Replacements)
src/attributes/HasClass.php, src/attributes/HasContentEditable.php, src/attributes/HasDir.php, src/attributes/HasDraggable.php, src/attributes/HasLang.php, src/attributes/HasSpellcheck.php, src/attributes/HasTabindex.php
Replaced imports of yii\ui\helpers\{CSSClass,Validator} with UIAwesome\Html\Helper\{CSSClass,Validator}.
Updated Core Helpers (Import Replacements)
src/element/BaseInline.php, src/html/base/BaseHtml.php, src/mixin/HasContent.php, src/mixin/HasPrefixCollection.php, src/mixin/HasSuffixCollection.php
Replaced imports of yii\ui\helpers\{Attributes,Encode,CSSClass,Template} with UIAwesome\Html\Helper\{Attributes,Encode,CSSClass,Template}.
Removed Test Suites
tests/helpers/AttributesTest.php, tests/helpers/CSSClassTest.php, tests/helpers/EncodeTest.php, tests/helpers/EnumTest.php, tests/helpers/TemplateTest.php, tests/helpers/ValidatorTest.php
Removed PHPUnit test classes that validated internal helper implementations.
Removed Test Providers
tests/providers/helpers/AttributesProvider.php, tests/providers/helpers/CSSClassProvider.php, tests/providers/helpers/EncodeProvider.php, tests/providers/helpers/EnumProvider.php, tests/providers/helpers/ValidatorProvider.php
Removed data provider classes supplying test cases for removed helpers.
Updated Test Imports (Attributes & Enum)
tests/attributes/CanBeAutofocusTest.php, tests/attributes/CanBeHiddenTest.php, tests/attributes/HasClassTest.php, tests/attributes/HasContentEditableTest.php, tests/attributes/HasDataTest.php, tests/attributes/HasDirTest.php, tests/attributes/HasDraggableTest.php, tests/attributes/HasIdTest.php, tests/attributes/HasLangTest.php, tests/attributes/HasMicroDataTest.php, tests/attributes/HasSpellcheckTest.php, tests/attributes/HasStyleTest.php, tests/attributes/HasTabIndexTest.php, tests/attributes/HasTitleTest.php
Replaced imports of yii\ui\helpers\{Attributes,Enum} with UIAwesome\Html\Helper\{Attributes,Enum}.
Updated Test Support
tests/support/EnumDataGenerator.php
Replaced import of yii\ui\helpers\Enum with UIAwesome\Html\Helper\Enum.
Documentation
CHANGELOG.md
Added changelog entry documenting the migration to UIAwesome/Helper package and removal of related classes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Broad scope: 60+ files modified across multiple layers (attributes, helpers, mixins, tests, test support).
  • Heterogeneous changes: Mix of file deletions, import replacements, and dependency updates requiring verification of external package compatibility.
  • Key areas needing attention:
    • Verify ui-awesome/html-helper package provides fully compatible implementations (signatures, behavior, encoding logic).
    • Confirm removal of test suites doesn't leave coverage gaps; external package should have equivalent tests.
    • Validate that the external Validator::oneOf and Validator::intLike behave identically to removed local implementations.
    • Check BaseAttributes removal preserves all attribute rendering and ordering logic in external package.

Possibly related PRs

Poem

🐰 With a hop and a bound, we've tidied our ground,
Helpers packed up and shipped to the UIAwesome town,
Fewer files to maintain, less code to refine,
Our imports now travel through cleaner design!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: migrating from local helpers to the UIAwesome/Helper package and removing related classes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_mini_81

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a6e54b8 and 6778163.

📒 Files selected for processing (52)
  • CHANGELOG.md (1 hunks)
  • composer.json (2 hunks)
  • src/attributes/HasClass.php (1 hunks)
  • src/attributes/HasContentEditable.php (1 hunks)
  • src/attributes/HasDir.php (1 hunks)
  • src/attributes/HasDraggable.php (1 hunks)
  • src/attributes/HasLang.php (1 hunks)
  • src/attributes/HasSpellcheck.php (1 hunks)
  • src/attributes/HasTabindex.php (1 hunks)
  • src/element/BaseInline.php (1 hunks)
  • src/helpers/Attributes.php (0 hunks)
  • src/helpers/CSSClass.php (0 hunks)
  • src/helpers/Encode.php (0 hunks)
  • src/helpers/Enum.php (0 hunks)
  • src/helpers/Template.php (0 hunks)
  • src/helpers/Validator.php (0 hunks)
  • src/helpers/base/BaseAttributes.php (0 hunks)
  • src/helpers/base/BaseCSSClass.php (0 hunks)
  • src/helpers/base/BaseEncode.php (0 hunks)
  • src/helpers/base/BaseEnum.php (0 hunks)
  • src/helpers/base/BaseTemplate.php (0 hunks)
  • src/helpers/base/BaseValidator.php (0 hunks)
  • src/html/base/BaseHtml.php (1 hunks)
  • src/mixin/HasContent.php (1 hunks)
  • src/mixin/HasPrefixCollection.php (1 hunks)
  • src/mixin/HasSuffixCollection.php (1 hunks)
  • tests/attributes/CanBeAutofocusTest.php (1 hunks)
  • tests/attributes/CanBeHiddenTest.php (1 hunks)
  • tests/attributes/HasClassTest.php (1 hunks)
  • tests/attributes/HasContentEditableTest.php (1 hunks)
  • tests/attributes/HasDataTest.php (1 hunks)
  • tests/attributes/HasDirTest.php (1 hunks)
  • tests/attributes/HasDraggableTest.php (1 hunks)
  • tests/attributes/HasIdTest.php (1 hunks)
  • tests/attributes/HasLangTest.php (1 hunks)
  • tests/attributes/HasMicroDataTest.php (1 hunks)
  • tests/attributes/HasSpellcheckTest.php (1 hunks)
  • tests/attributes/HasStyleTest.php (1 hunks)
  • tests/attributes/HasTabIndexTest.php (1 hunks)
  • tests/attributes/HasTitleTest.php (1 hunks)
  • tests/helpers/AttributesTest.php (0 hunks)
  • tests/helpers/CSSClassTest.php (0 hunks)
  • tests/helpers/EncodeTest.php (0 hunks)
  • tests/helpers/EnumTest.php (0 hunks)
  • tests/helpers/TemplateTest.php (0 hunks)
  • tests/helpers/ValidatorTest.php (0 hunks)
  • tests/providers/helpers/AttributesProvider.php (0 hunks)
  • tests/providers/helpers/CSSClassProvider.php (0 hunks)
  • tests/providers/helpers/EncodeProvider.php (0 hunks)
  • tests/providers/helpers/EnumProvider.php (0 hunks)
  • tests/providers/helpers/ValidatorProvider.php (0 hunks)
  • tests/support/EnumDataGenerator.php (1 hunks)
💤 Files with no reviewable changes (23)
  • tests/providers/helpers/EncodeProvider.php
  • src/helpers/base/BaseValidator.php
  • src/helpers/base/BaseTemplate.php
  • tests/providers/helpers/EnumProvider.php
  • src/helpers/Enum.php
  • tests/helpers/TemplateTest.php
  • tests/providers/helpers/CSSClassProvider.php
  • src/helpers/Attributes.php
  • tests/helpers/EnumTest.php
  • src/helpers/Template.php
  • src/helpers/CSSClass.php
  • src/helpers/base/BaseEncode.php
  • tests/providers/helpers/ValidatorProvider.php
  • tests/helpers/CSSClassTest.php
  • src/helpers/Validator.php
  • src/helpers/base/BaseAttributes.php
  • tests/helpers/EncodeTest.php
  • src/helpers/base/BaseEnum.php
  • tests/helpers/AttributesTest.php
  • src/helpers/Encode.php
  • tests/providers/helpers/AttributesProvider.php
  • tests/helpers/ValidatorTest.php
  • src/helpers/base/BaseCSSClass.php
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: terabytesoftw
Repo: yii2-framework/ui-awesome PR: 81
File: src/element/BaseElement.php:90-92
Timestamp: 2025-11-29T22:30:03.121Z
Learning: In the yii2-framework/ui-awesome codebase, the Template helper's render() method (src/helpers/base/BaseTemplate.php) explicitly converts literal `\n` sequences in template strings to actual newlines using `str_replace('\n', "\n", $template)`, so single-quoted strings with `\n` are valid and work as intended in template definitions.
📚 Learning: 2025-11-29T22:30:03.121Z
Learnt from: terabytesoftw
Repo: yii2-framework/ui-awesome PR: 81
File: src/element/BaseElement.php:90-92
Timestamp: 2025-11-29T22:30:03.121Z
Learning: In the yii2-framework/ui-awesome codebase, the Template helper's render() method (src/helpers/base/BaseTemplate.php) explicitly converts literal `\n` sequences in template strings to actual newlines using `str_replace('\n', "\n", $template)`, so single-quoted strings with `\n` are valid and work as intended in template definitions.

Applied to files:

  • src/mixin/HasPrefixCollection.php
  • src/mixin/HasSuffixCollection.php
  • src/element/BaseInline.php
  • src/mixin/HasContent.php
  • src/html/base/BaseHtml.php
🧬 Code graph analysis (16)
tests/attributes/HasDraggableTest.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/attributes/HasLang.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/attributes/HasContentEditable.php (1)
src/html/Html.php (1)
  • Html (32-32)
tests/attributes/HasSpellcheckTest.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/mixin/HasPrefixCollection.php (1)
src/html/Html.php (1)
  • Html (32-32)
tests/attributes/HasContentEditableTest.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/mixin/HasSuffixCollection.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/element/BaseInline.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/mixin/HasContent.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/attributes/HasDir.php (1)
src/html/Html.php (1)
  • Html (32-32)
tests/attributes/HasIdTest.php (1)
src/html/Html.php (1)
  • Html (32-32)
tests/attributes/HasDataTest.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/html/base/BaseHtml.php (1)
src/html/Html.php (1)
  • Html (32-32)
src/attributes/HasTabindex.php (1)
src/html/Html.php (1)
  • Html (32-32)
tests/attributes/HasMicroDataTest.php (1)
src/html/Html.php (1)
  • Html (32-32)
tests/attributes/CanBeAutofocusTest.php (1)
src/html/Html.php (1)
  • Html (32-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: composer-require-checker / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.1-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-windows-2022
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.3-windows-2022
  • GitHub Check: mutation / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: phpunit / PHP 8.2-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: mutation / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
🔇 Additional comments (29)
tests/attributes/HasMicroDataTest.php (1)

9-9: Import correctly migrated to external package.

The namespace change from an internal helper to UIAwesome\Html\Helper\Attributes aligns with using the external ui-awesome/html-helper package (version ^0.4) declared in composer.json. All test method calls to Attributes::render() remain unchanged, confirming API compatibility.

tests/support/EnumDataGenerator.php (1)

7-7: LGTM! Import migration to UIAwesome\Html\Helper\Enum.

The import change aligns with the PR objective. The Enum::normalizeValue() usage at line 46 maintains the same API pattern.

CHANGELOG.md (1)

117-117: LGTM! Changelog entry follows established format.

The entry accurately documents the migration to the UIAwesome/Helper package and is consistent with the existing changelog style.

src/attributes/HasDir.php (1)

8-8: LGTM! Import migration to UIAwesome\Html\Helper\Validator.

The import change aligns with the PR objective. The Validator::oneOf() usage at line 69 follows the same pattern as other migrated files.

src/element/BaseInline.php (1)

8-8: LGTM! Import migration to UIAwesome\Html\Helper\Template.

The import change aligns with the PR objective. The Template::render() usage at line 91 with the single-quoted '\n' sequences at line 88 should work correctly, as the Template helper's render method handles literal \n conversion. Based on learnings, this pattern is intentional and supported.

src/attributes/HasSpellcheck.php (1)

8-8: Import migration to UIAwesome\Html\Helper\Validator is correct and compatible.

The import change and Validator::oneOf() usage at line 74 match the UIAwesome package API exactly, with proper handling of boolean-to-string conversion before validation.

src/attributes/HasLang.php (1)

8-8: Consistent namespace migration.

The import change aligns with the broader migration pattern seen across the codebase. The Validator::oneOf() usage at Line 71 remains unchanged.

tests/attributes/HasTitleTest.php (1)

9-9: Test import migration is correct.

The test correctly updates the Attributes helper import to use the external package. The Attributes::render() call at Line 56 maintains the same usage pattern.

src/attributes/HasContentEditable.php (1)

8-8: Clean import migration.

The namespace update is consistent with other attribute traits in this PR. The Validator::oneOf() method usage at Line 78 remains unchanged.

src/mixin/HasSuffixCollection.php (1)

9-9: CSSClass helper migration is correct.

The import change from yii\ui\helpers\CSSClass to UIAwesome\Html\Helper\CSSClass is clean. The CSSClass::add() method at Line 115 maintains the same usage pattern with $attributes, $value, and $override parameters.

src/mixin/HasPrefixCollection.php (1)

9-9: Consistent with HasSuffixCollection migration.

The CSSClass import change mirrors the pattern in HasSuffixCollection.php. The CSSClass::add() usage at Line 115 remains unchanged.

tests/attributes/HasTabIndexTest.php (1)

10-10: Test import correctly updated.

The Attributes helper import change aligns with other test files in this PR. The Attributes::render() call at Line 59 maintains the same usage.

src/attributes/HasTabindex.php (1)

8-8: Import migration is clean and verified.

The namespace update from yii\ui\helpers\Validator to UIAwesome\Html\Helper\Validator is correct. The external package's Validator::intLike() method is documented and supports validation of integer-like strings, and the usage pattern in the code (calling with a single parameter and checking the boolean return) is compatible with the method's API.

src/mixin/HasContent.php (1)

8-8: No security concerns with external package implementation.

The Encode::content() method from UIAwesome provides equivalent HTML encoding for XSS prevention. The usage at line 54 is appropriate and maintains the same security guarantees as standard HTML content encoding.

tests/attributes/HasIdTest.php (1)

9-9: LGTM: Clean namespace migration to external helper.

The import update is straightforward and the usage of Attributes::render() remains consistent with the previous implementation.

src/attributes/HasClass.php (1)

7-7: LGTM: Clean namespace migration to external helper.

The import update is correct and the usage of CSSClass::add() at line 72 remains unchanged.

tests/attributes/HasContentEditableTest.php (1)

10-10: LGTM: Clean namespace migration to external helpers.

Both Attributes and Enum imports are correctly updated, and their usage patterns remain consistent throughout the test.

tests/attributes/CanBeHiddenTest.php (1)

9-9: LGTM: Clean namespace migration to external helper.

The import update is correct and usage remains consistent with the previous implementation.

tests/attributes/HasDataTest.php (1)

11-11: LGTM: Clean namespace migration to external helper.

The import update is correct and usage remains consistent.

tests/attributes/HasStyleTest.php (1)

9-9: LGTM: Clean namespace migration to external helper.

The import update is correct and usage remains consistent.

tests/attributes/CanBeAutofocusTest.php (1)

9-9: LGTM: Clean namespace migration to external helper.

The import update is correct and usage remains consistent.

tests/attributes/HasDraggableTest.php (1)

10-10: LGTM: Clean namespace migration to external helpers.

The latest stable version of ui-awesome/html-helper is 0.3.0, not 0.4.0. Both Attributes and Enum imports are correctly updated to the UIAwesome\Html\Helper namespace, and their usage patterns remain consistent throughout the test file.

tests/attributes/HasDirTest.php (1)

10-10: LGTM! Namespace migration to UIAwesome helper.

The import update aligns with the PR's objective to use the external ui-awesome/html-helper package. The test logic remains unchanged, and any API incompatibilities would be caught by test failures.

tests/attributes/HasSpellcheckTest.php (1)

10-10: LGTM! Consistent namespace migration.

The import change is consistent with the broader migration to UIAwesome\Html\Helper. Test logic is preserved.

tests/attributes/HasClassTest.php (1)

9-9: LGTM! Namespace updated correctly.

Consistent with the migration pattern across test files. No functional changes to test logic.

tests/attributes/HasLangTest.php (1)

10-10: LGTM! Import namespace updated.

Matches the migration pattern for Attributes and Enum helpers. Test assertions remain unchanged.

composer.json (1)

26-26: Dev dependency added for internal mocking.

The xepozz/internal-mocker package addition supports testing of internal/private methods. This is appropriate for the dev environment.

src/attributes/HasDraggable.php (1)

8-8: Import migration to UIAwesome\Html\Helper\Validator is complete and compatible.

Verified that Validator::oneOf() is used consistently across six attribute files (HasSpellcheck, HasTabindex, HasLang, HasDir, HasDraggable, HasContentEditable) with the signature Validator::oneOf($value, $allowedValues, $fieldName). The method successfully validates against both arrays and Enum cases with no breaking changes detected.

src/html/base/BaseHtml.php (1)

8-8: API compatibility with external helper library verified.

The ui-awesome/html-helper package is a PHP library that provides classes to generate HTML attributes and encode content. The Attributes::render() method accepts an array of attributes and returns a rendered string, while Encode::content() safely encodes content to prevent XSS attacks. The external library methods are well-established and compatible with standard HTML rendering workflows.

Comment thread composer.json
@terabytesoftw terabytesoftw merged commit cc2bf80 into main Dec 17, 2025
43 checks passed
@terabytesoftw terabytesoftw deleted the fix_mini_81 branch December 17, 2025 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant