Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f045117
Harden adapter validation and loop safety
somework Dec 5, 2025
d60b429
style: implement Yoda comparison style across codebase
somework Dec 5, 2025
e2bd1c0
feat: implement comprehensive exception architecture
somework Dec 5, 2025
6bcef75
feat: complete exception architecture integration
somework Dec 5, 2025
1407bfc
refactor: enhance type safety and test organization
somework Dec 5, 2025
4eb880b
docs: fix CHANGELOG versioning - separate 2.0.0 and 3.0.0 releases
somework Dec 5, 2025
606233b
docs: update README for v3.0.0 architecture changes
somework Dec 5, 2025
35a2cae
feat: enhance developer experience and Packagist discoverability
somework Dec 5, 2025
8077ba9
Apply fixes from StyleCI (#9)
somework Dec 5, 2025
9a3fa57
fix: enable Xdebug for code coverage in CI
somework Dec 5, 2025
b2ba230
fix: address CodeRabbit review comments
somework Dec 5, 2025
3a575f0
polish: address final CodeRabbit review suggestions
somework Dec 5, 2025
b011175
perf: make CI coverage configurable for optimal performance
somework Dec 5, 2025
c3ed63a
fix: address final CodeRabbit suggestions for code quality
somework Dec 5, 2025
e37554d
Apply fixes from StyleCI (#10)
somework Dec 5, 2025
3667f9b
fix: address final CodeRabbit suggestions
somework Dec 5, 2025
5ff9d71
πŸ“ Add docstrings to `codex/analyze-pagination-behavior-and-test-desig…
coderabbitai[bot] Dec 5, 2025
5ddf427
test: add comprehensive tests for OffsetAdapter::fromCallback method
somework Dec 5, 2025
9c10259
test: improve OffsetAdapter test coverage
somework Dec 5, 2025
bb29454
test: achieve near-perfect OffsetAdapter coverage
somework Dec 5, 2025
9f39cdb
test: add coverage for PaginationException base class
somework Dec 5, 2025
487259d
feat: complete package transformation to production-ready solution
somework Dec 5, 2025
115356e
Apply fixes from StyleCI (#13)
somework Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 29 additions & 25 deletions .github/actions/composer-install/action.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
name: Composer install with cache
description: Set up PHP with Composer and install dependencies using cache
inputs:
php-version:
description: PHP version to install
required: true
php-version:
description: PHP version to install
required: true
coverage:
description: Code coverage driver to enable (none, xdebug, pcov)
required: false
default: none
runs:
using: composite
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
coverage: none
tools: composer
using: composite
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
coverage: ${{ inputs.coverage }}
tools: composer

- name: Get composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT
- name: Get composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ inputs.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ inputs.php-version }}-composer-
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ inputs.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ inputs.php-version }}-composer-

- name: Install dependencies
shell: bash
run: composer install --no-interaction --no-progress --prefer-dist
- name: Install dependencies
shell: bash
run: composer install --no-interaction --no-progress --prefer-dist
28 changes: 14 additions & 14 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ci"
include: "scope"
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "deps"
include: "scope"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ci"
include: "scope"
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "deps"
include: "scope"
93 changes: 55 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,60 @@
name: CI

on:
push:
branches: ["master"]
pull_request:
push:
branches: [ "master" ]
pull_request:

jobs:
tests:
runs-on: ubuntu-latest
strategy: &php-matrix
fail-fast: false
matrix:
php-version: ['8.2', '8.3']

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Install dependencies
uses: ./.github/actions/composer-install
with:
php-version: ${{ matrix.php-version }}

- name: Run tests
run: composer test

quality:
needs: tests
runs-on: ubuntu-latest
strategy: *php-matrix

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Install dependencies
uses: ./.github/actions/composer-install
with:
php-version: ${{ matrix.php-version }}

- name: Quality checks
run: composer quality
tests:
runs-on: ubuntu-latest
strategy: &php-matrix
fail-fast: false
matrix:
php-version: [ '8.2', '8.3' ]

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Install dependencies
uses: ./.github/actions/composer-install
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug

- name: Run tests with coverage
run: composer test -- --coverage-clover=build/logs/clover.xml

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-php${{ matrix.php-version }}
path: build/logs/junit.xml

- name: Upload coverage reports
uses: actions/upload-artifact@v4
if: success()
with:
name: coverage-reports-php${{ matrix.php-version }}
path: |
build/logs/clover.xml
build/coverage/

quality:
needs: tests
runs-on: ubuntu-latest
strategy: *php-matrix

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Install dependencies
uses: ./.github/actions/composer-install
with:
php-version: ${{ matrix.php-version }}

- name: Quality checks
run: composer quality
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ phpunit.phar

### Tooling cache
var/

### Build artifacts
build/
6 changes: 3 additions & 3 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
$finder = PhpCsFixer\Finder::create()
->files()
->name('*.php')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');
->in(__DIR__.'/src')
->in(__DIR__.'/tests');

return (new PhpCsFixer\Config())
->setUsingCache(true)
Expand Down Expand Up @@ -43,7 +43,6 @@
'no_leading_namespace_whitespace' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
Expand All @@ -67,5 +66,6 @@
'single_line_after_imports' => true,
'single_quote' => true,
'visibility_required' => true,
'yoda_style' => ['equal' => true, 'identical' => true, 'less_and_greater' => true],
])
->setFinder($finder);
65 changes: 49 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,57 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/spec2.0.0.html).

## [3.0.0] - 2025-12-05

### Added

- Added comprehensive exception architecture with typed exception hierarchy:
- `PaginationExceptionInterface` for type-safe exception catching
- `PaginationException` as base exception class
- `InvalidPaginationArgumentException` for parameter validation errors
- `InvalidPaginationResultException` for result validation errors
- Added `OffsetAdapter::generator()` method for direct generator access
- Added `OffsetResult::empty()` static factory for creating empty results
- Added `OffsetResult::generator()` method for accessing internal generator
- Added strict input validation to `OffsetAdapter::execute()`, rejecting negative values and invalid `limit=0` combinations
- Added deterministic loop guards to prevent infinite pagination
- Enhanced `SourceInterface` documentation with comprehensive behavioral specifications

### Changed

- **BREAKING**: Renamed `OffsetResult::getTotalCount()` to `OffsetResult::getFetchedCount()` for semantic clarity
- **BREAKING**: Removed `SourceResultInterface` and `SourceResultCallbackAdapter` to simplify architecture
- **BREAKING**: `OffsetResult` no longer implements `SourceResultInterface`
- **BREAKING**: `SourceInterface::execute()` now returns `\Generator<T>` directly instead of wrapped interface
- Enhanced type safety with `positive-int` types in `SourceInterface` PHPDoc
- Reorganized test methods for better logical flow and maintainability
- Improved property visibility (changed some `protected` to `private` in `OffsetResult`)
- Updated `SourceCallbackAdapter` with enhanced validation and error messages

### Removed

- Removed `SourceResultInterface` and `SourceResultCallbackAdapter` classes
- Removed `ArraySourceResult` test utility class
- Removed `SourceResultCallbackAdapterTest` test class
- Removed unnecessary interface abstractions for cleaner architecture

### Fixed

- Fixed potential infinite loop scenarios in pagination logic
- Enhanced error messages for better developer experience
- Improved validation of pagination parameters

### Dev

- Enhanced test organization with logical method grouping
- Added comprehensive test coverage for new exception architecture
- Improved static analysis type safety
- Added 31 new tests for enhanced functionality

## [2.0.0] - 2025-12-04

### Added

- Added `declare(strict_types=1)` to all source files for improved type safety
- Added comprehensive README with usage examples and installation instructions
- Added PHP version badge to README
Expand All @@ -17,30 +65,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/spec2.
- Added PHP-CS-Fixer code style configuration

### Changed

- **BREAKING**: Updated minimum PHP version requirement from 7.4 to 8.2
- **BREAKING**: Updated `somework/offset-page-logic` dependency to `^2.0` (major version update)
- Updated PHPUnit to `^10.5` for PHP 8.2+ compatibility
- Updated PHPStan to `^2.1`
- Updated PHP-CS-Fixer to `^3.91`
- Improved property visibility in `OffsetResult` (changed `protected` to `private`)
- Fixed logic error in `OffsetResult::fetchAll()` method

### Removed
- Removed legacy CI configurations (if any existed)
- Removed deprecated code patterns and old PHP syntax

### Fixed
- Fixed incorrect while loop condition in `OffsetResult::fetchAll()`

### Dev
- Added `ci` composer script for running all quality checks at once
- Improved CI workflow to use consolidated quality checks
- Enhanced Dependabot configuration with better commit message prefixes
- Added explicit PHP version specification to PHPStan configuration
- Improved property declarations using PHP 8.2+ features (readonly properties)
- Added library type specification and stability settings to composer.json

### Dev
- Migrated from Travis CI to GitHub Actions
- Added comprehensive CI pipeline with tests, static analysis, and code style checks
- Added composer scripts: `test`, `stan`, `cs-check`, `cs-fix`
Expand Down
Loading