Skip to content

Commit 6562ec5

Browse files
jrfnlgrogy
authored andcommitted
CS: various minor fixes
Fix up the issues which will be flagged by PHP-Code-Style 2.0 and explicitly ignore a couple of (non-)issues.
1 parent 217a98a commit 6562ec5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+68
-47
lines changed

bin/skip-linting.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
$stdin = fopen('php://stdin', 'r');
34
$input = stream_get_contents($stdin);
45
fclose($stdin);

src/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function run()
4444
$this->showUsage();
4545
return self::FAILED;
4646
}
47-
$manager = new Manager;
47+
$manager = new Manager();
4848
$result = $manager->run($settings);
4949
if ($settings->ignoreFails) {
5050
return $result->hasSyntaxError() ? self::WITH_ERRORS : self::SUCCESS;
@@ -112,7 +112,7 @@ private function showOptions()
112112
*/
113113
private function showVersion()
114114
{
115-
echo 'PHP Parallel Lint version ' . self::VERSION.PHP_EOL;
115+
echo 'PHP Parallel Lint version ', self::VERSION, PHP_EOL;
116116
}
117117

118118
/**

src/Blame.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint;
34

45
use ReturnTypeWillChange;
@@ -24,7 +25,7 @@ class Blame implements \JsonSerializable
2425
* which is a value of any type other than a resource.
2526
*/
2627
#[ReturnTypeWillChange]
27-
function jsonSerialize()
28+
public function jsonSerialize()
2829
{
2930
return array(
3031
'name' => $this->name,

src/Contracts/SyntaxErrorCallback.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Contracts;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError;

src/ErrorFormatter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint;
34

45
use JakubOnderka\PhpConsoleColor\ConsoleColor as OldConsoleColor;
@@ -123,7 +124,7 @@ class_exists('\PHP_Parallel_Lint\PhpConsoleHighlighter\Highlighter')
123124
$colors = new ConsoleColor();
124125
$colors->setForceStyle($this->forceColors);
125126
$highlighter = new Highlighter($colors);
126-
} else if (
127+
} elseif (
127128
class_exists('\JakubOnderka\PhpConsoleHighlighter\Highlighter')
128129
&& class_exists('\JakubOnderka\PhpConsoleColor\ConsoleColor')
129130
) {

src/Errors/ParallelLintError.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Errors;
34

45
use ReturnTypeWillChange;

src/Errors/SyntaxError.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Errors;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Blame;
@@ -121,4 +122,4 @@ public function jsonSerialize()
121122
'blame' => $this->blame,
122123
);
123124
}
124-
}
125+
}

src/Exceptions/CallbackNotImplementedException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Exceptions;
34

45
class CallbackNotImplementedException extends ParallelLintException

src/Exceptions/ClassNotFoundException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Exceptions;
34

45
class ClassNotFoundException extends ParallelLintException

src/Exceptions/InvalidArgumentException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Exceptions;
34

45
class InvalidArgumentException extends ParallelLintException

src/Exceptions/ParallelLintException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Exceptions;
34

45
use ReturnTypeWillChange;

src/Exceptions/PathNotFoundException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Exceptions;
34

45
class PathNotFoundException extends ParallelLintException

src/Exceptions/RuntimeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Exceptions;
34

45
class RuntimeException extends ParallelLintException
56
{
6-
77
}

src/Iterators/ArrayIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Iterators;
34

45
class ArrayIterator extends \ArrayIterator

