Skip to content

Commit 63955d7

Browse files
committed
Small fixes
1 parent f964d37 commit 63955d7

File tree

10 files changed

+15
-33
lines changed

10 files changed

+15
-33
lines changed

src/ArgParser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct(array $args)
1818
public function getArg(string $name): string
1919
{
2020
if (is_numeric($name)) {
21+
$name = (int) $name;
2122
return $this->numericArg($name);
2223
}
2324

src/FileParser.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ private function handleNamespace(Namespace_ $node)
9393
}
9494
}
9595

96-
/**
97-
* @param $node
98-
*/
99-
protected function handleNode($node)
96+
protected function handleNode(Node $node)
10097
{
10198
$type = $node->getType();
10299
if ($type == 'Stmt_Namespace') {

src/Loaders/Buddy.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace exussum12\CoverageChecker\Loaders;
33

44
use exussum12\CoverageChecker\FileChecker;
5+
56
/**
67
* Class Buddy
78
* Used for parsing magic number reports from buddy

src/Loaders/PhanText.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace exussum12\CoverageChecker\Loaders;
33

44
use exussum12\CoverageChecker\FileChecker;
5+
56
/**
67
* Class PhanText
78
* Used for parsing phan text output

src/Loaders/PhpCs.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,9 @@ protected function addInvalidLine(string $file, stdClass $message)
138138
}
139139

140140
/**
141-
* @param $message
142-
* @param array $list
143141
* @return bool|string
144142
*/
145-
protected function messageStartsWith($message, array $list)
143+
protected function messageStartsWith(string $message, array $list)
146144
{
147145
foreach ($list as $item) {
148146
if (strpos($message, $item) === 0) {
@@ -154,10 +152,6 @@ protected function messageStartsWith($message, array $list)
154152

155153
protected function handleLookupError($file, $message, $error)
156154
{
157-
if ($file == '') {
158-
return;
159-
}
160-
161155
if ($error == 'Squiz.Commenting.FileComment') {
162156
$this->invalidFiles[$file][] = $message->message;
163157
}
@@ -167,7 +161,6 @@ protected function handleLookupError($file, $message, $error)
167161

168162
$this->addRangeError($file, $lookup, $message);
169163
} catch (FileNotFound $exception) {
170-
var_dump($file);
171164
error_log("Can't find file, may have missed an error");
172165
}
173166
}

src/Loaders/PhpMdStrict.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace exussum12\CoverageChecker\Loaders;
33

4-
54
/**
65
* Class PhpMdLoaderStrict
76
* Used for parsing phpmd xml output

src/Loaders/PhpStan.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ protected function getLineNumber(string $line, int $currentLineNumber)
9696
$matches = [];
9797
if (!preg_match($this->lineRegex, $line, $matches)) {
9898
if (preg_match('#^\s{3,}#', $line)) {
99-
return (int) $currentLineNumber;
99+
return $currentLineNumber;
100100
}
101101

102102
return false;
103103
}
104104

105-
return $matches['lineNumber'];
105+
return (int) $matches['lineNumber'];
106106
}
107107

108108
protected function getMessage($line)
@@ -167,11 +167,7 @@ protected function addError($filename, $lineNumber, $error)
167167
$this->invalidLines[$filename][$lineNumber][] = $error;
168168
}
169169

170-
/**
171-
* @param array $matches
172-
* @return ReflectionFunctionAbstract
173-
*/
174-
protected function getReflector($matches)
170+
protected function getReflector(array $matches): ReflectionFunctionAbstract
175171
{
176172
if ($matches['class']) {
177173
return $this->getClassReflector($matches);
@@ -187,11 +183,7 @@ private function appendError($filename, $lineNumber, $error)
187183
$this->invalidLines[$filename][$lineNumber][$key] .= ' ' . $error;
188184
}
189185

190-
/**
191-
* @param $matches
192-
* @return bool|ReflectionMethod
193-
*/
194-
protected function getClassReflector($matches)
186+
protected function getClassReflector(array $matches)
195187
{
196188
if (!method_exists($matches['class'], $matches['function'])) {
197189
return false;
@@ -203,10 +195,9 @@ protected function getClassReflector($matches)
203195
}
204196

205197
/**
206-
* @param $matches
207198
* @return bool|ReflectionFunction
208199
*/
209-
protected function getFunctionReflector($matches)
200+
protected function getFunctionReflector(array $matches)
210201
{
211202
if (!function_exists($matches['function'])) {
212203
return false;

src/Loaders/PhpUnit.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace exussum12\CoverageChecker\Loaders;
33

4-
54
/**
65
* Class PhpUnit
76
* Used for reading in a phpunit clover XML file

src/Runners/generic.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
CoverageChecker\checkCallIsCorrect($args);
1818

1919
try {
20-
$minimumPercentCovered = CoverageChecker\getMinPercent($args->getArg(3));
20+
$minimumPercentCovered = CoverageChecker\getMinPercent($args->getArg('3'));
2121
} catch (ArgumentNotFound $exception) {
2222
$minimumPercentCovered = 100;
2323
}
2424

2525
$matcher = new CoverageChecker\FileMatchers\EndsWith();
2626

2727
$diff = new CoverageChecker\DiffFileLoader(
28-
CoverageChecker\adjustForStdIn($args->getArg(1))
28+
CoverageChecker\adjustForStdIn($args->getArg('1'))
2929
);
3030

3131
try {
@@ -62,7 +62,7 @@
6262
$fileCheck = CoverageChecker\getFileChecker(
6363
$args,
6464
$checkerArray,
65-
CoverageChecker\adjustForStdIn($args->getArg(2))
65+
CoverageChecker\adjustForStdIn($args->getArg('2'))
6666
);
6767

6868
$outputArray = [

src/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ function findAutoLoader()
4040
function checkCallIsCorrect(ArgParser $args)
4141
{
4242
try {
43-
$args->getArg(1);
44-
$args->getArg(2);
43+
$args->getArg('1');
44+
$args->getArg('2');
4545
} catch (ArgumentNotFound $exception) {
4646
throw new Exception(
4747
"Missing arguments, please call with diff and check file\n" .

0 commit comments

Comments
 (0)