|
28 | 28 | use function is_numeric; |
29 | 29 | use function is_string; |
30 | 30 |
|
| 31 | +/** @api */ |
31 | 32 | class Module extends BaseModule |
32 | 33 | { |
33 | 34 | /** @var array<string,string> */ |
@@ -144,6 +145,10 @@ public function runPsalmOn(string $filename, array $options = []): void |
144 | 145 | public function runPsalmIn(string $dir, array $options = []): void |
145 | 146 | { |
146 | 147 | $pwd = getcwd(); |
| 148 | + if (false === $pwd) { |
| 149 | + throw new TestRuntimeException('Failed to get current working directory'); |
| 150 | + } |
| 151 | + |
147 | 152 | $this->fs()->amInPath($dir); |
148 | 153 |
|
149 | 154 | $config = $this->psalmConfig ?: self::DEFAULT_PSALM_CONFIG; |
@@ -197,7 +202,11 @@ public function seeThisError(string $type, string $message): void |
197 | 202 | private function matches(string $expected, string $actual): bool |
198 | 203 | { |
199 | 204 | $regexpDelimiter = '/'; |
200 | | - if ($expected[0] === $regexpDelimiter && $expected[strlen($expected) - 1] === $regexpDelimiter) { |
| 205 | + if ( |
| 206 | + $expected !== '' |
| 207 | + && $expected[0] === $regexpDelimiter |
| 208 | + && $expected[strlen($expected) - 1] === $regexpDelimiter |
| 209 | + ) { |
201 | 210 | $regexp = $expected; |
202 | 211 | } else { |
203 | 212 | $regexp = $this->convertToRegexp($expected); |
@@ -319,6 +328,10 @@ public function runPsalmWithTaintAnalysis(): void |
319 | 328 | public function runPsalmOnASingleFile(string $file): void |
320 | 329 | { |
321 | 330 | $pwd = getcwd(); |
| 331 | + if (false === $pwd) { |
| 332 | + throw new TestRuntimeException('Failed to get current working directory'); |
| 333 | + } |
| 334 | + |
322 | 335 | $this->fs()->amInPath($this->getDefaultDirectory()); |
323 | 336 |
|
324 | 337 | $config = $this->psalmConfig ?: self::DEFAULT_PSALM_CONFIG; |
@@ -473,6 +486,7 @@ public function haveADependencySatisfied(string $package, string $versionConstra |
473 | 486 | throw new SkippedTestError("This scenario requires $package to match $versionConstraint"); |
474 | 487 | } |
475 | 488 |
|
| 489 | + /** @return non-empty-string */ |
476 | 490 | private function convertToRegexp(string $in): string |
477 | 491 | { |
478 | 492 | return '@' . str_replace('%', '.*', preg_quote($in, '@')) . '@'; |
@@ -552,7 +566,7 @@ private function parseErrors(): void |
552 | 566 | return; |
553 | 567 | } |
554 | 568 |
|
555 | | - if (empty($this->output)) { |
| 569 | + if ($this->output === null || $this->output === '') { |
556 | 570 | $this->errors = []; |
557 | 571 | return; |
558 | 572 | } |
|
0 commit comments