Skip to content

use readonly in args of constructor, in components/ #18075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/clock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ determine the current time::
class ExpirationChecker
{
public function __construct(
private ClockInterface $clock
private readonly ClockInterface $clock
) {}

public function isExpired(DateTimeInterface $validUntil): bool
Expand Down
2 changes: 1 addition & 1 deletion components/console/logger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PSR-3 compliant logger::
class MyDependency
{
public function __construct(
private LoggerInterface $logger,
private readonly LoggerInterface $logger,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion components/http_foundation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ methods. You can inject this as a service anywhere in your application::
class UserApiNormalizer
{
public function __construct(
private UrlHelper $urlHelper,
private readonly UrlHelper $urlHelper,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions components/messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ you can create your own message sender::
class ImportantActionToEmailSender implements SenderInterface
{
public function __construct(
private MailerInterface $mailer,
private string $toEmail,
private readonly MailerInterface $mailer,
private readonly string $toEmail,
) {
}

Expand Down Expand Up @@ -284,8 +284,8 @@ do is to write your own CSV receiver::
class NewOrdersFromCsvFileReceiver implements ReceiverInterface
{
public function __construct(
private SerializerInterface $serializer,
private string $filePath,
private readonly SerializerInterface $serializer,
private readonly string $filePath,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion components/phpunit_bridge.rst
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ Consider the following example::
class Foo
{
public function __construct(
private Bar $bar,
private readonly Bar $bar,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions components/runtime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ is added in a new class implementing :class:`Symfony\\Component\\Runtime\\Runner
class ReactPHPRunner implements RunnerInterface
{
public function __construct(
private RequestHandlerInterface $application,
private int $port,
private readonly RequestHandlerInterface $application,
private readonly int $port,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion components/string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ the injected slugger is the same as the request locale::
class MyService
{
public function __construct(
private SluggerInterface $slugger,
private readonly SluggerInterface $slugger,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions components/uid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ on the configuration you defined::
class FooService
{
public function __construct(
private UuidFactory $uuidFactory,
private readonly UuidFactory $uuidFactory,
) {
}

Expand Down Expand Up @@ -358,7 +358,7 @@ Like UUIDs, ULIDs have their own factory, ``UlidFactory``, that can be used to g
class FooService
{
public function __construct(
private UlidFactory $ulidFactory,
private readonly UlidFactory $ulidFactory,
) {
}

Expand Down