Signatur
static::method(); new static();
Beschreibung
Wichtig bei Vererbung: self:: ist "compile-time", static:: ist "run-time".
Rückgabewert
Typ
void
Beispiele
Factory-Pattern
<?php
class Model {
public static function create(): static {
return new static();
}
}
class User extends Model {}
$u = User::create(); // User-Instanz, nicht Model