Skip to content

feat(embedded): add Iframe class for <iframe> element.#95

Merged
terabytesoftw merged 2 commits into
mainfrom
feature_52
May 26, 2026
Merged

feat(embedded): add Iframe class for <iframe> element.#95
terabytesoftw merged 2 commits into
mainfrom
feature_52

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

Pull Request

  • Breaking change (fix or feature that would cause existing functionality to change)
  • Bugfix (non-breaking change that fixes an issue)
  • CI/build configuration
  • Documentation update
  • New feature (non-breaking change that adds functionality)
  • Refactoring (no functional changes)

@terabytesoftw terabytesoftw added the enhancement New feature or request label May 26, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Review Change Stack

Warning

Review limit reached

@terabytesoftw, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 49 minutes and 8 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6d262196-cc8f-46f4-8aa6-aefd7b0caa8d

📥 Commits

Reviewing files that changed from the base of the PR and between 6705c19 and a44ae08.

📒 Files selected for processing (1)
  • tests/Embedded/IframeTest.php
📝 Walkthrough

Walkthrough

This pull request introduces a new Iframe class for rendering HTML <iframe> elements with fluent attribute setters, comprehensive test coverage, and supporting documentation updates. The implementation follows established patterns in the codebase for element rendering.

Changes

Iframe Class and Test Coverage

Layer / File(s) Summary
Iframe class implementation and attributes
src/Embedded/Iframe.php
New Iframe final class extending BaseBlock with fluent setters for iframe attributes (allow, allowfullscreen, height, loading, name, referrerpolicy, sandbox, src, srcdoc, width). Includes enum case validation for loading and referrerpolicy attributes, throwing InvalidArgumentException for invalid values. Overrides getTag() to return Block::IFRAME.
Iframe test suite
tests/Embedded/IframeTest.php
Comprehensive PHPUnit test suite with 67+ test methods covering attribute rendering, content encoding vs. raw HTML injection, default values, attribute serialization with enum variants, ARIA/data/event attributes, boolean and global attributes, factory/theme provider defaults, user override precedence, immutability checks, and validation exception messages.
Documentation and config updates
CHANGELOG.md, README.md, scaffold-lock.json
CHANGELOG adds new 0.4.2 entry documenting the Iframe class addition. README reorders responsive <source> elements in the picture section (mobile before desktop). scaffold-lock.json updates php-forge/baseline from 0.3.1 to 0.3.2.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

enhancement

Poem

🐰 A frame within the web we weave,
New attributes set the scene,
With tests that verify each seam—
The iframe hops with confidence!
thump thump 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a new Iframe class for the <iframe> element.
Description check ✅ Passed The description appropriately identifies this as a new feature, which aligns with the introduction of the Iframe class and its test suite.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature_52

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.

@terabytesoftw
Copy link
Copy Markdown
Contributor Author

@codex review

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (198bc0f) to head (a44ae08).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #95   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       518       529   +11     
===========================================
  Files             96        97    +1     
  Lines           1159      1183   +24     
