src/Utilities/Reflection.php
public static function setPropertyValue($object, $property, $value)
    {
        $reflectionProperty = self::getProperty($object, $property);

        // Oops, property does not exist
        if (null === $reflectionProperty) {
            throw NotExistingPropertyException::create($object, $property);
        }

        $isPublic = $reflectionProperty->isPublic();

        if (!$isPublic) {
            $reflectionProperty->setAccessible(true);
        }

        $reflectionProperty->setValue($object, $value);

        if (!$isPublic) {
            $reflectionProperty->setAccessible(false);
        }
    }
public static function setPropertyValue($object, $property, $value)
    {
        $reflectionProperty = self::getProperty($object, $property);

        // Oops, property does not exist
        if (null === $reflectionProperty) {
            throw NotExistingPropertyException::create($object, $property);
        }

        $isPublic = $reflectionProperty->isPublic();

        if (!$isPublic) {
            $reflectionProperty->setAccessible(true);
        }

        $reflectionProperty->setValue($object, $value);

        if (!$isPublic) {
            $reflectionProperty->setAccessible(false);
        }
    }
public static function setPropertyValue ( $ object , $ property , $ value ) { $ reflectionProperty = self :: getProperty ( $ object , $ property ) ; // Oops, property does not exist if ( null === $ reflectionProperty ) { throw NotExistingPropertyException :: create ( $ object , $ property ) ; } $ isPublic = $ reflectionProperty -> isPublic ( ) ; if ( ! $ isPublic ) { $ reflectionProperty -> setAccessible ( true ) ; } $ reflectionProperty -> setValue ( $ object , $ value ) ; if ( ! $ isPublic ) { $ reflectionProperty -> setAccessible ( false ) ; } }
Sets value of given property in given object

@param mixed  $object   Object that should contains given property
@param string $property Name of the property
@param mixed  $value    Value of the property
@throws NotExistingPropertyException
Sets value of given property in given object