diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..de07f19 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -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/setup-php@2.26.0 + 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 diff --git a/composer.json b/composer.json index 4d9b4b6..218bd24 100755 --- a/composer.json +++ b/composer.json @@ -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": { @@ -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" diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..2e837cd --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,6 @@ +parameters: + level: 8 + paths: + - src + tmpDir: build/phpstan + checkMissingIterableValueType: false diff --git a/src/Services/CallbackService.php b/src/Services/CallbackService.php index 5182734..ae649fb 100644 --- a/src/Services/CallbackService.php +++ b/src/Services/CallbackService.php @@ -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(), ]);