mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
0261024aa6
* initial implementation of psalm-require-extends * Added @psalm-require-implements * Added shortcode for ExtensionRequirementViolation * Docs & cofig entries for @pasalm-require-{implements,extends} * Added requirement violations to issues.md
68 lines
1.7 KiB
PHP
68 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
class ExtensionRequirementTest extends TestCase
|
|
{
|
|
use Traits\ValidCodeAnalysisTestTrait;
|
|
use Traits\InvalidCodeAnalysisTestTrait;
|
|
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->addFile(
|
|
'base.php',
|
|
'<?php
|
|
namespace ExtensionRequirements\Base;
|
|
|
|
class MyBaseClass { }
|
|
'
|
|
);
|
|
|
|
$this->addFile(
|
|
'trait.php',
|
|
'<?php
|
|
namespace ExtensionRequirements\Trait;
|
|
|
|
use ExtensionRequirements\Base\MyBaseClass as MyAliasedBaseClass;
|
|
|
|
/** @psalm-require-extends MyAliasedBaseClass */
|
|
trait ImposesExtensionRequirements { }
|
|
'
|
|
);
|
|
}
|
|
|
|
public function providerValidCodeParse(): iterable
|
|
{
|
|
return [
|
|
'extendsBaseClass' => [
|
|
'<?php
|
|
use ExtensionRequirements\Base\MyBaseClass;
|
|
use ExtensionRequirements\Trait\ImposesExtensionRequirements;
|
|
|
|
class Valid extends MyBaseClass {
|
|
use ImposesExtensionRequirements;
|
|
}
|
|
'
|
|
]
|
|
];
|
|
}
|
|
|
|
public function providerInvalidCodeParse(): iterable
|
|
{
|
|
return [
|
|
'extendsBaseClass' => [
|
|
'<?php
|
|
use ExtensionRequirements\Trait\ImposesExtensionRequirements;
|
|
|
|
class Invalid {
|
|
use ImposesExtensionRequirements;
|
|
}
|
|
',
|
|
'error_message' => 'requires using class to extend'
|
|
]
|
|
];
|
|
}
|
|
}
|