Skip to content

Commit 726ace9

Browse files
authored
Release v4.0.0 - Complete Library Redesign with Clean Parameter API
- Clean Parameter API: Eliminated array parameters entirely - Consistent Method Naming: All 60 methods follow verb-first pattern - Class Renaming: DiscogsApiClient → DiscogsClient - Enhanced Authentication: RFC 5849 compliant OAuth 1.0a - Ultra-Lightweight: ~750 lines, 2 core classes - Full Type Safety: Automatic parameter validation - PHP 8.1 - 8.5 compatibility
1 parent 87b0d9b commit 726ace9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+6070
-5794
lines changed

.gitattributes

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Normalize line endings
2+
* text=auto
3+
4+
# PHP files
5+
*.php text eol=lf diff=php
6+
7+
# Config files
8+
*.json text eol=lf
9+
*.md text eol=lf
10+
*.xml text eol=lf
11+
12+
# Exclude from releases
13+
.editorconfig export-ignore
14+
.gitattributes export-ignore
15+
.github/ export-ignore
16+
.gitignore export-ignore
17+
.markdownlint.json export-ignore
18+
.php-cs-fixer.php export-ignore
19+
.phpunit.* export-ignore
20+
codecov.yml export-ignore
21+
phpunit.xml* export-ignore
22+
tests/ export-ignore
23+
coverage/ export-ignore
24+
coverage.clover export-ignore
25+
coverage.xml export-ignore
26+
DEVELOPMENT.md export-ignore
27+
phpunit.xml* export-ignore
28+
tests/ export-ignore
29+
vendor/ export-ignore

.github/workflows/ci.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ jobs:
3131
allowed-to-fail: false
3232
- php: '8.4'
3333
allowed-to-fail: false
34-
35-
# Future-ready: PHP 8.5 (alpha/dev) - when available
3634
- php: '8.5'
37-
stability: 'dev'
38-
allowed-to-fail: true
35+
allowed-to-fail: false
3936

4037
# Development stability tests
4138
- php: '8.4'
@@ -78,11 +75,8 @@ jobs:
7875
composer config minimum-stability ${{ matrix.stability }}
7976
composer config prefer-stable true
8077
81-
- name: Remove composer.lock
82-
run: rm -f composer.lock
83-
8478
- name: Install dependencies
85-
run: composer update --prefer-dist --no-interaction --no-progress
79+
run: composer install --prefer-dist --no-interaction --no-progress
8680

8781
- name: Validate composer.json and composer.lock
8882
run: composer validate --strict
@@ -93,9 +87,19 @@ jobs:
9387
- name: Run static analysis
9488
run: composer analyse
9589

96-
- name: Run tests
90+
- name: Run tests (Unit Tests only)
9791
run: composer test
9892

93+
- name: Run integration tests (manual trigger)
94+
if: github.event_name == 'workflow_dispatch'
95+
env:
96+
DISCOGS_CONSUMER_KEY: ${{ secrets.DISCOGS_CONSUMER_KEY }}
97+
DISCOGS_CONSUMER_SECRET: ${{ secrets.DISCOGS_CONSUMER_SECRET }}
98+
DISCOGS_PERSONAL_ACCESS_TOKEN: ${{ secrets.DISCOGS_PERSONAL_ACCESS_TOKEN }}
99+
run: |
100+
# Public tests run without credentials, auth tests skip if credentials missing
101+
composer test-integration -- --testdox
102+
99103
code-quality:
100104
runs-on: ubuntu-latest
101105
name: Code Quality Checks
@@ -159,8 +163,8 @@ jobs:
159163
- name: Install dependencies
160164
run: composer install --prefer-dist --no-interaction --no-progress
161165

162-
- name: Run tests with coverage
163-
run: vendor/bin/phpunit --coverage-clover coverage.xml
166+
- name: Run tests with coverage (Unit Tests only)
167+
run: composer test-coverage
164168

165169
- name: Upload coverage to Codecov
166170
uses: codecov/codecov-action@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ composer.lock
1414

1515
# Coverage reports
1616
coverage/
17+
coverage.xml
18+
*.clover
1719

1820
# Environment files
1921
.env

CHANGELOG.md

