Skip to content

Commit da5763f

Browse files
committed
Merge pull request #81 from grogy/code-sniffer
Added code-sniffer into tests
2 parents 3fa4548 + 717023e commit da5763f

File tree

8 files changed

+22
-17
lines changed

8 files changed

+22
-17
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ script:
2626
- ./vendor/bin/tester -p php tests
2727
- ./parallel-lint --exclude vendor --exclude tests/examples --no-colors .
2828
- ./parallel-lint --exclude vendor --exclude tests/examples .
29+
- ./vendor/bin/phpcs --standard=phpcs-ruleset.xml -s src

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
"require-dev": {
1010
"nette/tester": "~1.3",
11-
"jakub-onderka/php-console-highlighter": "~0.3"
11+
"jakub-onderka/php-console-highlighter": "~0.3",
12+
"squizlabs/php_codesniffer": "~2.7"
1213
},
1314
"suggest": {
1415
"jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet"

phpcs-ruleset.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
5151

5252
<rule ref="Generic.Metrics.NestingLevel"/>
53-
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
5453

5554
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
5655
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>

src/JsonSerializable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

33
if (!interface_exists('JsonSerializable')) {
4-
interface JsonSerializable {
4+
interface JsonSerializable
5+
{
56
public function jsonSerialize();
67
}
78
}

src/Manager.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public function run(Settings $settings = null)
4949
$output = $this->output ?: $this->getDefaultOutput($settings);
5050

5151
$phpExecutable = PhpExecutable::getPhpExecutable($settings->phpExecutable);
52-
$translateTokens = $phpExecutable->isIsHhvmType() || $phpExecutable->getVersionId() < 50400; // From PHP version 5.4 are tokens translated by default
52+
$olderThanPhp54 = $phpExecutable->getVersionId() < 50400; // From PHP version 5.4 are tokens translated by default
53+
$translateTokens = $phpExecutable->isIsHhvmType() || $olderThanPhp54;
5354

5455
$output->writeHeader($phpExecutable->getVersionId(), $settings->parallelJobs, $phpExecutable->getHhvmVersion());
5556

@@ -68,9 +69,9 @@ public function run(Settings $settings = null)
6869
$parallelLint->setProcessCallback(function ($status, $file) use ($output) {
6970
if ($status === ParallelLint::STATUS_OK) {
7071
$output->ok();
71-
} elseif ($status === ParallelLint::STATUS_SKIP) {
72+
} else if ($status === ParallelLint::STATUS_SKIP) {
7273
$output->skip();
73-
} elseif ($status === ParallelLint::STATUS_ERROR) {
74+
} else if ($status === ParallelLint::STATUS_ERROR) {
7475
$output->error();
7576
} else {
7677
$output->fail();
@@ -155,7 +156,7 @@ protected function getFilesFromPaths(array $paths, array $extensions, array $exc
155156
foreach ($paths as $path) {
156157
if (is_file($path)) {
157158
$files[] = $path;
158-
} elseif (is_dir($path)) {
159+
} else if (is_dir($path)) {
159160
$iterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS);
160161
if (!empty($excluded)) {
161162
$iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded);

src/ParallelLint.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public function lint(array $files)
7373

7474
$skipLintProcess = new SkipLintProcess($this->phpExecutable, $files);
7575

76-
$processCallback = is_callable($this->processCallback) ? $this->processCallback : function() {};
76+
$processCallback = is_callable($this->processCallback) ? $this->processCallback : function () {
77+
};
7778

7879
/**
7980
* @var LintProcess[] $running
@@ -110,15 +111,15 @@ public function lint(array $files)
110111
if ($skipStatus === null) {
111112
$waiting[$file] = $process;
112113

113-
} elseif ($skipStatus === true) {
114+
} else if ($skipStatus === true) {
114115
$skippedFiles[] = $file;
115116
$processCallback(self::STATUS_SKIP, $file);
116117

117-
} elseif ($process->isSuccess()) {
118+
} else if ($process->isSuccess()) {
118119
$checkedFiles[] = $file;
119120
$processCallback(self::STATUS_OK, $file);
120121

121-
} elseif ($process->hasSyntaxError()) {
122+
} else if ($process->hasSyntaxError()) {
122123
$checkedFiles[] = $file;
123124
$errors[] = new SyntaxError($file, $process->getSyntaxError());
124125
$processCallback(self::STATUS_ERROR, $file);
@@ -139,15 +140,15 @@ public function lint(array $files)
139140
if ($skipStatus === null) {
140141
throw new \Exception("File $file has empty skip status. Please contact PHP Parallel Lint author.");
141142

142-
} elseif ($skipStatus === true) {
143+
} else if ($skipStatus === true) {
143144
$skippedFiles[] = $file;
144145
$processCallback(self::STATUS_SKIP, $file);
145146

146-
} elseif ($process->isSuccess()) {
147+
} else if ($process->isSuccess()) {
147148
$checkedFiles[] = $file;
148149
$processCallback(self::STATUS_OK, $file);
149150

150-
} elseif ($process->hasSyntaxError()) {
151+
} else if ($process->hasSyntaxError()) {
151152
$checkedFiles[] = $file;
152153
$errors[] = new SyntaxError($file, $process->getSyntaxError());
153154
$processCallback(self::STATUS_ERROR, $file);

src/Process/PhpProcess.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class PhpProcess extends Process
1111
*/
1212
public function __construct(PhpExecutable $phpExecutable, array $parameters = array(), $stdIn = null)
1313
{
14-
$cmdLine = escapeshellcmd($phpExecutable->getPath()) . ' ' . $this->constructParameters($parameters, $phpExecutable->isIsHhvmType());
14+
$constructedParameters = $this->constructParameters($parameters, $phpExecutable->isIsHhvmType());
15+
$cmdLine = escapeshellcmd($phpExecutable->getPath()) . ' ' . $constructedParameters;
1516
parent::__construct($cmdLine, $stdIn);
1617
}
1718

src/Process/Process.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ public function __construct($cmdLine, $stdInInput = null)
6464
*/
6565
public function isFinished()
6666
{
67-
if ($this->statusCode !== NULL) {
67+
if ($this->statusCode !== null) {
6868
return true;
6969
}
7070

7171
$status = proc_get_status($this->process);
7272

7373
if ($status['running']) {
7474
return false;
75-
} elseif ($this->statusCode === null) {
75+
} else if ($this->statusCode === null) {
7676
$this->statusCode = (int) $status['exitcode'];
7777
}
7878

0 commit comments

Comments
 (0)