diff --git a/src/Collector/RequestCollector.php b/src/Collector/RequestCollector.php index 4269eb9..e2d7d9a 100644 --- a/src/Collector/RequestCollector.php +++ b/src/Collector/RequestCollector.php @@ -11,9 +11,8 @@ use function array_filter; use function array_pop; use function explode; -use function gettype; +use function get_debug_type; use function in_array; -use function is_object; use function sort; use function sprintf; @@ -58,7 +57,7 @@ public function collect(MvcEvent $mvcEvent) $vars = (array) $vars; foreach ($vars as $key => &$var) { - $var = $key . ': ' . (is_object($var) ? $var::class : gettype($var)); + $var = $key . ': ' . get_debug_type($var); } sort($vars); @@ -80,7 +79,7 @@ public function collect(MvcEvent $mvcEvent) 'controller' => $match === null ? 'N/A' : $match->getParam('controller', 'N/A'), 'other_route_parameters' => $match === null ? 'N/A' : array_filter( $match->getParams(), - static fn($key) => ! in_array($key, ['action', 'controller']), + static fn($key): bool => ! in_array($key, ['action', 'controller']), ARRAY_FILTER_USE_KEY ), ]; diff --git a/src/EventLogging/EventContextProvider.php b/src/EventLogging/EventContextProvider.php index a371ae8..a0ac3e5 100644 --- a/src/EventLogging/EventContextProvider.php +++ b/src/EventLogging/EventContextProvider.php @@ -83,10 +83,9 @@ public function getEventTarget() /** * Determines a string label to represent an event target. * - * @param mixed $target * @return string */ - private function getEventTargetAsString($target) + private function getEventTargetAsString(mixed $target) { if (is_object($target)) { return $target::class; diff --git a/src/Listener/EventLoggingListenerAggregate.php b/src/Listener/EventLoggingListenerAggregate.php index c5a3180..2396ae6 100644 --- a/src/Listener/EventLoggingListenerAggregate.php +++ b/src/Listener/EventLoggingListenerAggregate.php @@ -38,7 +38,7 @@ public function __construct(array $collectors, array $identifiers) $collectors ); $this->identifiers = array_values(array_map( - static fn($identifier) => (string) $identifier, + static fn($identifier): string => (string) $identifier, $identifiers )); } diff --git a/src/Listener/ToolbarListener.php b/src/Listener/ToolbarListener.php index d304c6d..6e6b8e6 100644 --- a/src/Listener/ToolbarListener.php +++ b/src/Listener/ToolbarListener.php @@ -27,9 +27,9 @@ use function preg_match; use function preg_replace; use function sprintf; +use function str_contains; use function str_replace; use function stripos; -use function strpos; use function time; /** @@ -53,19 +53,15 @@ class ToolbarListener implements ListenerAggregateInterface */ public const DOC_URI = 'https://docs.laminas.dev/'; - /** @var object */ - protected $renderer; - /** @var Options */ protected $options; /** - * @param object $viewRenderer + * @param object $renderer */ - public function __construct($viewRenderer, Options $options) + public function __construct(protected $renderer, Options $options) { - $this->options = $options; - $this->renderer = $viewRenderer; + $this->options = $options; } /** @@ -97,7 +93,7 @@ public function onCollected(ProfilerEvent $event) $headers = $response->getHeaders(); if ( $headers->has('Content-Type') - && false === strpos($headers->get('Content-Type')->getFieldValue(), 'html') + && ! str_contains($headers->get('Content-Type')->getFieldValue(), 'html') ) { return; } @@ -204,7 +200,7 @@ protected function renderEntries(ProfilerEvent $event) ]); $collector->setTemplate($template); $entries[] = $this->renderer->render($collector); - } catch (RuntimeException $e) { + } catch (RuntimeException) { $errors[$name] = $template; } } diff --git a/src/Module.php b/src/Module.php index e37cbbb..3bad9d6 100644 --- a/src/Module.php +++ b/src/Module.php @@ -7,6 +7,9 @@ use BjyProfiler\Db\Adapter\ProfilingAdapter; use Laminas\DeveloperTools\Collector\DbCollector; use Laminas\DeveloperTools\Listener\EventLoggingListenerAggregate; +use Laminas\DeveloperTools\Listener\ProfilerListener; +use Laminas\DeveloperTools\Listener\StorageListener; +use Laminas\DeveloperTools\Listener\ToolbarListener; use Laminas\DeveloperTools\Options; use Laminas\DeveloperTools\Profiler; use Laminas\DeveloperTools\ProfilerEvent; @@ -110,11 +113,11 @@ public function onBootstrap(EventInterface $event) $eventLoggingListener->attachShared($sem); } - $profilerListener = $sm->get(Listener\ProfilerListener::class); + $profilerListener = $sm->get(ProfilerListener::class); $profilerListener->attach($em); if ($options->isToolbarEnabled()) { - $toolbarListener = $sm->get(Listener\ToolbarListener::class); + $toolbarListener = $sm->get(ToolbarListener::class); $toolbarListener->attach($em); } @@ -175,8 +178,8 @@ public function getServiceConfig() 'ZendDeveloperTools\Config' => 'Laminas\DeveloperTools\Config', 'ZendDeveloperTools\Event' => 'Laminas\DeveloperTools\Event', 'ZendDeveloperTools\StorageListener' => 'Laminas\DeveloperTools\StorageListener', - 'ZendDeveloperTools\Listener\ToolbarListener' => Listener\ToolbarListener::class, - 'ZendDeveloperTools\Listener\ProfilerListener' => Listener\ProfilerListener::class, + 'ZendDeveloperTools\Listener\ToolbarListener' => ToolbarListener::class, + 'ZendDeveloperTools\Listener\ProfilerListener' => ProfilerListener::class, 'ZendDeveloperTools\Listener\EventLoggingListenerAggregate' => EventLoggingListenerAggregate::class, 'ZendDeveloperTools\DbCollector' => 'Laminas\DeveloperTools\DbCollector', /** phpcs:enable Generic.Files.LineLength */ @@ -208,12 +211,12 @@ public function getServiceConfig() $event->setApplication($sm->get('Application')); return $event; }, - 'Laminas\DeveloperTools\StorageListener' => static fn($sm) => new Listener\StorageListener($sm), - Listener\ToolbarListener::class => static fn($sm) => new Listener\ToolbarListener( + 'Laminas\DeveloperTools\StorageListener' => static fn($sm): StorageListener => new StorageListener($sm), + ToolbarListener::class => static fn($sm): ToolbarListener => new ToolbarListener( $sm->get('ViewRenderer'), $sm->get('Laminas\DeveloperTools\Config') ), - Listener\ProfilerListener::class => static fn($sm) => new Listener\ProfilerListener( + ProfilerListener::class => static fn($sm): ProfilerListener => new ProfilerListener( $sm, $sm->get('Laminas\DeveloperTools\Config') ), diff --git a/src/Options.php b/src/Options.php index ea98059..0527d4c 100644 --- a/src/Options.php +++ b/src/Options.php @@ -80,8 +80,6 @@ public function __construct($options, ReportInterface $report) /** * Sets Profiler options. - * - * @param array $options */ public function setProfiler(array $options) { @@ -112,8 +110,6 @@ public function setProfiler(array $options) /** * Sets Event-level profiling options. - * - * @param array $options */ public function setEvents(array $options) { @@ -185,8 +181,6 @@ public function isEnabled() /** * Sets Event-level collectors. - * - * @param array $options */ public function setEventCollectors(array $options) { @@ -211,8 +205,6 @@ public function setEventCollectors(array $options) /** * Set Event-level collectors to listen to certain event identifiers. Defaults to '*' which causes the listener to * attach to all events. - * - * @param array $options */ public function setEventIdentifiers(array $options) { @@ -314,8 +306,6 @@ public function getEventIdentifiers() /** * Sets Toolbar options. - * - * @param array $options */ public function setToolbar(array $options) {