Skip to content

Conversation

@Kocal
Copy link
Member

@Kocal Kocal commented Feb 2, 2026

Q A
Bug fix? no
New feature? no
Deprecations? no
Documentation? yes
Issues Fix #3328
License MIT

@Kocal Kocal self-assigned this Feb 2, 2026
@carsonbot carsonbot added Documentation Improvements or additions to documentation TwigComponent Status: Needs Review Needs to be reviewed labels Feb 2, 2026
@Kocal Kocal requested a review from Copilot February 2, 2026 22:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds documentation explaining the interaction between PHP's readonly keyword and TwigComponent's property assignment system, addressing issue #3328.

Changes:

  • Adds a new "Readonly Components and Immutability" section explaining why readonly components can cause initialization errors
  • Provides two recommended solutions: making only constructor dependencies readonly, or using the mount() method for manual property assignment

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

**Option 1: Make individual properties readonly instead of the entire class** (Recommended)::

#[AsTwigComponent]
final class UserProfile // ✅ class is not readonly
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

The spacing before the inline comment is inconsistent with line 466. Consider using consistent spacing (two spaces) before inline comments throughout the code examples.

Copilot uses AI. Check for mistakes.
@Kocal Kocal merged commit efd12ee into symfony:2.x Feb 3, 2026
2 checks passed
@Kocal Kocal deleted the gh-3328 branch February 3, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Status: Needs Review Needs to be reviewed TwigComponent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TwigComponent] Read-only components

2 participants