qa: require and include phpstan/phpstan-phpunit rules

This commit is contained in:
Romain Canon 2022-02-19 15:27:30 +01:00
parent 6d427088f7
commit c1a884fadd
15 changed files with 115 additions and 63 deletions

View File

@ -26,6 +26,7 @@
"infection/infection": "^0.26", "infection/infection": "^0.26",
"phpstan/phpstan": "^1.3", "phpstan/phpstan": "^1.3",
"phpstan/phpstan-strict-rules": "^1.0", "phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"friendsofphp/php-cs-fixer": "^3.4", "friendsofphp/php-cs-fixer": "^3.4",
"marcocesarato/php-conventional-changelog": "^1.12", "marcocesarato/php-conventional-changelog": "^1.12",
"vimeo/psalm": "^4.18.1" "vimeo/psalm": "^4.18.1"

151
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "013b98c33870edb3907acd6b581c06ae", "content-hash": "a7859a25104b692f2001efb6f11b1ea0",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
@ -282,12 +282,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
], ],
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [ "classmap": [
"Resources/stubs" "Resources/stubs"
] ]
@ -461,12 +461,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Amp\\ByteStream\\": "lib"
},
"files": [ "files": [
"lib/functions.php" "lib/functions.php"
] ],
"psr-4": {
"Amp\\ByteStream\\": "lib"
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -1556,12 +1556,12 @@
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
},
"files": [ "files": [
"src/DeepCopy/deep_copy.php" "src/DeepCopy/deep_copy.php"
] ],
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -2273,6 +2273,61 @@
], ],
"time": "2022-01-07T09:49:03+00:00" "time": "2022-01-07T09:49:03+00:00"
}, },
{
"name": "phpstan/phpstan-phpunit",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "9eb88c9f689003a8a2a5ae9e010338ee94dc39b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/9eb88c9f689003a8a2a5ae9e010338ee94dc39b3",
"reference": "9eb88c9f689003a8a2a5ae9e010338ee94dc39b3",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0",
"phpstan/phpstan": "^1.0"
},
"conflict": {
"phpunit/phpunit": "<7.0"
},
"require-dev": {
"nikic/php-parser": "^4.13.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5"
},
"type": "phpstan-extension",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"phpstan": {
"includes": [
"extension.neon",
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.0.0"
},
"time": "2021-10-14T08:03:54+00:00"
},
{ {
"name": "phpstan/phpstan-strict-rules", "name": "phpstan/phpstan-strict-rules",
"version": "1.1.0", "version": "1.1.0",
@ -2704,11 +2759,11 @@
} }
}, },
"autoload": { "autoload": {
"classmap": [
"src/"
],
"files": [ "files": [
"src/Framework/Assert/Functions.php" "src/Framework/Assert/Functions.php"
],
"classmap": [
"src/"
] ]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -2921,12 +2976,12 @@
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": {
"Later\\": "src/"
},
"files": [ "files": [
"src/functions.php" "src/functions.php"
] ],
"psr-4": {
"Later\\": "src/"
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -4682,12 +4737,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Intl\\Grapheme\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
] ],
"psr-4": {
"Symfony\\Polyfill\\Intl\\Grapheme\\": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -4763,12 +4818,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
], ],
"psr-4": {
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
},
"classmap": [ "classmap": [
"Resources/stubs" "Resources/stubs"
] ]
@ -4850,12 +4905,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
] ],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -4927,12 +4982,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php73\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
], ],
"psr-4": {
"Symfony\\Polyfill\\Php73\\": ""
},
"classmap": [ "classmap": [
"Resources/stubs" "Resources/stubs"
] ]
@ -5006,12 +5061,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php81\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
], ],
"psr-4": {
"Symfony\\Polyfill\\Php81\\": ""
},
"classmap": [ "classmap": [
"Resources/stubs" "Resources/stubs"
] ]
@ -5379,13 +5434,6 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Safe\\": [
"lib/",
"deprecated/",
"generated/"
]
},
"files": [ "files": [
"deprecated/apc.php", "deprecated/apc.php",
"deprecated/libevent.php", "deprecated/libevent.php",
@ -5476,7 +5524,14 @@
"generated/yaz.php", "generated/yaz.php",
"generated/zip.php", "generated/zip.php",
"generated/zlib.php" "generated/zlib.php"
] ],
"psr-4": {
"Safe\\": [
"lib/",
"deprecated/",
"generated/"
]
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -5616,13 +5671,13 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Psalm\\": "src/Psalm/"
},
"files": [ "files": [
"src/functions.php", "src/functions.php",
"src/spl_object_id.php" "src/spl_object_id.php"
] ],
"psr-4": {
"Psalm\\": "src/Psalm/"
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [

View File

@ -1,6 +1,7 @@
includes: includes:
- qa/PHPStan/valinor-phpstan-configuration.php - qa/PHPStan/valinor-phpstan-configuration.php
- vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
rules: rules:
- CuyZ\Valinor\QA\PHPStan\Extension\ApiAndInternalAnnotationCheck - CuyZ\Valinor\QA\PHPStan\Extension\ApiAndInternalAnnotationCheck

View File

@ -45,7 +45,6 @@ final class ClassDefinitionCompilerTest extends TestCase
$class = FakeClassDefinition::fromReflection(new ReflectionClass($object)); $class = FakeClassDefinition::fromReflection(new ReflectionClass($object));
$className = get_class($object); $className = get_class($object);
/** @var ClassDefinition $class */
$class = $this->eval($this->compiler->compile($class)); $class = $this->eval($this->compiler->compile($class));
self::assertInstanceOf(ClassDefinition::class, $class); self::assertInstanceOf(ClassDefinition::class, $class);

View File

@ -487,7 +487,6 @@ final class NativeLexerTest extends TestCase
{ {
$raw = 'int|float|string'; $raw = 'int|float|string';
/** @var UnionType $unionType */
$unionType = $this->parser->parse($raw); $unionType = $this->parser->parse($raw);
self::assertInstanceOf(UnionType::class, $unionType); self::assertInstanceOf(UnionType::class, $unionType);
@ -512,7 +511,6 @@ final class NativeLexerTest extends TestCase
{ {
$raw = 'stdClass&DateTimeInterface&DateTime'; $raw = 'stdClass&DateTimeInterface&DateTime';
/** @var IntersectionType $intersectionType */
$intersectionType = $this->parser->parse($raw); $intersectionType = $this->parser->parse($raw);
self::assertInstanceOf(IntersectionType::class, $intersectionType); self::assertInstanceOf(IntersectionType::class, $intersectionType);

View File

@ -53,7 +53,7 @@ final class ShapedArrayValuesMappingTest extends IntegrationTest
self::assertSame(['foo' => 'foo'], $result->basicShapedArrayWithExcessiveKey); self::assertSame(['foo' => 'foo'], $result->basicShapedArrayWithExcessiveKey);
self::assertSame($source['basicShapedArrayWithStringKeys'], $result->basicShapedArrayWithStringKeys); self::assertSame($source['basicShapedArrayWithStringKeys'], $result->basicShapedArrayWithStringKeys);
self::assertSame($source['basicShapedArrayWithIntegerKeys'], $result->basicShapedArrayWithIntegerKeys); self::assertSame($source['basicShapedArrayWithIntegerKeys'], $result->basicShapedArrayWithIntegerKeys);
self::assertInstanceOf(SimpleObject::class, $result->shapedArrayWithObject['foo']); self::assertInstanceOf(SimpleObject::class, $result->shapedArrayWithObject['foo']); // @phpstan-ignore-line
self::assertSame($source['shapedArrayWithOptionalValue'], $result->shapedArrayWithOptionalValue); self::assertSame($source['shapedArrayWithOptionalValue'], $result->shapedArrayWithOptionalValue);
self::assertSame($source['shapedArrayOnSeveralLines'], $result->shapedArrayOnSeveralLines); self::assertSame($source['shapedArrayOnSeveralLines'], $result->shapedArrayOnSeveralLines);
self::assertSame('bar', $result->advancedShapedArray['mandatoryString']); self::assertSame('bar', $result->advancedShapedArray['mandatoryString']);

View File

@ -55,7 +55,6 @@ final class UnionOfObjectsMappingTest extends IntegrationTest
$this->mappingFail($error); $this->mappingFail($error);
} }
/** @var SomeBarAndFizObject $object */
$object = $result->objects[0]; $object = $result->objects[0];
self::assertInstanceOf(SomeBarAndFizObject::class, $object); self::assertInstanceOf(SomeBarAndFizObject::class, $object);

View File

@ -41,6 +41,6 @@ final class MapperBuilderTest extends TestCase
public function test_mapper_instance_is_the_same(): void public function test_mapper_instance_is_the_same(): void
{ {
self::assertSame($this->mapperBuilder->mapper(), $this->mapperBuilder->mapper()); self::assertSame($this->mapperBuilder->mapper(), $this->mapperBuilder->mapper()); // @phpstan-ignore-line
} }
} }

View File

@ -41,7 +41,6 @@ final class TypeAliasLexerTest extends TestCase
$lexer = new TypeAliasLexer($this->delegate, ['Template' => $type]); $lexer = new TypeAliasLexer($this->delegate, ['Template' => $type]);
/** @var TypeToken $result */
$result = $lexer->tokenize('Template'); $result = $lexer->tokenize('Template');
self::assertInstanceOf(TypeToken::class, $result); self::assertInstanceOf(TypeToken::class, $result);

View File

@ -14,9 +14,9 @@ final class ArrayKeyTypeTest extends TestCase
{ {
public function test_instances_are_memoized(): void public function test_instances_are_memoized(): void
{ {
self::assertSame(ArrayKeyType::default(), ArrayKeyType::default()); self::assertSame(ArrayKeyType::default(), ArrayKeyType::default()); // @phpstan-ignore-line
self::assertSame(ArrayKeyType::integer(), ArrayKeyType::integer()); self::assertSame(ArrayKeyType::integer(), ArrayKeyType::integer()); // @phpstan-ignore-line
self::assertSame(ArrayKeyType::string(), ArrayKeyType::string()); self::assertSame(ArrayKeyType::string(), ArrayKeyType::string()); // @phpstan-ignore-line
} }
public function test_string_values_are_correct(): void public function test_string_values_are_correct(): void

View File

@ -34,7 +34,7 @@ final class ArrayTypeTest extends TestCase
public function test_native_returns_same_instance(): void public function test_native_returns_same_instance(): void
{ {
self::assertSame(ArrayType::native(), ArrayType::native()); self::assertSame(ArrayType::native(), ArrayType::native()); // @phpstan-ignore-line
} }
public function test_native_subtype_is_correct(): void public function test_native_subtype_is_correct(): void

View File

@ -32,7 +32,7 @@ final class IterableTypeTest extends TestCase
public function test_native_returns_same_instance(): void public function test_native_returns_same_instance(): void
{ {
self::assertSame(IterableType::native(), IterableType::native()); self::assertSame(IterableType::native(), IterableType::native()); // @phpstan-ignore-line
} }
public function test_native_subtype_is_correct(): void public function test_native_subtype_is_correct(): void

View File

@ -34,7 +34,7 @@ final class ListTypeTest extends TestCase
public function test_native_returns_same_instance(): void public function test_native_returns_same_instance(): void
{ {
self::assertSame(ListType::native(), ListType::native()); self::assertSame(ListType::native(), ListType::native()); // @phpstan-ignore-line
} }
public function test_native_subtype_is_correct(): void public function test_native_subtype_is_correct(): void

View File

@ -33,7 +33,7 @@ final class NonEmptyArrayTypeTest extends TestCase
public function test_native_returns_same_instance(): void public function test_native_returns_same_instance(): void
{ {
self::assertSame(NonEmptyArrayType::native(), NonEmptyArrayType::native()); self::assertSame(NonEmptyArrayType::native(), NonEmptyArrayType::native()); // @phpstan-ignore-line
} }
public function test_native_subtype_is_correct(): void public function test_native_subtype_is_correct(): void

View File

@ -36,7 +36,7 @@ final class NonEmptyListTypeTest extends TestCase
public function test_native_returns_same_instance(): void public function test_native_returns_same_instance(): void
{ {
self::assertSame(NonEmptyListType::native(), NonEmptyListType::native()); self::assertSame(NonEmptyListType::native(), NonEmptyListType::native()); // @phpstan-ignore-line
} }
public function test_native_subtype_is_correct(): void public function test_native_subtype_is_correct(): void