Skip to content

Commit 866f561

Browse files
indykoningStyleCIBotroyduinrbnmulder
authored
Raise PHPStan to level 5, fix phpcs, add labels and update workflows (#149)
Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Roy Duineveld <royduineveld@gmail.com> Co-authored-by: Robin Mulder <rbn.mulder@gmail.com>
1 parent d416e4d commit 866f561

File tree

21 files changed

+308
-61
lines changed

21 files changed

+308
-61
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@
1818
Example: The exact commands you ran and their output,
1919
screenshots / videos if the pull request changes UI.
2020
-->
21+
22+
**Checklist**
23+
24+
- [ ] I've ran `composer run codestyle`
25+
- [ ] I've ran `composer run phpstan`

.github/workflows/analyse.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: PHPStan
22

3-
on: ['push', 'pull_request']
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
48

59
jobs:
610
test:
@@ -22,4 +26,4 @@ jobs:
2226
run: composer install --no-interaction
2327

2428
- name: Analyse
25-
run: vendor/bin/phpstan analyse
29+
run: composer run analyse

.github/workflows/php.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
name: PHPCS
2-
on: [push]
1+
name: Code Style
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
39
jobs:
4-
build:
10+
test:
511
runs-on: ubuntu-latest
12+
name: PHPCS
13+
614
steps:
7-
- uses: actions/checkout@master
8-
- name: PHPCS
9-
run: docker run --rm -v $PWD:/code:ro domw/phpcs phpcs --colors --standard=Magento2 --report=full,summary,gitblame --extensions=php,phtml ./
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.2
22+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
23+
coverage: none
24+
25+
- name: Install dependencies
26+
run: composer install --no-interaction
27+
28+
- name: Analyse
29+
run: composer run phpcs

Block/Adminhtml/System/Config/DeploymentConfigInfo.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class DeploymentConfigInfo extends Field
1818
* DeploymentConfigInfo constructor.
1919
*
2020
* @param Context $context
21-
* @param array $data
2221
* @param Version $version
22+
* @param array $data
2323
*/
2424
public function __construct(
2525
Context $context,
@@ -29,6 +29,13 @@ public function __construct(
2929
parent::__construct($context, $data);
3030
}
3131

32+
/**
33+
* Render the field.
34+
*
35+
* @param AbstractElement $element
36+
*
37+
* @return string
38+
*/
3239
public function render(AbstractElement $element)
3340
{
3441
return $this->_toHtml();

Block/SentryScript.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99

1010
class SentryScript extends Template
1111
{
12-
const CURRENT_VERSION = '8.7.0';
12+
public const CURRENT_VERSION = '8.7.0';
1313

1414
/**
1515
* SentryScript constructor.
1616
*
1717
* @param DataHelper $dataHelper
18+
* @param Version $version
1819
* @param Template\Context $context
20+
* @param Json $json
1921
* @param array $data
2022
*/
2123
public function __construct(
@@ -92,26 +94,41 @@ public function getEnvironment()
9294
return $this->dataHelper->getEnvironment();
9395
}
9496

97+
/**
98+
* Whether to enable session replay.
99+
*/
95100
public function useSessionReplay(): bool
96101
{
97102
return $this->dataHelper->useSessionReplay();
98103
}
99104

105+
/**
106+
* Get the session replay sample rate.
107+
*/
100108
public function getReplaySessionSampleRate(): float
101109
{
102110
return $this->dataHelper->getReplaySessionSampleRate();
103111
}
104112

113+
/**
114+
* Get the session replay error sample rate.
115+
*/
105116
public function getReplayErrorSampleRate(): float
106117
{
107118
return $this->dataHelper->getReplayErrorSampleRate();
108119
}
109120

121+
/**
122+
* Whether to block media during replay.
123+
*/
110124
public function getReplayBlockMedia(): bool
111125
{
112126
return $this->dataHelper->getReplayBlockMedia();
113127
}
114128

129+
/**
130+
* Whether to show mask text.
131+
*/
115132
public function getReplayMaskText(): bool
116133
{
117134
return $this->dataHelper->getReplayMaskText();
@@ -167,21 +184,35 @@ public function stripStoreCode()
167184
return $this->dataHelper->stripStoreCode();
168185
}
169186

187+
/**
188+
* Get Store code.
189+
*
190+
* @return string
191+
*/
170192
public function getStoreCode()
171193
{
172194
return $this->_storeManager->getStore()->getCode();
173195
}
174196

197+
/**
198+
* Whether tracing is enabled.
199+
*/
175200
public function isTracingEnabled(): bool
176201
{
177202
return $this->dataHelper->isTracingEnabled();
178203
}
179204

205+
/**
206+
* Get sample rate for tracing.
207+
*/
180208
public function getTracingSampleRate(): float
181209
{
182210
return $this->dataHelper->getTracingSampleRate();
183211
}
184212

213+
/**
214+
* Get a list of js errors to ignore.
215+
*/
185216
public function getIgnoreJsErrors(): string
186217
{
187218
return $this->json->serialize($this->dataHelper->getIgnoreJsErrors());

Controller/Adminhtml/Test/Sentry.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Sentry extends Action
1717
*
1818
* @see _isAllowed()
1919
*/
20-
const ADMIN_RESOURCE = 'JustBetter_Sentry::sentry';
20+
public const ADMIN_RESOURCE = 'JustBetter_Sentry::sentry';
2121

2222
/**
2323
* Sentry constructor.
@@ -43,7 +43,7 @@ public function __construct(
4343
/**
4444
* Execute view action.
4545
*
46-
* @return \Magento\Framework\Controller\ResultInterface
46+
* @return \Magento\Framework\Controller\ResultInterface|\Magento\Framework\App\ResponseInterface
4747
*/
4848
public function execute()
4949
{
@@ -68,7 +68,10 @@ public function execute()
6868
$result['content'] = implode(PHP_EOL, $activeWithReason['reasons']);
6969
}
7070

71-
return $this->getResponse()->representJson(
71+
/** @var \Magento\Framework\App\Response\Http $response */
72+
$response = $this->getResponse();
73+
74+
return $response->representJson(
7275
$this->jsonSerializer->serialize($result)
7376
);
7477
}

0 commit comments

Comments
 (0)