Skip to content

[Serializer] Update serializer example using type hints #16876

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

Merged
merged 1 commit into from
Oct 26, 2022
Merged
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
26 changes: 13 additions & 13 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ exists in your project::

class Person
{
private $age;
private $name;
private $sportsperson;
private $createdAt;
private int $age;
private string $name;
private bool $sportsperson;
private ?\DateTime $createdAt;

// Getters
public function getName()
public function getAge(): int
{
return $this->name;
return $this->age;
}

public function getAge()
public function getName(): string
{
return $this->age;
return $this->name;
}

public function getCreatedAt()
Expand All @@ -96,28 +96,28 @@ exists in your project::
}

// Issers
public function isSportsperson()
public function isSportsperson(): bool
{
return $this->sportsperson;
}

// Setters
public function setName($name)
public function setName(string $name): void
{
$this->name = $name;
}

public function setAge($age)
public function setAge(int $age): void
{
$this->age = $age;
}

public function setSportsperson($sportsperson)
public function setSportsperson(bool $sportsperson): void
{
$this->sportsperson = $sportsperson;
}

public function setCreatedAt($createdAt)
public function setCreatedAt(\DateTime $createdAt = null): void
{
$this->createdAt = $createdAt;
}
Expand Down