The keyword static is similar to self, except, that it related to a class which calls a method and do not related to a class which contains a call.
<?php
abstract class Drink {
private $category;
public function __construct() {
$this->category = static::getCategory();
}
public static function create() {
return new static();
}
public static function getCategory() {
return 'default';
}
}
class Water extends Drink {}
class Beer extends Drink {
public static function getCategory() {
return 'alcohol';
}
}
class CraftBeer extends Beer {}
print_r(Water::create()); // Water Object([category:Drink:private] => default)
print_r(CraftBeer::create()); // CraftBeer Object([category:Drink:private] => alcohol)