Skip to content

Commit 51710e0

Browse files
committed
Replace CodeSniffer with PHP CS Fixer and achieve 100% test coverage
- Replace squizlabs/php_codesniffer with friendsofphp/php-cs-fixer - Add .php-cs-fixer.php configuration with PSR-12 rules - Update composer scripts for cs and cs-fix commands - Achieve 100% code coverage (67/67 lines, 8/8 methods) - Add comprehensive test cases for all edge cases - Enhance CI workflow with PHP 8.1-8.5 matrix and stability testing - Add codecov.yml configuration for coverage reporting - Update README badges to remove branch-specific links - Add .php-cs-fixer.cache to .gitignore - Update CHANGELOG for v3.0.0 final release
1 parent 26f5329 commit 51710e0

10 files changed

Lines changed: 299 additions & 138 deletions

File tree

.github/workflows/ci.yml

Lines changed: 148 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -2,140 +2,170 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main, 'feature/v3.0.0', 'feature/**' ]
5+
branches:
6+
- 'main'
7+
- 'legacy/*' # Legacy branches: legacy/v2.x
8+
- 'feature/*' # Feature branches: feature/new-feature
9+
- 'hotfix/*' # Hotfix branches: hotfix/urgent-fix
10+
- 'release/*' # Release branches: release/v3.0.0
611
pull_request:
7-
branches: [ main ]
8-
workflow_dispatch:
9-
inputs:
10-
php_version:
11-
description: 'PHP version to test (optional, tests all if empty)'
12-
required: false
13-
default: ''
12+
branches:
13+
- 'main'
14+
- 'legacy/*' # PRs to legacy branches
15+
workflow_dispatch: # Allows manual triggering via GitHub UI
1416

1517
jobs:
16-
tests:
18+
test:
1719
runs-on: ubuntu-latest
18-
20+
1921
strategy:
2022
fail-fast: false
2123
matrix:
22-
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
23-
dependencies: ['stable']
24-
include: []
25-
# Lowest dependency testing removed due to compatibility issues
26-
# with old package versions on modern PHP releases
27-
28-
continue-on-error: ${{ matrix.php-version == '8.5' }}
29-
30-
name: Tests - PHP ${{ matrix.php-version }} (${{ matrix.dependencies }})
24+
include:
25+
# Core PHP version testing
26+
- php: '8.1'
27+
allowed-to-fail: false
28+
- php: '8.2'
29+
allowed-to-fail: false
30+
- php: '8.3'
31+
allowed-to-fail: false
32+
- php: '8.4'
33+
allowed-to-fail: false
34+
35+
# Future-ready: PHP 8.5 (alpha/dev) - when available
36+
- php: '8.5'
37+
stability: 'dev'
38+
allowed-to-fail: true
39+
40+
# Development stability tests
41+
- php: '8.4'
42+
stability: 'dev'
43+
allowed-to-fail: true
44+
- php: '8.5'
45+
stability: 'dev'
46+
allowed-to-fail: true
47+
48+
name: "PHP ${{ matrix.php }}${{ matrix.stability && format(' | {0}', matrix.stability) || '' }}"
49+
50+
continue-on-error: ${{ matrix.allowed-to-fail }}
3151

