Declare immutable constructor state with a PHP 8.1 readonly property: ~~~php final class User { public function __construct( public readonly string $id, ) { } } ~~~ A readonly property can be initialized once, so use it for values that must not change after construction.
Installs into .claude/skills of the current project.
Are you the author of Php Language?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-php-language-e0bad568)
Declare immutable constructor state with a PHP 8.1 readonly property:
~~~php
final class User
{
public function __construct(
public readonly string $id,
) {
}
}
~~~
A readonly property can be initialized once, so use it for values that must not change after construction.