Constructor property promotion
Në shqip: Promovimi i vetive në konstruktor
ShpjegimiSQ
Që nga PHP 8, mund t'i deklarosh vetitë direkt te konstruktori: public function __construct(private string $emri) {}. Kursen shumë rreshta të përsëritur.
EnglishEN
Since PHP 8, you can declare properties right in the constructor: public function __construct(private string $name) {}. It saves lots of repetitive lines.
Si ta mendosh
Si të plotësosh formularin dhe dosja të krijohet vetë.
Lexoje në anglisht
Like filling in a form and the file creates itself.
Shembull kodiphp
class Nxenes {
public function __construct(
public readonly string $emri,
private int $nota = 0,
) {} }