mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
89 lines
2.2 KiB
PHP
89 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
|
|
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
|
|
|
|
class ExtendsFinalClassTest extends TestCase
|
|
{
|
|
use InvalidCodeAnalysisTestTrait;
|
|
use ValidCodeAnalysisTestTrait;
|
|
|
|
/**
|
|
* @return iterable<string,array{code:string,assertions?:array<string,string>,ignored_issues?:list<string>}>
|
|
*/
|
|
public function providerValidCodeParse(): iterable
|
|
{
|
|
return [
|
|
'suppressingIssueWhenUsedWithKeyword' => [
|
|
'code' => '<?php
|
|
|
|
final class A {}
|
|
|
|
/**
|
|
* @psalm-suppress InvalidExtendClass
|
|
*/
|
|
class B extends A {}'
|
|
],
|
|
'suppressingIssueWhenUsedWithAnnotation' => [
|
|
'code' => '<?php
|
|
|
|
/**
|
|
* @final
|
|
*/
|
|
class A {}
|
|
|
|
/**
|
|
* @psalm-suppress InvalidExtendClass
|
|
*/
|
|
class B extends A {}'
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return iterable<string,array{code:string,error_message:string,ignored_issues?:list<string>,php_version?:string}>
|
|
*/
|
|
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',
|
|
],
|
|
];
|
|
}
|
|
}
|