public static function createNewInstanceWithoutConstructor(
        $className,
        array $arguments = []
    ) {
        $reflectedClass = new ReflectionClass($className);
        $newInstance = $reflectedClass->newInstanceWithoutConstructor();
        $reflectedConstructor = $reflectedClass->getConstructor();

        if (null !== $reflectedConstructor) {
            $reflectedConstructor->setAccessible(true);
            $reflectedConstructor->invokeArgs($newInstance, $arguments);
        }

        return $newInstance;
    }
public static function createNewInstanceWithoutConstructor(
        $className,
        array $arguments = []
    ) {
        $reflectedClass = new ReflectionClass($className);
        $newInstance = $reflectedClass->newInstanceWithoutConstructor();
        $reflectedConstructor = $reflectedClass->getConstructor();

        if (null !== $reflectedConstructor) {
            $reflectedConstructor->setAccessible(true);
            $reflectedConstructor->invokeArgs($newInstance, $arguments);
        }

        return $newInstance;
    }
public static function createNewInstanceWithoutConstructor ( $ className , array $ arguments = [ ] ) { $ reflectedClass = new ReflectionClass ( $ className ) ; $ newInstance = $ reflectedClass -> newInstanceWithoutConstructor ( ) ; $ reflectedConstructor = $ reflectedClass -> getConstructor ( ) ; if ( null !== $ reflectedConstructor ) { $ reflectedConstructor -> setAccessible ( true ) ; $ reflectedConstructor -> invokeArgs ( $ newInstance , $ arguments ) ; } return $ newInstance ; }
Creates a new instance of the class with the specified class name
without invoking its constructor.

The constructor is set accessible if it is not declared with `public`
visibility.

The method `createNewInstanceWithoutConstructor` accepts a variable
number of arguments which are passed to the constructor of the class.

@param string  $className The name of the class to reflect.
@param mixed[] $arguments The optional arguments to be passed to the
constructor.

@return object A new instance of the class to reflect.

@throws ReflectionException If the class with the specified class name
does not exist.
Creates a new instance of the class with the specified class name without invoking its constructor .