Skip to content

Commit 262fe8e

Browse files
committed
Fix tests
1 parent 63955d7 commit 262fe8e

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ matrix:
1010
- php: 7.1
1111
- php: 7.2
1212
env: UPDATE_COVERAGE=1
13-
- php: 7.3
1413
- php: nightly
1514
fast_finish: true
1615
before_script:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"bin": ["bin/diffFilter"],
2121
"require": {
22-
"php": ">=5.5",
22+
"php": ">=7.0",
2323
"ext-xmlreader": "*",
2424
"ext-json": "*",
2525
"nikic/php-parser": "^3.1||^4.0"

src/Loaders/PhpStan.php

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

4+
use Exception;
45
use exussum12\CoverageChecker\FileChecker;
56
use ReflectionFunction;
67
use ReflectionFunctionAbstract;
@@ -144,12 +145,16 @@ protected function handleRelatedError($filename, $line, $error)
144145
$line
145146
);
146147

147-
$reflection = $this->getReflector($matches);
148-
if ($reflection && ($filename = $reflection->getFileName())) {
148+
try {
149+
$reflection = $this->getReflector($matches);
150+
$filename = $reflection->getFileName();
149151
$currentLine = $reflection->getStartLine();
152+
150153
while ($currentLine < $reflection->getEndLine()) {
151154
$this->addError($filename, $currentLine++, $error);
152155
}
156+
} catch (Exception $exception) {
157+
// can't find any more info about this method, so just carry on
153158
}
154159
}
155160
}
@@ -167,7 +172,7 @@ protected function addError($filename, $lineNumber, $error)
167172
$this->invalidLines[$filename][$lineNumber][] = $error;
168173
}
169174

170-
protected function getReflector(array $matches): ReflectionFunctionAbstract
175+
protected function getReflector(array $matches): ReflectionFunctionAbstract
171176
{
172177
if ($matches['class']) {
173178
return $this->getClassReflector($matches);
@@ -176,31 +181,28 @@ protected function getReflector(array $matches): ReflectionFunctionAbstract
176181
return $this->getFunctionReflector($matches);
177182
}
178183

179-
private function appendError($filename, $lineNumber, $error)
184+
private function appendError(string $filename, int $lineNumber, string $error)
180185
{
181186
end($this->invalidLines[$filename][$lineNumber]);
182187
$key = key($this->invalidLines[$filename][$lineNumber]);
183188
$this->invalidLines[$filename][$lineNumber][$key] .= ' ' . $error;
184189
}
185190

186-
protected function getClassReflector(array $matches)
191+
protected function getClassReflector(array $matches): ReflectionMethod
187192
{
188193
if (!method_exists($matches['class'], $matches['function'])) {
189-
return false;
194+
throw new Exception("Missing class function");
190195
}
191196
return new ReflectionMethod(
192197
$matches['class'],
193198
$matches['function']
194199
);
195200
}
196201

197-
/**
198-
* @return bool|ReflectionFunction
199-
*/
200-
protected function getFunctionReflector(array $matches)
202+
protected function getFunctionReflector(array $matches): ReflectionFunction
201203
{
202204
if (!function_exists($matches['function'])) {
203-
return false;
205+
throw new Exception("Missing function reflector");
204206
}
205207
return new ReflectionFunction(
206208
$matches['function']

0 commit comments

Comments
 (0)