Lines changed: 155 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,164 @@ 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-
## [Unreleased]
8+
## [4.0.0](https://github.com/calliostro/php-discogs-api/releases/tag/v4.0.0) – 2025-12-01
9+
10+
### 🚀 Complete Library Redesign – v4.0 is a Fresh Start
11+
12+
**v4.0.0** represents a fundamental architectural overhaul. This is not an incremental update – it's a complete rewrite prioritizing developer experience, type safety, and minimal code footprint.
13+
14+
### Breaking Changes from v3.x
15+
16+
#### 1. Class Renaming for Consistency
17+
18+
- `DiscogsApiClient``DiscogsClient`
19+
- `ClientFactory``DiscogsClientFactory`
20+
21+
#### 2. Method Naming Revolution
22+
23+
**All 60 API methods renamed** following consistent `verb + noun` patterns:
24+
25+
- `artistGet()``getArtist()`
26+
- `artistReleases()``listArtistReleases()`
27+
- `releaseGet()``getRelease()`
28+
- `userEdit()``updateUser()`
29+
- `collectionFolders()``listCollectionFolders()`
30+
- `inventoryGet()``getUserInventory()`
31+
- `listingCreate()``createMarketplaceListing()`
32+
- `ordersGet()``getMarketplaceOrders()`
33+
34+
#### 3. Clean Parameter API (No More Arrays)
35+
36+
**Revolutionary method signatures** eliminate array parameters entirely:
37+
38+
```php
39+
// v3.x (OLD)
40+
$artist = $discogs->artistGet(['id' => 5590213]);
41+
$search = $discogs->search(['q' => 'Billie Eilish', 'type' => 'artist', 'per_page' => 50]);
42+
$collection = $discogs->collectionItems(['username' => 'user', 'folder_id' => 0]);
43+
44+
// v4.0 (NEW) - Clean parameters
45+
$artist = $discogs->getArtist(5590213);
46+
$search = $discogs->search(query: 'Billie Eilish', type: 'artist', perPage: 50);
47+
$collection = $discogs->listCollectionItems(username: 'user', folderId: 0);
48+
```
49+
50+
#### 4. Enhanced Authentication Architecture
51+
52+
**Complete authentication rewrite** with proper security standards:
53+
54+
- **Personal Access Token**: Now requires consumer credentials for proper Discogs Auth format
55+
- **OAuth 1.0a**: RFC 5849 compliant with PLAINTEXT signatures
56+
- **Method Renaming**: `createWithToken()``createWithPersonalAccessToken()`
57+
58+
```php
59+
// v3.x (OLD)
60+
$discogs = ClientFactory::createWithToken('token');
61+
62+
// v4.0 (NEW)
63+
$discogs = DiscogsClientFactory::createWithPersonalAccessToken('key', 'secret', 'token');
64+
```
65+
66+
### What's New in v4.0
67+
68+
#### Revolutionary Developer Experience
69+
70+
- **Zero Array Parameters** – Direct method calls: `getArtist(123)` vs `getArtist(['id' => 123])`
71+
- **Perfect IDE Autocomplete** – Full IntelliSense support with typed parameters
72+
- **Type Safety** – Automatic parameter validation and conversion (DateTime, booleans, objects)
73+
- **Self-Documenting Code** – Method names clearly indicate action and resource
74+
75+
#### Ultra-Lightweight Architecture
76+
77+
- **~750 Lines Total** – Minimal codebase covering all 60 Discogs API endpoints
78+
- **2 Core Classes**`DiscogsClient` and `DiscogsClientFactory` handle everything
79+
- **Zero Bloat** – No unnecessary abstractions or complex inheritance hierarchies
80+
- **Direct API Mapping** – Each method maps 1:1 to a Discogs endpoint
81+
82+
#### Enterprise-Grade Security
83+
84+
- **RFC 5849 OAuth 1.0a** – Industry-standard OAuth implementation
85+
- **Secure Nonce Generation** – Cryptographically secure random values
86+
- **ReDoS Protection** – Input validation prevents regular expression attacks
87+
- **Proper Authentication Headers** – Discogs-compliant auth format
88+
89+
#### Comprehensive Type Safety
90+
91+
- **Strict Parameter Validation** – Only camelCase parameters from PHPDoc accepted
92+
- **Automatic Type Conversion** – DateTime → ISO 8601, boolean → "1"/"0" for queries
93+
- **Required Parameter Enforcement**`null` values rejected for required parameters
94+
- **Object Support** – Custom objects with `__toString()` method automatically converted
95+
96+
### Migration Impact
97+
98+
**This is a complete breaking change.** Every method call in your codebase will need updating:
99+
100+
1. **Update class names**: `DiscogsApiClient``DiscogsClient`, `ClientFactory``DiscogsClientFactory`
101+
2. **Update method names**: Use the complete mapping table in [UPGRADE.md](UPGRADE.md)
102+
3. **Remove all arrays**: Convert array parameters to positional parameters
103+
4. **Update authentication**: Personal tokens now require consumer credentials
104+
105+
### Design Goals
106+
107+
**v4.0 prioritizes long-term developer experience:**
108+
109+
- **Cleaner Code**: Direct method calls without array parameters
110+
- **Better IDE Support**: Full autocomplete and type checking
111+
- **Consistent API**: All methods follow the same naming pattern
112+
- **Type Safety**: Catch errors at development time, not runtime
113+
114+
### Added Features
115+
116+
- **Complete OAuth 1.0a Support** with `OAuthHelper` class for full authorization flows
117+
- **Enhanced Error Handling** with clear exception messages for migration issues
118+
- **Integration Test Suite** with comprehensive authentication level testing
119+
- **CI/CD Integration** with automatic rate limiting and retry logic
120+
- **Static Analysis** – PHPStan Level 8 compliance with zero errors
121+
- **Performance Optimizations** – Config caching and reduced file I/O operations
122+
- **Consistent Class Naming**`DiscogsClient` and `DiscogsClientFactory` for better clarity
123+
124+
### Migration Resources
125+
126+
- **Complete Method Mapping**: See [UPGRADE.md](UPGRADE.md) for all 60 method name changes
127+
- **Parameter Examples**: Detailed before/after code samples for common operations
128+
- **Authentication Guide**: Step-by-step migration for all authentication types
129+
- **Automated Scripts**: Bash/sed commands to help identify and replace common patterns
130+
131+
---
132+
133+
## [3.1.0](https://github.com/calliostro/php-discogs-api/releases/tag/v3.1.0) – 2025-09-09
134+
135+
### Added
136+
137+
- **OAuth 1.0a Helper Methods** – Complete OAuth flow support with a separate OAuthHelper class
138+
- `getRequestToken()` – Get temporary request token for authorization flow
139+
- `getAuthorizationUrl()` – Generate user authorization URL
140+
- `getAccessToken()` – Exchange request token for permanent access token
141+
- **Clean Authentication API** – Dedicated methods for different authentication types
142+
- `createWithPersonalAccessToken()` – Clean 3-parameter method for Personal Access Tokens
143+
- `createWithOAuth()` – Refined 4-parameter method for OAuth 1.0a tokens only
144+
- **Enhanced OAuth Documentation** – Comprehensive OAuth workflow examples and security best practices
145+
- **OAuth Unit Tests** – Full test coverage for new OAuth helper methods and authentication methods
146+
147+
### Changed
148+
149+
- **BREAKING**: ClientFactory methods now accept array|GuzzleClient parameters (following LastFm pattern)
150+
- **Authentication API Redesign** – Cleaner separation between Personal Access Token and OAuth 1.0a authentication
151+
- Updated all default User-Agent strings to version `3.1.0`
152+
- Enhanced OAuth client creation with a proper PLAINTEXT signature method
153+
- Documentation restructured for better usability
154+
155+
### Fixed
156+
157+
- OAuth request token method now uses a proper HTTP method (GET instead of POST)
158+
- OAuth signature generation follows Discogs API requirements exactly
159+
- PHPStan Level 8 compatibility with proper type annotations for OAuth responses
9160

10161
## [3.0.1](https://github.com/calliostro/php-discogs-api/releases/tag/v3.0.1) – 2025-09-09
11162

12163
### Added
13164

14-
- Complete PHPDoc coverage for all 62 Discogs API endpoints
165+
- Complete PHPDoc coverage for all 60 Discogs API endpoints
15166
- Missing @method annotations for 22 additional API methods
16167
- Full IDE autocomplete support for inventory, collection, and marketplace operations
17168

@@ -33,8 +184,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
33184
### Added
34185

35186
- Ultra-lightweight 2-class architecture: `ClientFactory` and `DiscogsApiClient`
36-
- Magic method API calls: `$client->artistGet(['id' => '108713'])`
37-
- Complete API coverage: 65+ endpoints across all Discogs areas
187+
- Magic method API calls: `$client->artistGet(['id' => '5590213'])`
188+
- Complete API coverage: 60 endpoints across all Discogs areas
38189
- Multiple authentication methods: OAuth, Personal Token, or anonymous
39190
- Modern PHP 8.1–8.5 support with strict typing
40191
- 100% test coverage with 43 comprehensive tests

0 commit comments

Comments
 (0)