Skip to content

Commit 371c6b8

Browse files
committed
Fix cs
1 parent dd66d16 commit 371c6b8

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

src/Command/ReleaseCommand.php

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the Sonata Project package.
57
*
@@ -23,19 +25,19 @@
2325
*/
2426
final class ReleaseCommand extends AbstractCommand
2527
{
26-
private static $labels = array(
28+
private static $labels = [
2729
'patch' => 'blue',
2830
'bug' => 'red',
2931
'docs' => 'yellow',
3032
'minor' => 'green',
3133
'pedantic' => 'cyan',
32-
);
34+
];
3335

34-
private static $stabilities = array(
36+
private static $stabilities = [
3537
'patch' => 'blue',
3638
'minor' => 'green',
3739
'pedantic' => 'yellow',
38-
);
40+
];
3941

4042
protected function configure(): void
4143
{
@@ -73,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7375
{
7476
$project = $this->getProject($input, $output);
7577
$branches = array_keys($this->configs['projects'][$project]['branches']);
76-
$branch = count($branches) > 1 ? next($branches) : current($branches);
78+
$branch = \count($branches) > 1 ? next($branches) : current($branches);
7779

7880
try {
7981
$package = $this->packagistClient->get(static::PACKAGIST_GROUP.'/'.$project);
@@ -92,11 +94,11 @@ private function getProject(InputInterface $input, OutputInterface $output)
9294

9395
$question = new Question('<info>Please enter the name of the project to release:</info> ');
9496
$question->setAutocompleterValues(array_keys($this->configs['projects']));
95-
$question->setNormalizer(function ($answer) {
97+
$question->setNormalizer(static function ($answer) {
9698
return $answer ? trim($answer) : '';
9799
});
98100
$question->setValidator(function ($answer) {
99-
if (!array_key_exists($answer, $this->configs['projects'])) {
101+
if (!\array_key_exists($answer, $this->configs['projects'])) {
100102
throw new \RuntimeException('The name of the project should be on `projects.yml`');
101103
}
102104

@@ -107,7 +109,7 @@ private function getProject(InputInterface $input, OutputInterface $output)
107109
return $helper->ask($input, $output, $question);
108110
}
109111

110-
private function prepareRelease(Package $package, $branch, OutputInterface $output)
112+
private function prepareRelease(Package $package, $branch, OutputInterface $output): void
111113
{
112114
$repositoryName = $this->getRepositoryName($package);
113115

@@ -137,7 +139,7 @@ private function prepareRelease(Package $package, $branch, OutputInterface $outp
137139
$changelog = array_reduce(
138140
array_filter(array_column($pulls, 'changelog')),
139141
'array_merge_recursive',
140-
array()
142+
[]
141143
);
142144

143145
$this->io->section('Project');
@@ -174,9 +176,9 @@ private function prepareRelease(Package $package, $branch, OutputInterface $outp
174176
}
175177
}
176178

177-
private function printPullRequest($pull, OutputInterface $output)
179+
private function printPullRequest($pull, OutputInterface $output): void
178180
{
179-
if (array_key_exists($pull['stability'], static::$stabilities)) {
181+
if (\array_key_exists($pull['stability'], static::$stabilities)) {
180182
$output->write('<fg=black;bg='.static::$stabilities[$pull['stability']].'>['
181183
.strtoupper($pull['stability']).']</> ');
182184
} else {
@@ -185,7 +187,7 @@ private function printPullRequest($pull, OutputInterface $output)
185187
$output->write('<info>'.$pull['title'].'</info>');
186188

187189
foreach ($pull['labels'] as $label) {
188-
if (!array_key_exists($label['name'], static::$labels)) {
190+
if (!\array_key_exists($label['name'], static::$labels)) {
189191
$output->write(' <error>['.$label['name'].']</error>');
190192
} else {
191193
$output->write(' <fg='.static::$labels[$label['name']].'>['.$label['name'].']</>');
@@ -210,18 +212,18 @@ private function printPullRequest($pull, OutputInterface $output)
210212
$this->io->newLine();
211213
}
212214

213-
private function printRelease($currentVersion, $nextVersion, Package $package, OutputInterface $output)
215+
private function printRelease($currentVersion, $nextVersion, Package $package, OutputInterface $output): void
214216
{
215217
$output->writeln('## ['.$nextVersion.']('
216218
.$package->getRepository().'/compare/'.$currentVersion.'...'.$nextVersion
217219
.') - '.date('Y-m-d'));
218220
}
219221

220-
private function printChangelog($changelog, OutputInterface $output)
222+
private function printChangelog($changelog, OutputInterface $output): void
221223
{
222224
ksort($changelog);
223225
foreach ($changelog as $type => $changes) {
224-
if (count($changes) === 0) {
226+
if (0 === \count($changes)) {
225227
continue;
226228
}
227229

@@ -236,11 +238,11 @@ private function printChangelog($changelog, OutputInterface $output)
236238

237239
private function parseChangelog($pull)
238240
{
239-
$changelog = array();
241+
$changelog = [];
240242
$body = preg_replace('/<!--(.*)-->/Uis', '', $pull['body']);
241243
preg_match('/## Changelog.*```\s*markdown\s*\\n(.*)\\n```/Uis', $body, $matches);
242244

243-
if (count($matches) == 2) {
245+
if (2 == \count($matches)) {
244246
$lines = explode(PHP_EOL, $matches[1]);
245247

246248
$section = '';
@@ -269,10 +271,10 @@ private function determineNextVersion($currentVersion, $pulls)
269271
$stabilities = array_column($pulls, 'stability');
270272
$parts = explode('.', $currentVersion);
271273

272-
if (in_array('minor', $stabilities)) {
273-
return implode(array($parts[0], $parts[1] + 1, 0), '.');
274-
} elseif (in_array('patch', $stabilities)) {
275-
return implode(array($parts[0], $parts[1], $parts[2] + 1), '.');
274+
if (\in_array('minor', $stabilities)) {
275+
return implode('.', [$parts[0], $parts[1] + 1, 0]);
276+
} elseif (\in_array('patch', $stabilities)) {
277+
return implode('.', [$parts[0], $parts[1], $parts[2] + 1]);
276278
}
277279

278280
return $currentVersion;
@@ -282,23 +284,23 @@ private function determinePullRequestStability($pull)
282284
{
283285
$labels = array_column($pull['labels'], 'name');
284286

285-
if (in_array('minor', $labels)) {
287+
if (\in_array('minor', $labels)) {
286288
return 'minor';
287-
} elseif (in_array('patch', $labels)) {
289+
} elseif (\in_array('patch', $labels)) {
288290
return 'patch';
289-
} elseif (array_intersect(array('docs', 'pedantic'), $labels)) {
291+
} elseif (array_intersect(['docs', 'pedantic'], $labels)) {
290292
return 'pedantic';
291293
}
292294
}
293295

294296
private function findPullRequestsSince($date, $repositoryName, $branch)
295297
{
296-
$pulls = $this->githubPaginator->fetchAll($this->githubClient->search(), 'issues', array(
298+
$pulls = $this->githubPaginator->fetchAll($this->githubClient->search(), 'issues', [
297299
'repo:'.static::GITHUB_GROUP.'/'.$repositoryName.
298300
' type:pr is:merged base:'.$branch.' merged:>'.$date,
299-
));
301+
]);
300302

301-
$filteredPulls = array();
303+
$filteredPulls = [];
302304
foreach ($pulls as $pull) {
303305
if ('SonataCI' === $pull['user']['login']) {
304306
continue;

0 commit comments

Comments
 (0)