From b71eded9428495b960748e02554d7b8af51604ae Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Mon, 3 Aug 2020 20:51:24 +0000 Subject: [PATCH] [COMMAND] Fix ListEvents command to properly display the callable --- src/Command/ListEventsCommand.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Command/ListEventsCommand.php b/src/Command/ListEventsCommand.php index 7558450471..f2e6e149b5 100644 --- a/src/Command/ListEventsCommand.php +++ b/src/Command/ListEventsCommand.php @@ -69,9 +69,6 @@ EOF protected function execute(InputInterface $input, OutputInterface $output): int { - $io = new SymfonyStyle($input, $output); - - $options = []; $patterm = $input->getArgument('pattern') ?? 'GNUsocial.*'; $listeners = $this->dispatcher->getListeners(); $listeners = F\select($listeners, @@ -79,18 +76,24 @@ EOF return preg_match('/' . $patterm . '/', $key); }); + echo "\n"; foreach ($listeners as $event => $listener) { - echo "Event '{$event}' handled by:\n"; + echo "Event '{$event}':\n"; foreach ($listener as $c) { $r = new ReflectionFunction($c); - echo ' ' . get_class($r->getStaticVariables()['handler'][0]) . "\n"; + $m = $r->getStaticVariables()['handler']; + echo ' ' . get_class($m[0]) . '::' . $m[1] . "\n"; } + echo "\n"; } - $helper = new DescriptorHelper(); - $options['output'] = $io; - $helper->describe($io, null, $options); - + if (!$input->hasArgument('pattern')) { + $io = new SymfonyStyle($input, $output); + $options = []; + $helper = new DescriptorHelper(); + $options['output'] = $io; + $helper->describe($io, null, $options); + } return 0; } }