Skip to content

Commit 8936bbe

Browse files
authored
Upgrade phpstan and infection php-kafka#15 (php-kafka#32)
* Bump phpstan version * Adjust ignored errors * Fix phpstan errors * Bump infection * Add missing command * Improve infection * Ignore infection where code coverage is ignored * Added missing binary * Fix CS
1 parent 8cc5b4c commit 8936bbe

File tree

12 files changed

+25
-21
lines changed

12 files changed

+25
-21
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
.PHONY: clean code-style coverage help static-analysis update-dependencies install-dependencies infection-testing
1+
.PHONY: clean code-style coverage fix-code-style help static-analysis update-dependencies install-dependencies infection-testing
22
.DEFAULT_GOAL := coverage
33

44
PHPUNIT = ./vendor/bin/phpunit -c ./phpunit.xml
55
PHPSTAN = ./vendor/bin/phpstan
66
PHPCS = ./vendor/bin/phpcs --extensions=php
7-
PHPCBF = ./vendor/bin/
7+
PHPCBF = ./vendor/bin/phpcbf
88
INFECTION = ./vendor/bin/infection
99
CONSOLE = ./bin/console
1010
COVCHECK = ./vendor/bin/coverage-check

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
"license": "MIT",
1010
"require": {
1111
"ext-json": "*",
12-
"symfony/console": "^4.3|^5.1",
13-
"flix-tech/avro-php": "^3.0|^4.0"
12+
"flix-tech/avro-php": "^3.0|^4.0",
13+
"symfony/console": "^4.3|^5.1"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "^9.3",
17-
"phpstan/phpstan": "^0.12",
18-
"squizlabs/php_codesniffer": "^3.4.2",
1916
"friendsofphp/php-cs-fixer": "^2.15",
20-
"infection/infection": "^0.20.2",
21-
"rregeer/phpunit-coverage-check": "^0.3"
17+
"infection/infection": "^0.25",
18+
"phpstan/phpstan": "^1.2",
19+
"phpunit/phpunit": "^9.3",
20+
"rregeer/phpunit-coverage-check": "^0.3",
21+
"squizlabs/php_codesniffer": "^3.4.2"
2222
},
2323
"bin": [
2424
"bin/avro-cli"

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ parameters:
44
checkGenericClassInNonGenericObjectType: false
55
ignoreErrors:
66
- "#Call to function token_get_all\\(\\) on a separate line has no effect.#"
7-
- "#Strict comparison using === between array<int, mixed>&nonEmpty and ',' will always evaluate to false.#"
8-
- "#Strict comparison using === between array<int, mixed>&nonEmpty and ';' will always evaluate to false.#"
7+
- "#Strict comparison using === between non-empty-array<int, mixed> and ',' will always evaluate to false.#"
8+
- "#Strict comparison using === between non-empty-array<int, mixed> and ';' will always evaluate to false.#"
99
- "#Method PhpKafka\\\\\\PhpAvroSchemaGenerator\\\\\\Optimizer\\\\\\OptimizerInterface::optimize\\(\\) invoked with 2 parameters, 1 required.#"

src/Command/SubSchemaMergeCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpKafka\PhpAvroSchemaGenerator\Optimizer\FieldOrderOptimizer;
88
use PhpKafka\PhpAvroSchemaGenerator\Optimizer\FullNameOptimizer;
9+
use PhpKafka\PhpAvroSchemaGenerator\Optimizer\OptimizerInterface;
910
use PhpKafka\PhpAvroSchemaGenerator\Optimizer\PrimitiveSchemaOptimizer;
1011
use PhpKafka\PhpAvroSchemaGenerator\Registry\SchemaRegistry;
1112
use PhpKafka\PhpAvroSchemaGenerator\Merger\SchemaMerger;
@@ -76,6 +77,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
7677

7778
$merger = new SchemaMerger($registry, $outputDirectory);
7879

80+
/** @var OptimizerInterface $optimizerClass */
7981
foreach ($this->optimizerOptionMapping as $optionName => $optimizerClass) {
8082
if (true === (bool) $input->getOption($optionName)) {
8183
$merger->addOptimizer(new $optimizerClass());

src/Generator/SchemaGenerator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
final class SchemaGenerator implements SchemaGeneratorInterface
1313
{
14-
1514
/**
1615
* @var int[]
1716
*/

src/Merger/SchemaMergerInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
interface SchemaMergerInterface
1212
{
13-
1413
/**
1514
* @return SchemaRegistryInterface
1615
*/

src/Parser/TokenParser.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TokenParser
3939
/**
4040
* @var string
4141
*/
42-
private $className;
42+
private string $className;
4343

4444
/**
4545
* @var string
@@ -143,6 +143,7 @@ public function getNamespace(): string
143143
*
144144
* @return array<string|int,mixed> A list with all found use statements.
145145
* @codeCoverageIgnore
146+
* @infection-ignore-all
146147
*/
147148
public function parseUseStatements($namespaceName)
148149
{
@@ -196,12 +197,15 @@ public function getProperties(string $classPath): array
196197
* @throws \RuntimeException
197198
* @return string|null Type of the property (content of var annotation)
198199
* @codeCoverageIgnore
200+
* @infection-ignore-all
199201
*/
200202
public function getPropertyClass(ReflectionProperty $property, bool $ignorePrimitive = true)
201203
{
202204
$type = null;
203-
$phpVersion = false === phpversion() ? '7.0.0' : phpversion();
204-
// Get is explicit type decralation if possible
205+
/** @var false|string $phpVersionResult */
206+
$phpVersionResult = phpversion();
207+
$phpVersion = false === $phpVersionResult ? '7.0.0' : $phpVersionResult;
208+
// Get is explicit type declaration if possible
205209
if (version_compare($phpVersion, '7.4.0', '>=') && null !== $property->getType()) {
206210
$reflectionType = $property->getType();
207211

@@ -281,6 +285,7 @@ public function getPropertyClass(ReflectionProperty $property, bool $ignorePrimi
281285
*
282286
* @return string|null Fully qualified name of the type, or null if it could not be resolved
283287
* @codeCoverageIgnore
288+
* @infection-ignore-all
284289
*/
285290
private function tryResolveFqn($type, ReflectionClass $class, Reflector $member)
286291
{
@@ -324,6 +329,7 @@ private function tryResolveFqn($type, ReflectionClass $class, Reflector $member)
324329
*
325330
* @return string|null Fully qualified name of the type, or null if it could not be resolved
326331
* @codeCoverageIgnore
332+
* @infection-ignore-all
327333
*/
328334
private function tryResolveFqnInTraits($type, ReflectionClass $class, Reflector $member)
329335
{
@@ -389,6 +395,7 @@ private function next($docCommentIsComment = true)
389395
*
390396
* @return array<string,class-string> A list with all found class names for a use statement.
391397
* @codeCoverageIgnore
398+
* @infection-ignore-all
392399
*/
393400
private function parseUseStatement()
394401
{

src/PhpClass/PhpClassProperty.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
class PhpClassProperty implements PhpClassPropertyInterface
88
{
9-
109
/**
1110
* @var string
1211
*/

src/Registry/ClassRegistry.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
final class ClassRegistry implements ClassRegistryInterface
1616
{
17-
1817
/**
1918
* @var array<string,int>
2019
*/

src/Registry/ClassRegistryInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
interface ClassRegistryInterface
1010
{
11-
1211
/**
1312
* @param string $classDirectory
1413
* @return ClassRegistryInterface

0 commit comments

Comments
 (0)