3252
steps:
33-
- name: Checkout code
34-
uses: actions/checkout@v4
35-
36-
- name: Setup PHP
37-
uses: shivammathur/setup-php@v2
38-
with:
39-
php-version: ${{ matrix.php-version }}
40-
extensions: dom, curl, libxml, mbstring, zip, json
41-
coverage: xdebug
42-
tools: composer:v2
43-
44-
- name: Cache Composer packages
45-
id: composer-cache
46-
uses: actions/cache@v4
47-
with:
48-
path: ~/.composer/cache
49-
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}
50-
restore-keys: |
51-
${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-
52-
53-
- name: Install dependencies (lowest)
54-
if: matrix.dependencies == 'lowest'
55-
run: composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction
56-
57-
- name: Install dependencies (stable)
58-
if: matrix.dependencies == 'stable'
59-
run: composer update --prefer-stable --prefer-dist --no-interaction
60-
61-
- name: Validate composer.json
62-
run: composer validate --strict --no-check-lock
63-
64-
- name: Run PHPUnit tests
65-
run: composer test
53+
- name: Checkout code
54+
uses: actions/checkout@v4
55+
56+
- name: Setup PHP
57+
uses: shivammathur/setup-php@v2
58+
with:
59+
php-version: ${{ matrix.php }}
60+
extensions: json, mbstring, tokenizer
61+
coverage: none
62+
tools: composer:v2
63+
64+
- name: Get composer cache directory
65+
id: composer-cache
66+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
67+
68+
- name: Cache composer dependencies
69+
uses: actions/cache@v4
70+
with:
71+
path: ${{ steps.composer-cache.outputs.dir }}
72+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
73+
restore-keys: ${{ runner.os }}-composer-
74+
75+
- name: Configure stability
76+
if: matrix.stability
77+
run: |
78+
composer config minimum-stability ${{ matrix.stability }}
79+
composer config prefer-stable true
80+
81+
- name: Remove composer.lock
82+
run: rm -f composer.lock
83+
84+
- name: Install dependencies
85+
run: composer update --prefer-dist --no-interaction --no-progress
86+
87+
- name: Validate composer.json and composer.lock
88+
run: composer validate --strict
89+
90+
- name: Run code style check
91+
run: composer cs
92+
93+
- name: Run static analysis
94+
run: composer analyse
95+
96+
- name: Run tests
97+
run: composer test
6698

6799
code-quality:
68100
runs-on: ubuntu-latest
69-
name: Code Quality
101+
name: Code Quality Checks
70102

71103
steps:
72-
- name: Checkout code
73-
uses: actions/checkout@v4
74-
75-
- name: Setup PHP
76-
uses: shivammathur/setup-php@v2
77-
with:
78-
php-version: '8.4'
79-
extensions: dom, curl, libxml, mbstring, zip, json
80-
coverage: none
81-
tools: composer:v2
82-
83-
- name: Cache Composer packages
84-
id: composer-cache
85-
uses: actions/cache@v4
86-
with:
87-
path: ~/.composer/cache
88-
key: ${{ runner.os }}-php-8.4-stable-${{ hashFiles('**/composer.lock') }}
89-
restore-keys: |
90-
${{ runner.os }}-php-8.4-stable-
91-
92-
- name: Install dependencies
93-
run: composer update --prefer-stable --prefer-dist --no-interaction
94-
95-
- name: Run PHPStan static analysis
96-
run: composer analyse
97-
continue-on-error: true
98-
99-
- name: Run PHP CodeSniffer check
100-
run: composer cs
101-
continue-on-error: true
104+
- name: Checkout code
105+
uses: actions/checkout@v4
106+
107+
- name: Setup PHP
108+
uses: shivammathur/setup-php@v2
109+
with:
110+
php-version: '8.4'
111+
extensions: json, mbstring, tokenizer
112+
coverage: none
113+
tools: composer:v2
114+
115+
- name: Get composer cache directory
116+
id: composer-cache
117+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
118+
119+
- name: Cache composer dependencies
120+
uses: actions/cache@v4
121+
with:
122+
path: ${{ steps.composer-cache.outputs.dir }}
123+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
124+
restore-keys: ${{ runner.os }}-composer-
125+
126+
- name: Install dependencies
127+
run: composer install --prefer-dist --no-interaction --no-progress
128+
129+
- name: Validate composer.json and composer.lock
130+
run: composer validate --strict
102131

103132
coverage:
104133
runs-on: ubuntu-latest
105-
name: Coverage Report
134+
name: Code Coverage
106135

107136
steps:
108-
- name: Checkout code
109-
uses: actions/checkout@v4
110-
111-
- name: Setup PHP
112-
uses: shivammathur/setup-php@v2
113-
with:
114-
php-version: '8.4'
115-
extensions: dom, curl, libxml, mbstring, zip, json
116-
coverage: xdebug
117-
tools: composer:v2
118-
119-
- name: Cache Composer packages
120-
id: composer-cache
121-
uses: actions/cache@v4
122-
with:
123-
path: ~/.composer/cache
124-
key: ${{ runner.os }}-php-8.4-coverage-${{ hashFiles('**/composer.lock') }}
125-
restore-keys: |
126-
${{ runner.os }}-php-8.4-coverage-
127-
128-
- name: Install dependencies
129-
run: composer update --prefer-stable --prefer-dist --no-interaction
130-
131-
- name: Generate coverage report
132-
run: vendor/bin/phpunit --coverage-clover coverage.xml
133-
134-
- name: Upload coverage to Codecov
135-
uses: codecov/codecov-action@v4
136-
with:
137-
files: ./coverage.xml
138-
fail_ci_if_error: false
139-
verbose: true
140-
env:
141-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
137+
- name: Checkout code
138+
uses: actions/checkout@v4
139+
140+
- name: Setup PHP
141+
uses: shivammathur/setup-php@v2
142+
with:
143+
php-version: '8.4'
144+
extensions: json, mbstring, tokenizer
145+
coverage: xdebug
146+
tools: composer:v2
147+
148+
- name: Get composer cache directory
149+
id: composer-cache
150+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
151+
152+
- name: Cache composer dependencies
153+
uses: actions/cache@v4
154+
with:
155+
path: ${{ steps.composer-cache.outputs.dir }}
156+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
157+
restore-keys: ${{ runner.os }}-composer-
158+
159+
- name: Install dependencies
160+
run: composer install --prefer-dist --no-interaction --no-progress
161+
162+
- name: Run tests with coverage
163+
run: vendor/bin/phpunit --coverage-clover coverage.xml
164+
165+
- name: Upload coverage to Codecov
166+
uses: codecov/codecov-action@v4
167+
with:
168+
file: ./coverage.xml
169+
flags: unittests
170+
name: codecov-umbrella
171+
fail_ci_if_error: false

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ composer.lock
99
# PHPStan
1010
.phpstan/
1111

12-
# IDE files
13-
.idea/
14-
.vscode/
12+
# PHP CS Fixer
13+
.php-cs-fixer.cache
1514

1615
# Coverage reports
1716
coverage/

.markdownlint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
"MD024": {
33
"siblings_only": true
44
},
5-
"MD032": false,
65
"MD013": false
76
}

