From eed49dca369465d3e3d7bd066760e588824b6797 Mon Sep 17 00:00:00 2001 From: James Read Date: Mon, 4 Mar 2024 23:34:55 +0800 Subject: [PATCH] Setting PHP Version in psalm Psalm is being tested with 8.3, but when infers the PHP version from the package.json it uses 7.1 package can user new langauge features but Psalm will throw errors when this happens. Setting the php version resolve the errors from beenig thrown. --- psalm.xml | 1 + src/analyzer/Config/YamlConfigProvider.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/psalm.xml b/psalm.xml index c687ab6..b96573e 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,6 +7,7 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" findUnusedBaselineEntry="true" findUnusedCode="false" + phpVersion="8.3" > diff --git a/src/analyzer/Config/YamlConfigProvider.php b/src/analyzer/Config/YamlConfigProvider.php index 2066717..985ab34 100644 --- a/src/analyzer/Config/YamlConfigProvider.php +++ b/src/analyzer/Config/YamlConfigProvider.php @@ -8,6 +8,11 @@ use Scheb\Tombstone\Core\PathNormalizer; use Symfony\Component\Yaml\Yaml; +/** + * @psalm-type SourceConfig array{root_directory: string} + * @psalm-type LogConfig array{directory: string, custom: array{file: string}} + * @psalm-type ReportConfig array{php: string, checkstyle: string, html: string} + */ class YamlConfigProvider implements ConfigProviderInterface { /** @@ -30,6 +35,9 @@ public function __construct(string $configFile) public function readConfiguration(): array { + /** + * @var array{source_code: SourceConfig, logs: LogConfig, report: ReportConfig} $config + */ $config = Yaml::parseFile($this->configFile); if (isset($config['source_code']['root_directory'])) {