Skip to content

Commit

Permalink
feat: add phpstan analyse webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Nov 3, 2023
1 parent 19c4216 commit 0a2784b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHPStan

on: [push, pull_request]

jobs:
phpstan:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: '8.1'

- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
composer install --no-interaction --no-progress --no-suggest
- name: Run PHPStan
run: |
composer analyse --error-format=github
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"cslant/telegram-git-notifier": "^1.3.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.37.1"
"friendsofphp/php-cs-fixer": "^v3.37.1",
"phpstan/phpstan": "^1.10.39"
},
"autoload": {
"psr-4": {
Expand All @@ -48,6 +49,7 @@
"optimize-autoloader": true
},
"scripts": {
"analyse": "vendor/bin/phpstan",
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"post-install-cmd": [
"bash vendor/cslant/telegram-git-notifier/install.sh"
Expand Down
6 changes: 6 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
level: 8
paths:
- src
tmpDir: build/phpstan
checkMissingIterableValueType: false
8 changes: 7 additions & 1 deletion src/Services/CallbackService.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ public function handle(): void

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

if ($this->bot->setting->updateSetting($callback, !$this->bot->setting->getSettings()[$callback])) {
$settings = $this->bot->setting->getSettings();
if (array_key_exists($callback, $settings)
&& $this->bot->setting->updateSetting(
$callback,
!$settings[$callback]
)
) {
$this->bot->editMessageReplyMarkup([
'reply_markup' => $this->bot->settingMarkup(),
]);
Expand Down

0 comments on commit 0a2784b

Please sign in to comment.