Skip to content

Commit 0a2784b

Browse files
committed
feat: add phpstan analyse webhook
1 parent 19c4216 commit 0a2784b

4 files changed

Lines changed: 42 additions & 2 deletions

File tree

.github/workflows/phpstan.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: PHPStan
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
phpstan:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Setup PHP
13+
uses: shivammathur/setup-php@2.26.0
14+
with:
15+
php-version: '8.1'
16+
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Install dependencies
21+
run: |
22+
composer install --no-interaction --no-progress --no-suggest
23+
24+
- name: Run PHPStan
25+
run: |
26+
composer analyse --error-format=github

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"cslant/telegram-git-notifier": "^1.3.1"
2626
},
2727
"require-dev": {
28-
"friendsofphp/php-cs-fixer": "^v3.37.1"
28+
"friendsofphp/php-cs-fixer": "^v3.37.1",
29+
"phpstan/phpstan": "^1.10.39"
2930
},
3031
"autoload": {
3132
"psr-4": {
@@ -48,6 +49,7 @@
4849
"optimize-autoloader": true
4950
},
5051
"scripts": {
52+
"analyse": "vendor/bin/phpstan",
5153
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
5254
"post-install-cmd": [
5355
"bash vendor/cslant/telegram-git-notifier/install.sh"

phpstan.neon.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src
5+
tmpDir: build/phpstan
6+
checkMissingIterableValueType: false

src/Services/CallbackService.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ public function handle(): void
8686

8787
$callback = str_replace(SettingConstant::SETTING_PREFIX, '', $callback);
8888

89-
if ($this->bot->setting->updateSetting($callback, !$this->bot->setting->getSettings()[$callback])) {
89+
$settings = $this->bot->setting->getSettings();
90+
if (array_key_exists($callback, $settings)
91+
&& $this->bot->setting->updateSetting(
92+
$callback,
93+
!$settings[$callback]
94+
)
95+
) {
9096
$this->bot->editMessageReplyMarkup([
9197
'reply_markup' => $this->bot->settingMarkup(),
9298
]);

0 commit comments

Comments
 (0)