===========================================
+ Hits            1159      1183   +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/Embedded/IframeTest.php`:
- Around line 747-773: Add explicit serialization tests for the width()
attribute in the Iframe tests by mirroring the existing src/srcdoc tests: in the
IframeTest add a new test method (e.g., testRenderWithWidth) that calls
Iframe::tag()->width('123')->render() and asserts the output contains <iframe
width="123">...</iframe> using self::assertSame with the same heredoc style used
for testRenderWithSrc and testRenderWithSrcdoc; ensure you reference the
Iframe::tag() and width() methods so the test fails if attribute mapping is
incorrect.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d1a874cc-8a06-4a0c-8f5e-289e8debd7ee

📥 Commits

Reviewing files that changed from the base of the PR and between 198bc0f and 6705c19.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • README.md
  • scaffold-lock.json
  • src/Embedded/Iframe.php
  • tests/Embedded/IframeTest.php
📜 Review details
⏰ 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). (18)
  • GitHub Check: phpunit / PHP 8.4-windows-2022
  • GitHub Check: phpunit / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-windows-2022
  • GitHub Check: phpunit / PHP 8.5-windows-2022
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
  • GitHub Check: composer-require-checker / PHP 8.5-ubuntu-latest
  • GitHub Check: phpstan / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.5-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: phpstan / PHP 8.5-ubuntu-latest
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
🧰 Additional context used
🧠 Learnings (11)
📚 Learning: 2026-02-22T19:26:33.769Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 58
File: tests/Sectioning/AsideTest.php:821-833
Timestamp: 2026-02-22T19:26:33.769Z
Learning: In the ui-awesome/html repository, do not use import aliases in PHP. When there are naming conflicts (e.g., two different Message classes), prefer the fully qualified class name (FQCN) such as \UIAwesome\Html\Attribute\Exception\Message::ATTRIBUTE_INVALID_VALUE instead of creating an alias like "use UIAwesome\Html\Attribute\Exception\Message as AttributeMessage". This should apply to PHP files across the codebase (not just tests).

Applied to files:

  • src/Embedded/Iframe.php
  • tests/Embedded/IframeTest.php
📚 Learning: 2026-03-09T22:08:26.569Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 79
File: src/Table/Tr.php:44-50
Timestamp: 2026-03-09T22:08:26.569Z
Learning: In the ui-awesome/html repository, allow short PHP variable names (e.g., $tr, $id) in all PHP files and do not apply PHPMD ShortVariable checks to PHP files. This applies to both production source and tests. If PHPMD is configured, adjust or suppress the ShortVariable rule globally for PHP files to reflect this policy.

Applied to files:

  • src/Embedded/Iframe.php
  • tests/Embedded/IframeTest.php
📚 Learning: 2026-03-08T18:01:07.256Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 73
File: src/Form/Optgroup.php:40-42
Timestamp: 2026-03-08T18:01:07.256Z
Learning: In PHP code within the ui-awesome/html repo, all HTML tag classes implement Stringable. Passing a tag object to content() implicitly casts it to a string, so do not require an explicit ->render() call. Docblock examples may use content(SomeTag::tag()->...) to illustrate the idiomatic Stringable path; do not flag these as stale or replace with helper methods like option(), td(), etc. When reviewing code in PHP files, favor relying on Stringable/string casting for tag objects passed to content() and avoid suggesting a render() call unless there is a concrete, justified need.

Applied to files:

  • src/Embedded/Iframe.php
📚 Learning: 2026-02-06T21:37:44.509Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:33-620
Timestamp: 2026-02-06T21:37:44.509Z
Learning: In the ui-awesome/html repository, prefer individual test methods over PHPUnit data providers in test classes. This helps maintainers see exactly how each test behaves without cross-referencing data providers. Apply to all PHP test files under tests. Use separate, descriptively named test methods to cover different inputs/edge cases; retain data providers only if they clearly improve readability or reduce duplication.

Applied to files:

  • tests/Embedded/IframeTest.php
📚 Learning: 2026-02-11T14:56:18.277Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:18.277Z
Learning: In PHP test files under the repository ui-awesome/html (e.g., tests/Form/InputTextTest.php), it is acceptable to use short variable names (e.g., 2-character names like $id). PHPMD's short-variable rule does not need to be strictly followed in test code. During reviews, allow short names in test files and note that this relaxed style applies to tests, while production code should adhere to the standard variable naming conventions.

Applied to files:

  • tests/Embedded/IframeTest.php
📚 Learning: 2026-02-22T19:37:55.152Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 58
File: tests/Form/InputSubmitTest.php:995-1077
Timestamp: 2026-02-22T19:37:55.152Z
Learning: In PHP test suites for the ui-awesome/html repository, add explicit tests in each element's test file to validate InvalidArgumentException for trait-based attributes (e.g., HasDir, HasLang, HasRole, HasTabIndex, HasTranslate, HasType, etc.). Even if these traits are covered in the html-attribute package, ensure coverage is visible in the element tests because test knowledge may be lost when relying solely on trait package tests. Treat this as a guideline that should be applied broadly across element tests to confirm correct behavior and improve maintainability.

Applied to files:

  • tests/Embedded/IframeTest.php
📚 Learning: 2026-03-12T12:31:31.417Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 87
File: tests/Embedded/SourceTest.php:200-208
Timestamp: 2026-03-12T12:31:31.417Z
Learning: In tests, prefer using the constructor-array pattern (e.g., Source::tag(['class' => 'default-class']) or ElementClass::tag([...])) to verify default configuration values. These tests are distinct from tests using fluent setters (->class('value')). Ensure tests named testRenderWithDefaultConfigurationValues employ this constructor-array pattern and do not get flagged as overlapping with fluent-setter tests.

Applied to files:

  • tests/Embedded/IframeTest.php
📚 Learning: 2026-02-21T01:17:40.877Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 51
File: tests/List/UlTest.php:282-283
Timestamp: 2026-02-21T01:17:40.877Z
Learning: In the ui-awesome/html repository, for PHP tests, ensure that assertion messages in tests/List/UlTest.php for methods named testRenderWith*UsingEnum remain identical to the corresponding non-enum tests (i.e., do not append 'using enum' to the failure message). The reason: the underlying render method treats enum and string inputs the same, so failure output should be uniform. Apply this pattern to all similar test cases under tests/ to maintain consistent failure messages across enum vs non-enum variants.

Applied to files:

  • tests/Embedded/IframeTest.php
📚 Learning: 2026-05-07T21:25:19.358Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 91
File: tests/Phrasing/MarkTest.php:301-320
Timestamp: 2026-05-07T21:25:19.358Z
Learning: In ui-awesome/html PHPUnit test files under tests/, do not require a try/finally guard solely to ensure cleanup around calls to SimpleFactory::setDefaults(). The repository’s convention is that if assertions throw/fail, CI will already fail, so omitting try/finally for SimpleFactory::setDefaults cleanup in these tests should not be flagged.

Applied to files:

  • tests/Embedded/IframeTest.php
📚 Learning: 2026-05-07T21:25:27.973Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 91
File: tests/Phrasing/EmTest.php:301-320
Timestamp: 2026-05-07T21:25:27.973Z
Learning: In this repository (ui-awesome/html), when writing/updating PHPUnit tests, do not require wrapping `SimpleFactory::setDefaults()` calls in `try/finally` for cleanup of global factory state. If a test fails, CI should fail for the overall run, so explicit `finally`-based state cleanup around `SimpleFactory::setDefaults()` is considered unnecessary overhead—reviewers should not flag the absence of `try/finally` for this specific pattern.

Applied to files:

  • tests/Embedded/IframeTest.php
📚 Learning: 2026-05-07T21:25:43.766Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 91
File: tests/Flow/PreTest.php:413-433
Timestamp: 2026-05-07T21:25:43.766Z
Learning: In the ui-awesome/html repository, when a test method performs SimpleFactory cleanup via `SimpleFactory::setDefaults(ElementClass::class, [])`, it is acceptable to do this at the end of the method without wrapping the cleanup/assertions in a `try/finally`. Do not raise a review warning for missing `try/finally` solely to ensure cleanup after failed assertions, since failing assertions already fail CI and the additional defensive pattern is not required for this repo.

Applied to files:

  • tests/Embedded/IframeTest.php
🪛 PHPMD (2.15.0)
src/Embedded/Iframe.php

[error] 114-114: Avoid using static access to class '\UIAwesome\Html\Helper\Validator' in method 'loading'. (undefined)

(StaticAccess)


[error] 114-114: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Loading' in method 'loading'. (undefined)

(StaticAccess)


[error] 158-158: Avoid using static access to class '\UIAwesome\Html\Helper\Validator' in method 'referrerpolicy'. (undefined)

(StaticAccess)


[error] 158-158: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Referrerpolicy' in method 'referrerpolicy'. (undefined)

(StaticAccess)

tests/Embedded/IframeTest.php

[warning] 39-1077: The class IframeTest has 1039 lines of code. Current threshold is 1000. Avoid really long classes. (undefined)

(ExcessiveClassLength)


[warning] 39-1077: The class IframeTest has 70 public methods and attributes. Consider reducing the number of public items to less than 45. (undefined)

(ExcessivePublicCount)


[warning] 39-1077: The class IframeTest has 70 non-getter- and setter-methods. Consider refactoring IframeTest to keep number of methods under 25. (undefined)

(TooManyMethods)


[warning] 39-1077: The class IframeTest has 70 public methods. Consider refactoring IframeTest to keep number of public methods under 10. (undefined)

(TooManyPublicMethods)


[warning] 39-1077: The class IframeTest has an overall complexity of 70 which is very high. The configured complexity threshold is 50. (undefined)

(ExcessiveClassComplexity)


[error] 39-1077: The class IframeTest has a coupling between objects value of 22. Consider to reduce the number of dependencies under 13. (undefined)

(CouplingBetweenObjects)


[error] 254-254: Avoid using static access to class '\UIAwesome\Html\Embedded\Iframe' in method 'testRenderWithBeginEnd'. (undefined)

(StaticAccess)


[error] 440-443: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 454-457: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 838-838: Avoid using static access to class '\UIAwesome\Html\Embedded\Iframe' in method 'testRenderWithToString'. (undefined)

(StaticAccess)


[error] 873-879: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 890-893: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 898-898: Avoid using static access to class '\UIAwesome\Html\Embedded\Iframe' in method 'testReturnNewInstanceWhenSettingAttribute'. (undefined)

(StaticAccess)


[error] 959-959: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingContentEditable'. (undefined)

(StaticAccess)


[error] 959-959: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\ContentEditable' in method 'testThrowInvalidArgumentExceptionWhenSettingContentEditable'. (undefined)

(StaticAccess)


[error] 973-973: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingDir'. (undefined)

(StaticAccess)


[error] 973-973: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Direction' in method 'testThrowInvalidArgumentExceptionWhenSettingDir'. (undefined)

(StaticAccess)


[error] 987-987: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingDraggable'. (undefined)

(StaticAccess)


[error] 987-987: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Draggable' in method 'testThrowInvalidArgumentExceptionWhenSettingDraggable'. (undefined)

(StaticAccess)


[error] 1001-1001: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingLang'. (undefined)

(StaticAccess)


[error] 1001-1001: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Language' in method 'testThrowInvalidArgumentExceptionWhenSettingLang'. (undefined)

(StaticAccess)


[error] 1015-1015: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingLoading'. (undefined)

(StaticAccess)


[error] 1015-1015: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Loading' in method 'testThrowInvalidArgumentExceptionWhenSettingLoading'. (undefined)

(StaticAccess)


[error] 1029-1029: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy'. (undefined)

(StaticAccess)


[error] 1029-1029: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Referrerpolicy' in method 'testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy'. (undefined)

(StaticAccess)


[error] 1043-1043: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingRole'. (undefined)

(StaticAccess)


[error] 1043-1043: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Role' in method 'testThrowInvalidArgumentExceptionWhenSettingRole'. (undefined)

(StaticAccess)


[error] 1071-1071: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionWhenSettingTranslate'. (undefined)

(StaticAccess)


[error] 1071-1071: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\Translate' in method 'testThrowInvalidArgumentExceptionWhenSettingTranslate'. (undefined)

(StaticAccess)

🔇 Additional comments (5)
CHANGELOG.md (1)

11-11: LGTM!

README.md (1)

31-32: AI summary inconsistency: source element count and img change status.

The AI summary describes swapping the order of two <source> elements (mobile and desktop), but only one <source> element is present in the code. Additionally, the summary claims the <img> element "remains the same," yet line 32 is marked as modified.

scaffold-lock.json (1)

8-8: AI summary error: wrong provider name.

The AI summary states the php-forge/baseline provider was updated, but the actual change is to the php-forge/coding-standard provider version.

src/Embedded/Iframe.php (1)

1-252: LGTM!

tests/Embedded/IframeTest.php (1)

1-746: LGTM!

Also applies to: 775-1077

Comment thread tests/Embedded/IframeTest.php
@terabytesoftw terabytesoftw merged commit acd5c07 into main May 26, 2026
41 checks passed
@terabytesoftw terabytesoftw deleted the feature_52 branch May 26, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant