mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +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",
|
"phpunit/phpunit": "^6.0 || ^7.0",
|
||||||
"squizlabs/php_codesniffer": "^3.0",
|
"squizlabs/php_codesniffer": "^3.0",
|
||||||
"php-coveralls/php-coveralls": "^2.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": {
|
"suggest": {
|
||||||
"ext-igbinary": "^2.0.5"
|
"ext-igbinary": "^2.0.5"
|
||||||
|
134
psalm.xml.dist
134
psalm.xml.dist
@ -1,168 +1,158 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<psalm
|
<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">
|
||||||
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"
|
|
||||||
>
|
|
||||||
<projectFiles>
|
<projectFiles>
|
||||||
<directory name="src" />
|
<directory name="src"/>
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
<directory name="examples" />
|
<directory name="examples"/>
|
||||||
<ignoreFiles>
|
<ignoreFiles>
|
||||||
<file name="src/Psalm/Internal/CallMap.php" />
|
<file name="src/Psalm/Internal/CallMap.php"/>
|
||||||
<directory name="src/Psalm/Internal/Stubs" />
|
<directory name="src/Psalm/Internal/Stubs"/>
|
||||||
<directory name="tests/stubs" />
|
<directory name="tests/stubs"/>
|
||||||
<directory name="tests/DummyProject" />
|
<directory name="tests/DummyProject"/>
|
||||||
<file name="vendor/phpunit/phpunit/src/Framework/TestCase.php" />
|
<file name="vendor/phpunit/phpunit/src/Framework/TestCase.php"/>
|
||||||
<file name="src/Psalm/Internal/Traverser/CustomTraverser.php" />
|
<file name="src/Psalm/Internal/Traverser/CustomTraverser.php"/>
|
||||||
<directory name="tests/performance/a.test" />
|
<directory name="tests/performance/a.test"/>
|
||||||
<directory name="tests/performance/b.test" />
|
<directory name="tests/performance/b.test"/>
|
||||||
<file name="tests/ErrorBaselineTest.php" />
|
<file name="tests/ErrorBaselineTest.php"/>
|
||||||
</ignoreFiles>
|
</ignoreFiles>
|
||||||
</projectFiles>
|
</projectFiles>
|
||||||
|
|
||||||
<ignoreExceptions>
|
<ignoreExceptions>
|
||||||
<class name="UnexpectedValueException" />
|
<class name="UnexpectedValueException"/>
|
||||||
<class name="InvalidArgumentException" />
|
<class name="InvalidArgumentException"/>
|
||||||
<class name="LogicException" />
|
<class name="LogicException"/>
|
||||||
</ignoreExceptions>
|
</ignoreExceptions>
|
||||||
|
|
||||||
<issueHandlers>
|
<issueHandlers>
|
||||||
<MisplacedRequiredParam errorLevel="suppress" />
|
<MisplacedRequiredParam errorLevel="suppress"/>
|
||||||
<PossiblyNullOperand errorLevel="suppress" />
|
<PossiblyNullOperand errorLevel="suppress"/>
|
||||||
<MissingConstructor>
|
<MissingConstructor>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<file name="src/Psalm/Internal/Scanner/FunctionDocblockComment.php" />
|
<file name="src/Psalm/Internal/Scanner/FunctionDocblockComment.php"/>
|
||||||
<file name="src/Psalm/Internal/Scanner/VarDocblockComment.php" />
|
<file name="src/Psalm/Internal/Scanner/VarDocblockComment.php"/>
|
||||||
<file name="src/Psalm/Storage/FunctionLikeStorage.php" />
|
<file name="src/Psalm/Storage/FunctionLikeStorage.php"/>
|
||||||
<file name="src/Psalm/Storage/MethodStorage.php" />
|
<file name="src/Psalm/Storage/MethodStorage.php"/>
|
||||||
<file name="src/Psalm/Storage/PropertyStorage.php" />
|
<file name="src/Psalm/Storage/PropertyStorage.php"/>
|
||||||
<file name="src/Psalm/Internal/Scanner/VarDocblockComment.php" />
|
<file name="src/Psalm/Internal/Scanner/VarDocblockComment.php"/>
|
||||||
<file name="src/Psalm/Internal/Scope/SwitchScope.php" />
|
<file name="src/Psalm/Internal/Scope/SwitchScope.php"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</MissingConstructor>
|
</MissingConstructor>
|
||||||
<DeprecatedProperty errorLevel="suppress" />
|
<DeprecatedProperty errorLevel="suppress"/>
|
||||||
|
|
||||||
<UnusedParam>
|
<UnusedParam>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="examples" />
|
<directory name="examples"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</UnusedParam>
|
</UnusedParam>
|
||||||
|
|
||||||
<PossiblyUnusedParam>
|
<PossiblyUnusedParam>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="examples" />
|
<directory name="examples"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</PossiblyUnusedParam>
|
</PossiblyUnusedParam>
|
||||||
|
|
||||||
<UnusedClass>
|
<UnusedClass>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="examples" />
|
<directory name="examples"/>
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</UnusedClass>
|
</UnusedClass>
|
||||||
|
|
||||||
<UnusedProperty>
|
<UnusedProperty>
|
||||||
<errorLevel type="info">
|
<errorLevel type="info">
|
||||||
<file name="src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php" />
|
<file name="src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</UnusedProperty>
|
</UnusedProperty>
|
||||||
|
|
||||||
<PossiblyUnusedProperty>
|
<PossiblyUnusedProperty>
|
||||||
<errorLevel type="info">
|
<errorLevel type="info">
|
||||||
<file name="src/Psalm/Internal/LanguageServer/LanguageClient.php" />
|
<file name="src/Psalm/Internal/LanguageServer/LanguageClient.php"/>
|
||||||
<file name="src/Psalm/Storage/FunctionLikeStorage.php" />
|
<file name="src/Psalm/Storage/FunctionLikeStorage.php"/>
|
||||||
<file name="src/Psalm/Type/Atomic/TNonEmptyArray.php" />
|
<file name="src/Psalm/Type/Atomic/TNonEmptyArray.php"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</PossiblyUnusedProperty>
|
</PossiblyUnusedProperty>
|
||||||
|
|
||||||
<MissingThrowsDocblock errorLevel="info" />
|
<MissingThrowsDocblock errorLevel="info"/>
|
||||||
|
|
||||||
<PossiblyUnusedMethod>
|
<PossiblyUnusedMethod>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
<directory name="src/Psalm/Plugin" />
|
<directory name="src/Psalm/Plugin"/>
|
||||||
<file name="src/Psalm/Internal/LanguageServer/Client/TextDocument.php" />
|
<file name="src/Psalm/Internal/LanguageServer/Client/TextDocument.php"/>
|
||||||
<file name="src/Psalm/Internal/LanguageServer/Server/TextDocument.php" />
|
<file name="src/Psalm/Internal/LanguageServer/Server/TextDocument.php"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getParentInterfaces" />
|
<referencedMethod name="Psalm\Codebase::getParentInterfaces"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getMethodParams" />
|
<referencedMethod name="Psalm\Codebase::getMethodParams"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getMethodReturnType" />
|
<referencedMethod name="Psalm\Codebase::getMethodReturnType"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getMethodReturnTypeLocation" />
|
<referencedMethod name="Psalm\Codebase::getMethodReturnTypeLocation"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getDeclaringMethodId" />
|
<referencedMethod name="Psalm\Codebase::getDeclaringMethodId"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getAppearingMethodId" />
|
<referencedMethod name="Psalm\Codebase::getAppearingMethodId"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getOverriddenMethodIds" />
|
<referencedMethod name="Psalm\Codebase::getOverriddenMethodIds"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getCasedMethodId" />
|
<referencedMethod name="Psalm\Codebase::getCasedMethodId"/>
|
||||||
<referencedMethod name="Psalm\Codebase::isVariadic" />
|
<referencedMethod name="Psalm\Codebase::isVariadic"/>
|
||||||
<referencedMethod name="Psalm\Codebase::getMethodReturnsByRef" />
|
<referencedMethod name="Psalm\Codebase::getMethodReturnsByRef"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</PossiblyUnusedMethod>
|
</PossiblyUnusedMethod>
|
||||||
|
|
||||||
<PropertyNotSetInConstructor>
|
<PropertyNotSetInConstructor>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
<file name="src/Psalm/Config.php" />
|
<file name="src/Psalm/Config.php"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</PropertyNotSetInConstructor>
|
</PropertyNotSetInConstructor>
|
||||||
|
|
||||||
<MixedArgument>
|
<MixedArgument>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</MixedArgument>
|
</MixedArgument>
|
||||||
|
|
||||||
<MixedOperand>
|
<MixedOperand>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</MixedOperand>
|
</MixedOperand>
|
||||||
|
|
||||||
<MixedPropertyFetch>
|
<MixedPropertyFetch>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</MixedPropertyFetch>
|
</MixedPropertyFetch>
|
||||||
|
|
||||||
<NoInterfaceProperties>
|
<NoInterfaceProperties>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</NoInterfaceProperties>
|
</NoInterfaceProperties>
|
||||||
|
|
||||||
<NullArrayAccess>
|
<NullArrayAccess>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</NullArrayAccess>
|
</NullArrayAccess>
|
||||||
|
|
||||||
<NullPropertyFetch>
|
<NullPropertyFetch>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</NullPropertyFetch>
|
</NullPropertyFetch>
|
||||||
|
|
||||||
<NullArgument>
|
<NullArgument>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</NullArgument>
|
</NullArgument>
|
||||||
|
|
||||||
<PossiblyFalseArgument>
|
<PossiblyFalseArgument>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</PossiblyFalseArgument>
|
</PossiblyFalseArgument>
|
||||||
|
|
||||||
<TypeCoercion>
|
<TypeCoercion>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests"/>
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</TypeCoercion>
|
</TypeCoercion>
|
||||||
</issueHandlers>
|
</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));
|
$this->assertNotNull($b_doc, var_export($a_doc, true));
|
||||||
|
|
||||||
if (!$b_doc) {
|
|
||||||
throw new \UnexpectedValueException('');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertNotSame($a_doc, $b_doc);
|
$this->assertNotSame($a_doc, $b_doc);
|
||||||
|
|
||||||
$this->assertSame($a_doc->getLine(), $b_doc->getLine());
|
$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()');
|
$method_symbol_location = $codebase->getSymbolLocation('somefile.php', 'B\A::foo()');
|
||||||
|
|
||||||
$this->assertNotNull($method_symbol_location);
|
$this->assertNotNull($method_symbol_location);
|
||||||
|
|
||||||
if ($method_symbol_location === null) {
|
|
||||||
throw new \UnexpectedValueException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame(10, $method_symbol_location->getLineNumber());
|
$this->assertSame(10, $method_symbol_location->getLineNumber());
|
||||||
$this->assertSame(21, $method_symbol_location->getColumn());
|
$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');
|
$property_symbol_location = $codebase->getSymbolLocation('somefile.php', 'B\A::$a');
|
||||||
|
|
||||||
$this->assertNotNull($property_symbol_location);
|
$this->assertNotNull($property_symbol_location);
|
||||||
|
|
||||||
if ($property_symbol_location === null) {
|
|
||||||
throw new \UnexpectedValueException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame(6, $property_symbol_location->getLineNumber());
|
$this->assertSame(6, $property_symbol_location->getLineNumber());
|
||||||
$this->assertSame(31, $property_symbol_location->getColumn());
|
$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');
|
$constant_symbol_location = $codebase->getSymbolLocation('somefile.php', 'B\A::BANANA');
|
||||||
|
|
||||||
$this->assertNotNull($constant_symbol_location);
|
$this->assertNotNull($constant_symbol_location);
|
||||||
|
|
||||||
if ($constant_symbol_location === null) {
|
|
||||||
throw new \UnexpectedValueException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame(8, $constant_symbol_location->getLineNumber());
|
$this->assertSame(8, $constant_symbol_location->getLineNumber());
|
||||||
$this->assertSame(27, $constant_symbol_location->getColumn());
|
$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()');
|
$function_symbol_location = $codebase->getSymbolLocation('somefile.php', 'B\bar()');
|
||||||
|
|
||||||
$this->assertNotNull($function_symbol_location);
|
$this->assertNotNull($function_symbol_location);
|
||||||
|
|
||||||
if ($function_symbol_location === null) {
|
|
||||||
throw new \UnexpectedValueException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame(13, $function_symbol_location->getLineNumber());
|
$this->assertSame(13, $function_symbol_location->getLineNumber());
|
||||||
$this->assertSame(17, $function_symbol_location->getColumn());
|
$this->assertSame(17, $function_symbol_location->getColumn());
|
||||||
}
|
}
|
||||||
@ -236,30 +216,18 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
|
|||||||
|
|
||||||
$this->assertNotNull($symbol_at_position);
|
$this->assertNotNull($symbol_at_position);
|
||||||
|
|
||||||
if ($symbol_at_position === null) {
|
|
||||||
throw new \UnexpectedValueException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame('type: int|null', $symbol_at_position[0]);
|
$this->assertSame('type: int|null', $symbol_at_position[0]);
|
||||||
|
|
||||||
$symbol_at_position = $codebase->getReferenceAtPosition('somefile.php', new Position(12, 30));
|
$symbol_at_position = $codebase->getReferenceAtPosition('somefile.php', new Position(12, 30));
|
||||||
|
|
||||||
$this->assertNotNull($symbol_at_position);
|
$this->assertNotNull($symbol_at_position);
|
||||||
|
|
||||||
if ($symbol_at_position === null) {
|
|
||||||
throw new \UnexpectedValueException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame('type: int', $symbol_at_position[0]);
|
$this->assertSame('type: int', $symbol_at_position[0]);
|
||||||
|
|
||||||
$symbol_at_position = $codebase->getReferenceAtPosition('somefile.php', new Position(17, 30));
|
$symbol_at_position = $codebase->getReferenceAtPosition('somefile.php', new Position(17, 30));
|
||||||
|
|
||||||
$this->assertNotNull($symbol_at_position);
|
$this->assertNotNull($symbol_at_position);
|
||||||
|
|
||||||
if ($symbol_at_position === null) {
|
|
||||||
throw new \UnexpectedValueException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame('type: int', $symbol_at_position[0]);
|
$this->assertSame('type: int', $symbol_at_position[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,7 @@ class PsalmPluginTest extends TestCase
|
|||||||
* @return void
|
* @return void
|
||||||
* @dataProvider commands
|
* @dataProvider commands
|
||||||
* @test
|
* @test
|
||||||
|
* @psalm-suppress RedundantConditionGivenDocblockType
|
||||||
*/
|
*/
|
||||||
public function showsHelpForCommand(string $command)
|
public function showsHelpForCommand(string $command)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user