Skip to content

Commit 1cf2a6e

Browse files
committed
Fix code style
1 parent a54013d commit 1cf2a6e

38 files changed

+673
-601
lines changed

bin/create-phar.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
$finder->files()
2626
->ignoreVCS(true)
2727
->name('*.php')
28-
->in(__DIR__.'/../src')
28+
->in(__DIR__ . '/../src')
2929
->sort($finderSort);
3030

3131
foreach ($finder as $file) {
@@ -36,7 +36,9 @@
3636
$finder = new Finder();
3737
$finder->files()
3838
->ignoreVCS(true)
39-
->notPath('/\/(composer\.(json|lock)|[A-Z]+\.md(?:own)?|\.gitignore|appveyor.yml|phpunit\.xml\.dist|phpstan\.neon\.dist|phpstan-config\.neon|phpstan-baseline\.neon)$/')
39+
->notPath(
40+
'/\/(composer\.(json|lock)|[A-Z]+\.md(?:own)?|\.gitignore|appveyor.yml|phpunit\.xml\.dist|phpstan\.neon\.dist|phpstan-config\.neon|phpstan-baseline\.neon)$/'
41+
)
4042
->notPath('/bin\/(jsonlint|validate-json|simple-phpunit|phpstan|phpstan\.phar)(\.bat)?$/')
4143
->notPath('composer/installed.json')
4244
->notPath('composer/LICENSE')
@@ -47,15 +49,14 @@
4749
->exclude('Tests')
4850
->exclude('tests')
4951
->exclude('docs')
50-
->in(__DIR__.'/../vendor/')
51-
->sort($finderSort)
52-
;
52+
->in(__DIR__ . '/../vendor/')
53+
->sort($finderSort);
5354

5455
foreach ($finder as $file) {
5556
$phar->addFromString(getRelativeFilePath($file), $file->getContents());
5657
}
5758

58-
$content = file_get_contents(__DIR__.'/dev-tool');
59+
$content = file_get_contents(__DIR__ . '/dev-tool');
5960
$content = str_replace('{^#!/usr/bin/env php\s*}', '', $content);
6061
$phar->addFromString('bin/dev-tool', $content);
6162

@@ -92,7 +93,7 @@ function getStub(): string
9293
function getRelativeFilePath(SplFileInfo $file): string
9394
{
9495
$realPath = $file->getRealPath();
95-
$pathPrefix = dirname(__DIR__).DIRECTORY_SEPARATOR;
96+
$pathPrefix = dirname(__DIR__) . DIRECTORY_SEPARATOR;
9697

9798
$pos = strpos($realPath, $pathPrefix);
9899
$relativePath = ($pos !== false) ? substr_replace($realPath, '', $pos, strlen($pathPrefix)) : $realPath;

src/App/Command/Composer/ComposerFixDependenciesCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616

1717
final class ComposerFixDependenciesCommand extends PackageCommand
1818
{
19-
private array $skippedPackageIds = [];
20-
2119
private const DEV_PATHS = [
2220
'tests',
2321
'config/params-test.php',
2422
'config/tests.php',
2523
'public/index-test.php',
2624
];
27-
2825
private const PRODUCTION_PATHS = [
2926
'config',
3027
'src',
3128
'public/index.php',
3229
];
30+
private array $skippedPackageIds = [];
3331

3432
protected function configure(): void
3533
{
3634
$this
3735
->setName('composer/fix-dependencies')
38-
->setDescription('Fix <fg=yellow;options=bold>require</> and <fg=yellow;options=bold>require-dev</> sections in <fg=blue;options=bold>composer.json</> according to the actual use of classes');
36+
->setDescription(
37+
'Fix <fg=yellow;options=bold>require</> and <fg=yellow;options=bold>require-dev</> sections in <fg=blue;options=bold>composer.json</> according to the actual use of classes'
38+
);
3939

4040
parent::configure();
4141
}

src/App/Command/Git/CheckoutCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ protected function configure(): void
2121
{
2222
$this
2323
->setAliases(['checkout'])
24-
->addArgument('branch', InputArgument::REQUIRED, 'Branch name')
25-
;
24+
->addArgument('branch', InputArgument::REQUIRED, 'Branch name');
2625

2726
parent::configure();
2827
}
2928

3029
protected function beforeProcessingPackages(InputInterface $input): void
3130
{
32-
$this->branch = (string) $input->getArgument('branch');
31+
$this->branch = (string)$input->getArgument('branch');
3332
}
3433

3534
protected function getMessageWhenNothingHasBeenOutput(): ?string

src/App/Command/Git/CommitCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ protected function configure()
2222
{
2323
$this
2424
->setAliases(['commit'])
25-
->addArgument('message', InputArgument::REQUIRED, 'Commit message')
26-
;
25+
->addArgument('message', InputArgument::REQUIRED, 'Commit message');
2726

2827
parent::configure();
2928
}

src/App/Command/Git/RequestPullCommand.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@ protected function configure(): void
2828
->setAliases(['pr'])
2929
->addArgument('title', InputArgument::REQUIRED, 'Title of a pull request.')
3030
->addOption('body', 'b', InputOption::VALUE_REQUIRED, 'Description of a pull request.')
31-
->addOption('no-draft', null, InputOption::VALUE_NONE, 'Make a non-draft pull request.')
32-
;
31+
->addOption('no-draft', null, InputOption::VALUE_NONE, 'Make a non-draft pull request.');
3332

3433
parent::configure();
3534
}
3635

3736
protected function beforeProcessingPackages(InputInterface $input): void
3837
{
39-
$this->title = trim((string) $input->getArgument('title'));
40-
$this->body = trim((string) $input->getOption('body'));
41-
$this->isDraft = !(bool) $input->getOption('no-draft');
38+
$this->title = trim((string)$input->getArgument('title'));
39+
$this->body = trim((string)$input->getOption('body'));
40+
$this->isDraft = !(bool)$input->getOption('no-draft');
4241
}
4342

4443
protected function getMessageWhenNothingHasBeenOutput(): ?string

src/App/Command/Github/ForksRepositoriesCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Yiisoft\YiiDevTool\App\Component\Console\YiiDevToolStyle;
1818
use Yiisoft\YiiDevTool\App\YiiDevToolApplication;
1919

20-
/** @method YiiDevToolApplication getApplication() **/
20+
/** @method YiiDevToolApplication getApplication() */
2121
final class ForksRepositoriesCommand extends Command
2222
{
2323
private ?OutputManager $io = null;
@@ -80,8 +80,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080
private function getToken(): string
8181
{
8282
return $this
83-
->getApplication()
84-
->getConfig()
85-
->getApiToken();
83+
->getApplication()
84+
->getConfig()
85+
->getApiToken();
8686
}
8787
}

src/App/Command/Github/SettingsCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ protected function processPackage(Package $package): void
3939
$repoApi->update($package->getVendor(), $package->getId(), $this->getSettings());
4040
}
4141

42+
private function getToken(): string
43+
{
44+
return $this->getConfig()->getApiToken();
45+
}
46+
4247
private function getSettings(): array
4348
{
4449
$settingsFile = $this->getConfig()->getConfigDir() . 'settings.php';
@@ -47,9 +52,4 @@ private function getSettings(): array
4752
}
4853
return require $settingsFile;
4954
}
50-
51-
private function getToken(): string
52-
{
53-
return $this->getConfig()->getApiToken();
54-
}
5555
}

