Skip to content

Commit 112b91a

Browse files
committed
minor #92 Automated CS fixes (Nyholm)
This PR was merged into the master branch. Discussion ---------- Automated CS fixes I just ran `php-cs-fixer fix` Commits ------- c1ad683 Automated CS fixes
2 parents 3ddc5ca + c1ad683 commit 112b91a

21 files changed

+58
-86
lines changed

src/Event/GitHubEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
class GitHubEvent extends Event
1414
{
15-
protected $responseData = array();
15+
protected $responseData = [];
1616

1717
private $data;
1818
private $repository;

src/Issues/GitHub/GitHubStatusApi.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,16 @@ public function __construct(CachedLabelsApi $labelsApi, LoggerInterface $logger)
3535
}
3636

3737
/**
38-
* @param int $issueNumber The GitHub issue number
38+
* @param int $issueNumber The GitHub issue number
3939
* @param string|null $newStatus A Status::* constant
40-
* @param Repository $repository
4140
*/
4241
public function setIssueStatus($issueNumber, $newStatus, Repository $repository)
4342
{
4443
if (null !== $newStatus && !isset(self::$statusToLabel[$newStatus])) {
4544
throw new \InvalidArgumentException(sprintf('Invalid status "%s"', $newStatus));
4645
}
4746

48-
$newLabel = $newStatus === null ? null : self::$statusToLabel[$newStatus];
47+
$newLabel = null === $newStatus ? null : self::$statusToLabel[$newStatus];
4948
$this->logger->info(sprintf(
5049
'Fetching issue labels for issue %s, repository %s',
5150
$issueNumber,

src/Issues/GitHub/MilestonesApi.php

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

55
use App\Repository\Repository;
66
use Github\Api\Issue;
7-
use Github\Api\Issue\Labels;
87
use Github\Api\Issue\Milestones;
98

109
/**
@@ -58,7 +57,7 @@ public function updateMilestone(Repository $repository, int $issueNumber, string
5857
}
5958
}
6059

61-
if ($milestoneNumber === null) {
60+
if (null === $milestoneNumber) {
6261
throw new \LogicException(\sprintf('Milestone "%s" does not exist', $milestoneName));
6362
}
6463

src/Issues/GitHubRequestHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public function __construct(EventDispatcherInterface $dispatcher, RepositoryProv
3333
}
3434

3535
/**
36-
* @param Request $request
37-
*
3836
* @return array The response data
3937
*/
4038
public function handle(Request $request)

src/Repository/Provider/InMemoryRepositoryProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
class InMemoryRepositoryProvider implements RepositoryProviderInterface
1111
{
12-
private $repositories = array();
12+
private $repositories = [];
1313

1414
public function __construct(array $repositories)
1515
{

src/Subscriber/AbstractStatusChangeSubscriber.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(StatusApi $statusApi)
2828
*
2929
* @param string $body
3030
*
31-
* @return null|string
31+
* @return string|null
3232
*/
3333
protected function parseStatusFromText($body)
3434
{
@@ -46,4 +46,3 @@ protected function parseStatusFromText($body)
4646
return null;
4747
}
4848
}
49-

src/Subscriber/AutoLabelPRFromContentSubscriber.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public function __construct(CachedLabelsApi $labelsApi)
2929
$this->labelsApi = $labelsApi;
3030
}
3131

32-
/**
33-
* @param GitHubEvent $event
34-
*/
3532
public function onPullRequest(GitHubEvent $event)
3633
{
3734
$data = $event->getData();
@@ -42,7 +39,7 @@ public function onPullRequest(GitHubEvent $event)
4239
$prNumber = $data['pull_request']['number'];
4340
$prTitle = $data['pull_request']['title'];
4441
$prBody = $data['pull_request']['body'];
45-
$prLabels = array();
42+
$prLabels = [];
4643

4744
// the PR title usually contains one or more labels
4845
foreach ($this->extractLabels($prTitle) as $label) {
@@ -65,21 +62,21 @@ public function onPullRequest(GitHubEvent $event)
6562

6663
$this->labelsApi->addIssueLabels($prNumber, $prLabels, $event->getRepository());
6764

68-
$event->setResponseData(array(
65+
$event->setResponseData([
6966
'pull_request' => $prNumber,
7067
'pr_labels' => $prLabels,
71-
));
68+
]);
7269
}
7370

7471
private function extractLabels($prTitle)
7572
{
76-
$labels = array();
73+
$labels = [];
7774

7875
// e.g. "[PropertyAccess] [RFC] [WIP] Allow custom methods on property accesses"
7976
if (preg_match_all('/\[(?P<labels>.+)\]/U', $prTitle, $matches)) {
8077
// creates a key=>val array, but the key is lowercased
8178
$validLabels = array_combine(
82-
array_map(function($s) {
79+
array_map(function ($s) {
8380
return strtolower($s);
8481
}, $this->getValidLabels()),
8582
$this->getValidLabels()
@@ -103,7 +100,7 @@ private function extractLabels($prTitle)
103100
*/
104101
private function getValidLabels()
105102
{
106-
$realLabels = array(
103+
$realLabels = [
107104
'Asset', 'BC Break', 'BrowserKit', 'Bug', 'Cache', 'Config', 'Console',
108105
'Contracts', 'Critical', 'CssSelector', 'Debug', 'DebugBundle', 'DependencyInjection',
109106
'Deprecation', 'Doctrine', 'DoctrineBridge', 'DomCrawler', 'Dotenv',
@@ -117,7 +114,7 @@ private function getValidLabels()
117114
'Translator', 'TwigBridge', 'TwigBundle', 'Uid', 'Validator', 'VarDumper',
118115
'VarExporter', 'WebLink', 'WebProfilerBundle', 'WebServerBundle', 'Workflow',
119116
'Yaml',
120-
);
117+
];
121118

122119
return array_merge(
123120
$realLabels,
@@ -143,8 +140,8 @@ private function fixLabelName($label)
143140

144141
public static function getSubscribedEvents()
145142
{
146-
return array(
143+
return [
147144
GitHubEvents::PULL_REQUEST => 'onPullRequest',
148-
);
145+
];
149146
}
150147
}

src/Subscriber/BugLabelNewIssueSubscriber.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public function __construct(StatusApi $statusApi)
2222

2323
/**
2424
* Changes "Bug" issues to "Needs Review".
25-
*
26-
* @param GitHubEvent $event
2725
*/
2826
public function onIssues(GitHubEvent $event)
2927
{
@@ -33,7 +31,7 @@ public function onIssues(GitHubEvent $event)
3331
return;
3432
}
3533

36-
$responseData = array('issue' => $issueNumber = $data['issue']['number']);
34+
$responseData = ['issue' => $issueNumber = $data['issue']['number']];
3735
// Ignore non-bugs or issue which already has a status
3836
if ('bug' !== strtolower($data['label']['name']) || null !== $this->statusApi->getIssueStatus($issueNumber, $repository)) {
3937
$responseData['status_change'] = null;
@@ -52,8 +50,8 @@ public function onIssues(GitHubEvent $event)
5250

5351
public static function getSubscribedEvents()
5452
{
55-
return array(
53+
return [
5654
GitHubEvents::ISSUES => 'onIssues',
57-
);
55+
];
5856
}
5957
}

src/Subscriber/MilestoneNewPRSubscriber.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
use App\Event\GitHubEvent;
66
use App\GitHubEvents;
7-
use App\Issues\GitHub\CachedMilestonesApi;
87
use App\Issues\GitHub\MilestonesApi;
9-
use App\Issues\Status;
10-
use App\Issues\StatusApi;
118
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
129

1310
/**
@@ -24,8 +21,6 @@ public function __construct(MilestonesApi $milestonesApi)
2421

2522
/**
2623
* Sets milestone on PRs that target non-default branch.
27-
*
28-
* @param GitHubEvent $event
2924
*/
3025
public function onPullRequest(GitHubEvent $event)
3126
{
@@ -47,16 +42,16 @@ public function onPullRequest(GitHubEvent $event)
4742
$pullRequestNumber = $data['pull_request']['number'];
4843
$this->milestonesApi->updateMilestone($repository, $pullRequestNumber, $targetBranch);
4944

50-
$event->setResponseData(array(
45+
$event->setResponseData([
5146
'pull_request' => $pullRequestNumber,
5247
'milestone' => $targetBranch,
53-
));
48+
]);
5449
}
5550

5651
public static function getSubscribedEvents()
5752
{
58-
return array(
53+
return [
5954
GitHubEvents::PULL_REQUEST => 'onPullRequest',
60-
);
55+
];
6156
}
6257
}

src/Subscriber/NeedsReviewNewPRSubscriber.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ public function __construct(StatusApi $statusApi)
1919

2020
/**
2121
* Adds a "Needs Review" label to new PRs.
22-
*
23-
* @param GitHubEvent $event
2422
*/
2523
public function onPullRequest(GitHubEvent $event)
2624
{
@@ -35,16 +33,16 @@ public function onPullRequest(GitHubEvent $event)
3533

3634
$this->statusApi->setIssueStatus($pullRequestNumber, $newStatus, $repository);
3735

38-
$event->setResponseData(array(
36+
$event->setResponseData([
3937
'pull_request' => $pullRequestNumber,
4038
'status_change' => $newStatus,
41-
));
39+
]);
4240
}
4341

4442
public static function getSubscribedEvents()
4543
{
46-
return array(
44+
return [
4745
GitHubEvents::PULL_REQUEST => 'onPullRequest',
48-
);
46+
];
4947
}
5048
}

0 commit comments

Comments
 (0)