Skip to content

Commit 6babdc3

Browse files
committed
Complete v4.0 redesign: clean parameter API and consistent method naming
- Replace array parameters with positional parameters for all methods - Rename all methods to consistent verb-first pattern (getArtist, listReleases, etc.) - Rename classes: DiscogsApiClient -> DiscogsClient, ClientFactory -> DiscogsClientFactory - Add ConfigCache for performance optimization - Enhance authentication with proper OAuth 1.0a and personal token support - Update all tests and documentation for new API design
1 parent 416264f commit 6babdc3

26 files changed

+3638
-2323
lines changed

CHANGELOG.md

Lines changed: 115 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,128 @@ 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-
## [4.0.0-beta.1](https://github.com/calliostro/php-discogs-api/releases/tag/v4.0.0-beta.1) – 2025-09-10
8+
## [4.0.0-beta](https://github.com/calliostro/php-discogs-api/releases/tag/v4.0.0-beta.2) – 2025-09-13
99

10-
### Added
10+
### 🚀 Complete Library Redesign – v4.0 is a Fresh Start
1111

12-
- **RFC 5849 compliant OAuth 1.0a** implementation with PLAINTEXT signatures
13-
- **Integration tests** for authentication validation
14-
- **Static header authentication** replacing complex middleware
15-
- **Complete OAuth 1.0a Support** with dedicated `OAuthHelper` class
16-
- **Consistent Method Naming** following `get*()`, `list*()`, `create*()`, `update*()`, `delete*()` patterns
17-
- **Performance optimizations** with config caching and reduced file I/O
18-
- **Enhanced Security** with cryptographically secure nonce generation and ReDoS protection
19-
- **CI/CD Integration** with automatic rate limiting and retry logic for integration tests
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.
2013

21-
### Changed
14+
### Breaking Changes from v3.x
2215

23-
- **BREAKING**: Authentication completely rewritten – now secure and RFC-compliant
24-
- **BREAKING**: All method names changed for consistency (see UPGRADE.md)
25-
- **Enhanced**: User headers preserved but authentication headers protected from override
26-
- **Enhanced**: HTTP exceptions now pass through unchanged for better error transparency
27-
- **Enhanced**: Improved input validation with ReDoS attack prevention
16+
#### 1. Class Renaming for Consistency
2817

29-
### Removed
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
30115

31-
- **BREAKING**: No backward compatibility with v3.x method names
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
32123

33-
### Migration
124+
### Migration Resources
34125

35-
- See [UPGRADE.md](UPGRADE.md) for a complete migration guide with method mapping tables
36-
- **Parameters, Authentication, Return Values**: All unchanged
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
37130

38131
---
39132

@@ -91,7 +184,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
91184
### Added
92185

93186
- Ultra-lightweight 2-class architecture: `ClientFactory` and `DiscogsApiClient`
94-
- Magic method API calls: `$client->artistGet(['id' => '108713'])`
187+
- Magic method API calls: `$client->artistGet(['id' => '5590213'])`
95188
- Complete API coverage: 60 endpoints across all Discogs areas
96189
- Multiple authentication methods: OAuth, Personal Token, or anonymous
97190
- Modern PHP 8.1–8.5 support with strict typing

0 commit comments

Comments
 (0)