99 * the LICENSE file that was distributed with this source code.
1010 */
1111
12+ declare (strict_types=1 );
13+
1214namespace Composer \XdebugHandler ;
1315
1416use Psr \Log \LoggerInterface ;
@@ -48,12 +50,10 @@ class Status
4850 private $ time ;
4951
5052 /**
51- * Constructor
52- *
5353 * @param string $envAllowXdebug Prefixed _ALLOW_XDEBUG name
5454 * @param bool $debug Whether debug output is required
5555 */
56- public function __construct ($ envAllowXdebug , $ debug )
56+ public function __construct (string $ envAllowXdebug , bool $ debug )
5757 {
5858 $ start = getenv (self ::ENV_RESTART );
5959 Process::setEnv (self ::ENV_RESTART );
@@ -65,25 +65,21 @@ public function __construct($envAllowXdebug, $debug)
6565 }
6666
6767 /**
68- * @param LoggerInterface $ logger
68+ * Activates status message output to a PSR3 logger
6969 *
7070 * @return void
7171 */
72- public function setLogger (LoggerInterface $ logger )
72+ public function setLogger (LoggerInterface $ logger ): void
7373 {
7474 $ this ->logger = $ logger ;
7575 }
7676
7777 /**
7878 * Calls a handler method to report a message
7979 *
80- * @param string $op The handler constant
81- * @param null|string $data Data required by the handler
82- *
83- * @return void
8480 * @throws \InvalidArgumentException If $op is not known
8581 */
86- public function report ($ op , $ data )
82+ public function report (string $ op , ? string $ data ): void
8783 {
8884 if ($ this ->logger !== null || $ this ->debug ) {
8985 $ callable = [$ this , 'report ' .$ op ];
@@ -99,13 +95,8 @@ public function report($op, $data)
9995
10096 /**
10197 * Outputs a status message
102- *
103- * @param string $text
104- * @param string $level
105- *
106- * @return void
10798 */
108- private function output ($ text , $ level = null )
99+ private function output (string $ text , ? string $ level = null ): void
109100 {
110101 if ($ this ->logger !== null ) {
111102 $ this ->logger ->log ($ level !== null ? $ level : LogLevel::DEBUG , $ text );
@@ -117,70 +108,64 @@ private function output($text, $level = null)
117108 }
118109
119110 /**
120- * @param string $loaded
121- *
122- * @return void
111+ * Checking status message
123112 */
124- private function reportCheck ($ loaded )
113+ private function reportCheck (string $ loaded ): void
125114 {
126115 list ($ version , $ mode ) = explode ('| ' , $ loaded );
127116
128117 if ($ version !== '' ) {
129- $ this ->loaded = '( ' .$ version .') ' .($ mode !== '' ? ' mode= ' .$ mode : '' );
118+ $ this ->loaded = '( ' .$ version .') ' .($ mode !== '' ? ' xdebug. mode= ' .$ mode : '' );
130119 }
131120 $ this ->modeOff = $ mode === 'off ' ;
132121 $ this ->output ('Checking ' .$ this ->envAllowXdebug );
133122 }
134123
135124 /**
136- * @param string $error
137- *
138- * @return void
125+ * Error status message
139126 */
140- private function reportError ($ error )
127+ private function reportError (string $ error ): void
141128 {
142129 $ this ->output (sprintf ('No restart (%s) ' , $ error ), LogLevel::WARNING );
143130 }
144131
145132 /**
146- * @param string $info
147- *
148- * @return void
133+ * Info status message
149134 */
150- private function reportInfo ($ info )
135+ private function reportInfo (string $ info ): void
151136 {
152137 $ this ->output ($ info );
153138 }
154139
155140 /**
156- * @return void
141+ * No restart status message
157142 */
158- private function reportNoRestart ()
143+ private function reportNoRestart (): void
159144 {
160145 $ this ->output ($ this ->getLoadedMessage ());
161146
162147 if ($ this ->loaded !== null ) {
163148 $ text = sprintf ('No restart (%s) ' , $ this ->getEnvAllow ());
164149 if (!((bool ) getenv ($ this ->envAllowXdebug ))) {
165- $ text .= ' Allowed by ' .($ this ->modeOff ? 'mode ' : 'application ' );
150+ $ text .= ' Allowed by ' .($ this ->modeOff ? 'xdebug. mode ' : 'application ' );
166151 }
167152 $ this ->output ($ text );
168153 }
169154 }
170155
171156 /**
172- * @return void
157+ * Restart status message
173158 */
174- private function reportRestart ()
159+ private function reportRestart (): void
175160 {
176161 $ this ->output ($ this ->getLoadedMessage ());
177162 Process::setEnv (self ::ENV_RESTART , (string ) microtime (true ));
178163 }
179164
180165 /**
181- * @return void
166+ * Restarted status message
182167 */
183- private function reportRestarted ()
168+ private function reportRestarted (): void
184169 {
185170 $ loaded = $ this ->getLoadedMessage ();
186171 $ text = sprintf ('Restarted (%d ms). %s ' , $ this ->time , $ loaded );
@@ -189,11 +174,9 @@ private function reportRestarted()
189174 }
190175
191176 /**
192- * @param string $command
193- *
194- * @return void
177+ * Restarting status message
195178 */
196- private function reportRestarting ($ command )
179+ private function reportRestarting (string $ command ): void
197180 {
198181 $ text = sprintf ('Process restarting (%s) ' , $ this ->getEnvAllow ());
199182 $ this ->output ($ text );
@@ -203,20 +186,16 @@ private function reportRestarting($command)
203186
204187 /**
205188 * Returns the _ALLOW_XDEBUG environment variable as name=value
206- *
207- * @return string
208189 */
209- private function getEnvAllow ()
190+ private function getEnvAllow (): string
210191 {
211192 return $ this ->envAllowXdebug .'= ' .getenv ($ this ->envAllowXdebug );
212193 }
213194
214195 /**
215196 * Returns the Xdebug status and version
216- *
217- * @return string
218197 */
219- private function getLoadedMessage ()
198+ private function getLoadedMessage (): string
220199 {
221200 $ loaded = $ this ->loaded !== null ? sprintf ('loaded %s ' , $ this ->loaded ) : 'not loaded ' ;
222201 return 'The Xdebug extension is ' .$ loaded ;
0 commit comments