Skip to content

Commit 07cf92d

Browse files
committed
phsptan fixes
1 parent efb6ae9 commit 07cf92d

7 files changed

Lines changed: 26 additions & 41 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"clue/ndjson-react": "^1.3",
1717
"composer/pcre": "^3.4",
1818
"composer/xdebug-handler": "^3.0.5",
19-
"entropy/entropy": "^0.4",
19+
"entropy/entropy": "^0.4.6",
2020
"fidry/cpu-core-counter": "^1.3",
2121
"friendsofphp/php-cs-fixer": "^3.95.10",
2222
"nette/utils": "^4.1",
@@ -37,7 +37,7 @@
3737
"rector/jack": "^1.0",
3838
"rector/rector": "^2.4",
3939
"rector/type-perfect": "^2.1",
40-
"symplify/phpstan-rules": "^14.11",
40+
"symplify/phpstan-rules": "^14.12",
4141
"symplify/vendor-patches": "^11.5",
4242
"tomasvotruba/class-leak": "^2.1.7",
4343
"tomasvotruba/type-coverage": "^2.2",

packages/coding-standard/src/Fixer/LineLength/LineLengthFixer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
/**
2727
* @see \Symplify\CodingStandard\Tests\Fixer\LineLength\LineLengthFixer\LineLengthFixerTest
2828
* @see \Symplify\CodingStandard\Tests\Fixer\LineLength\LineLengthFixer\ConfiguredLineLengthFixerTest
29+
*
30+
* @implements ConfigurableFixerInterface<
31+
* array{
32+
* self::LINE_LENGTH?: int,
33+
* self::BREAK_LONG_LINES?: bool,
34+
* self::INLINE_SHORT_LINES?: bool
35+
* }, array{
36+
* self::LINE_LENGTH: int,
37+
* self::BREAK_LONG_LINES: bool,
38+
* self::INLINE_SHORT_LINES: bool
39+
* }
40+
* >
2941
*/
3042
final class LineLengthFixer extends AbstractSymplifyFixer implements ConfigurableFixerInterface
3143
{

phpstan.neon

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ parameters:
3333
bootstrapFiles:
3434
- tests/bootstrap.php
3535

36+
errorFormat: symplify
3637
treatPhpDocTypesAsCertain: false
3738

3839
ignoreErrors:
40+
# @todo revisit: split return into typed file_diffs/coding_standard_errors buckets
41+
- '#Method Symplify\\EasyCodingStandard\\Application\\SingleFileProcessor\:\:processFilePath\(\) should return array\{file_diffs\?\: array<Symplify\\EasyCodingStandard\\ValueObject\\Error\\FileDiff>, coding_standard_errors\?\: array<Symplify\\EasyCodingStandard\\SniffRunner\\ValueObject\\Error\\CodingStandardError>\} but returns array<(.*?), array<Symplify\\EasyCodingStandard\\SniffRunner\\ValueObject\\Error\\CodingStandardError\|Symplify\\EasyCodingStandard\\ValueObject\\Error\\FileDiff>>#'
42+
3943
# on purpose to override a config
4044
-
4145
message: '#Missing call to parent\:\:setUp\(\) method#'
@@ -45,29 +49,16 @@ parameters:
4549
- tests/Skipper/SkipCriteriaResolver/SkippedPathsResolver/SkippedPathsResolverTest.php
4650
- src/Testing/PHPUnit/AbstractCheckerTestCase.php
4751

48-
# testing instance of on purpose
49-
-
50-
message: '#Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf#'
51-
path: tests/*
52-
53-
# overly detailed
54-
- '#PHPDoc tag @var with type string\|false is not subtype of native type non\-empty\-string\|false#'
55-
56-
# hack to autoload contants
52+
# intentional: hack to autoload contants
5753
- '#Call to new PHP_CodeSniffer\\Util\\Tokens\(\) on a separate line has no effect#'
5854

59-
# php version condition
60-
-
61-
identifier: smaller.alwaysFalse
62-
path: src/Configuration/ConfigInitializer.php
63-
6455
# coding-standard: runtime-defined PHP_CodeSniffer/php-cs-fixer token constants
6556
- '#Constant T_OPEN_CURLY_BRACKET|T_START_NOWDOC not found#'
6657

67-
# coding-standard: php-cs-fixer interface generics intentionally left unspecified
68-
- '#Class (.*?) implements generic interface PhpCsFixer\\Fixer\\ConfigurableFixerInterface but does not specify its types\: TFixerInputConfig, TFixerComputedConfig#'
69-
7058
# coding-standard: intentional cross-version condition
7159
-
7260
message: '#Comparison operation ">\=" between int<\d+, \d+> and (.*?) is always true#'
7361
path: packages/coding-standard/src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php
62+
-
63+
identifier: smaller.alwaysFalse
64+
path: src/Configuration/ConfigInitializer.php

src/Application/SingleFileProcessor.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public function processFilePath(string $filePath, Configuration $configuration):
2828
return [];
2929
}
3030

31-
$fileDiffs = [];
32-
$codingStandardErrors = [];
31+
$errorsAndDiffs = [];
3332

3433
$this->changedFilesDetector->addFilePath($filePath);
3534
$fileProcessors = $this->fileProcessorCollector->getFileProcessors();
@@ -44,27 +43,14 @@ public function processFilePath(string $filePath, Configuration $configuration):
4443
continue;
4544
}
4645

47-
$fileDiffs = [...$fileDiffs, ...($currentErrorsAndFileDiffs['file_diffs'] ?? [])];
48-
$codingStandardErrors = [
49-
...$codingStandardErrors,
50-
...($currentErrorsAndFileDiffs['coding_standard_errors'] ?? []),
51-
];
46+
$errorsAndDiffs = [...$errorsAndDiffs, ...$currentErrorsAndFileDiffs];
5247
}
5348

5449
// invalidate broken file, to analyse in next run too
55-
if ($fileDiffs !== [] || $codingStandardErrors !== []) {
50+
if ($errorsAndDiffs !== []) {
5651
$this->changedFilesDetector->invalidateFilePath($filePath);
5752
}
5853

59-
$errorsAndDiffs = [];
60-
if ($fileDiffs !== []) {
61-
$errorsAndDiffs['file_diffs'] = $fileDiffs;
62-
}
63-
64-
if ($codingStandardErrors !== []) {
65-
$errorsAndDiffs['coding_standard_errors'] = $codingStandardErrors;
66-
}
67-
6854
return $errorsAndDiffs;
6955
}
7056
}

src/Skipper/FileSystem/FnMatchPathNormalizer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public function normalizeForFnmatch(string $path): string
1616
}
1717

1818
if (\str_contains($path, '..')) {
19-
/** @var string|false $realPath */
2019
$realPath = realpath($path);
2120
if ($realPath === false) {
2221
return '';

src/Skipper/RealpathMatcher.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ final class RealpathMatcher
88
{
99
public function match(string $matchingPath, string $filePath): bool
1010
{
11-
/** @var string|false $realPathMatchingPath */
11+
/** @var non-empty-string|false $realPathMatchingPath */
1212
$realPathMatchingPath = realpath($matchingPath);
1313
if ($realPathMatchingPath === false) {
1414
return false;
1515
}
1616

17-
/** @var string|false $realpathFilePath */
1817
$realpathFilePath = realpath($filePath);
1918
if ($realpathFilePath === false) {
2019
return false;

tests/SniffRunner/File/FileFactoryTest.php

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

55
namespace Symplify\EasyCodingStandard\Tests\SniffRunner\File;
66

7-
use PHP_CodeSniffer\Files\File as PhpCodeSnifferFile;
87
use PHP_CodeSniffer\Fixer;
98
use Symplify\EasyCodingStandard\SniffRunner\File\FileFactory;
109
use Symplify\EasyCodingStandard\SniffRunner\ValueObject\File;
@@ -20,7 +19,6 @@ public function test(): void
2019
$file = $fileFactory->createFromFile($filePath);
2120

2221
$this->assertInstanceOf(File::class, $file);
23-
$this->assertInstanceOf(PhpCodeSnifferFile::class, $file);
2422
$this->assertInstanceOf(Fixer::class, $file->fixer);
2523
$this->assertSame($filePath, $file->getFilename());
2624
}

0 commit comments

Comments
 (0)