phpstorm.dev

PHP ecosystem insights

PHP knowledge

Versioned PHP knowledge with primary sources and explicit verification dates.

Source checks through 2026-10-14 · 56 sources

Verified 2026-10-12 Permanent entry

Readonly property default values (PHP 8.6)

From PHP 8.1, when readonly properties were introduced, through PHP 8.5, a readonly property cannot declare an explicit default value; the compiler rejects it. The Readonly Property Defaults RFC removes that restriction for instance readonly properties, including the implicitly readonly properties of a readonly class. No new syntax is added. Default values follow the same rules as for other properties.

Status and versions

Event Evidence
RFC version 1.0, dated 2026-07-04 RFC page
Vote passed 24 yes, 0 no, 5 abstain (2/3 majority needed); the poll is closed RFC page
Merged to php-src on 2026-08-11 (commit a2640ae, PR #22588) php-src commit
Listed under PHP 8.6 New Features → Core in UPGRADING on the PHP-8.6 branch php-src UPGRADING, read 2026-10-12

A GitHub comparison shows the commit is already in the php-8.6.0RC1 tag. As of 12 October 2026, PHP 8.6 has reached release candidates but is not generally available, so no stable PHP release has this behavior yet. The RFC lists no backward-incompatible changes.

Behavior described by the RFC

The RFC's main argument is interface properties (PHP 8.4). A readonly property with a default satisfies a get-only ({ get; }) interface property but not one that also requires set. This lets a class provide fixed values for such an interface without assigning them in the constructor.

Limitations

Related