Skip to content

Commit 65341ec

Browse files
committed
Fixed output format for methods.
1 parent f4f977e commit 65341ec

File tree

2 files changed

+51
-52
lines changed

2 files changed

+51
-52
lines changed

src/CheckerCommand.php

+45-46
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
124124
$fileCountLength = strlen((string)$totalFiles);
125125

126126
if ($this->verbose) {
127-
$output->writeln('');
128-
$output->writeln('PHP Docblock Checker <fg=blue>by Dan Cryer (https://www.dancryer.com)</>');
127+
$output->writeln('<fg=blue>PHPDoc Checker</>');
129128
$output->writeln('');
130129
}
131130

@@ -179,7 +178,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
179178
}
180179

181180
if ($error['type'] == 'method') {
182-
$this->output->write('Method <info>' . $error['method'] . '</info> is missing a docblock.');
181+
$this->output->write('Method <info>' . $error['class'] . '::' . $error['method'] . '</info> is missing a docblock.');
183182
}
184183

185184
$this->output->writeln('');
@@ -191,19 +190,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
191190
$this->output->write('<fg=yellow>WARNING </> ');
192191

193192
if ($error['type'] == 'param-missing') {
194-
$this->output->write('<info>' . $error['method'] . '</info> - @param <fg=blue>'.$error['param'] . '</> missing.');
193+
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @param <fg=blue>'.$error['param'] . '</> missing.');
195194
}
196195

197196
if ($error['type'] == 'param-mismatch') {
198-
$this->output->write('<info>' . $error['method'] . '</info> - @param <fg=blue>'.$error['param'] . '</> ('.$error['doc-type'].') does not match method signature ('.$error['param-type'].').');
197+
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @param <fg=blue>'.$error['param'] . '</> ('.$error['doc-type'].') does not match method signature ('.$error['param-type'].').');
199198
}
200199

201200
if ($error['type'] == 'return-missing') {
202-
$this->output->write('<info>' . $error['method'] . '</info> - @return missing.');
201+
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @return missing.');
203202
}
204203

205204
if ($error['type'] == 'return-mismatch') {
206-
$this->output->write('<info>' . $error['method'] . '</info> - @return <fg=blue>'.$error['doc-type'] . '</> does not match method signature ('.$error['return-type'].').');
205+
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @return <fg=blue>'.$error['doc-type'] . '</> does not match method signature ('.$error['return-type'].').');
207206
}
208207

209208
$this->output->writeln('');
@@ -267,10 +266,10 @@ protected function processFile($file)
267266
if (is_null($class['docblock'])) {
268267
$errors = true;
269268
$this->errors[] = [
270-
'type' => 'class',
271-
'file' => $file,
272-
'class' => $name,
273-
'line' => $class['line'],
269+
'type' => 'class',
270+
'file' => $file,
271+
'class' => $class['name'],
272+
'line' => $class['line'],
274273
];
275274
}
276275
}
@@ -281,11 +280,11 @@ protected function processFile($file)
281280
if (is_null($method['docblock'])) {
282281
$errors = true;
283282
$this->errors[] = [
284-
'type' => 'method',
285-
'file' => $file,
286-
'class' => $name,
287-
'method' => $name,
288-
'line' => $method['line'],
283+
'type' => 'method',
284+
'file' => $file,
285+
'class' => $method['class'],
286+
'method' => $method['name'],
287+
'line' => $method['line'],
289288
];
290289
}
291290
}
@@ -298,27 +297,27 @@ protected function processFile($file)
298297
if (!isset($method['docblock']['params'][$param])) {
299298
$warnings = true;
300299
$this->warnings[] = [
301-
'type' => 'param-missing',
302-
'file' => $file,
303-
'class' => $name,
304-
'method' => $name,
305-
'line' => $method['line'],
306-
'param' => $param,
300+
'type' => 'param-missing',
301+
'file' => $file,
302+
'class' => $method['class'],
303+
'method' => $method['name'],
304+
'line' => $method['line'],
305+
'param' => $param,
307306
];
308307
} elseif (!empty($type) && $method['docblock']['params'][$param] != $type) {
309308
if ($type == 'array' && substr($method['docblock']['params'][$param], -2) == '[]') {
310309
// Do nothing because this is fine.
311310
} else {
312311
$warnings = true;
313312
$this->warnings[] = [
314-
'type' => 'param-mismatch',
315-
'file' => $file,
316-
'class' => $name,
317-
'method' => $name,
318-
'line' => $method['line'],
319-
'param' => $param,
313+
'type' => 'param-mismatch',
314+
'file' => $file,
315+
'class' => $method['class'],
316+
'method' => $method['name'],
317+
'line' => $method['line'],
318+
'param' => $param,
320319
'param-type' => $type,
321-
'doc-type' => $method['docblock']['params'][$param],
320+
'doc-type' => $method['docblock']['params'][$param],
322321
];
323322
}
324323
}
@@ -330,25 +329,25 @@ protected function processFile($file)
330329
if (empty($method['docblock']['return'])) {
331330
$warnings = true;
332331
$this->warnings[] = [
333-
'type' => 'return-missing',
334-
'file' => $file,
335-
'class' => $name,
336-
'method' => $name,
337-
'line' => $method['line'],
332+
'type' => 'return-missing',
333+
'file' => $file,
334+
'class' => $method['class'],
335+
'method' => $method['name'],
336+
'line' => $method['line'],
338337
];
339338
} elseif (is_array($method['return'])) {
340339
$docblockTypes = explode('|', $method['docblock']['return']);
341340
sort($docblockTypes);
342341
if ($method['return'] != $docblockTypes) {
343342
$warnings = true;
344343
$this->warnings[] = [
345-
'type' => 'return-mismatch',
346-
'file' => $file,
347-
'class' => $name,
348-
'method' => $name,
349-
'line' => $method['line'],
344+
'type' => 'return-mismatch',
345+
'file' => $file,
346+
'class' => $method['class'],
347+
'method' => $method['name'],
348+
'line' => $method['line'],
350349
'return-type' => implode('|', $method['return']),
351-
'doc-type' => $method['docblock']['return'],
350+
'doc-type' => $method['docblock']['return'],
352351
];
353352
}
354353
} elseif ($method['docblock']['return'] != $method['return']) {
@@ -357,13 +356,13 @@ protected function processFile($file)
357356
} else {
358357
$warnings = true;
359358
$this->warnings[] = [
360-
'type' => 'return-mismatch',
361-
'file' => $file,
362-
'class' => $name,
363-
'method' => $name,
364-
'line' => $method['line'],
359+
'type' => 'return-mismatch',
360+
'file' => $file,
361+
'class' => $method['class'],
362+
'method' => $method['name'],
363+
'line' => $method['line'],
365364
'return-type' => $method['return'],
366-
'doc-type' => $method['docblock']['return'],
365+
'doc-type' => $method['docblock']['return'],
367366
];
368367
}
369368
}

src/FileProcessor.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ protected function processStatements(array $statements, $prefix = '')
114114
}
115115

116116
$thisMethod = [
117-
'file' => $this->file,
118-
'class' => $fullClassName,
119-
'name' => $fullMethodName,
120-
'line' => $method->getAttribute('startLine'),
121-
'return' => $type,
122-
'params' => [],
117+
'file' => $this->file,
118+
'class' => $fullClassName,
119+
'name' => (string)$method->name,
120+
'line' => $method->getAttribute('startLine'),
121+
'return' => $type,
122+
'params' => [],
123123
'docblock' => $this->getDocblock($method, $uses),
124124
];
125125

0 commit comments

Comments
 (0)