Skip to content

Commit 26107db

Browse files
committed
Code style fixes.
1 parent 71b9d7e commit 26107db

File tree

6 files changed

+17
-70
lines changed

6 files changed

+17
-70
lines changed

src/CheckerApplication.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace PhpDocChecker;
66

@@ -20,9 +20,6 @@ class CheckerApplication extends Application
2020
{
2121
/**
2222
* Override the default command name logic and return our check command.
23-
*
24-
* @param InputInterface $input
25-
* @return string
2623
*/
2724
protected function getCommandName(InputInterface $input): string
2825
{

src/CheckerCommand.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace PhpDocChecker;
66

@@ -29,7 +29,7 @@ class CheckerCommand extends Command
2929
protected array $warnings = [];
3030

3131
protected array $exclude = [];
32-
32+
3333
protected array $files = [];
3434

3535
protected OutputInterface $output;
@@ -60,11 +60,6 @@ protected function configure(): void
6060

6161
/**
6262
* Execute the actual docblock checker.
63-
*
64-
* @param InputInterface $input
65-
* @param OutputInterface $output
66-
*
67-
* @return int
6863
*/
6964
protected function execute(InputInterface $input, OutputInterface $output): int
7065
{
@@ -92,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9287
if (!\is_null($exclude)) {
9388
$this->exclude = \array_map('trim', \explode(',', $exclude));
9489
}
95-
90+
9691
// Set up files:
9792
if (!\is_null($files)) {
9893
$this->files = \array_map('trim', \explode(',', $files));
@@ -218,7 +213,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
218213
/**
219214
* Iterate through a directory and check all of the PHP files within it.
220215
*
221-
* @param string $path
222216
* @param string[] $workList
223217
*/
224218
protected function processDirectory(string $path = '', array &$workList = []): void
@@ -232,7 +226,7 @@ protected function processDirectory(string $path = '', array &$workList = []): v
232226

233227
$itemPath = $path . $item->getFilename();
234228

235-
if (\in_array($itemPath, $this->exclude)) {
229+
if (\in_array($itemPath, $this->exclude, true)) {
236230
continue;
237231
}
238232

@@ -245,11 +239,10 @@ protected function processDirectory(string $path = '', array &$workList = []): v
245239
}
246240
}
247241
}
248-
242+
249243
/**
250244
* Iterate through the files and check them out
251245
*
252-
* @param string $path
253246
* @param string[] $files
254247
* @param string[] $workList
255248
*/
@@ -258,7 +251,7 @@ protected function processFiles(string $path = '', array $files = [], array &$wo
258251
foreach ($files as $item) {
259252
$itemPath = $path . $item;
260253

261-
if (\in_array($itemPath, $this->exclude)) {
254+
if (\in_array($itemPath, $this->exclude, true)) {
262255
continue;
263256
}
264257

@@ -271,16 +264,14 @@ protected function processFiles(string $path = '', array $files = [], array &$wo
271264
/**
272265
* Check a specific PHP file for errors.
273266
*
274-
* @param string $file
275267
*
276-
* @return array
277268
*/
278269
protected function processFile(string $file): array
279270
{
280271
$result = $this->checkerFileProcessor->processFile($file);
281272

282273
$this->errors = \array_merge($this->errors, $result['errors']);
283-
$this->warnings = \array_merge($this->warnings, $result['warnings']);;
274+
$this->warnings = \array_merge($this->warnings, $result['warnings']);
284275

285276
if (0 === \count($result['errors'])) {
286277
$this->passed += 1;

src/CheckerFileProcessor.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace PhpDocChecker;
66

@@ -48,10 +48,6 @@ public function __construct(
4848

4949
/**
5050
* Check a specific PHP file for errors.
51-
*
52-
* @param string $file
53-
*
54-
* @return array
5551
*/
5652
public function processFile(string $file): array
5753
{

src/DocBlockParser.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace PhpDocChecker;
66

@@ -95,7 +95,7 @@ protected function parseComment(string $comment): void
9595
$comment = \preg_split('/\r?\n\r?/', $comment);
9696

9797
// Trim asterisks and whitespace from the beginning and whitespace from the end of lines
98-
$comment = \array_map(function($line) {
98+
$comment = \array_map(function ($line) {
9999
return \ltrim(\rtrim($line), "* \t\n\r\0\x0B");
100100
}, $comment);
101101

@@ -106,7 +106,7 @@ protected function parseComment(string $comment): void
106106
if (self::isTagged($line)) {
107107
$b++;
108108
$blocks[] = [];
109-
} else if($b == -1) {
109+
} elseif ($b == -1) {
110110
$b = 0;
111111
$blocks[] = [];
112112
}
@@ -141,7 +141,7 @@ protected function parseComment(string $comment): void
141141
$parts
142142
);
143143

144-
if (isset($mapped['var']) && \substr( $mapped['var'], 0, 3) === '...') {
144+
if (isset($mapped['var']) && \substr($mapped['var'], 0, 3) === '...') {
145145
$mapped['var'] = substr($mapped['var'], 3);
146146
}
147147
// Store as a mapped array
@@ -158,8 +158,6 @@ protected function parseComment(string $comment): void
158158
* Whether or not a docblock contains a given @tag.
159159
*
160160
* @param string $tag The name of the @tag to check for
161-
*
162-
* @return bool
163161
*/
164162
public function hasTag(string $tag): bool
165163
{
@@ -168,10 +166,6 @@ public function hasTag(string $tag): bool
168166

169167
/**
170168
* The value of a tag
171-
*
172-
* @param String $tag
173-
*
174-
* @return array|null
175169
*/
176170
public function tag(string $tag): ?array
177171
{
@@ -181,10 +175,7 @@ public function tag(string $tag): ?array
181175
/**
182176
* The value of a tag (concatenated for multiple values)
183177
*
184-
* @param string $tag
185178
* @param string $sep The separator for concatenating
186-
*
187-
* @return string|null
188179
*/
189180
public function tagImplode(string $tag, string $sep = ' '): ?string
190181
{
@@ -194,8 +185,6 @@ public function tagImplode(string $tag, string $sep = ' '): ?string
194185
/**
195186
* The value of a tag (merged recursively)
196187
*
197-
* @param string $tag
198-
*
199188
* @return array
200189
*/
201190
public function tagMerge(string $tag): ?array
@@ -205,10 +194,6 @@ public function tagMerge(string $tag): ?array
205194

206195
/**
207196
* Whether or not a string begins with a @tag
208-
*
209-
* @param string $str
210-
*
211-
* @return bool
212197
*/
213198
public static function isTagged(string $str): bool
214199
{
@@ -217,10 +202,6 @@ public static function isTagged(string $str): bool
217202

218203
/**
219204
* The tag at the beginning of a string
220-
*
221-
* @param string $str
222-
*
223-
* @return string
224205
*/
225206
public static function strTag(string $str): string
226207
{

src/FileProcessor.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace PhpDocChecker;
66

@@ -32,8 +32,6 @@ class FileProcessor
3232

3333
/**
3434
* Load and parse a PHP file.
35-
*
36-
* @param string $file
3735
*/
3836
public function __construct(string $file)
3937
{
@@ -43,13 +41,12 @@ public function __construct(string $file)
4341
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
4442
$stmts = $parser->parse(file_get_contents($file));
4543
$this->processStatements($stmts);
46-
} catch (\Exception $ex) {}
44+
} catch (\Exception $ex) {
45+
}
4746
}
4847

4948
/**
5049
* Return a list of class details from the given PHP file.
51-
*
52-
* @return array
5350
*/
5451
public function getClasses(): array
5552
{
@@ -58,8 +55,6 @@ public function getClasses(): array
5855

5956
/**
6057
* Return a list of method details from the given PHP file.
61-
*
62-
* @return array
6358
*/
6459
public function getMethods(): array
6560
{
@@ -69,9 +64,6 @@ public function getMethods(): array
6964
/**
7065
* Looks for class definitions, and then within them method definitions, docblocks, etc.
7166
*
72-
* @param array $statements
73-
* @param string $prefix
74-
*
7567
* @return mixed
7668
*/
7769
protected function processStatements(array $statements, string $prefix = '')
@@ -197,11 +189,6 @@ protected function processStatements(array $statements, string $prefix = '')
197189

198190
/**
199191
* Find and parse a docblock for a given class or method.
200-
*
201-
* @param Stmt $stmt
202-
* @param array $uses
203-
*
204-
* @return array|null
205192
*/
206193
protected function getDocblock(Stmt $stmt, array $uses = []): ?array
207194
{
@@ -220,11 +207,6 @@ protected function getDocblock(Stmt $stmt, array $uses = []): ?array
220207

221208
/**
222209
* Use Paul Scott's docblock parser to parse a docblock, then return the relevant parts.
223-
*
224-
* @param string $text
225-
* @param array $uses
226-
*
227-
* @return array
228210
*/
229211
protected function processDocblock(string $text, array $uses = []): array
230212
{

tests/src/CheckerFileProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace Tests\PhpDocChecker;
66

0 commit comments

Comments
 (0)