Skip to content

Commit 23c9ec9

Browse files
tomio2480claude
andcommitted
Fix CodeQL and PHPStan warnings
GitHub ActionsとPHPStanの指摘を修正: - GitHub Actions: GITHUB_TOKEN権限を明示的に制限(contents: read) - Windows.php: 冗長な is_int() チェックを削除(PHPStan警告解消) 変更内容: - セキュリティ強化: 最小権限の原則に従いトークン権限を制限 - 型チェック最適化: Configuration クラスで型が保証されているため不要 - PHPStan レベル8 エラー解消 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0122a52 commit 23c9ec9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
test:
1111
runs-on: ${{ matrix.os }}
12+
permissions:
13+
contents: read
1214

1315
strategy:
1416
matrix:
@@ -47,6 +49,8 @@ jobs:
4749

4850
code-quality:
4951
runs-on: ubuntu-latest
52+
permissions:
53+
contents: read
5054

5155
steps:
5256
- uses: actions/checkout@v4

src/PhpSerial/Platform/Windows.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,21 @@ public function configure(string $device, Configuration $config): void
7070

7171
$parity = $parityMap[$config->getParity()] ?? 'n';
7272

73-
// セキュリティ: 数値パラメータの型と範囲を明示的に検証
73+
// セキュリティ: 数値パラメータの範囲を検証
74+
// Configuration クラスで型は保証されているため is_int() チェックは不要
7475
$baudRate = $config->getBaudRate();
7576
$dataBits = $config->getDataBits();
7677
$stopBits = $config->getStopBits();
7778

78-
if (!is_int($baudRate) || $baudRate <= 0) {
79+
if ($baudRate <= 0) {
7980
throw new RuntimeException('Invalid baud rate');
8081
}
8182

82-
if (!is_int($dataBits) || $dataBits < 5 || $dataBits > 8) {
83+
if ($dataBits < 5 || $dataBits > 8) {
8384
throw new RuntimeException('Invalid data bits');
8485
}
8586

86-
if (!is_int($stopBits) || ($stopBits !== 1 && $stopBits !== 2)) {
87+
if ($stopBits !== 1 && $stopBits !== 2) {
8788
throw new RuntimeException('Invalid stop bits');
8889
}
8990

0 commit comments

Comments
 (0)