protected static function rejectFunction(self &$target)
    {
        return function ($reason = null) use (&$target) {
            if ($target !== null) {
                $target->reject($reason);
                $target = null;
            }
        };
    }