Most of this is pretty simple, but we'll walk through the whole thing for the sake of completeness. Starting with the inner bit
return ${ ! ${''} = (new ReflectionClass( get_called_class() ) ) }->newInstanceArgs( func_get_args() );
return ${ ! ${''} = (new ReflectionClass( 'A' ) ) }->newInstanceArgs( func_get_args() );
return ${ ! ${''} = ReflectionClass('A') }->newInstanceArgs( func_get_args() );
The next bit is the magic, ${<identifier>}
lets you access a variable with the name <identifier>
, so with ${''}
a variable with a name of '' is being accessed. Or in this case, the Reflection object is being assigned to the empty string variable. It is essentially equivilent to $GLOBALS[''] = ...
.
return $GLOBALS[ ! $GLOBALS[''] = (ReflectionClass('A')) ]->newInstanceArgs( func_get_args() );
The empty string var is then negated with !
, and since non-empty objects are truthy in PHP, it evaluates as false. Then the outer variable syntax converts the false value to a string to get a variable name, and false converts to an empty string, so the variable just created is accessed.