src/Manager.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Contracts\SyntaxErrorCallback;
@@ -30,7 +31,7 @@ class Manager
3031
*/
3132
public function run(Settings $settings = null)
3233
{
33-
$settings = $settings ?: new Settings;
34+
$settings = $settings ?: new Settings();
3435
$output = $this->output ?: $this->getDefaultOutput($settings);
3536

3637
$phpExecutable = PhpExecutable::getPhpExecutable($settings->phpExecutable);
@@ -56,9 +57,9 @@ public function run(Settings $settings = null)
5657
$parallelLint->setProcessCallback(function ($status, $file) use ($output) {
5758
if ($status === ParallelLint::STATUS_OK) {
5859
$output->ok();
59-
} else if ($status === ParallelLint::STATUS_SKIP) {
60+
} elseif ($status === ParallelLint::STATUS_SKIP) {
6061
$output->skip();
61-
} else if ($status === ParallelLint::STATUS_ERROR) {
62+
} elseif ($status === ParallelLint::STATUS_ERROR) {
6263
$output->error();
6364
} else {
6465
$output->fail();
@@ -90,7 +91,7 @@ public function setOutput(OutputInterface $output)
9091
*/
9192
protected function getDefaultOutput(Settings $settings)
9293
{
93-
$writer = new ConsoleWriter;
94+
$writer = new ConsoleWriter();
9495
switch ($settings->format) {
9596
case Settings::FORMAT_JSON:
9697
return new JsonOutput($writer);
@@ -128,7 +129,7 @@ protected function gitBlame(Result $result, Settings $settings)
128129
$process->waitForFinish();
129130

130131
if ($process->isSuccess()) {
131-
$blame = new Blame;
132+
$blame = new Blame();
132133
$blame->name = $process->getAuthor();
133134
$blame->email = $process->getAuthorEmail();
134135
$blame->datetime = $process->getAuthorTime();
@@ -157,7 +158,7 @@ protected function getFilesFromPaths(array $paths, array $extensions, array $exc
157158
foreach ($paths as $path) {
158159
if (is_file($path)) {
159160
$files[] = $path;
160-
} else if (is_dir($path)) {
161+
} elseif (is_dir($path)) {
161162
$iterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS);
162163
if (!empty($excluded)) {
163164
$iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded);
@@ -202,7 +203,7 @@ protected function createSyntaxErrorCallback(Settings $settings)
202203
throw new ClassNotFoundException($expectedClassName, $settings->syntaxErrorCallbackFile);
203204
}
204205

205-
$callbackInstance = new $expectedClassName;
206+
$callbackInstance = new $expectedClassName();
206207

207208
if (!($callbackInstance instanceof SyntaxErrorCallback)) {
208209
throw new CallbackNotImplementedException($expectedClassName);

src/Outputs/CheckstyleOutput.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Outputs;
34

45
use PHP_Parallel_Lint\PhpParallelLint\ErrorFormatter;

src/Outputs/GitLabOutput.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Outputs;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Outputs\OutputInterface;

src/Outputs/JsonOutput.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Outputs;
34

45
use PHP_Parallel_Lint\PhpParallelLint\ErrorFormatter;
@@ -29,27 +30,22 @@ public function __construct(WriterInterface $writer)
2930

3031
public function ok()
3132
{
32-
3333
}
3434

3535
public function skip()
3636
{
37-
3837
}
3938

4039
public function error()
4140
{
42-
4341
}
4442

4543
public function fail()
4644
{
47-
4845
}
4946

5047
public function setTotalFileCount($count)
5148
{
52-
5349
}
5450

5551
public function writeHeader($phpVersion, $parallelJobs, $hhvmVersion = null)

src/Outputs/OutputInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Outputs;
34

45
use PHP_Parallel_Lint\PhpParallelLint\ErrorFormatter;

src/Outputs/TextOutput.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Outputs;
34

45
use PHP_Parallel_Lint\PhpParallelLint\ErrorFormatter;
@@ -175,13 +176,13 @@ protected function writeMark($type)
175176
if ($type === self::TYPE_OK) {
176177
$this->writer->write('.');
177178

178-
} else if ($type === self::TYPE_SKIP) {
179+
} elseif ($type === self::TYPE_SKIP) {
179180
$this->write('S', self::TYPE_SKIP);
180181

181-
} else if ($type === self::TYPE_ERROR) {
182+
} elseif ($type === self::TYPE_ERROR) {
182183
$this->write('X', self::TYPE_ERROR);
183184

184-
} else if ($type === self::TYPE_FAIL) {
185+
} elseif ($type === self::TYPE_FAIL) {
185186
$this->writer->write('-');
186187
}
187188

src/Outputs/TextOutputColored.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Outputs;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Settings;
@@ -16,7 +17,7 @@ public function __construct(WriterInterface $writer, $colors = Settings::AUTODET
1617
if (class_exists('\PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor')) {
1718
$this->colors = new \PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor();
1819
$this->colors->setForceStyle($colors === Settings::FORCED);
19-
} else if (class_exists('\JakubOnderka\PhpConsoleColor\ConsoleColor')) {
20+
} elseif (class_exists('\JakubOnderka\PhpConsoleColor\ConsoleColor')) {
2021
$this->colors = new \JakubOnderka\PhpConsoleColor\ConsoleColor();
2122
$this->colors->setForceStyle($colors === Settings::FORCED);
2223
}

src/ParallelLint.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Contracts\SyntaxErrorCallback;
@@ -93,20 +94,19 @@ public function lint(array $files)
9394
if ($skipStatus === null) {
9495
$waiting[$file] = $process;
9596

96-
} else if ($skipStatus === true) {
97+
} elseif ($skipStatus === true) {
9798
$skippedFiles[] = $file;
9899
$processCallback(self::STATUS_SKIP, $file);
99100

100-
} else if ($process->containsError()) {
101+
} elseif ($process->containsError()) {
101102
$checkedFiles[] = $file;
102103
$errors[] = $this->triggerSyntaxErrorCallback(new SyntaxError($file, $process->getSyntaxError()));
103104
$processCallback(self::STATUS_ERROR, $file);
104105

105-
} else if ($process->isSuccess()) {
106+
} elseif ($process->isSuccess()) {
106107
$checkedFiles[] = $file;
107108
$processCallback(self::STATUS_OK, $file);
108109

109-
110110
} else {
111111
$errors[] = new ParallelLintError($file, $process->getOutput());
112112
$processCallback(self::STATUS_FAIL, $file);
@@ -128,15 +128,15 @@ public function lint(array $files)
128128
if ($skipStatus === null) {
129129
throw new \Exception("File $file has empty skip status. Please contact the author of PHP Parallel Lint.");
130130

131-
} else if ($skipStatus === true) {
131+
} elseif ($skipStatus === true) {
132132
$skippedFiles[] = $file;
133133
$processCallback(self::STATUS_SKIP, $file);
134134

135-
} else if ($process->isSuccess()) {
135+
} elseif ($process->isSuccess()) {
136136
$checkedFiles[] = $file;
137137
$processCallback(self::STATUS_OK, $file);
138138

139-
} else if ($process->containsError()) {
139+
} elseif ($process->containsError()) {
140140
$checkedFiles[] = $file;
141141
$errors[] = $this->triggerSyntaxErrorCallback(new SyntaxError($file, $process->getSyntaxError()));
142142
$processCallback(self::STATUS_ERROR, $file);

src/Process/GitBlameProcess.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Process;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\RuntimeException;

src/Process/LintProcess.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Process;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\ParallelLintException;

src/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function isFinished()
7474

7575
if ($status['running']) {
7676
return false;
77-
} else if ($this->statusCode === null) {
77+
} elseif ($this->statusCode === null) {
7878
$this->statusCode = (int) $status['exitcode'];
7979
}
8080

src/Process/SkipLintProcess.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint\Process;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\RuntimeException;

src/Result.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpParallelLint;
34

45
use PHP_Parallel_Lint\PhpParallelLint\Errors\ParallelLintError;
@@ -159,7 +160,7 @@ public function getTestTime()
159160
* which is a value of any type other than a resource.
160161
*/
161162
#[ReturnTypeWillChange]
162-
function jsonSerialize()
163+
public function jsonSerialize()
163164
{
164165
return array(
165166
'checkedFiles' => $this->getCheckedFiles(),
@@ -168,6 +169,4 @@ function jsonSerialize()
168169
'errors' => $this->getErrors(),
169170
);
170171
}
171-
172-
173-
}
172+
}

0 commit comments

Comments
 (0)