1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Add a 7th level with even more permissive checks

This commit is contained in:
Matt Brown 2018-04-18 15:31:00 -04:00
parent 6a8fcaef56
commit aa3ea9c14c
5 changed files with 126 additions and 4 deletions

View File

@ -94,7 +94,7 @@
<FalsableReturnStatement errorLevel="info" />
<MoreSpecificImplementedParamType errorLevel="info" />
<MoreSpecificImplementedReturnType errorLevel="info" />
<LessSpecificImplementedReturnType errorLevel="info" />
<InvalidReturnStatement errorLevel="info" />
<InvalidReturnType errorLevel="info" />

122
assets/config_levels/7.xml Normal file
View File

@ -0,0 +1,122 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
</projectFiles>
<issueHandlers>
<LessSpecificReturnType errorLevel="info" />
<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />
<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />
<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />
<UnresolvableInclude errorLevel="info" />
<RawObjectIteration errorLevel="info" />
<!-- level 4 issues - points to possible deficiencies in logic, higher false-positives -->
<MoreSpecificReturnType errorLevel="info" />
<LessSpecificReturnStatement errorLevel="info" />
<TypeCoercion errorLevel="info" />
<RedundantCondition errorLevel="info" />
<PossiblyFalseArgument errorLevel="info" />
<PossiblyFalseIterator errorLevel="info" />
<PossiblyFalseOperand errorLevel="info" />
<PossiblyFalsePropertyAssignmentValue errorLevel="info" />
<PossiblyFalseReference errorLevel="info" />
<PossiblyInvalidArgument errorLevel="info" />
<PossiblyInvalidArrayAccess errorLevel="info" />
<PossiblyInvalidArrayAssignment errorLevel="info" />
<PossiblyInvalidArrayOffset errorLevel="info" />
<PossiblyInvalidFunctionCall errorLevel="info" />
<PossiblyInvalidIterator errorLevel="info" />
<PossiblyInvalidMethodCall errorLevel="info" />
<PossiblyInvalidOperand errorLevel="info" />
<PossiblyInvalidPropertyAssignment errorLevel="info" />
<PossiblyInvalidPropertyAssignmentValue errorLevel="info" />
<PossiblyInvalidPropertyFetch errorLevel="info" />
<PossiblyNullArgument errorLevel="info" />
<PossiblyNullArrayAccess errorLevel="info" />
<PossiblyNullArrayAssignment errorLevel="info" />
<PossiblyNullArrayOffset errorLevel="info" />
<PossiblyNullFunctionCall errorLevel="info" />
<PossiblyNullIterator errorLevel="info" />
<PossiblyNullOperand errorLevel="info" />
<PossiblyNullPropertyAssignment errorLevel="info" />
<PossiblyNullPropertyAssignmentValue errorLevel="info" />
<PossiblyNullPropertyFetch errorLevel="info" />
<PossiblyNullReference errorLevel="info" />
<PossiblyUndefinedGlobalVariable errorLevel="info" />
<PossiblyUndefinedVariable errorLevel="info" />
<PossiblyUndefinedArrayOffset errorLevel="info" />
<PossiblyUndefinedMethod errorLevel="info" />
<!-- level 5 issues - should be avoided at mosts costs... -->
<ForbiddenCode errorLevel="info" />
<ImplicitToStringCast errorLevel="info" />
<InvalidScalarArgument errorLevel="info" />
<InvalidToString errorLevel="info" />
<MethodSignatureMismatch errorLevel="info" />
<NoInterfaceProperties errorLevel="info" />
<TooManyArguments errorLevel="info" />
<TypeDoesNotContainType errorLevel="info" />
<TypeDoesNotContainNull errorLevel="info" />
<!-- level 6 issues - really bad things -->
<InvalidNullableReturnType errorLevel="info" />
<NullableReturnStatement errorLevel="info" />
<InvalidFalsableReturnType errorLevel="info" />
<FalsableReturnStatement errorLevel="info" />
<MoreSpecificImplementedParamType errorLevel="info" />
<LessSpecificImplementedReturnType errorLevel="info" />
<InvalidReturnStatement errorLevel="info" />
<InvalidReturnType errorLevel="info" />
<UndefinedThisPropertyAssignment errorLevel="info" />
<InvalidArgument errorLevel="info" />
<PossiblyUndefinedMethod errorLevel="info" />
<ReservedWord errorLevel="info" />
<!-- level 7 issues - even worse -->
<UndefinedThisPropertyAssignment errorLevel="info" />
<UndefinedPropertyAssignment errorLevel="info" />
<UndefinedThisPropertyFetch errorLevel="info" />
<UndefinedPropertyFetch errorLevel="info" />
<InvalidReturnStatement errorLevel="info" />
<InvalidReturnType errorLevel="info" />
<InvalidArgument errorLevel="info" />
<ReservedWord errorLevel="info" />
</issueHandlers>
</psalm>

View File

@ -12,7 +12,7 @@ Add a `psalm.xml` config:
./vendor/bin/psalm --init [source_directory=src] [config_level=3]
```
where `config_level` represents how strict you want Psalm to be. `1` is the strictest, `6` is the most lenient.
where `config_level` represents how strict you want Psalm to be. `1` is the strictest, `7` is the most lenient.
Then run Psalm:

View File

@ -61,7 +61,7 @@ Options:
-i, --init [source_dir=src] [level=3]
Create a psalm config file in the current directory that points to [source_dir]
at the required level, from 1, most strict, to 6, most permissive.
at the required level, from 1, most strict, to 7, most permissive.
--debug
Debug information

View File

@ -697,7 +697,7 @@ class ConfigTest extends TestCase
*/
public function testTemplatedFiles()
{
foreach (['1.xml', '2.xml', '3.xml', '4.xml', '5.xml'] as $file_name) {
foreach (['1.xml', '2.xml', '3.xml', '4.xml', '5.xml', '6.xml', '7.xml'] as $file_name) {
Config::loadFromXMLFile(
realpath(dirname(__DIR__) . '/assets/config_levels/' . $file_name),
dirname(__DIR__)