private function bindApplicationEvent(ServiceDefinition $application, string $event, string $class, string $property, string $argument = null): void
    {
        $argument = $argument ? ', $'.$argument : '';
        $application->addSetup(
            sprintf(
                '?->?[] = function ($application%s = null) use ($dispatcher) { $dispatcher->dispatch(?, new %s($application%s)); }',
                $argument,
                $class,
                $argument
            ),
            [
                '@self',
                $property,
                $event,
            ]
        );
    }