diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
index e913706..a461e6a 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -117,7 +117,7 @@ jobs:
run: "composer dev:test:coverage:ci"
- name: "Publish coverage report to Codecov"
- uses: "codecov/codecov-action@v3.1.0"
+ uses: "codecov/codecov-action@v3.1.4"
unit-tests:
name: "Unit tests"
diff --git a/composer.json b/composer.json
index 38c3bcc..ca076fc 100644
--- a/composer.json
+++ b/composer.json
@@ -40,18 +40,18 @@
"php-parallel-lint/php-console-highlighter": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/extension-installer": "^1.1",
- "phpstan/phpstan": "~1.8.0",
+ "phpstan/phpstan": "^1.10.30",
"phpstan/phpstan-mockery": "^1.0",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^9.0",
- "psalm/plugin-mockery": "^0.9.1",
- "psalm/plugin-phpunit": "^0.17.0",
+ "psalm/plugin-mockery": "^1.1",
+ "psalm/plugin-phpunit": "^0.18.4",
"ramsey/coding-standard": "^2.0.3",
"ramsey/composer-repl": "^1.4",
"ramsey/conventional-commits": "^1.3",
"roave/security-advisories": "dev-latest",
"spatie/phpunit-snapshot-assertions": "^4.2",
- "vimeo/psalm": "~4.26.0"
+ "vimeo/psalm": "^5.15"
},
"suggest": {
"mdwheele/zalgo": "Zalgo commands you install mdwheele/zalgo for Zalgo pseudo-locale support!"
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
deleted file mode 100644
index ca62028..0000000
--- a/psalm-baseline.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/psalm.xml b/psalm.xml
index c3e6c03..14f84f3 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -3,8 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="1"
- cacheDirectory="./build/cache/psalm"
- errorBaseline="./psalm-baseline.xml">
+ findUnusedBaselineEntry="true"
+ findUnusedCode="false"
+ cacheDirectory="./build/cache/psalm">
diff --git a/src/Extractor/MessageExtractor.php b/src/Extractor/MessageExtractor.php
index 1954a75..4a5dbfa 100644
--- a/src/Extractor/MessageExtractor.php
+++ b/src/Extractor/MessageExtractor.php
@@ -281,8 +281,14 @@ public function __invoke(
};
}
+ /**
+ * @psalm-return Closure(DescriptorInterface):mixed
+ */
private function flattenMessage(): Closure
{
+ /**
+ * @var Closure(DescriptorInterface):mixed
+ */
return function (Descriptor $descriptor): ?Descriptor {
$message = $descriptor->getDefaultMessage();
$messageFormatParser = new MessageFormatParser((string) $message);
diff --git a/src/FormatPHP.php b/src/FormatPHP.php
index 1e1671a..e6e3aa5 100644
--- a/src/FormatPHP.php
+++ b/src/FormatPHP.php
@@ -93,7 +93,7 @@ public function formatMessage(array $descriptor, array $values = []): string
} catch (Exception\UnableToGenerateMessageIdException $exception) {
throw new Exception\InvalidArgumentException(
'The message descriptor must have an ID or default message',
- (int) $exception->getCode(),
+ $exception->getCode(),
$exception,
);
}
diff --git a/src/Icu/MessageFormat/Parser/Type/OptionSerializer.php b/src/Icu/MessageFormat/Parser/Type/OptionSerializer.php
index 187725b..03a492a 100644
--- a/src/Icu/MessageFormat/Parser/Type/OptionSerializer.php
+++ b/src/Icu/MessageFormat/Parser/Type/OptionSerializer.php
@@ -38,7 +38,6 @@ public function jsonSerialize()
$options = [];
/**
- * @var string $property
* @var scalar | mixed[] | null $value
*/
foreach (get_object_vars($this) as $property => $value) {
diff --git a/src/Intl/DateTimeFormat.php b/src/Intl/DateTimeFormat.php
index bb7f862..7ffa11d 100644
--- a/src/Intl/DateTimeFormat.php
+++ b/src/Intl/DateTimeFormat.php
@@ -33,6 +33,7 @@
use MessageFormatter as PhpMessageFormatter;
use Throwable;
+use function assert;
use function date_default_timezone_get;
use function date_default_timezone_set;
use function is_int;
@@ -192,16 +193,17 @@ public function __construct(?LocaleInterface $locale = null, ?DateTimeFormatOpti
$this->timeStyle = $options->timeStyle;
$timeZoneId = $options->timeZone ?? date_default_timezone_get();
- $this->intlTimeZone = IntlTimeZone::createTimeZone($timeZoneId);
+ $intlTimeZone = IntlTimeZone::createTimeZone($timeZoneId);
+ assert($intlTimeZone instanceof IntlTimeZone);
+ $this->intlTimeZone = $intlTimeZone;
if ($this->intlTimeZone->getID() === IntlTimeZone::getUnknown()->getID()) {
throw new InvalidArgumentException(sprintf('Unknown time zone "%s"', $timeZoneId));
}
- $this->intlCalendar = IntlCalendar::createInstance(
- $this->intlTimeZone,
- $locale->toString(),
- );
+ $intlCalendar = IntlCalendar::createInstance($this->intlTimeZone, $locale->toString());
+ assert($intlCalendar instanceof IntlCalendar);
+ $this->intlCalendar = $intlCalendar;
$this->localeName = $locale->toString();
$this->skeleton = $this->buildSkeleton($options, $locale);
diff --git a/src/Intl/MessageFormat.php b/src/Intl/MessageFormat.php
index aaede50..04761fc 100644
--- a/src/Intl/MessageFormat.php
+++ b/src/Intl/MessageFormat.php
@@ -139,6 +139,7 @@ private function applyPreprocessing(string $pattern, array &$values = []): strin
assert($parsed->val instanceof Parser\Type\ElementCollection);
+ /** @psalm-suppress InvalidArgument */
return (new Printer())->printAst($this->processAst($parsed->val, $callbacks, $valuesWithoutCallables));
}
diff --git a/src/Util/FileSystemHelper.php b/src/Util/FileSystemHelper.php
index 5990b95..3988d51 100644
--- a/src/Util/FileSystemHelper.php
+++ b/src/Util/FileSystemHelper.php
@@ -164,7 +164,7 @@ public function writeContents($file, string $contents): void
public function writeJsonContents($file, $contents): void
{
try {
- $encodedContents = (string) @json_encode($contents, self::JSON_ENCODE_FLAGS);
+ $encodedContents = @json_encode($contents, self::JSON_ENCODE_FLAGS);
} catch (JsonException $exception) {
throw new InvalidArgumentException('Unable to encode contents as JSON', 0, $exception);
}
diff --git a/src/Util/FormatHelper.php b/src/Util/FormatHelper.php
index 7729843..b05da90 100644
--- a/src/Util/FormatHelper.php
+++ b/src/Util/FormatHelper.php
@@ -188,6 +188,7 @@ public function validateReaderCallable(?callable $formatter): callable
));
}
+ /** @var ReaderCallableType */
return $formatter;
}
@@ -227,6 +228,7 @@ public function validateWriterCallable(?callable $formatter): callable
));
}
+ /** @var WriterCallableType */
return $formatter;
}
}