Skip to content

Commit b528c74

Browse files
authored
Fixed static analysers (#205)
* Fixed static analyers * Update config files * PHPStan fixes * PHP-cs-fixer fixes * fixes
1 parent 15188fe commit b528c74

File tree

11 files changed

+69
-66
lines changed

11 files changed

+69
-66
lines changed

.github/workflows/static.yml

+25-20
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,59 @@ on:
99
jobs:
1010
phpstan:
1111
name: PHPStan
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-20.04
1313

1414
steps:
15-
- name: Set up PHP
16-
uses: shivammathur/setup-php@2.7.0
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
1717
with:
18-
php-version: '7.4'
18+
php-version: 7.4
1919
coverage: none
20+
tools: phpstan:1.4.6, cs2pr
2021

2122
- name: Checkout code
2223
uses: actions/checkout@v2
2324

2425
- name: Download dependencies
25-
run: composer install --no-interaction --optimize-autoloader
26+
uses: ramsey/composer-install@v1
2627

2728
- name: PHPStan
28-
uses: docker://oskarstark/phpstan-ga:0.12.48
29-
with:
30-
entrypoint: /composer/vendor/bin/phpstan
31-
args: analyze --no-progress
29+
run: phpstan analyze --no-progress --error-format=checkstyle | cs2pr
3230

3331
php-cs-fixer:
3432
name: PHP-CS-Fixer
35-
runs-on: ubuntu-latest
33+
runs-on: ubuntu-20.04
3634

3735
steps:
36+
- name: Setup PHP
37+
uses: shivammathur/setup-php@v2
38+
with:
39+
php-version: 7.4
40+
coverage: none
41+
tools: php-cs-fixer:3.6, cs2pr
42+
3843
- name: Checkout code
3944
uses: actions/checkout@v2
4045

4146
- name: PHP-CS-Fixer
42-
uses: docker://oskarstark/php-cs-fixer-ga:2.16.4
43-
with:
44-
args: --dry-run --diff-format udiff
47+
run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr
4548

4649
psalm:
4750
name: Psalm
48-
runs-on: ubuntu-latest
51+
runs-on: ubuntu-20.04
4952
steps:
50-
- name: Set up PHP
51-
uses: shivammathur/setup-php@2.7.0
53+
- name: Setup PHP
54+
uses: shivammathur/setup-php@v2
5255
with:
53-
php-version: '7.4'
56+
php-version: 8.1
5457
coverage: none
58+
tools: vimeo/psalm:4.22.0
5559

5660
- name: Checkout code
5761
uses: actions/checkout@v2
5862

63+
- name: Download dependencies
64+
uses: ramsey/composer-install@v1
65+
5966
- name: Psalm
60-
uses: docker://vimeo/psalm-github-actions:3.17.2
61-
with:
62-
args: --no-progress --show-info=false --stats
67+
run: psalm --no-progress --output-format=github

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/vendor/
99
###< symfony/framework-bundle ###
1010

11-
.php_cs.cache
11+
.php-cs-fixer.cache
1212

1313
###> phpunit/phpunit ###
1414
/phpunit.xml

.php_cs renamed to .php-cs-fixer.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
22

3-
$finder = PhpCsFixer\Finder::create()
3+
$finder = (new PhpCsFixer\Finder())
44
->in(__DIR__.'/src')
55
->in(__DIR__.'/tests')
66
;
77

8-
return PhpCsFixer\Config::create()
9-
->setRiskyAllowed(false)
8+
return (new PhpCsFixer\Config())
109
->setRules([
1110
'@PSR2' => true,
1211
'@Symfony' => true,

phpstan.neon.dist

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
parameters:
22
level: 5
3+
reportUnmatchedIgnoredErrors: false
34
paths:
45
- src
6+
ignoreErrors:
7+
- "#\\\\Entity\\\\.* is never written, only read#"
8+
- "#\\\\Entity\\\\.* is never read, only written#"
9+
- "#^Property .*\\\\Entity\\\\.* is unused#"

src/Api/Status/Status.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
*/
1010
final class Status
1111
{
12-
const NEEDS_REVIEW = 'needs_review';
12+
public const NEEDS_REVIEW = 'needs_review';
1313

14-
const NEEDS_WORK = 'needs_work';
14+
public const NEEDS_WORK = 'needs_work';
1515

16-
const WORKS_FOR_ME = 'works_for_me';
16+
public const WORKS_FOR_ME = 'works_for_me';
1717

18-
const REVIEWED = 'reviewed';
18+
public const REVIEWED = 'reviewed';
1919
}

src/Api/Workflow/GithubWorkflowApi.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use App\Model\Repository;
66
use Github\Api\Repository\Actions\WorkflowRuns;
77
use Github\ResultPager;
8-
use Psr\Log\LoggerInterface;
98

109
/**
1110
* @author Tobias Nyholm <[email protected]>
@@ -14,13 +13,11 @@ class GithubWorkflowApi implements WorkflowApi
1413
{
1514
private ResultPager $resultPager;
1615
private WorkflowRuns $workflowApi;
17-
private LoggerInterface $logger;
1816

19-
public function __construct(ResultPager $resultPager, WorkflowRuns $workflowApi, LoggerInterface $logger)
17+
public function __construct(ResultPager $resultPager, WorkflowRuns $workflowApi)
2018
{
2119
$this->resultPager = $resultPager;
2220
$this->workflowApi = $workflowApi;
23-
$this->logger = $logger;
2421
}
2522

2623
public function approveWorkflowsForPullRequest(Repository $repository, string $headRepository, string $headBranch): void

src/Entity/Task.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616
class Task
1717
{
18-
const ACTION_CLOSE_STALE = 1;
19-
const ACTION_CLOSE_DRAFT = 2;
20-
const ACTION_INFORM_CLOSE_STALE = 3;
21-
const ACTION_SUGGEST_REVIEWER = 4;
18+
public const ACTION_CLOSE_STALE = 1;
19+
public const ACTION_CLOSE_DRAFT = 2;
20+
public const ACTION_INFORM_CLOSE_STALE = 3;
21+
public const ACTION_SUGGEST_REVIEWER = 4;
2222

2323
/**
2424
* @var int

src/GitHubEvents.php

+22-22
Original file line numberDiff line numberDiff line change
@@ -12,68 +12,68 @@
1212
final class GitHubEvents
1313
{
1414
/** @Event('\App\Event\GitHubEvent') */
15-
const COMMIT_COMMENT = 'github.commit_comment';
15+
public const COMMIT_COMMENT = 'github.commit_comment';
1616

1717
/** @Event('\App\Event\GitHubEvent') */
18-
const CREATE = 'github.create';
18+
public const CREATE = 'github.create';
1919

2020
/** @Event('\App\Event\GitHubEvent') */
21-
const DELETE = 'github.delete';
21+
public const DELETE = 'github.delete';
2222

2323
/** @Event('\App\Event\GitHubEvent') */
24-
const DEPLOYMENT = 'github.deployment';
24+
public const DEPLOYMENT = 'github.deployment';
2525

2626
/** @Event('\App\Event\GitHubEvent') */
27-
const DEPLOYMENT_STATUS = 'github.deployment_status';
27+
public const DEPLOYMENT_STATUS = 'github.deployment_status';
2828

2929
/** @Event('\App\Event\GitHubEvent') */
30-
const FORK = 'github.fork';
30+
public const FORK = 'github.fork';
3131

3232
/** @Event('\App\Event\GitHubEvent') */
33-
const GOLLUM = 'github.gollum';
33+
public const GOLLUM = 'github.gollum';
3434

3535
/** @Event('\App\Event\GitHubEvent') */
36-
const ISSUE_COMMENT = 'github.issue_comment';
36+
public const ISSUE_COMMENT = 'github.issue_comment';
3737

3838
/** @Event('\App\Event\GitHubEvent') */
39-
const ISSUES = 'github.issues';
39+
public const ISSUES = 'github.issues';
4040

4141
/** @Event('\App\Event\GitHubEvent') */
42-
const MEMBER = 'github.member';
42+
public const MEMBER = 'github.member';
4343

4444
/** @Event('\App\Event\GitHubEvent') */
45-
const MEMBERSHIP = 'github.membership';
45+
public const MEMBERSHIP = 'github.membership';
4646

4747
/** @Event('\App\Event\GitHubEvent') */
48-
const PAGE_BUILD = 'github.page_build';
48+
public const PAGE_BUILD = 'github.page_build';
4949

5050
/** @Event('\App\Event\GitHubEvent') */
51-
const IS_PUBLIC = 'github.public';
51+
public const IS_PUBLIC = 'github.public';
5252

5353
/** @Event('\App\Event\GitHubEvent') */
54-
const PR_REVIEW_COMMENT = 'github.pull_request_review_comment';
54+
public const PR_REVIEW_COMMENT = 'github.pull_request_review_comment';
5555

5656
/** @Event('\App\Event\GithubEvent') */
57-
const PULL_REQUEST_REVIEW = 'github.pull_request_review';
57+
public const PULL_REQUEST_REVIEW = 'github.pull_request_review';
5858

5959
/** @Event('\App\Event\GitHubEvent') */
60-
const PULL_REQUEST = 'github.pull_request';
60+
public const PULL_REQUEST = 'github.pull_request';
6161

6262
/** @Event('\App\Event\GitHubEvent') */
63-
const PUSH = 'github.push';
63+
public const PUSH = 'github.push';
6464

6565
/** @Event('\App\Event\GitHubEvent') */
66-
const REPOSITORY = 'github.repository';
66+
public const REPOSITORY = 'github.repository';
6767

6868
/** @Event('\App\Event\GitHubEvent') */
69-
const RELEASE = 'github.release';
69+
public const RELEASE = 'github.release';
7070

7171
/** @Event('\App\Event\GitHubEvent') */
72-
const STATUS = 'github.status';
72+
public const STATUS = 'github.status';
7373

7474
/** @Event('\App\Event\GitHubEvent') */
75-
const TEAM_ADD = 'github.team_add';
75+
public const TEAM_ADD = 'github.team_add';
7676

7777
/** @Event('\App\Event\GitHubEvent') */
78-
const WATCH = 'github.watch';
78+
public const WATCH = 'github.watch';
7979
}

src/Subscriber/AllowEditFromMaintainerSubscriber.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Subscriber;
44

55
use App\Api\Issue\IssueApi;
6-
use App\Api\PullRequest\PullRequestApi;
76
use App\Event\GitHubEvent;
87
use App\GitHubEvents;
98
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -14,12 +13,10 @@
1413
class AllowEditFromMaintainerSubscriber implements EventSubscriberInterface
1514
{
1615
private $commentsApi;
17-
private $pullRequestApi;
1816

19-
public function __construct(IssueApi $commentsApi, PullRequestApi $pullRequestApi)
17+
public function __construct(IssueApi $commentsApi)
2018
{
2119
$this->commentsApi = $commentsApi;
22-
$this->pullRequestApi = $pullRequestApi;
2320
}
2421

2522
public function onPullRequest(GitHubEvent $event)

tests/Api/Label/GithubLabelApiTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
*/
1717
class GithubLabelApiTest extends TestCase
1818
{
19-
const USER_NAME = 'weaverryan';
19+
public const USER_NAME = 'weaverryan';
2020

21-
const REPO_NAME = 'carson';
21+
public const REPO_NAME = 'carson';
2222

2323
/**
2424
* @var Labels|MockObject

tests/Api/Status/GitHubStatusApiTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
class GitHubStatusApiTest extends TestCase
1717
{
18-
const USER_NAME = 'weaverryan';
18+
public const USER_NAME = 'weaverryan';
1919

20-
const REPO_NAME = 'carson';
20+
public const REPO_NAME = 'carson';
2121

2222
/**
2323
* @var GithubLabelApi|MockObject

0 commit comments

Comments
 (0)