@@ -100,73 +100,75 @@ This example shows all available events and how to use the events to create a ve
100100``` php
101101<?php
102102
103- require_once(__DIR__.'/init.php');
104103use Solarium\Core\Event\Events;
104+ use Solarium\Core\Event\PreExecuteRequest;
105+
106+ require_once(__DIR__.'/init.php');
105107
106108// this very simple plugin shows a timing for each event and display some request debug info
107109class BasicDebug extends Solarium\Core\Plugin\AbstractPlugin
108110{
109- protected $start;
110- protected $output = array() ;
111+ protected float $start;
112+ protected array $output = [] ;
111113
112114 // This method is called when the plugin is registered with the client.
113115 protected function initPluginType(): void
114116 {
115117 $this->start = microtime(true);
116118
117119 $dispatcher = $this->client->getEventDispatcher();
118- $dispatcher->addListener(Events::PRE_CREATE_REQUEST, array( $this, 'preCreateRequest') );
119- $dispatcher->addListener(Events::POST_CREATE_REQUEST, array( $this, 'postCreateRequest') );
120- $dispatcher->addListener(Events::PRE_EXECUTE_REQUEST, array( $this, 'preExecuteRequest') );
121- $dispatcher->addListener(Events::POST_EXECUTE_REQUEST, array( $this, 'postExecuteRequest') );
122- $dispatcher->addListener(Events::PRE_CREATE_RESULT, array( $this, 'preCreateResult') );
123- $dispatcher->addListener(Events::POST_CREATE_RESULT, array( $this, 'postCreateResult') );
124- $dispatcher->addListener(Events::PRE_EXECUTE, array( $this, 'preExecute') );
125- $dispatcher->addListener(Events::POST_EXECUTE, array( $this, 'postExecute') );
126- $dispatcher->addListener(Events::PRE_CREATE_QUERY, array( $this, 'preCreateQuery') );
127- $dispatcher->addListener(Events::POST_CREATE_QUERY, array( $this, 'postCreateQuery') );
120+ $dispatcher->addListener(Events::PRE_CREATE_REQUEST, [ $this, 'preCreateRequest'] );
121+ $dispatcher->addListener(Events::POST_CREATE_REQUEST, [ $this, 'postCreateRequest'] );
122+ $dispatcher->addListener(Events::PRE_EXECUTE_REQUEST, [ $this, 'preExecuteRequest'] );
123+ $dispatcher->addListener(Events::POST_EXECUTE_REQUEST, [ $this, 'postExecuteRequest'] );
124+ $dispatcher->addListener(Events::PRE_CREATE_RESULT, [ $this, 'preCreateResult'] );
125+ $dispatcher->addListener(Events::POST_CREATE_RESULT, [ $this, 'postCreateResult'] );
126+ $dispatcher->addListener(Events::PRE_EXECUTE, [ $this, 'preExecute'] );
127+ $dispatcher->addListener(Events::POST_EXECUTE, [ $this, 'postExecute'] );
128+ $dispatcher->addListener(Events::PRE_CREATE_QUERY, [ $this, 'preCreateQuery'] );
129+ $dispatcher->addListener(Events::POST_CREATE_QUERY, [ $this, 'postCreateQuery'] );
128130 }
129131
130132 // This method is called if the plugin is removed from the client.
131133 public function deinitPlugin(): void
132134 {
133135 $dispatcher = $this->client->getEventDispatcher();
134- $dispatcher->removeListener(Events::PRE_CREATE_REQUEST, array( $this, 'preCreateRequest') );
135- $dispatcher->removeListener(Events::POST_CREATE_REQUEST, array( $this, 'postCreateRequest') );
136- $dispatcher->removeListener(Events::PRE_EXECUTE_REQUEST, array( $this, 'preExecuteRequest') );
137- $dispatcher->removeListener(Events::POST_EXECUTE_REQUEST, array( $this, 'postExecuteRequest') );
138- $dispatcher->removeListener(Events::PRE_CREATE_RESULT, array( $this, 'preCreateResult') );
139- $dispatcher->removeListener(Events::POST_CREATE_RESULT, array( $this, 'postCreateResult') );
140- $dispatcher->removeListener(Events::PRE_EXECUTE, array( $this, 'preExecute') );
141- $dispatcher->removeListener(Events::POST_EXECUTE, array( $this, 'postExecute') );
142- $dispatcher->removeListener(Events::PRE_CREATE_QUERY, array( $this, 'preCreateQuery') );
143- $dispatcher->removeListener(Events::POST_CREATE_QUERY, array( $this, 'postCreateQuery') );
136+ $dispatcher->removeListener(Events::PRE_CREATE_REQUEST, [ $this, 'preCreateRequest'] );
137+ $dispatcher->removeListener(Events::POST_CREATE_REQUEST, [ $this, 'postCreateRequest'] );
138+ $dispatcher->removeListener(Events::PRE_EXECUTE_REQUEST, [ $this, 'preExecuteRequest'] );
139+ $dispatcher->removeListener(Events::POST_EXECUTE_REQUEST, [ $this, 'postExecuteRequest'] );
140+ $dispatcher->removeListener(Events::PRE_CREATE_RESULT, [ $this, 'preCreateResult'] );
141+ $dispatcher->removeListener(Events::POST_CREATE_RESULT, [ $this, 'postCreateResult'] );
142+ $dispatcher->removeListener(Events::PRE_EXECUTE, [ $this, 'preExecute'] );
143+ $dispatcher->removeListener(Events::POST_EXECUTE, [ $this, 'postExecute'] );
144+ $dispatcher->removeListener(Events::PRE_CREATE_QUERY, [ $this, 'preCreateQuery'] );
145+ $dispatcher->removeListener(Events::POST_CREATE_QUERY, [ $this, 'postCreateQuery'] );
144146 }
145147
146- protected function timer($event)
148+ protected function timer(string $event): void
147149 {
148150 $time = round(microtime(true) - $this->start, 5);
149151 $this->output[] = '['.$time.'] ' . $event;
150152 }
151153
152- public function display()
154+ public function display(): void
153155 {
154156 echo implode('<br />', $this->output);
155157 }
156158
157- public function preCreateRequest()
159+ public function preCreateRequest(): void
158160 {
159161 $this->timer('preCreateRequest');
160162 }
161163
162- public function postCreateRequest()
164+ public function postCreateRequest(): void
163165 {
164166 $this->timer('postCreateRequest');
165167 }
166168
167169 // This method uses the available param(s) (see plugin abstract class).
168170 // You can access or modify data this way.
169- public function preExecuteRequest($event)
171+ public function preExecuteRequest(PreExecuteRequest $event): void
170172 {
171173 $this->timer('preExecuteRequest');
172174
@@ -176,37 +178,37 @@ class BasicDebug extends Solarium\Core\Plugin\AbstractPlugin
176178 $this->output[] = 'Request URI: ' . $event->getRequest()->getUri();
177179 }
178180
179- public function postExecuteRequest()
181+ public function postExecuteRequest(): void
180182 {
181183 $this->timer('postExecuteRequest');
182184 }
183185
184- public function preCreateResult()
186+ public function preCreateResult(): void
185187 {
186188 $this->timer('preCreateResult');
187189 }
188190
189- public function postCreateResult()
191+ public function postCreateResult(): void
190192 {
191193 $this->timer('postCreateResult');
192194 }
193195
194- public function preExecute()
196+ public function preExecute(): void
195197 {
196198 $this->timer('preExecute');
197199 }
198200
199- public function postExecute()
201+ public function postExecute(): void
200202 {
201203 $this->timer('postExecute');
202204 }
203205
204- public function preCreateQuery()
206+ public function preCreateQuery(): void
205207 {
206208 $this->timer('preCreateResult');
207209 }
208210
209- public function postCreateQuery()
211+ public function postCreateQuery(): void
210212 {
211213 $this->timer('postCreateResult');
212214 }
@@ -252,11 +254,12 @@ The second example shows how to replace the built-in select querytype with a cus
252254``` php
253255<?php
254256
255- require_once(__DIR__.'/init.php');
256257use Solarium\Client;
257258use Solarium\Core\Plugin\AbstractPlugin;
258259use Solarium\QueryType\Select\Query\Query as Select;
259260
261+ require_once(__DIR__.'/init.php');
262+
260263// This is a custom query class that could have some customized logic
261264class MyQuery extends Select
262265{
@@ -266,7 +269,7 @@ class MyQuery extends Select
266269// this very simple plugin that modifies the default querytype mapping
267270class QueryCustomizer extends AbstractPlugin
268271{
269- public function initPlugin($client, $options)
272+ public function initPlugin($client, array $options): void
270273 {
271274 $client->registerQueryType(
272275 Client::QUERY_SELECT,
0 commit comments