src/App/Command/Github/SyncUpstreamRepositoriesCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,24 @@ protected function processPackage(Package $package): void
5757
}
5858
}
5959

60-
private function errorMessage($packageName, $message = ''): array
61-
{
62-
$error = $message ? "{$packageName}: {$message}" : $packageName;
63-
return [
64-
"Error when syncing a repository $error ",
65-
'Check if the nickname of the owner and the name of the repository are correct',
66-
];
67-
}
68-
6960
private function getGithubApiRepository(): Repo
7061
{
7162
$client = new Client();
7263
$client->authenticate($this->getToken(), null, AuthMethod::ACCESS_TOKEN);
73-
return (new Repo($client));
64+
return new Repo($client);
7465
}
7566

7667
private function getToken(): string
7768
{
7869
return $this->getConfig()->getApiToken();
7970
}
71+
72+
private function errorMessage($packageName, $message = ''): array
73+
{
74+
$error = $message ? "{$packageName}: {$message}" : $packageName;
75+
return [
76+
"Error when syncing a repository $error ",
77+
'Check if the nickname of the owner and the name of the repository are correct',
78+
];
79+
}
8080
}

src/App/Command/LintCommand.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHP_CodeSniffer\Config;
88
use PHP_CodeSniffer\Runner;
99
use PHP_CodeSniffer\Util\Timing;
10+
use ReflectionClass;
1011
use Yiisoft\YiiDevTool\App\Component\Console\PackageCommand;
1112
use Yiisoft\YiiDevTool\App\Component\Package\Package;
1213

@@ -32,8 +33,8 @@ protected function processPackage(Package $package): void
3233
$io->preparePackageHeader($package, 'Linting package {package}');
3334

