test: configure vimeo/psalm to verify type inference

This is mostly to include type inference in regression tests: out-of-the
box type inference for 99% of usages is based on
`TreeMapper#map(class-string<T>, mixed): T`, and it is worth preserving
that behavior without the need of plugins.

This test covers that.
This commit is contained in:
Marco Pivetta 2022-01-11 16:20:50 +01:00 committed by Romain Canon
parent 822865876d
commit 7a49f45175
3 changed files with 37 additions and 0 deletions

14
psalm.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="tests/StaticAnalysis" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\StaticAnalysis\Stub;
final class A
{
}

View File

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\StaticAnalysis;
use CuyZ\Valinor\Mapper\TreeMapper;
use CuyZ\Valinor\Tests\StaticAnalysis\Stub\A;
/** @param mixed $input */
function mappingClassWillInferObjectOfSameType(TreeMapper $mapper, $input): A
{
return $mapper->map(A::class, $input);
}