PHP ( ) . PHP 5.5, YourClass::class, .
php, ( calss) :
<?php
$obj = new YourClass();
$clazz = get_class($obj);
?>
, :
<?php
class YourClass {
public static function getClassName() {
return get_called_class();
}
?>
, :
<?php
function do_somthing($arg1, $clazz) {
$clazz::someStaticMethod($arg1);
}
?>
<?php
function do_somthing($arg1, $clazz) {
call_user_func(array($clazz, 'someStaticMethod')), $arg1);
}
?>
, :
<?php
function do_somthing($arg1, $clazz) {
$obj = new $clazz();
$obj->someNonStaticMethod();
}
?>
.. PHP :
<?php
function do_somthing($arg1, MyInterface $clazz) {
$obj = new $clazz();
$obj->someInterfaceMethod();
}
?>