Skip to content

Commit 78b6f7e

Browse files
Narrow types
1 parent a61b489 commit 78b6f7e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.psalm/baseline.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.18.0@b113f3ed0259fd6e212d87c3df80eec95a6abf19">
2+
<files psalm-version="5.19.1@b9583493b08eb36259c0f6b746a787c4c9b3ac45">
33
<file src="src/Framework/Assert.php">
44
<ArgumentTypeCoercion>
55
<code><![CDATA[$actualElement->childNodes->item($i)]]></code>
@@ -1210,6 +1210,14 @@
12101210
<code><![CDATA[$this->cache !== null]]></code>
12111211
</RedundantConditionGivenDocblockType>
12121212
</file>
1213+
<file src="src/Runner/Version.php">
1214+
<LessSpecificReturnStatement>
1215+
<code><![CDATA[implode('.', array_slice(explode('.', $version), 0, 2))]]></code>
1216+
</LessSpecificReturnStatement>
1217+
<MoreSpecificReturnType>
1218+
<code>non-empty-string</code>
1219+
</MoreSpecificReturnType>
1220+
</file>
12131221
<file src="src/TextUI/CliArguments/Builder.php">
12141222
<ArgumentTypeCoercion>
12151223
<code>$parameters</code>

src/Runner/Version.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace PHPUnit\Runner;
1111

1212
use function array_slice;
13+
use function assert;
1314
use function dirname;
1415
use function explode;
1516
use function implode;
@@ -33,6 +34,8 @@ final class Version
3334

3435
/**
3536
* Returns the current version of PHPUnit.
37+
*
38+
* @psalm-return non-empty-string
3639
*/
3740
public static function id(): string
3841
{
@@ -42,11 +45,16 @@ public static function id(): string
4245

4346
if (self::$version === '') {
4447
self::$version = (new VersionId('9.6.15', dirname(__DIR__, 2)))->getVersion();
48+
49+
assert(!empty(self::$version));
4550
}
4651

4752
return self::$version;
4853
}
4954

55+
/**
56+
* @psalm-return non-empty-string
57+
*/
5058
public static function series(): string
5159
{
5260
if (strpos(self::id(), '-')) {
@@ -58,6 +66,9 @@ public static function series(): string
5866
return implode('.', array_slice(explode('.', $version), 0, 2));
5967
}
6068

69+
/**
70+
* @psalm-return non-empty-string
71+
*/
6172
public static function getVersionString(): string
6273
{
6374
return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann and contributors.';

0 commit comments

Comments
 (0)