mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 12:24:49 +01:00
Add phpunit psalm plugin
This commit is contained in:
parent
3ba2510096
commit
46cbd0de8d
@ -46,7 +46,8 @@
|
||||
"phpunit/phpunit": "^6.0 || ^7.0",
|
||||
"squizlabs/php_codesniffer": "^3.0",
|
||||
"php-coveralls/php-coveralls": "^2.0",
|
||||
"bamarni/composer-bin-plugin": "^1.2"
|
||||
"bamarni/composer-bin-plugin": "^1.2",
|
||||
"psalm/plugin-phpunit": "dev-master"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-igbinary": "^2.0.5"
|
||||
|
134
psalm.xml.dist
134
psalm.xml.dist
@ -1,168 +1,158 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
name="Psalm for Psalm"
|
||||
useDocblockTypes="true"
|
||||
totallyTyped="true"
|
||||
strictBinaryOperands="false"
|
||||
rememberPropertyAssignmentsAfterCall="true"
|
||||
checkForThrowsDocblock="false"
|
||||
throwExceptionOnError="0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config config.xsd"
|
||||
>
|
||||
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" name="Psalm for Psalm" useDocblockTypes="true" totallyTyped="true" strictBinaryOperands="false" rememberPropertyAssignmentsAfterCall="true" checkForThrowsDocblock="false" throwExceptionOnError="0" xsi:schemaLocation="https://getpsalm.org/schema/config config.xsd">
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
<directory name="tests" />
|
||||
<directory name="examples" />
|
||||
<directory name="src"/>
|
||||
<directory name="tests"/>
|
||||
<directory name="examples"/>
|
||||
<ignoreFiles>
|
||||
<file name="src/Psalm/Internal/CallMap.php" />
|
||||
<directory name="src/Psalm/Internal/Stubs" />
|
||||
<directory name="tests/stubs" />
|
||||
<directory name="tests/DummyProject" />
|
||||
<file name="vendor/phpunit/phpunit/src/Framework/TestCase.php" />
|
||||
<file name="src/Psalm/Internal/Traverser/CustomTraverser.php" />
|
||||
<directory name="tests/performance/a.test" />
|
||||
<directory name="tests/performance/b.test" />
|
||||
<file name="tests/ErrorBaselineTest.php" />
|
||||
<file name="src/Psalm/Internal/CallMap.php"/>
|
||||
<directory name="src/Psalm/Internal/Stubs"/>
|
||||
<directory name="tests/stubs"/>
|
||||
<directory name="tests/DummyProject"/>
|
||||
<file name="vendor/phpunit/phpunit/src/Framework/TestCase.php"/>
|
||||
<file name="src/Psalm/Internal/Traverser/CustomTraverser.php"/>
|
||||
<directory name="tests/performance/a.test"/>
|
||||
<directory name="tests/performance/b.test"/>
|
||||
<file name="tests/ErrorBaselineTest.php"/>
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
|
||||
<ignoreExceptions>
|
||||
<class name="UnexpectedValueException" />
|
||||
<class name="InvalidArgumentException" />
|
||||
<class name="LogicException" />
|
||||
<class name="UnexpectedValueException"/>
|
||||
<class name="InvalidArgumentException"/>
|
||||
<class name="LogicException"/>
|
||||
</ignoreExceptions>
|
||||
|
||||
<issueHandlers>
|
||||
<MisplacedRequiredParam errorLevel="suppress" />
|
||||
<PossiblyNullOperand errorLevel="suppress" />
|
||||
<MisplacedRequiredParam errorLevel="suppress"/>
|
||||
<PossiblyNullOperand errorLevel="suppress"/>
|
||||
<MissingConstructor>
|
||||
<errorLevel type="suppress">
|
||||
<file name="src/Psalm/Internal/Scanner/FunctionDocblockComment.php" />
|
||||
<file name="src/Psalm/Internal/Scanner/VarDocblockComment.php" />
|
||||
<file name="src/Psalm/Storage/FunctionLikeStorage.php" />
|
||||
<file name="src/Psalm/Storage/MethodStorage.php" />
|
||||
<file name="src/Psalm/Storage/PropertyStorage.php" />
|
||||
<file name="src/Psalm/Internal/Scanner/VarDocblockComment.php" />
|
||||
<file name="src/Psalm/Internal/Scope/SwitchScope.php" />
|
||||
<file name="src/Psalm/Internal/Scanner/FunctionDocblockComment.php"/>
|
||||
<file name="src/Psalm/Internal/Scanner/VarDocblockComment.php"/>
|
||||
<file name="src/Psalm/Storage/FunctionLikeStorage.php"/>
|
||||
<file name="src/Psalm/Storage/MethodStorage.php"/>
|
||||
<file name="src/Psalm/Storage/PropertyStorage.php"/>
|
||||
<file name="src/Psalm/Internal/Scanner/VarDocblockComment.php"/>
|
||||
<file name="src/Psalm/Internal/Scope/SwitchScope.php"/>
|
||||
</errorLevel>
|
||||
</MissingConstructor>
|
||||
<DeprecatedProperty errorLevel="suppress" />
|
||||
<DeprecatedProperty errorLevel="suppress"/>
|
||||
|
||||
<UnusedParam>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="examples" />
|
||||
<directory name="examples"/>
|
||||
</errorLevel>
|
||||
</UnusedParam>
|
||||
|
||||
<PossiblyUnusedParam>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="examples" />
|
||||
<directory name="examples"/>
|
||||
</errorLevel>
|
||||
</PossiblyUnusedParam>
|
||||
|
||||
<UnusedClass>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="examples" />
|
||||
<directory name="tests" />
|
||||
<directory name="examples"/>
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</UnusedClass>
|
||||
|
||||
<UnusedProperty>
|
||||
<errorLevel type="info">
|
||||
<file name="src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php" />
|
||||
<file name="src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php"/>
|
||||
</errorLevel>
|
||||
</UnusedProperty>
|
||||
|
||||
<PossiblyUnusedProperty>
|
||||
<errorLevel type="info">
|
||||
<file name="src/Psalm/Internal/LanguageServer/LanguageClient.php" />
|
||||
<file name="src/Psalm/Storage/FunctionLikeStorage.php" />
|
||||
<file name="src/Psalm/Type/Atomic/TNonEmptyArray.php" />
|
||||
<file name="src/Psalm/Internal/LanguageServer/LanguageClient.php"/>
|
||||
<file name="src/Psalm/Storage/FunctionLikeStorage.php"/>
|
||||
<file name="src/Psalm/Type/Atomic/TNonEmptyArray.php"/>
|
||||
</errorLevel>
|
||||
</PossiblyUnusedProperty>
|
||||
|
||||
<MissingThrowsDocblock errorLevel="info" />
|
||||
<MissingThrowsDocblock errorLevel="info"/>
|
||||
|
||||
<PossiblyUnusedMethod>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="src/Psalm/Plugin" />
|
||||
<file name="src/Psalm/Internal/LanguageServer/Client/TextDocument.php" />
|
||||
<file name="src/Psalm/Internal/LanguageServer/Server/TextDocument.php" />
|
||||
<referencedMethod name="Psalm\Codebase::getParentInterfaces" />
|
||||
<referencedMethod name="Psalm\Codebase::getMethodParams" />
|
||||
<referencedMethod name="Psalm\Codebase::getMethodReturnType" />
|
||||
<referencedMethod name="Psalm\Codebase::getMethodReturnTypeLocation" />
|
||||
<referencedMethod name="Psalm\Codebase::getDeclaringMethodId" />
|
||||
<referencedMethod name="Psalm\Codebase::getAppearingMethodId" />
|
||||
<referencedMethod name="Psalm\Codebase::getOverriddenMethodIds" />
|
||||
<referencedMethod name="Psalm\Codebase::getCasedMethodId" />
|
||||
<referencedMethod name="Psalm\Codebase::isVariadic" />
|
||||
<referencedMethod name="Psalm\Codebase::getMethodReturnsByRef" />
|
||||
<directory name="tests"/>
|
||||
<directory name="src/Psalm/Plugin"/>
|
||||
<file name="src/Psalm/Internal/LanguageServer/Client/TextDocument.php"/>
|
||||
<file name="src/Psalm/Internal/LanguageServer/Server/TextDocument.php"/>
|
||||
<referencedMethod name="Psalm\Codebase::getParentInterfaces"/>
|
||||
<referencedMethod name="Psalm\Codebase::getMethodParams"/>
|
||||
<referencedMethod name="Psalm\Codebase::getMethodReturnType"/>
|
||||
<referencedMethod name="Psalm\Codebase::getMethodReturnTypeLocation"/>
|
||||
<referencedMethod name="Psalm\Codebase::getDeclaringMethodId"/>
|
||||
<referencedMethod name="Psalm\Codebase::getAppearingMethodId"/>
|
||||
<referencedMethod name="Psalm\Codebase::getOverriddenMethodIds"/>
|
||||
<referencedMethod name="Psalm\Codebase::getCasedMethodId"/>
|
||||
<referencedMethod name="Psalm\Codebase::isVariadic"/>
|
||||
<referencedMethod name="Psalm\Codebase::getMethodReturnsByRef"/>
|
||||
</errorLevel>
|
||||
</PossiblyUnusedMethod>
|
||||
|
||||
<PropertyNotSetInConstructor>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<file name="src/Psalm/Config.php" />
|
||||
<directory name="tests"/>
|
||||
<file name="src/Psalm/Config.php"/>
|
||||
</errorLevel>
|
||||
</PropertyNotSetInConstructor>
|
||||
|
||||
<MixedArgument>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</MixedArgument>
|
||||
|
||||
<MixedOperand>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</MixedOperand>
|
||||
|
||||
<MixedPropertyFetch>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</MixedPropertyFetch>
|
||||
|
||||
<NoInterfaceProperties>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</NoInterfaceProperties>
|
||||
|
||||
<NullArrayAccess>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</NullArrayAccess>
|
||||
|
||||
<NullPropertyFetch>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</NullPropertyFetch>
|
||||
|
||||
<NullArgument>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</NullArgument>
|
||||
|
||||
<PossiblyFalseArgument>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</PossiblyFalseArgument>
|
||||
|
||||
<TypeCoercion>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="tests" />
|
||||
<directory name="tests"/>
|
||||
</errorLevel>
|
||||
</TypeCoercion>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/></plugins></psalm>
|
||||
|
@ -162,10 +162,6 @@ class FileDiffTest extends TestCase
|
||||
|
||||
$this->assertNotNull($b_doc, var_export($a_doc, true));
|
||||
|
||||
if (!$b_doc) {
|
||||
throw new \UnexpectedValueException('');
|
||||
}
|
||||
|
||||
$this->assertNotSame($a_doc, $b_doc);
|
||||
|
||||
$this->assertSame($a_doc->getLine(), $b_doc->getLine());
|
||||
|
@ -121,11 +121,6 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
|
||||
$method_symbol_location = $codebase->getSymbolLocation('somefile.php', 'B\A::foo()');
|
||||
|
||||
$this->assertNotNull($method_symbol_location);
|
||||
|
||||
if ($method_symbol_location === null) {
|
||||
throw new \UnexpectedValueException();
|
||||
}
|
||||
|
||||
$this->assertSame(10, $method_symbol_location->getLineNumber());
|
||||
$this->assertSame(21, $method_symbol_location->getColumn());
|
||||
|
||||
@ -133,11 +128,6 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
|
||||
$property_symbol_location = $codebase->getSymbolLocation('somefile.php', 'B\A::$a');
|
||||
|
||||
$this->assertNotNull($property_symbol_location);
|
||||
|
||||
if ($property_symbol_location === null) {
|
||||
throw new \UnexpectedValueException();
|
||||
}
|
||||
|
||||
$this->assertSame(6, $property_symbol_location->getLineNumber());
|
||||
$this->assertSame(31, $property_symbol_location->getColumn());
|
||||
|
||||
@ -145,11 +135,6 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
|
||||
$constant_symbol_location = $codebase->getSymbolLocation('somefile.php', 'B\A::BANANA');
|
||||
|
||||
$this->assertNotNull($constant_symbol_location);
|
||||
|
||||
if ($constant_symbol_location === null) {
|
||||
throw new \UnexpectedValueException();
|
||||
}
|
||||
|
||||
$this->assertSame(8, $constant_symbol_location->getLineNumber());
|
||||
$this->assertSame(27, $constant_symbol_location->getColumn());
|
||||
|
||||
@ -157,11 +142,6 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
|
||||
$function_symbol_location = $codebase->getSymbolLocation('somefile.php', 'B\bar()');
|
||||
|
||||
$this->assertNotNull($function_symbol_location);
|
||||
|
||||
if ($function_symbol_location === null) {
|
||||
throw new \UnexpectedValueException();
|
||||
}
|
||||
|
||||
$this->assertSame(13, $function_symbol_location->getLineNumber());
|
||||
$this->assertSame(17, $function_symbol_location->getColumn());
|
||||
}
|
||||
@ -236,30 +216,18 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
|
||||
|
||||
$this->assertNotNull($symbol_at_position);
|
||||
|
||||
if ($symbol_at_position === null) {
|
||||
throw new \UnexpectedValueException();
|
||||
}
|
||||
|
||||
$this->assertSame('type: int|null', $symbol_at_position[0]);
|
||||
|
||||
$symbol_at_position = $codebase->getReferenceAtPosition('somefile.php', new Position(12, 30));
|
||||
|
||||
$this->assertNotNull($symbol_at_position);
|
||||
|
||||
if ($symbol_at_position === null) {
|
||||
throw new \UnexpectedValueException();
|
||||
}
|
||||
|
||||
$this->assertSame('type: int', $symbol_at_position[0]);
|
||||
|
||||
$symbol_at_position = $codebase->getReferenceAtPosition('somefile.php', new Position(17, 30));
|
||||
|
||||
$this->assertNotNull($symbol_at_position);
|
||||
|
||||
if ($symbol_at_position === null) {
|
||||
throw new \UnexpectedValueException();
|
||||
}
|
||||
|
||||
$this->assertSame('type: int', $symbol_at_position[0]);
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +149,7 @@ class PsalmPluginTest extends TestCase
|
||||
* @return void
|
||||
* @dataProvider commands
|
||||
* @test
|
||||
* @psalm-suppress RedundantConditionGivenDocblockType
|
||||
*/
|
||||
public function showsHelpForCommand(string $command)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user