static, ?
-, - COP ( ). , TemplateParser::parse_template . , (: )? , PHP 5.3 , , - . static .
-, . . :
interface ParserInterface
{
public function parse_template($template_file);
}
interface ReplacerInterface
{
}
class Parser implements ParserInterface
{
private $replacer;
public function __construct(ReplacerInterface $replacer)
{
$this->replacer = $replacer;
}
public function parse_template($template_file)
{
$specials = array_filter(function($method) {
return strpos($method, "replace_") === 0;
}, get_class_methods($this->replacer));
foreach ($specials as $method) {
$this->replacer->$method($template_file);
}
}
}
Injection Dependency wiki, , , - static.