Skip to content

Commit

Permalink
Narrow types
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jan 18, 2024
1 parent a61b489 commit 78b6f7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .psalm/baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.18.0@b113f3ed0259fd6e212d87c3df80eec95a6abf19">
<files psalm-version="5.19.1@b9583493b08eb36259c0f6b746a787c4c9b3ac45">
<file src="src/Framework/Assert.php">
<ArgumentTypeCoercion>
<code><![CDATA[$actualElement->childNodes->item($i)]]></code>
Expand Down Expand Up @@ -1210,6 +1210,14 @@
<code><![CDATA[$this->cache !== null]]></code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/Runner/Version.php">
<LessSpecificReturnStatement>
<code><![CDATA[implode('.', array_slice(explode('.', $version), 0, 2))]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code>non-empty-string</code>
</MoreSpecificReturnType>
</file>
<file src="src/TextUI/CliArguments/Builder.php">
<ArgumentTypeCoercion>
<code>$parameters</code>
Expand Down
11 changes: 11 additions & 0 deletions src/Runner/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace PHPUnit\Runner;

use function array_slice;
use function assert;
use function dirname;
use function explode;
use function implode;
Expand All @@ -33,6 +34,8 @@ final class Version

/**
* Returns the current version of PHPUnit.
*
* @psalm-return non-empty-string
*/
public static function id(): string
{
Expand All @@ -42,11 +45,16 @@ public static function id(): string

if (self::$version === '') {
self::$version = (new VersionId('9.6.15', dirname(__DIR__, 2)))->getVersion();

assert(!empty(self::$version));
}

return self::$version;
}

/**
* @psalm-return non-empty-string
*/
public static function series(): string
{
if (strpos(self::id(), '-')) {
Expand All @@ -58,6 +66,9 @@ public static function series(): string
return implode('.', array_slice(explode('.', $version), 0, 2));
}

/**
* @psalm-return non-empty-string
*/
public static function getVersionString(): string
{
return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann and contributors.';
Expand Down

0 comments on commit 78b6f7e

Please sign in to comment.