Skip to content

Commit

Permalink
Enhancement: Executed rector PHP 8.2 set
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Sep 17, 2024
1 parent 1397f2d commit bb02049
Show file tree
Hide file tree
Showing 51 changed files with 346 additions and 523 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
php-version: 8.3
coverage: none
tools: php-cs-fixer:3.42, cs2pr
tools: php-cs-fixer:3.64, cs2pr

- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doctrine:
mappings:
App:
is_bundle: false
type: annotation
type: attribute
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
7 changes: 2 additions & 5 deletions public/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
exit("This script cannot be run from the CLI. Run it from a browser.\n");
}

if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))) {
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
header('HTTP/1.0 403 Forbidden');
exit('This script is only accessible from localhost.');
}

require_once dirname(__FILE__).'/../app/SymfonyRequirements.php';
require_once __DIR__.'/../app/SymfonyRequirements.php';

$symfonyRequirements = new SymfonyRequirements();

Expand Down
4 changes: 1 addition & 3 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
return fn(array $context) => new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
20 changes: 7 additions & 13 deletions src/Api/Issue/GithubIssueApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@

class GithubIssueApi implements IssueApi
{
private $resultPager;
private $issueCommentApi;
private $issueApi;
private $searchApi;
private $botUsername;

public function __construct(ResultPager $resultPager, Comments $issueCommentApi, Issue $issueApi, Search $searchApi, string $botUsername)
{
$this->resultPager = $resultPager;
$this->issueCommentApi = $issueCommentApi;
$this->issueApi = $issueApi;
$this->searchApi = $searchApi;
$this->botUsername = $botUsername;
public function __construct(
private readonly ResultPager $resultPager,
private readonly Comments $issueCommentApi,
private readonly Issue $issueApi,
private readonly Search $searchApi,
private readonly string $botUsername,
) {
}

public function open(Repository $repository, string $title, string $body, array $labels)
Expand Down
36 changes: 8 additions & 28 deletions src/Api/Label/GithubLabelApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,14 @@ class GithubLabelApi implements LabelApi
*
* @var array<array-key, array<array-key, bool>>
*/
private $labelCache = [];

/**
* @var Labels
*/
private $labelsApi;

/**
* @var ResultPager
*/
private $resultPager;

/**
* @var CacheInterface
*/
private $cache;

/**
* @var LoggerInterface
*/
private $logger;

public function __construct(Labels $labelsApi, ResultPager $resultPager, CacheInterface $cache, LoggerInterface $logger)
{
$this->labelsApi = $labelsApi;
$this->resultPager = $resultPager;
$this->cache = $cache;
$this->logger = $logger;
private array $labelCache = [];

public function __construct(
private readonly Labels $labelsApi,
private readonly ResultPager $resultPager,
private readonly CacheInterface $cache,
private readonly LoggerInterface $logger,
) {
}

public function getIssueLabels($issueNumber, Repository $repository): array
Expand Down
20 changes: 5 additions & 15 deletions src/Api/Milestone/GithubMilestoneApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,15 @@
*/
class GithubMilestoneApi implements MilestoneApi
{
/**
* @var Milestones
*/
private $milestonesApi;

/**
* @var Issue
*/
private $issuesApi;

/**
* @var string[][]
*/
private $cache = [];
private array $cache = [];

public function __construct(Milestones $milestonesApi, Issue $issuesApi)
{
$this->milestonesApi = $milestonesApi;
$this->issuesApi = $issuesApi;
public function __construct(
private readonly Milestones $milestonesApi,
private readonly Issue $issuesApi,
) {
}

private function getMilestones(Repository $repository): array
Expand Down
13 changes: 5 additions & 8 deletions src/Api/PullRequest/GithubPullRequestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@
*/
class GithubPullRequestApi implements PullRequestApi
{
private $pullRequest;
private $search;

public function __construct(PullRequest $pullRequest, Search $search)
{
$this->pullRequest = $pullRequest;
$this->search = $search;
public function __construct(
private readonly PullRequest $pullRequest,
private readonly Search $search,
) {
}

public function show(Repository $repository, $number): array
{
return (array) $this->pullRequest->show($repository->getVendor(), $repository->getName(), $number);
}

public function updateTitle(Repository $repository, $number, string $title, string $body = null): void
public function updateTitle(Repository $repository, $number, string $title, ?string $body = null): void
{
$params = ['title' => $title];

Expand Down
2 changes: 1 addition & 1 deletion src/Api/PullRequest/NullPullRequestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function show(Repository $repository, $number): array
return [];
}

public function updateTitle(Repository $repository, $number, string $title, string $body = null): void
public function updateTitle(Repository $repository, $number, string $title, ?string $body = null): void
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Api/PullRequest/PullRequestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface PullRequestApi
{
public function show(Repository $repository, $number): array;

public function updateTitle(Repository $repository, $number, string $title, string $body = null): void;
public function updateTitle(Repository $repository, $number, string $title, ?string $body = null): void;

public function getAuthorCount(Repository $repository, string $author): int;
}
23 changes: 7 additions & 16 deletions src/Api/Status/GitHubStatusApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,20 @@

class GitHubStatusApi implements StatusApi
{
private static $statusToLabel = [
private static array $statusToLabel = [
Status::NEEDS_REVIEW => 'Status: Needs Review',
Status::NEEDS_WORK => 'Status: Needs Work',
Status::WORKS_FOR_ME => 'Status: Works for me',
Status::REVIEWED => 'Status: Reviewed',
];

private $labelToStatus = [];
private array $labelToStatus;

/**
* @var LabelApi
*/
private $labelsApi;
/**
* @var LoggerInterface
*/
private $logger;

public function __construct(LabelApi $labelsApi, LoggerInterface $logger)
{
$this->labelsApi = $labelsApi;
public function __construct(
private readonly LabelApi $labelsApi,
private readonly LoggerInterface $logger,
) {
$this->labelToStatus = array_flip(self::$statusToLabel);
$this->logger = $logger;
}

/**
Expand Down Expand Up @@ -92,7 +83,7 @@ public function getIssueStatus($issueNumber, Repository $repository): ?string
return null;
}

public static function getNeedsReviewLabel()
public static function getNeedsReviewLabel(): string
{
return self::$statusToLabel[Status::NEEDS_REVIEW];
}
Expand Down
11 changes: 4 additions & 7 deletions src/Api/Workflow/GithubWorkflowApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
*/
class GithubWorkflowApi implements WorkflowApi
{
private ResultPager $resultPager;
private WorkflowRuns $workflowApi;

public function __construct(ResultPager $resultPager, WorkflowRuns $workflowApi)
{
$this->resultPager = $resultPager;
$this->workflowApi = $workflowApi;
public function __construct(
private readonly ResultPager $resultPager,
private readonly WorkflowRuns $workflowApi,
) {
}

public function approveWorkflowsForPullRequest(Repository $repository, string $headRepository, string $headBranch): void
Expand Down
7 changes: 3 additions & 4 deletions src/Command/ListTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
class ListTaskCommand extends Command
{
protected static $defaultName = 'app:task:list';
private $repository;

public function __construct(TaskRepository $repository)
{
public function __construct(
private readonly TaskRepository $repository,
) {
parent::__construct();
$this->repository = $repository;
}

protected function configure()
Expand Down
20 changes: 7 additions & 13 deletions src/Command/PingStaleIssuesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,14 @@ class PingStaleIssuesCommand extends Command

protected static $defaultName = 'app:issue:ping-stale';

private $repositoryProvider;
private $issueApi;
private $scheduler;
private $commentGenerator;
private $labelApi;

public function __construct(RepositoryProvider $repositoryProvider, IssueApi $issueApi, TaskScheduler $scheduler, StaleIssueCommentGenerator $commentGenerator, LabelApi $labelApi)
{
public function __construct(
private readonly RepositoryProvider $repositoryProvider,
private readonly IssueApi $issueApi,
private readonly TaskScheduler $scheduler,
private readonly StaleIssueCommentGenerator $commentGenerator,
private readonly LabelApi $labelApi,
) {
parent::__construct();
$this->repositoryProvider = $repositoryProvider;
$this->issueApi = $issueApi;
$this->scheduler = $scheduler;
$this->commentGenerator = $commentGenerator;
$this->labelApi = $labelApi;
}

protected function configure()
Expand Down
13 changes: 5 additions & 8 deletions src/Command/RunTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@
class RunTaskCommand extends Command
{
protected static $defaultName = 'app:task:run';
private $repository;
private $taskRunner;
private $logger;

public function __construct(TaskRepository $repository, TaskRunner $taskRunner, LoggerInterface $logger)
{
public function __construct(
private readonly TaskRepository $repository,
private readonly TaskRunner $taskRunner,
private readonly LoggerInterface $logger,
) {
parent::__construct();
$this->repository = $repository;
$this->taskRunner = $taskRunner;
$this->logger = $logger;
}

protected function configure()
Expand Down
Loading

0 comments on commit bb02049

Please # to comment.