protected function resolveInstancePopulation($instance, ReflectionParameter $parameter, $value)
    {

        // Check if instance is populatable and if the given value
        // is an array.
        if ($instance instanceof Populatable && is_array($value)) {
            $instance->populate($value);

            return $instance;
        }

        // If we reach this part, then we are simply going to fail.
        // It is NOT safe to continue and make assumptions on how
        // we can populate the given instance. For this reason, we
        // just throw an exception
        $message = sprintf(
            'Unable to resolve dependency for property "%s" of the type "%s"; do not know how to populate with "%s"',
            $parameter->getName(),
            $parameter->getClass()->getName(),
            var_export($value, true)
        );

        throw new BindingResolutionException($message);
    }
protected function resolveInstancePopulation($instance, ReflectionParameter $parameter, $value)
    {

        // Check if instance is populatable and if the given value
        // is an array.
        if ($instance instanceof Populatable && is_array($value)) {
            $instance->populate($value);

            return $instance;
        }

        // If we reach this part, then we are simply going to fail.
        // It is NOT safe to continue and make assumptions on how
        // we can populate the given instance. For this reason, we
        // just throw an exception
        $message = sprintf(
            'Unable to resolve dependency for property "%s" of the type "%s"; do not know how to populate with "%s"',
            $parameter->getName(),
            $parameter->getClass()->getName(),
            var_export($value, true)
        );

        throw new BindingResolutionException($message);
    }
protected function resolveInstancePopulation ( $ instance , ReflectionParameter $ parameter , $ value ) { // Check if instance is populatable and if the given value // is an array. if ( $ instance instanceof Populatable && is_array ( $ value ) ) { $ instance -> populate ( $ value ) ; return $ instance ; } // If we reach this part, then we are simply going to fail. // It is NOT safe to continue and make assumptions on how // we can populate the given instance. For this reason, we // just throw an exception $ message = sprintf ( 'Unable to resolve dependency for property "%s" of the type "%s"; do not know how to populate with "%s"' , $ parameter -> getName ( ) , $ parameter -> getClass ( ) -> getName ( ) , var_export ( $ value , true ) ) ; throw new BindingResolutionException ( $ message ) ; }
Attempts to populate instance, if possible

@param object $instance The instance that must be populated
@param ReflectionParameter $parameter Setter method's parameter reflection that requires the given instance
@param mixed $value The value to be passed to the setter method

@return mixed
@throws BindingResolutionException If the instance is not populatable and or the given value is not an
array that can be passed to the populatable instance
Attempts to populate instance if possible