// *** before: ***
class Person {
private string $firstName;
private string $lastName;
public function __construct(string $firstName, string $lastName) {
$this->firstName = $firstName;
$this->lastName = $lastName;
}
public function getFullName(): string {
return $this->firstName . ' ' . $this->lastName;
}
}
echo $person->getFullName();
// *** in version 8.4: ***
class Person {
public function __construct(
public string $firstName,
public string $lastName,
) {}
public string $fullName {
get => $this->firstName . ' ' . $this->lastName;
}
}
echo $person->fullName; // reads like a plain property, computed on access