Skip to content

Commit

Permalink
Setting PHP Version in psalm
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JimTools committed Mar 4, 2024
1 parent 05dd35c commit eed49dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="false"
phpVersion="8.3"
>
<projectFiles>
<directory name="src/" />
Expand Down
8 changes: 8 additions & 0 deletions src/analyzer/Config/YamlConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand All @@ -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'])) {
Expand Down

0 comments on commit eed49dc

Please sign in to comment.