Skip to content

Commit

Permalink
Use PHP8 typed properties
Browse files Browse the repository at this point in the history
Use property type
  • Loading branch information
GromNaN authored Feb 12, 2025
1 parent 72f0db4 commit 1cb130d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion core/dto.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints as Assert;
final class UserResetPasswordDto
{
#[Assert\Email]
public $email;
public string $email;
}
```

Expand Down
5 changes: 1 addition & 4 deletions core/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ use Symfony\Component\Mailer\MailerInterface;

final class BookMailSubscriber implements EventSubscriberInterface
{
private $mailer;

public function __construct(MailerInterface $mailer)
public function __construct(private MailerInterface $mailer)
{
$this->mailer = $mailer;
}

public static function getSubscribedEvents()
Expand Down
10 changes: 2 additions & 8 deletions core/identifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ use App\Uuid;
#[ApiResource(provider: PersonProvider::class)]
final class Person
{
/**
* @var Uuid
*/
#[ApiProperty(identifier: true)]
public $code;
public Uuid $code;

// ...
}
Expand Down Expand Up @@ -214,12 +211,9 @@ final class Person
#[ApiProperty(identifier: false)]
private ?int $id = null;

/**
* @var Uuid
*/
#[ORM\Column(type: 'uuid', unique: true)]
#[ApiProperty(identifier: true)]
public $code;
public Uuid $code;

// ...
}
Expand Down
16 changes: 6 additions & 10 deletions core/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,10 @@ use Symfony\Component\Serializer\Annotation\Groups;
class Person
{
#[Groups('person')]
public $name;
public string $name;
/**
* @var Person
*/
#[Groups('person')]
public $parent; // Note that a Person instance has a relation with another Person.
public ?Person $parent; // Note that a Person instance has a relation with another Person.
// ...
}
Expand Down Expand Up @@ -607,7 +604,7 @@ class Person
#[Groups('person')]
#[ApiProperty(readableLink: false, writableLink: false)]
public Person $parent; // This property is now serialized/deserialized as an IRI.
public ?Person $parent; // This property is now serialized/deserialized as an IRI.
// ...
}
Expand Down Expand Up @@ -808,9 +805,8 @@ class Greeting
#[Groups("greeting:collection:get")]
private ?int $id = null;
private $a = 1;
private $b = 2;
private int $a = 1;
private int $b = 2;
#[ORM\Column]
#[Groups("greeting:collection:get")]
Expand Down Expand Up @@ -1182,7 +1178,7 @@ class Book
// ...
#[ApiProperty(identifier: true)]
private $id;
private ?int $id;
/**
* This field can be managed only by an admin
Expand Down

0 comments on commit 1cb130d

Please sign in to comment.