Skip to content

Commit

Permalink
Merge branch 'master' into 8_0__braces
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus authored Dec 18, 2024
2 parents 25a1f78 + a942a21 commit f373238
Show file tree
Hide file tree
Showing 28 changed files with 136 additions and 193 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"symfony/polyfill-mbstring": "^1.28",
"symfony/polyfill-php80": "^1.28",
"symfony/polyfill-php81": "^1.28",
"symfony/process": "^5.4 || ^6.0 || ^7.0",
"symfony/process": "^5.4 || ^6.0 || ^7.0 <7.2",
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
Expand Down
6 changes: 3 additions & 3 deletions dev-tools/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"mi-schi/phpmd-extension": "^4.3.0",
"phpmd/phpmd": "^2.15.0",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^2.0.2",
"phpstan/phpstan-phpunit": "^2.0.1",
"phpstan/phpstan-strict-rules": "^2.0.0",
"phpstan/phpstan": "^2.0.4",
"phpstan/phpstan-phpunit": "^2.0.2",
"phpstan/phpstan-strict-rules": "^2.0.1",
"phpstan/phpstan-symfony": "^2.0.0"
},
"config": {
Expand Down
34 changes: 17 additions & 17 deletions dev-tools/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 0 additions & 78 deletions dev-tools/phpstan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,18 +325,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Output/ErrorOutput.php',
];
$ignoreErrors[] = [
'message' => '#^Offset int might not exist on array\\<1\\|2\\|3\\|4\\|5\\|6, array\\{symbol\\: string, format\\: string, description\\: string\\}\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Output/Progress/DotsOutput.php',
];
$ignoreErrors[] = [
'message' => '#^Offset string might not exist on array\\<string, class\\-string\\<PhpCsFixer\\\\Console\\\\Output\\\\Progress\\\\ProgressOutputInterface\\>\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Output/Progress/ProgressOutputFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Console\\\\Report\\\\FixReport\\\\CheckstyleReporter\\:\\:generate\\(\\) should return string but returns string\\|false\\.$#',
'identifier' => 'return.type',
Expand Down Expand Up @@ -745,24 +733,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/AbstractPhpUnitFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset 0 might not exist on array\\<int, string\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Alias/EregToPregFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset 1 might not exist on array\\<int, string\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Alias/EregToPregFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset 2 might not exist on array\\<int, string\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Alias/EregToPregFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset 2 might not exist on non\\-empty\\-list\\<int\\<0, max\\>\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
Expand All @@ -775,12 +745,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Alias/PowToExponentiationFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset string might not exist on array\\<string, array\\<int, int\\>\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Alias/RandomApiMigrationFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset 0 might not exist on list\\<int\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
Expand Down Expand Up @@ -835,12 +799,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Casing/MagicConstantCasingFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset string might not exist on array\\<string, string\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Casing/MagicMethodCasingFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'elements\' on array\\{index\\: int, open\\: int\\|null, close\\: int\\<0, max\\>, elements\\: list\\<array\\{token\\: PhpCsFixer\\\\Tokenizer\\\\Token, type\\: \'case\'\\|\'const\'\\|\'method\'\\|\'property\'\\|\'trait_import\', index\\: int, start\\: int, end\\: int\\}\\>\\}\\|false\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
Expand Down Expand Up @@ -1597,12 +1555,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Operator/BinaryOperatorSpacesFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset string might not exist on array\\<string, array\\{int, string\\}\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Operator/LongToShorthandOperatorFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Fixer\\\\Operator\\\\TernaryToElvisOperatorFixer\\:\\:getAfterOperator\\(\\) should return array\\{start\\: int, end\\: int\\} but returns array\\{start\\: int\\|null, end\\?\\: int\\|null\\}\\.$#',
'identifier' => 'return.type',
Expand Down Expand Up @@ -1681,12 +1633,6 @@
'count' => 2,
'path' => __DIR__ . '/../../src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset string might not exist on array\\<string, array\\{positive\\: string, negative\\: string\\|false, argument_count\\?\\: int, swap_arguments\\?\\: true\\}\\|true\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset \'expectExceptionMessageRegExp\' might not exist on array\\<string, string\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
Expand Down Expand Up @@ -1753,12 +1699,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset \'assertAttributeEquals\'\\|\'assertAttributeNotEquals\'\\|\'assertEquals\'\\|\'assertNotEquals\' might not exist on array\\<string, string\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/PhpUnit/PhpUnitStrictFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Fixer\\\\PhpUnit\\\\PhpUnitTestAnnotationFixer\\:\\:updateLines\\(\\) should return list\\<PhpCsFixer\\\\DocBlock\\\\Line\\> but returns array\\<int\\<0, max\\>, PhpCsFixer\\\\DocBlock\\\\Line\\>\\.$#',
'identifier' => 'return.type',
Expand Down Expand Up @@ -2089,12 +2029,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Whitespace/ArrayIndentationFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset \'break\'\\|\'case\'\\|\'continue\'\\|\'declare\'\\|\'default\'\\|\'do\'\\|\'exit\'\\|\'for\'\\|\'foreach\'\\|\'goto\'\\|\'if\'\\|\'include\'\\|\'include_once\'\\|\'phpdoc\'\\|\'require\'\\|\'require_once\'\\|\'return\'\\|\'switch\'\\|\'throw\'\\|\'try\'\\|\'while\'\\|\'yield\'\\|\'yield_from\' might not exist on array\\<string, int\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Offset int\\<0, max\\> might not exist on list\\<int\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
Expand Down Expand Up @@ -2923,12 +2857,6 @@
'count' => 1,
'path' => __DIR__ . '/../../tests/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixerTest.php',
];
$ignoreErrors[] = [
'message' => '#^Offset \'operators\' might not exist on array\\<string, mixed\\>\\.$#',
'identifier' => 'offsetAccess.notFound',
'count' => 1,
'path' => __DIR__ . '/../../tests/Fixer/Operator/LongToShorthandOperatorFixerTest.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a negated boolean, string\\|false given\\.$#',
'identifier' => 'booleanNot.exprNotBoolean',
Expand Down Expand Up @@ -3229,12 +3157,6 @@
'count' => 1,
'path' => __DIR__ . '/../../tests/Test/TestCaseUtils.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Tests\\\\Test\\\\TokensWithObservedTransformers\\:\\:\\$observedModificationsPerTransformer \\(array\\<string, list\\<int\\|string\\>\\>\\) does not accept non\\-empty\\-array\\<int\\|string, list\\<int\\|string\\>\\>\\.$#',
'identifier' => 'assign.propertyType',
'count' => 1,
'path' => __DIR__ . '/../../tests/Test/TokensWithObservedTransformers.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Tests\\\\TestCase\\:\\:\\$actualDeprecations \\(list\\<string\\>\\) does not accept array\\<int\\<0, max\\>, string\\>\\.$#',
'identifier' => 'assign.propertyType',
Expand Down
4 changes: 3 additions & 1 deletion src/Console/ConfigurationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ final class ConfigurationResolver
private ?array $path = null;

/**
* @var null|string
* @var null|ProgressOutputType::*
*/
private $progress;

Expand Down Expand Up @@ -409,6 +409,8 @@ static function (string $rawPath) use ($cwd, $filesystem): string {
}

/**
* @return ProgressOutputType::*
*
* @throws InvalidConfigurationException
*/
public function getProgressType(): string
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Output/Progress/DotsOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class DotsOutput implements ProgressOutputInterface
*
* @var array<FileProcessed::STATUS_*, array{symbol: string, format: string, description: string}>
*/
private static array $eventStatusMap = [
private const EVENT_STATUS_MAP = [
FileProcessed::STATUS_NO_CHANGES => ['symbol' => '.', 'format' => '%s', 'description' => 'no changes'],
FileProcessed::STATUS_FIXED => ['symbol' => 'F', 'format' => '<fg=green>%s</fg=green>', 'description' => 'fixed'],
FileProcessed::STATUS_SKIPPED => ['symbol' => 'S', 'format' => '<fg=cyan>%s</fg=cyan>', 'description' => 'skipped (cached or empty file)'],
Expand Down Expand Up @@ -81,7 +81,7 @@ public function __wakeup(): void

public function onFixerFileProcessed(FileProcessed $event): void
{
$status = self::$eventStatusMap[$event->getStatus()];
$status = self::EVENT_STATUS_MAP[$event->getStatus()];
$this->getOutput()->write($this->getOutput()->isDecorated() ? \sprintf($status['format'], $status['symbol']) : $status['symbol']);

++$this->processedFiles;
Expand All @@ -108,9 +108,9 @@ public function printLegend(): void
{
$symbols = [];

foreach (self::$eventStatusMap as $status) {
foreach (self::EVENT_STATUS_MAP as $status) {
$symbol = $status['symbol'];
if ('' === $symbol || isset($symbols[$symbol])) {
if (isset($symbols[$symbol])) {
continue;
}

Expand Down
12 changes: 9 additions & 3 deletions src/Console/Output/Progress/ProgressOutputFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@
final class ProgressOutputFactory
{
/**
* @var array<string, class-string<ProgressOutputInterface>>
* @var array<ProgressOutputType::*, class-string<ProgressOutputInterface>>
*/
private static array $outputTypeMap = [
private const OUTPUT_TYPE_MAP = [
ProgressOutputType::NONE => NullOutput::class,
ProgressOutputType::DOTS => DotsOutput::class,
ProgressOutputType::BAR => PercentageBarOutput::class,
];

/**
* @param ProgressOutputType::* $outputType
*/
public function create(string $outputType, OutputContext $context): ProgressOutputInterface
{
if (null === $context->getOutput()) {
Expand All @@ -45,7 +48,10 @@ public function create(string $outputType, OutputContext $context): ProgressOutp
);
}

return new self::$outputTypeMap[$outputType]($context);
$outputClass = self::OUTPUT_TYPE_MAP[$outputType];

// @phpstan-ignore-next-line new.noConstructor
return new $outputClass($context);
}

private function isBuiltInType(string $outputType): bool
Expand Down
6 changes: 3 additions & 3 deletions src/DocBlock/Annotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class Annotation
*
* @var list<string>
*/
private static array $tags = [
private const TAGS = [
'method',
'param',
'property',
Expand Down Expand Up @@ -127,7 +127,7 @@ public function __toString(): string
*/
public static function getTagsWithTypes(): array
{
return self::$tags;
return self::TAGS;
}

/**
Expand Down Expand Up @@ -291,7 +291,7 @@ public function getContent(): string

public function supportTypes(): bool
{
return \in_array($this->getTag()->getName(), self::$tags, true);
return \in_array($this->getTag()->getName(), self::TAGS, true);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/Alias/EregToPregFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class EregToPregFixer extends AbstractFixer
* @var list<array<int, string>> the list of the ext/ereg function names, their preg equivalent and the preg modifier(s), if any
* all condensed in an array of arrays
*/
private static array $functions = [
private const FUNCTIONS = [
['ereg', 'preg_match', ''],
['eregi', 'preg_match', 'i'],
['ereg_replace', 'preg_replace', ''],
Expand Down Expand Up @@ -82,7 +82,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$end = $tokens->count() - 1;
$functionsAnalyzer = new FunctionsAnalyzer();

foreach (self::$functions as $map) {
foreach (self::FUNCTIONS as $map) {
// the sequence is the function name, followed by "(" and a quoted string
$seq = [[T_STRING, $map[0]], '(', [T_CONSTANT_ENCAPSED_STRING]];
$currIndex = 0;
Expand Down
Loading

0 comments on commit f373238

Please sign in to comment.