.php-cs-fixer.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__.'/src')
5+
->in(__DIR__.'/tests')
6+
->exclude('vendor');
7+
8+
$config = new PhpCsFixer\Config();
9+
$config->setFinder($finder)
10+
->setRules([
11+
'@PSR12' => true,
12+
'@PSR12:risky' => true,
13+
])
14+
->setRiskyAllowed(true)
15+
->setUnsupportedPhpVersionAllowed(true);
16+
17+
return $config;

CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [3.0.0](https://github.com/calliostro/php-discogs-api/releases/tag/v3.0.0) – 2025-09-07
8+
## [3.0.0](https://github.com/calliostro/php-discogs-api/releases/tag/v3.0.0) – 2025-09-08
99

1010
### Added
1111

@@ -14,16 +14,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Complete API coverage: 65+ endpoints across all Discogs areas
1515
- Multiple authentication methods: OAuth, Personal Token, or anonymous
1616
- Modern PHP 8.1–8.5 support with strict typing
17-
- 97% test coverage with 37 comprehensive tests
17+
- 100% test coverage with 43 comprehensive tests
1818
- PHPStan Level 8 static analysis
19-
- GitHub Actions CI with multi-version testing
19+
- GitHub Actions CI with multi-version testing and enhanced branch support
20+
- Codecov integration for code coverage reporting
2021

2122
### Changed
2223

2324
- **BREAKING**: Namespace changed from `Discogs\*` to `Calliostro\Discogs\*`
2425
- **BREAKING**: API surface changed from Guzzle Services to magic methods
2526
- **BREAKING**: Minimum PHP version now 8.1+ (was 7.3)
2627
- Simplified dependencies: removed Guzzle Services, Command, OAuth Subscriber
28+
- Replace `squizlabs/php_codesniffer` with `friendsofphp/php-cs-fixer` for code style checking
29+
- Update code style standard from PSR-12 via PHPCS to PSR-12 via PHP-CS-Fixer
30+
- Add `.php-cs-fixer.php` configuration file with PSR-12 rules
31+
- Update composer scripts: `cs` and `cs-fix` now use php-cs-fixer instead of phpcs/phpcbf
32+
- Update README badges for better consistency and proper branch links
33+
- Enhanced CI workflow with comprehensive PHP version matrix (8.1–8.5)
34+
- Add codecov.yml configuration for coverage reporting
2735

2836
### Removed
2937

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# ⚡ Discogs API Client for PHP 8.1+ – Ultra-Lightweight
22

3-
[![Latest Stable Version](https://img.shields.io/packagist/v/calliostro/php-discogs-api.svg)](https://packagist.org/packages/calliostro/php-discogs-api)
3+
[![Package Version](https://img.shields.io/packagist/v/calliostro/php-discogs-api.svg)](https://packagist.org/packages/calliostro/php-discogs-api)
44
[![Total Downloads](https://img.shields.io/packagist/dt/calliostro/php-discogs-api.svg)](https://packagist.org/packages/calliostro/php-discogs-api)
5-
[![License](https://img.shields.io/packagist/l/calliostro/php-discogs-api.svg)](https://packagist.org/packages/calliostro/php-discogs-api)
6-
[![PHP Version](https://img.shields.io/badge/php-8.1%7C8.2%7C8.3%7C8.4%7C8.5-blue.svg)](https://php.net)
7-
[![Guzzle](https://img.shields.io/badge/guzzle-%5E6.5%7C%5E7.0-orange.svg)](https://docs.guzzlephp.org/)
8-
[![CI](https://github.com/calliostro/php-discogs-api/workflows/CI/badge.svg?branch=feature/v3.0.0)](https://github.com/calliostro/php-discogs-api/actions)
9-
[![Coverage](https://img.shields.io/codecov/c/github/calliostro/php-discogs-api)](https://codecov.io/gh/calliostro/php-discogs-api)
5+
[![License](https://poser.pugx.org/calliostro/php-discogs-api/license)](https://packagist.org/packages/calliostro/php-discogs-api)
6+
[![PHP Version](https://img.shields.io/badge/php-%5E8.1-blue.svg)](https://php.net)
7+
[![CI](https://github.com/calliostro/php-discogs-api/actions/workflows/ci.yml/badge.svg)](https://github.com/calliostro/php-discogs-api/actions/workflows/ci.yml)
8+
[![Code Coverage](https://codecov.io/gh/calliostro/php-discogs-api/graph/badge.svg?token=0SV4IXE9V1)](https://codecov.io/gh/calliostro/php-discogs-api)
9+
[![PHPStan Level](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg)](https://phpstan.org/)
10+
[![Code Style](https://img.shields.io/badge/code%20style-PSR12-brightgreen.svg)](https://github.com/FriendsOfPHP/PHP-CS-Fixer)
1011

1112
> **🚀 ONLY 2 CLASSES!** The most lightweight Discogs API client for PHP. Zero bloats, maximum performance.
1213
@@ -95,7 +96,7 @@ $labelReleases = $discogs->labelReleases(['id' => '1']);
9596
- **Type Safe + IDE Support** – Full PHP 8.1+ types, PHPStan Level 8, method autocomplete
9697
- **Future-Ready** – PHP 8.5 compatible (beta/dev testing)
9798
- **Pure Guzzle** – Modern HTTP client, no custom transport layers
98-
- **Well Tested**97% test coverage, PSR-12 compliant
99+
- **Well Tested**100% test coverage, PSR-12 compliant
99100
- **Secure Authentication** – Full OAuth and Personal Access Token support
100101

101102
## 🎵 All Discogs API Methods as Direct Calls

0 commit comments

Comments
 (0)