придумали ли программисты в PHP
 
  
  ( new class( "Hello" )
{
    public function __construct( $str )
    {
        echo( $str );
    }
});
// Можно без скобок :
new class( "Hello" )
{
    public function __construct( $str )
    {
        echo( $str );
    }
};
// Можно с переменной:
$cl = new class( "Hello" ){
    public function __construct( $str )
    {
        echo( $str );
    }
};
var_dump( $cl );(new class {
    public function log($msg)
    {
        echo $msg;
    }
})->log("hello");class foo {
    protected $bar;
    public function bar(string $data ) {
        $this->bar = $data; 
    }
    private function baz() {
        if (isset($this->bar)) {
            // сделать что-то
        }
    }
}class Baz
{
    public function bar() {
        $this->foo();
    }
    
    public function foo() {
        $backtrace = debug_backtrace();
        $stack = array_map(
            function($el) {
                return "{$el['class']}{$el['type']}{$el['function']}";
            },
            $backtrace
        );
        var_dump($stack);
    }
}
$t = new Baz;
$t->bar();
/* array(2) {
  [0] => string(8) "Baz->foo"
  [1] => string(8) "Baz->bar"
} */ 
  
  the difference between
__FUNCTION__ and __METHOD__ as in PHP 5.0.4 is that
__FUNCTION__ returns only the name of the function
while as __METHOD__ returns the name of the class alongwith the name of the function
class trick
{
      function doit()
      {
                echo __FUNCTION__;
      }
      function doitagain()
      {
                echo __METHOD__;
      }
}
$obj=new trick();
$obj->doit();
output will be ----  doit
$obj->doitagain();
output will be ----- trick::doitagain 
  
  foo у себя в теле вызывает функцию-аргумент и возвращает результат вывода этой функции, назовём её xfunc, значит:function foo(xfunc) {
    n = 1
    return xfunc(n)
} 
  
  $dom = new \DOMDocument;
$dom->loadXML( $html );
$output = $dom->saveHTML((new \DOMXPath($dom))->query('/')->item(0));<body>
  <p>Привет!</p>
</body>BODY
  #text "\n  "
  P
    #text "Привет!"
  #text "\n"