1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
psalm/tests/ExtendsFinalClassTest.php

83 lines
1.9 KiB
PHP
Raw Normal View History

<?php
namespace Psalm\Tests;
2021-12-04 21:55:53 +01:00
use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
class ExtendsFinalClassTest extends TestCase
{
2021-12-04 21:55:53 +01:00
use InvalidCodeAnalysisTestTrait;
use ValidCodeAnalysisTestTrait;
public function providerValidCodeParse(): iterable
{
return [
'suppressingIssueWhenUsedWithKeyword' => [
'code' => '<?php
final class A {}
/**
* @psalm-suppress InvalidExtendClass
*/
2022-12-18 17:15:15 +01:00
class B extends A {}',
],
'suppressingIssueWhenUsedWithAnnotation' => [
'code' => '<?php
/**
* @final
*/
class A {}
/**
* @psalm-suppress InvalidExtendClass
*/
2022-12-18 17:15:15 +01:00
class B extends A {}',
],
];
}
public function providerInvalidCodeParse(): iterable
{
return [
'invalidExtendsFinalClass' => [
'code' => '<?php
final class A {}
class B extends A {}',
'error_message' => 'InvalidExtendClass',
],
'invalidExtendsAnnotatedFinalClass' => [
'code' => '<?php
/**
* @final
*/
class DoctrineA {}
class DoctrineB extends DoctrineA {}',
'error_message' => 'InvalidExtendClass',
],
'invalidExtendsFinalClassAndOtherAnnotation' => [
'code' => '<?php
/**
* @something-else-no-final annotation
*/
final class DoctrineA {}
class DoctrineB extends DoctrineA {}',
'error_message' => 'InvalidExtendClass',
],
];
}
}