public function setMiddlewareOrFallback(string $name, $value, $middleMan, $result = null)
    {
        // asserts instead of type-hints because this is a trait and another trait uses it.
        assert($middleMan instanceof MiddlewareDispatcher);

        if (! $middleMan->groupIsEmpty('setters')) {
            $result = $middleMan->callSetters($name, $value, $result);
        } elseif (is_object($result)) {
            $result = $result->$name = $value;
        } else {
            $result = $this->setVisibleAttribute($name, $value);
        }
        return $result;
    }