src/Util/Closure/Serializer.php
public static function serialize(\Closure $closure, string $type = null): string
    {
        self::$serializeType = $type;

        $serialized = Serialize::encode(new SerializableClosure($closure), $type);

        if ($serialized === null) {
            throw new \RuntimeException('The closure could not be serialized.');
        }

        return $serialized;
    }
public static function serialize(\Closure $closure, string $type = null): string
    {
        self::$serializeType = $type;

        $serialized = Serialize::encode(new SerializableClosure($closure), $type);

        if ($serialized === null) {
            throw new \RuntimeException('The closure could not be serialized.');
        }

        return $serialized;
    }
public static function serialize ( \ Closure $ closure , string $ type = null ) : string { self :: $ serializeType = $ type ; $ serialized = Serialize :: encode ( new SerializableClosure ( $ closure ) , $ type ) ; if ( $ serialized === null ) { throw new \ RuntimeException ( 'The closure could not be serialized.' ) ; } return $ serialized ; }
Takes a Closure object, decorates it with a SerializableClosure object,
then performs the serialization.

@param \Closure    $closure Closure to serialize.
@param string|null $type

@return string Serialized closure.
@throws \RuntimeException
Takes a Closure object decorates it with a SerializableClosure object then performs the serialization .