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",
"phpstan/phpstan": "^1.3",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"friendsofphp/php-cs-fixer": "^3.4",
"marcocesarato/php-conventional-changelog": "^1.12",
"vimeo/psalm": "^4.18.1"

149
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "013b98c33870edb3907acd6b581c06ae",
"content-hash": "a7859a25104b692f2001efb6f11b1ea0",
"packages": [
{
"name": "doctrine/annotations",
@ -282,12 +282,12 @@
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
"Resources/stubs"
]
@ -461,12 +461,12 @@
}
},
"autoload": {
"psr-4": {
"Amp\\ByteStream\\": "lib"
},
"files": [
"lib/functions.php"
]
],
"psr-4": {
"Amp\\ByteStream\\": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -1556,12 +1556,12 @@
},
"type": "library",
"autoload": {
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
},
"files": [
"src/DeepCopy/deep_copy.php"
]
],
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -2273,6 +2273,61 @@
],
"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",
"version": "1.1.0",
@ -2704,11 +2759,11 @@
}
},
"autoload": {
"classmap": [
"src/"
],
"files": [
"src/Framework/Assert/Functions.php"
],
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
@ -2921,12 +2976,12 @@
},
"type": "library",
"autoload": {
"psr-4": {
"Later\\": "src/"
},
"files": [
"src/functions.php"
]
],
"psr-4": {
"Later\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -4682,12 +4737,12 @@
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Intl\\Grapheme\\": ""
},
"files": [
"bootstrap.php"
]
],
"psr-4": {
"Symfony\\Polyfill\\Intl\\Grapheme\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -4763,12 +4818,12 @@
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
},
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
},
"classmap": [
"Resources/stubs"
]
@ -4850,12 +4905,12 @@
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -4927,12 +4982,12 @@
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php73\\": ""
},
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php73\\": ""
},
"classmap": [
"Resources/stubs"
]
@ -5006,12 +5061,12 @@
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php81\\": ""
},
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php81\\": ""
},
"classmap": [
"Resources/stubs"
]
@ -5379,13 +5434,6 @@
}
},
"autoload": {
"psr-4": {
"Safe\\": [
"lib/",
"deprecated/",
"generated/"
]
},
"files": [
"deprecated/apc.php",
"deprecated/libevent.php",
@ -5476,7 +5524,14 @@
"generated/yaz.php",
"generated/zip.php",
"generated/zlib.php"
],
"psr-4": {
"Safe\\": [
"lib/",
"deprecated/",
"generated/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -5616,13 +5671,13 @@
}
},
"autoload": {
"psr-4": {
"Psalm\\": "src/Psalm/"
},
"files": [
"src/functions.php",
"src/spl_object_id.php"
]
],
"psr-4": {
"Psalm\\": "src/Psalm/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [

View File

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

View File

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

View File

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

View File

@ -53,7 +53,7 @@ final class ShapedArrayValuesMappingTest extends IntegrationTest
self::assertSame(['foo' => 'foo'], $result->basicShapedArrayWithExcessiveKey);
self::assertSame($source['basicShapedArrayWithStringKeys'], $result->basicShapedArrayWithStringKeys);
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['shapedArrayOnSeveralLines'], $result->shapedArrayOnSeveralLines);
self::assertSame('bar', $result->advancedShapedArray['mandatoryString']);

View File

@ -55,7 +55,6 @@ final class UnionOfObjectsMappingTest extends IntegrationTest
$this->mappingFail($error);
}
/** @var SomeBarAndFizObject $object */
$object = $result->objects[0];
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
{
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]);
/** @var TypeToken $result */
$result = $lexer->tokenize('Template');
self::assertInstanceOf(TypeToken::class, $result);

View File

@ -14,9 +14,9 @@ final class ArrayKeyTypeTest extends TestCase
{
public function test_instances_are_memoized(): void
{
self::assertSame(ArrayKeyType::default(), ArrayKeyType::default());
self::assertSame(ArrayKeyType::integer(), ArrayKeyType::integer());
self::assertSame(ArrayKeyType::string(), ArrayKeyType::string());
self::assertSame(ArrayKeyType::default(), ArrayKeyType::default()); // @phpstan-ignore-line
self::assertSame(ArrayKeyType::integer(), ArrayKeyType::integer()); // @phpstan-ignore-line
self::assertSame(ArrayKeyType::string(), ArrayKeyType::string()); // @phpstan-ignore-line
}
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
{
self::assertSame(ArrayType::native(), ArrayType::native());
self::assertSame(ArrayType::native(), ArrayType::native()); // @phpstan-ignore-line
}
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
{
self::assertSame(IterableType::native(), IterableType::native());
self::assertSame(IterableType::native(), IterableType::native()); // @phpstan-ignore-line
}
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
{
self::assertSame(ListType::native(), ListType::native());
self::assertSame(ListType::native(), ListType::native()); // @phpstan-ignore-line
}
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
{
self::assertSame(NonEmptyArrayType::native(), NonEmptyArrayType::native());
self::assertSame(NonEmptyArrayType::native(), NonEmptyArrayType::native()); // @phpstan-ignore-line
}
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
{
self::assertSame(NonEmptyListType::native(), NonEmptyListType::native());
self::assertSame(NonEmptyListType::native(), NonEmptyListType::native()); // @phpstan-ignore-line
}
public function test_native_subtype_is_correct(): void