1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00
psalm/tests/IfThisIsTest.php
2020-07-08 19:51:02 +00:00

93 lines
2.4 KiB
PHP

<?php
namespace Psalm\Tests;
class SelfOutTest extends TestCase
{
use Traits\ValidCodeAnalysisTestTrait;
use Traits\InvalidCodeAnalysisTestTrait;
/**
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}>
*/
public function providerValidCodeParse()
{
return [
'worksAfterConvert' => [
'<?php
interface I {
/**
* @return void
*/
public function test();
}
class F implements I
{
/**
* @psalm-self-out I
* @return void
*/
public function convert()
{
}
/**
* @psalm-if-this-is I
* @return void
*/
public function test()
{
}
}
$f = new F();
$f->convert();
$f->test();
'
]
];
}
/**
* @return array<string, array{0: string, error_message: string}>
*/
public function providerInvalidCodeParse()
{
return [
'blocksWithoutConvert' => [
'<?php
interface I {
/**
* @return void
*/
public function test();
}
class F implements I
{
/**
* @psalm-self-out I
* @return void
*/
public function convert()
{
}
/**
* @psalm-if-this-is I
* @return void
*/
public function test()
{
}
}
$f = new F();
$f->test();
',
'error_message' => 'IfThisIsMismatch'
]
];
}
}