Skip to content

Commit

Permalink
Raise PHPStan to level 5, fix phpcs, add labels and update workflows (#…
Browse files Browse the repository at this point in the history
…149)

Co-authored-by: StyleCI Bot <[email protected]>
Co-authored-by: Roy Duineveld <[email protected]>
Co-authored-by: Robin Mulder <[email protected]>
  • Loading branch information
4 people authored Oct 11, 2024
1 parent d416e4d commit 866f561
Show file tree
Hide file tree
Showing 21 changed files with 308 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@
Example: The exact commands you ran and their output,
screenshots / videos if the pull request changes UI.
-->

**Checklist**

- [ ] I've ran `composer run codestyle`
- [ ] I've ran `composer run phpstan`
8 changes: 6 additions & 2 deletions .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: PHPStan

on: ['push', 'pull_request']
on:
push:
branches:
- master
pull_request:

jobs:
test:
Expand All @@ -22,4 +26,4 @@ jobs:
run: composer install --no-interaction

- name: Analyse
run: vendor/bin/phpstan analyse
run: composer run analyse
32 changes: 26 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
name: PHPCS
on: [push]
name: Code Style

on:
push:
branches:
- master
pull_request:

jobs:
build:
test:
runs-on: ubuntu-latest
name: PHPCS

steps:
- uses: actions/checkout@master
- name: PHPCS
run: docker run --rm -v $PWD:/code:ro domw/phpcs phpcs --colors --standard=Magento2 --report=full,summary,gitblame --extensions=php,phtml ./
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: composer install --no-interaction

- name: Analyse
run: composer run phpcs
9 changes: 8 additions & 1 deletion Block/Adminhtml/System/Config/DeploymentConfigInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class DeploymentConfigInfo extends Field
* DeploymentConfigInfo constructor.
*
* @param Context $context
* @param array $data
* @param Version $version
* @param array $data
*/
public function __construct(
Context $context,
Expand All @@ -29,6 +29,13 @@ public function __construct(
parent::__construct($context, $data);
}

/**
* Render the field.
*
* @param AbstractElement $element
*
* @return string
*/
public function render(AbstractElement $element)
{
return $this->_toHtml();
Expand Down
33 changes: 32 additions & 1 deletion Block/SentryScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

class SentryScript extends Template
{
const CURRENT_VERSION = '8.7.0';
public const CURRENT_VERSION = '8.7.0';

/**
* SentryScript constructor.
*
* @param DataHelper $dataHelper
* @param Version $version
* @param Template\Context $context
* @param Json $json
* @param array $data
*/
public function __construct(
Expand Down Expand Up @@ -92,26 +94,41 @@ public function getEnvironment()
return $this->dataHelper->getEnvironment();
}

/**
* Whether to enable session replay.
*/
public function useSessionReplay(): bool
{
return $this->dataHelper->useSessionReplay();
}

/**
* Get the session replay sample rate.
*/
public function getReplaySessionSampleRate(): float
{
return $this->dataHelper->getReplaySessionSampleRate();
}

/**
* Get the session replay error sample rate.
*/
public function getReplayErrorSampleRate(): float
{
return $this->dataHelper->getReplayErrorSampleRate();
}

/**
* Whether to block media during replay.
*/
public function getReplayBlockMedia(): bool
{
return $this->dataHelper->getReplayBlockMedia();
}

/**
* Whether to show mask text.
*/
public function getReplayMaskText(): bool
{
return $this->dataHelper->getReplayMaskText();
Expand Down Expand Up @@ -167,21 +184,35 @@ public function stripStoreCode()
return $this->dataHelper->stripStoreCode();
}

/**
* Get Store code.
*
* @return string
*/
public function getStoreCode()
{
return $this->_storeManager->getStore()->getCode();
}

/**
* Whether tracing is enabled.
*/
public function isTracingEnabled(): bool
{
return $this->dataHelper->isTracingEnabled();
}

/**
* Get sample rate for tracing.
*/
public function getTracingSampleRate(): float
{
return $this->dataHelper->getTracingSampleRate();
}

/**
* Get a list of js errors to ignore.
*/
public function getIgnoreJsErrors(): string
{
return $this->json->serialize($this->dataHelper->getIgnoreJsErrors());
Expand Down
9 changes: 6 additions & 3 deletions Controller/Adminhtml/Test/Sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Sentry extends Action
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'JustBetter_Sentry::sentry';
public const ADMIN_RESOURCE = 'JustBetter_Sentry::sentry';

/**
* Sentry constructor.
Expand All @@ -43,7 +43,7 @@ public function __construct(
/**
* Execute view action.
*
* @return \Magento\Framework\Controller\ResultInterface
* @return \Magento\Framework\Controller\ResultInterface|\Magento\Framework\App\ResponseInterface
*/
public function execute()
{
Expand All @@ -68,7 +68,10 @@ public function execute()
$result['content'] = implode(PHP_EOL, $activeWithReason['reasons']);
}

return $this->getResponse()->representJson(
/** @var \Magento\Framework\App\Response\Http $response */
$response = $this->getResponse();

return $response->representJson(
$this->jsonSerializer->serialize($result)
);
}
Expand Down
Loading

0 comments on commit 866f561

Please sign in to comment.