Skip to content

Commit d64be18

Browse files
authored
CS Fixes (#1567)
* Fix CS * Fix CS (risky)
1 parent 7e152f6 commit d64be18

File tree

156 files changed

+1262
-1308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+1262
-1308
lines changed

.php-cs-fixer.php

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,71 +16,25 @@
1616
->in(__DIR__.'/tests')
1717
->name('*.php')
1818
->notPath('Fixtures')
19+
->notPath('Search/results')
1920
;
2021

2122
$config = new PhpCsFixer\Config();
22-
return $config->setRules([
23-
'@PSR2' => true,
24-
'binary_operator_spaces' => true,
25-
'blank_line_before_statement' => ['statements' => ['declare', 'return']],
26-
'cast_spaces' => ['space' => 'single'],
27-
'header_comment' => ['header' => $header],
28-
'include' => true,
29-
30-
'class_attributes_separation' => ['elements' => ['method' => 'one', 'trait_import' => 'none']],
31-
'no_blank_lines_after_class_opening' => true,
32-
'no_blank_lines_after_phpdoc' => true,
33-
'no_empty_statement' => true,
34-
'no_extra_blank_lines' => true,
35-
'no_leading_namespace_whitespace' => true,
36-
'no_trailing_comma_in_singleline' => true,
37-
'no_whitespace_in_blank_line' => true,
38-
'object_operator_without_whitespace' => true,
39-
//'phpdoc_align' => true,
40-
'phpdoc_indent' => true,
41-
'no_empty_comment' => true,
42-
'no_empty_phpdoc' => true,
43-
'phpdoc_no_access' => true,
44-
'phpdoc_no_package' => true,
45-
//'phpdoc_order' => true,
46-
'phpdoc_scalar' => true,
47-
'phpdoc_trim' => true,
48-
'phpdoc_types' => true,
49-
'psr_autoloading' => true,
50-
'blank_lines_before_namespace' => true,
51-
'standardize_not_equals' => true,
52-
'ternary_operator_spaces' => true,
53-
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
54-
'unary_operator_spaces' => true,
55-
56-
// imports
57-
'no_unused_imports' => true,
58-
'fully_qualified_strict_types' => true,
59-
'single_line_after_imports' => true,
60-
//'global_namespace_import' => ['import_classes' => true],
61-
'no_leading_import_slash' => true,
62-
'single_import_per_statement' => true,
63-
64-
// PHP 7.2 migration
65-
'array_syntax' => true,
66-
'list_syntax' => true,
67-
'regular_callable_call' => true,
68-
'static_lambda' => true,
69-
'nullable_type_declaration_for_default_null_value' => true,
70-
'explicit_indirect_variable' => true,
71-
'visibility_required' => ['elements' => ['property', 'method', 'const']],
72-
'non_printable_character' => true,
73-
'combine_nested_dirname' => true,
74-
'random_api_migration' => true,
75-
'ternary_to_null_coalescing' => true,
76-
'phpdoc_to_param_type' => true,
77-
'declare_strict_types' => true,
78-
'no_superfluous_phpdoc_tags' => [
79-
'allow_mixed' => true,
80-
],
81-
82-
// TODO php 7.4 migration (one day..)
83-
'phpdoc_to_property_type' => true,
23+
return $config
24+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
25+
->setRules([
26+
'@PHP84Migration' => true,
27+
'@PHPUnit100Migration:risky' => true,
28+
'@PER-CS' => true,
29+
'@Symfony' => true,
30+
'@Symfony:risky' => true,
31+
32+
// overrides
33+
'blank_line_after_opening_tag' => false,
34+
'linebreak_after_opening_tag' => false,
35+
'yoda_style' => false,
36+
'phpdoc_summary' => false,
37+
'increment_style' => false,
8438
])
8539
->setUsingCache(true)
8640
->setRiskyAllowed(true)

src/ArgumentResolver/UserResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
4949
}
5050

5151
$username = $request->attributes->get($varName);
52-
if (!is_string($username)) {
52+
if (!\is_string($username)) {
5353
throw new \UnexpectedValueException('Missing "'.$varName.'" in request attributes, cannot resolve $'.$argument->getName());
5454
}
5555

src/Audit/AuditRecordType.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@
1414

1515
enum AuditRecordType: string
1616
{
17-
# package ownership
18-
case AddMaintainer = 'add_maintainer'; # TODO
19-
case RemoveMaintainer = 'remove_maintainer'; # TODO
20-
case TransferPackage = 'transfer_package'; # TODO
17+
// package ownership
18+
case AddMaintainer = 'add_maintainer'; // TODO
19+
case RemoveMaintainer = 'remove_maintainer'; // TODO
20+
case TransferPackage = 'transfer_package'; // TODO
2121

22-
# package management
22+
// package management
2323
case PackageCreated = 'package_created';
2424
case PackageDeleted = 'package_deleted';
2525
case CanonicalUrlChange = 'canonical_url_change';
2626
case VersionDeleted = 'version_deleted';
2727
case VersionReferenceChange = 'version_reference_change';
28-
case PackageAbandoned = 'package_abandoned'; # TODO
29-
case PackageUnabandoned = 'package_unabandoned'; # TODO
28+
case PackageAbandoned = 'package_abandoned'; // TODO
29+
case PackageUnabandoned = 'package_unabandoned'; // TODO
3030

31-
# user management
32-
case UserCreated = 'user_created'; # TODO
33-
case UserDeleted = 'user_deleted'; # TODO
34-
case PasswordResetRequest = 'password_reset_request'; # TODO
35-
case PasswordReset = 'password_reset'; # TODO
36-
case PasswordChange = 'password_change'; # TODO
37-
case EmailChange = 'email_change'; # TODO
38-
case UsernameChange = 'username_change'; # TODO
39-
case GitHubLinkedWithUser = 'github_linked_with_user'; # TODO
40-
case GitHubDisconnectedFromUser = 'github_disconnected_from_user'; # TODO
41-
case TwoFaActivated = 'two_fa_activated'; # TODO
42-
case TwoFaDeactivated = 'two_fa_deactivated'; # TODO
31+
// user management
32+
case UserCreated = 'user_created'; // TODO
33+
case UserDeleted = 'user_deleted'; // TODO
34+
case PasswordResetRequest = 'password_reset_request'; // TODO
35+
case PasswordReset = 'password_reset'; // TODO
36+
case PasswordChange = 'password_change'; // TODO
37+
case EmailChange = 'email_change'; // TODO
38+
case UsernameChange = 'username_change'; // TODO
39+
case GitHubLinkedWithUser = 'github_linked_with_user'; // TODO
40+
case GitHubDisconnectedFromUser = 'github_disconnected_from_user'; // TODO
41+
case TwoFaActivated = 'two_fa_activated'; // TODO
42+
case TwoFaDeactivated = 'two_fa_deactivated'; // TODO
4343
}

src/Command/CleanIndexCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
namespace App\Command;
1414

1515
use Algolia\AlgoliaSearch\SearchClient;
16-
use Symfony\Component\Console\Input\InputInterface;
17-
use Symfony\Component\Console\Output\OutputInterface;
1816
use App\Service\Locker;
1917
use Doctrine\ORM\EntityManagerInterface;
2018
use Symfony\Component\Console\Command\Command;
19+
use Symfony\Component\Console\Input\InputInterface;
20+
use Symfony\Component\Console\Output\OutputInterface;
2121

2222
class CleanIndexCommand extends Command
2323
{
@@ -74,11 +74,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7474
$page = 0;
7575
$perPage = 100;
7676
do {
77-
$results = $index->search('', ['facets' => "*,type,tags", 'facetFilters' => ['type:virtual-package'], 'numericFilters' => ['trendiness=100'], 'hitsPerPage' => $perPage, 'page' => $page]);
77+
$results = $index->search('', ['facets' => '*,type,tags', 'facetFilters' => ['type:virtual-package'], 'numericFilters' => ['trendiness=100'], 'hitsPerPage' => $perPage, 'page' => $page]);
7878
foreach ($results['hits'] as $result) {
79-
if (0 !== strpos($result['objectID'], 'virtual:')) {
80-
$duplicate = $index->search('', ['facets' => "*,objectID,type,tags", 'facetFilters' => ['objectID:virtual:'.$result['objectID']]]);
81-
if (count($duplicate['hits']) === 1) {
79+
if (!str_starts_with($result['objectID'], 'virtual:')) {
80+
$duplicate = $index->search('', ['facets' => '*,objectID,type,tags', 'facetFilters' => ['objectID:virtual:'.$result['objectID']]]);
81+
if (\count($duplicate['hits']) === 1) {
8282
if ($verbose) {
8383
$output->writeln('Deleting '.$result['objectID'].' which is a duplicate of '.$duplicate['hits'][0]['objectID']);
8484
}
@@ -95,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9595
}
9696
}
9797
$page++;
98-
} while (count($results['hits']) >= $perPage);
98+
} while (\count($results['hits']) >= $perPage);
9999

100100
$this->locker->unlockCommand(__CLASS__);
101101

src/Command/CleanSpamPackagesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
namespace App\Command;
1414

15+
use App\Entity\Package;
1516
use App\Entity\PackageFreezeReason;
1617
use App\Entity\Version;
1718
use App\Entity\VersionRepository;
1819
use App\Model\PackageManager;
1920
use App\Model\ProviderManager;
2021
use Doctrine\Persistence\ManagerRegistry;
21-
use App\Entity\Package;
2222
use Symfony\Component\Console\Command\Command;
2323
use Symfony\Component\Console\Input\InputInterface;
2424
use Symfony\Component\Console\Output\OutputInterface;

src/Command/ClearVersionsCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
namespace App\Command;
1414

15-
use Doctrine\Persistence\ManagerRegistry;
1615
use App\Entity\Package;
1716
use App\Entity\Version;
17+
use Doctrine\Persistence\ManagerRegistry;
1818
use Symfony\Component\Console\Command\Command;
19+
use Symfony\Component\Console\Input\InputArgument;
1920
use Symfony\Component\Console\Input\InputInterface;
2021
use Symfony\Component\Console\Input\InputOption;
21-
use Symfony\Component\Console\Input\InputArgument;
2222
use Symfony\Component\Console\Output\OutputInterface;
2323

2424
/**

src/Command/CompileStatsCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
namespace App\Command;
1414

15-
use Doctrine\DBAL\Connection;
16-
use Doctrine\Persistence\ManagerRegistry;
17-
use Symfony\Component\Console\Input\InputInterface;
18-
use Symfony\Component\Console\Output\OutputInterface;
1915
use App\Entity\Download;
2016
use App\Service\Locker;
17+
use Doctrine\DBAL\Connection;
18+
use Doctrine\Persistence\ManagerRegistry;
2119
use Predis\Client;
2220
use Symfony\Component\Console\Command\Command;
21+
use Symfony\Component\Console\Input\InputInterface;
22+
use Symfony\Component\Console\Output\OutputInterface;
2323

2424
/**
2525
* @author Jordi Boggiano <j.boggiano@seld.be>

src/Command/DumpPackagesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
namespace App\Command;
1414

15-
use Doctrine\Persistence\ManagerRegistry;
1615
use App\Entity\Package;
1716
use App\Package\SymlinkDumper;
1817
use App\Service\Locker;
18+
use Doctrine\Persistence\ManagerRegistry;
1919
use Psr\Log\LoggerInterface;
2020
use Seld\Signal\SignalHandler;
2121
use Symfony\Component\Console\Command\Command;

src/Command/DumpPackagesV2Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
namespace App\Command;
1414

15-
use Doctrine\Persistence\ManagerRegistry;
1615
use App\Entity\Package;
1716
use App\Package\V2Dumper;
1817
use App\Service\Locker;
18+
use Doctrine\Persistence\ManagerRegistry;
1919
use Psr\Log\LoggerInterface;
2020
use Seld\Signal\SignalHandler;
2121
use Symfony\Component\Console\Command\Command;

src/Command/GenerateTokensCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
namespace App\Command;
1414

15+
use App\Entity\User;
1516
use App\Util\DoctrineTrait;
1617
use Doctrine\Persistence\ManagerRegistry;
17-
use App\Entity\User;
1818
use Symfony\Component\Console\Command\Command;
1919
use Symfony\Component\Console\Input\InputInterface;
2020
use Symfony\Component\Console\Output\OutputInterface;

0 commit comments

Comments
 (0)