From e01bdd753fb714dc61b416c0334f0bc9304ff812 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Thu, 22 Oct 2026 13:26:43 +0200 Subject: [PATCH 1/6] Remove no-op ReflectionProperty::setAccessible calls (deprecated in PHP 8.5) Co-Authored-By: Claude Opus 5.5 --- test/MenuStyleTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/MenuStyleTest.php b/test/MenuStyleTest.php index e841443..667edbd 100644 --- a/test/MenuStyleTest.php +++ b/test/MenuStyleTest.php @@ -51,7 +51,6 @@ public function testMenuStyleCanBeInstantiatedByCliMenuBuilder(): void self::assertTrue($reflectionMenu->hasProperty('style')); $styleProperty = $reflectionMenu->getProperty('style'); - $styleProperty->setAccessible(true); $style = $styleProperty->getValue($menu); self::assertSame(MenuStyle::class, get_class($style)); @@ -678,7 +677,6 @@ public function testDebugMode(): void $style = $this->getMenuStyle(8, 40); $prop = new \ReflectionProperty(MenuStyle::class, 'debugMode'); - $prop->setAccessible(true); $prop->setValue($style, true); $style->setWidth(30); From 5c0540a972863ce499825ae6404e5aa48ca6ea1f Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Thu, 22 Oct 2026 13:26:43 +0200 Subject: [PATCH 2/6] Fix PHPStan 2 offsetAccess errors for nullable selected item index Co-Authored-By: Claude Opus 5.5 --- src/CliMenu.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/CliMenu.php b/src/CliMenu.php index 87a9603..cbf9868 100644 --- a/src/CliMenu.php +++ b/src/CliMenu.php @@ -345,17 +345,26 @@ protected function moveSelectionVertically(string $direction): void } while (!$this->canSelect()); } + private function getSelectedMenuItem(): MenuItemInterface + { + if (null === $this->selectedItem) { + throw new \RuntimeException('No item is currently selected'); + } + + return $this->items[$this->selectedItem]; + } + /** * Move the selection in a given direction, left / right */ protected function moveSelectionHorizontally(string $direction): void { - if (!$this->items[$this->selectedItem] instanceof SplitItem) { + if (!$this->getSelectedMenuItem() instanceof SplitItem) { return; } /** @var SplitItem $item */ - $item = $this->items[$this->selectedItem]; + $item = $this->getSelectedMenuItem(); $itemKeys = array_keys($item->getItems()); $selectedItemIndex = $item->getSelectedItemIndex(); @@ -391,7 +400,7 @@ protected function moveSelectionHorizontally(string $direction): void */ private function canSelect(): bool { - return $this->items[$this->selectedItem]->canSelect(); + return $this->getSelectedMenuItem()->canSelect(); } /** @@ -404,7 +413,7 @@ public function getSelectedItem(): MenuItemInterface throw new \RuntimeException('No selected item'); } - $item = $this->items[$this->selectedItem]; + $item = $this->getSelectedMenuItem(); return $item instanceof SplitItem ? $item->getSelectedItem() : $item; @@ -441,7 +450,7 @@ public function getItemByIndex(int $index): MenuItemInterface public function executeAsSelected(MenuItemInterface $item): void { - $current = $this->items[$this->selectedItem]; + $current = $this->getSelectedMenuItem(); $this->setSelectedItem($item); $this->executeCurrentItem(); $this->setSelectedItem($current); From 5be48b6aecd1601fb70a8d1de78e817f29abdb58 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Thu, 22 Oct 2026 13:29:18 +0200 Subject: [PATCH 3/6] CI: add PHP 8.5, job timeouts and phpunit --stop-on-error Co-Authored-By: Claude Opus 5.5 --- .github/workflows/static.yml | 3 ++- .github/workflows/test.yml | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 7e44aa7..db74180 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -5,9 +5,10 @@ on: ['push', 'pull_request'] jobs: ci: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: - php: ['8.4'] + php: ['8.5'] name: Code Style steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d091432..c215769 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,9 +5,10 @@ on: ['push', 'pull_request'] jobs: ci: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: - php: ['8.2', '8.3', '8.4'] + php: ['8.2', '8.3', '8.4', '8.5'] name: PHP ${{ matrix.php }} @@ -31,6 +32,6 @@ jobs: run: composer update --no-interaction --no-progress - name: Tests - run: TERM=xterm-256color ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml + run: TERM=xterm-256color ./vendor/bin/phpunit --stop-on-error --coverage-clover ./build/logs/clover.xml - uses: codecov/codecov-action@v1 From e29830ef0328905fe35121583571a6942e4a1182 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Thu, 22 Oct 2026 13:30:34 +0200 Subject: [PATCH 4/6] Allow php-school/terminal 0.3 Co-Authored-By: Claude Opus 5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 03ae403..fa03ef4 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require": { "php" : ">=8.2", "beberlei/assert": "^2.4 | ^3", - "php-school/terminal": "^0.2.1", + "php-school/terminal": "^0.2.1 || ^0.3", "ext-posix": "*", "ext-mbstring": "*" }, From 21ae6eedc0fbf4b0e4aaedb40fbf176403b6183d Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Thu, 22 Oct 2026 17:23:19 +0200 Subject: [PATCH 5/6] Merge CI workflows into one and drop dead CI badges Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 36 +++++++++++++++++++++++++++++++++++ .github/workflows/static.yml | 33 -------------------------------- .github/workflows/test.yml | 37 ------------------------------------ README.md | 11 +---------- 4 files changed, 37 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/static.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..55c512b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + php: ['8.2', '8.3', '8.4', '8.5'] + name: PHP ${{ matrix.php }} + env: + TERM: xterm-256color + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + - uses: ramsey/composer-install@v3 + with: + dependency-versions: highest + - run: vendor/bin/phpunit --stop-on-error + - if: matrix.php == '8.5' + run: composer cs-dry-run + - if: matrix.php == '8.5' + run: composer static diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml deleted file mode 100644 index db74180..0000000 --- a/.github/workflows/static.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Static Analysis - -on: ['push', 'pull_request'] - -jobs: - ci: - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - matrix: - php: ['8.5'] - name: Code Style - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: composer:v2 - ini-values: pcov.directory=api #optional, see above for usage. - coverage: pcov - - - name: Install Dependencies - run: composer update --no-interaction --no-progress - - - name: Run cs fixer - run: composer run cs-dry-run - - - name: Run PHPStan - run: composer run static diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index c215769..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Tests - -on: ['push', 'pull_request'] - -jobs: - ci: - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - matrix: - php: ['8.2', '8.3', '8.4', '8.5'] - - name: PHP ${{ matrix.php }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: composer:v2 - coverage: xdebug - - - name: Setup Problem Matches - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install cdependencies - run: composer update --no-interaction --no-progress - - - name: Tests - run: TERM=xterm-256color ./vendor/bin/phpunit --stop-on-error --coverage-clover ./build/logs/clover.xml - - - uses: codecov/codecov-action@v1 diff --git a/README.md b/README.md index adcc49c..288a337 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,7 @@

- - - - - - - - - - + From 411c067c2d120f75bba29c24d1952bda44a03623 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Thu, 22 Oct 2026 17:27:25 +0200 Subject: [PATCH 6/6] Require php-school/terminal ^0.3 Co-Authored-By: Claude Opus 5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fa03ef4..bc5d9a8 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require": { "php" : ">=8.2", "beberlei/assert": "^2.4 | ^3", - "php-school/terminal": "^0.2.1 || ^0.3", + "php-school/terminal": "^0.3", "ext-posix": "*", "ext-mbstring": "*" },