2020-06-13 06:29:59 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
|
|
|
class ExtendsFinalClassTest extends TestCase
|
|
|
|
{
|
|
|
|
use Traits\InvalidCodeAnalysisTestTrait;
|
|
|
|
use Traits\ValidCodeAnalysisTestTrait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}>
|
|
|
|
*/
|
2020-09-12 17:24:05 +02:00
|
|
|
public function providerValidCodeParse(): iterable
|
2020-06-13 06:29:59 +02:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'suppressingIssueWhenUsedWithKeyword' => [
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
final class A {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-suppress InvalidExtendClass
|
|
|
|
*/
|
|
|
|
class B extends A {}'
|
|
|
|
],
|
|
|
|
'suppressingIssueWhenUsedWithAnnotation' => [
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @final
|
|
|
|
*/
|
|
|
|
class A {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @psalm-suppress InvalidExtendClass
|
|
|
|
*/
|
|
|
|
class B extends A {}'
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-20 02:44:44 +01:00
|
|
|
* @return iterable<string,array{string,error_message:string,1?:string[],2?:bool,3?:string}>
|
2020-06-13 06:29:59 +02:00
|
|
|
*/
|
2020-09-12 17:24:05 +02:00
|
|
|
public function providerInvalidCodeParse(): iterable
|
2020-06-13 06:29:59 +02:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'invalidExtendsFinalClass' => [
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
final class A {}
|
|
|
|
|
|
|
|
class B extends A {}',
|
|
|
|
|
|
|
|
'error_message' => 'InvalidExtendClass',
|
|
|
|
],
|
|
|
|
|
|
|
|
'invalidExtendsAnnotatedFinalClass' => [
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @final
|
|
|
|
*/
|
|
|
|
class DoctrineA {}
|
|
|
|
|
|
|
|
class DoctrineB extends DoctrineA {}',
|
|
|
|
|
|
|
|
'error_message' => 'InvalidExtendClass',
|
|
|
|
],
|
|
|
|
|
|
|
|
'invalidExtendsFinalClassAndOtherAnnotation' => [
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @something-else-no-final annotation
|
|
|
|
*/
|
|
|
|
final class DoctrineA {}
|
|
|
|
|
|
|
|
class DoctrineB extends DoctrineA {}',
|
|
|
|
|
|
|
|
'error_message' => 'InvalidExtendClass',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|