public function setProtectedProperty(...$params)
    {
        if (is_string($params[0])) {
            list($className, $object, $name, $value) = $params;
        } elseif (is_object($params[0])) {
            list($object, $name, $value) = $params;
            $className = get_class($object);
        }

        /** @var string $className */
        /** @var object $object */
        /** @var string $name */
        /** @var mixed $value */

        $this->checkOnObject($object);
        $this->checkOnMemberName($name);

        $reflector = $this->getReflectionProperty($className, $name);
        $isProtected = $reflector->isProtected() || $reflector->isPrivate();

        if ($isProtected) {
            $reflector->setAccessible(true);
        }
        $reflector->setValue($object, $value);
        if ($isProtected) {
            $reflector->setAccessible(false);
        }
    }
public function setProtectedProperty(...$params)
    {
        if (is_string($params[0])) {
            list($className, $object, $name, $value) = $params;
        } elseif (is_object($params[0])) {
            list($object, $name, $value) = $params;
            $className = get_class($object);
        }

        /** @var string $className */
        /** @var object $object */
        /** @var string $name */
        /** @var mixed $value */

        $this->checkOnObject($object);
        $this->checkOnMemberName($name);

        $reflector = $this->getReflectionProperty($className, $name);
        $isProtected = $reflector->isProtected() || $reflector->isPrivate();

        if ($isProtected) {
            $reflector->setAccessible(true);
        }
        $reflector->setValue($object, $value);
        if ($isProtected) {
            $reflector->setAccessible(false);
        }
    }
public function setProtectedProperty ( ... $ params ) { if ( is_string ( $ params [ 0 ] ) ) { list ( $ className , $ object , $ name , $ value ) = $ params ; } elseif ( is_object ( $ params [ 0 ] ) ) { list ( $ object , $ name , $ value ) = $ params ; $ className = get_class ( $ object ) ; } /** @var string $className */ /** @var object $object */ /** @var string $name */ /** @var mixed $value */ $ this -> checkOnObject ( $ object ) ; $ this -> checkOnMemberName ( $ name ) ; $ reflector = $ this -> getReflectionProperty ( $ className , $ name ) ; $ isProtected = $ reflector -> isProtected ( ) || $ reflector -> isPrivate ( ) ; if ( $ isProtected ) { $ reflector -> setAccessible ( true ) ; } $ reflector -> setValue ( $ object , $ value ) ; if ( $ isProtected ) { $ reflector -> setAccessible ( false ) ; } }
Sets a protected property for the object

@param array ...$params
@throws ProtectedMembersAccessException
Sets a protected property for the object