Use constructor property promotion to combine declaration, visibility, and assignment: ~~~php final class UserService { public function __construct( private readonly UserRepository $repository, private readonly LoggerInterface $logger, ) { } } ~~~ Keep promoted properties typed and readonly when they represent immutable dependencies.
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-a3895dbb)
Use constructor property promotion to combine declaration, visibility, and assignment:
~~~php
final class UserService
{
public function __construct(
private readonly UserRepository $repository,
private readonly LoggerInterface $logger,
) {
}
}
~~~
Keep promoted properties typed and readonly when they represent immutable dependencies.