3435
$pharFile = 'phar://' . $this->getApplication()->getRootDir() . 'devtool.phar';
35-
if (is_file($pharFile .'/vendor/squizlabs/php_codesniffer/autoload.php') === true) {
36-
include_once $pharFile .'/vendor/squizlabs/php_codesniffer/autoload.php';
36+
if (is_file($pharFile . '/vendor/squizlabs/php_codesniffer/autoload.php') === true) {
37+
include_once $pharFile . '/vendor/squizlabs/php_codesniffer/autoload.php';
3738
} else {
3839
$io->error('Failed to load autoload file php_codesniffer vendor package.');
3940
exit(1);
@@ -42,19 +43,19 @@ protected function processPackage(Package $package): void
4243
$_SERVER['argv'] = [
4344
'',
4445
$package->getPath(),
45-
$io->hasColorSupport() ? "--colors" : "--no-colors",
46-
"--standard=PSR12",
47-
"--ignore=*/vendor/*,*/docs/*",
46+
$io->hasColorSupport() ? '--colors' : '--no-colors',
47+
'--standard=PSR12',
48+
'--ignore=*/vendor/*,*/docs/*',
4849
];
4950

50-
$reflection = new \ReflectionClass(Config::class);
51+
$reflection = new ReflectionClass(Config::class);
5152
$reflection->setStaticPropertyValue('overriddenDefaults', []);
5253

53-
$reflection = new \ReflectionClass(Timing::class);
54+
$reflection = new ReflectionClass(Timing::class);
5455
$reflection->setStaticPropertyValue('printed', false);
5556

5657
ob_start();
57-
$runner = new Runner();
58+
$runner = new Runner();
5859
$exitCode = $runner->runPHPCS();
5960
$result = ob_get_contents();
6061
ob_clean();

src/App/Command/Packages/AddCommand.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Yiisoft\YiiDevTool\App\Component\Console\YiiDevToolStyle;
1717
use Yiisoft\YiiDevTool\App\YiiDevToolApplication;
1818

19-
/** @method YiiDevToolApplication getApplication() **/
19+
/** @method YiiDevToolApplication getApplication() */
2020
final class AddCommand extends Command
2121
{
2222
protected function configure()
@@ -26,16 +26,21 @@ protected function configure()
2626
->setAliases(['add'])
2727
->setDescription('Add packages')
2828
->addArgument(
29-
'packages',
30-
InputArgument::OPTIONAL,
31-
<<<DESCRIPTION
32-
Package names separated by commas. For example: <fg=cyan;options=bold>rbac,di,demo,db-mysql</>
33-
DESCRIPTION
34-
)
35-
->addOption('owner', null, InputOption::VALUE_REQUIRED, 'Packages Owner')
36-
->addOption('all', 'a', InputOption::VALUE_NONE, 'Add all packages')
37-
->addOption('perPage', null, InputOption::VALUE_REQUIRED, 'Number of requested repositories. Default 30 (мax: 100) ')
38-
->addOption('page', null, InputOption::VALUE_REQUIRED, 'Page number of the requested repositories list');
29+
'packages',
30+
InputArgument::OPTIONAL,
31+
<<<DESCRIPTION
32+
Package names separated by commas. For example: <fg=cyan;options=bold>rbac,di,demo,db-mysql</>
33+
DESCRIPTION
34+
)
35+
->addOption('owner', null, InputOption::VALUE_REQUIRED, 'Packages Owner')
36+
->addOption('all', 'a', InputOption::VALUE_NONE, 'Add all packages')
37+
->addOption(
38+
'perPage',
39+
null,
40+
InputOption::VALUE_REQUIRED,
41+
'Number of requested repositories. Default 30 (мax: 100) '
42+
)
43+
->addOption('page', null, InputOption::VALUE_REQUIRED, 'Page number of the requested repositories list');
3944
}
4045

4146
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -95,7 +100,7 @@ private function getRepositories(string $owner, int $page = 1, int $perPage = 30
95100
{
96101
$client = new Client();
97102
$client->authenticate($this->getToken(), null, AuthMethod::ACCESS_TOKEN);
98-
$user = new class ($client) extends User {
103+
$user = new class ($client) extends User {
99104
public function userRepositories(
100105
string $username,
101106
string $type = 'owner',
@@ -104,7 +109,7 @@ public function userRepositories(
104109
int $perPage = 30,
105110
int $page = 1
106111
) {
107-
return $this->get('/users/'.rawurlencode($username).'/repos', [
112+
return $this->get('/users/' . rawurlencode($username) . '/repos', [
108113
'type' => $type,
109114
'sort' => $sort,
110115
'direction' => $direction,

0 commit comments

Comments
 (0)