fix(helpers): Use UIAwesome/Helper package, remove related classes, and update tests accordingly.#113
Conversation
… and update tests accordingly.
WalkthroughThis PR migrates from internal helper implementations to the external UIAwesome Html-Helper package. It removes local helper classes ( Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 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.phpsrc/mixin/HasSuffixCollection.phpsrc/element/BaseInline.phpsrc/mixin/HasContent.phpsrc/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\Attributesaligns with using the externalui-awesome/html-helperpackage (version ^0.4) declared in composer.json. All test method calls toAttributes::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/Helperpackage 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\nconversion. 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
Attributeshelper import to use the external package. TheAttributes::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\CSSClasstoUIAwesome\Html\Helper\CSSClassis clean. TheCSSClass::add()method at Line 115 maintains the same usage pattern with$attributes,$value, and$overrideparameters.src/mixin/HasPrefixCollection.php (1)
9-9: Consistent with HasSuffixCollection migration.The
CSSClassimport change mirrors the pattern inHasSuffixCollection.php. TheCSSClass::add()usage at Line 115 remains unchanged.tests/attributes/HasTabIndexTest.php (1)
10-10: Test import correctly updated.The
Attributeshelper import change aligns with other test files in this PR. TheAttributes::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\ValidatortoUIAwesome\Html\Helper\Validatoris correct. The external package'sValidator::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
AttributesandEnumimports 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
AttributesandEnumimports are correctly updated to theUIAwesome\Html\Helpernamespace, 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-helperpackage. 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-mockerpackage 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 signatureValidator::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.
Pull Request
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.