Skip to content

Conversation

@calliostro
Copy link
Owner

Breaking Changes

  • Minimum PHP version: 8.1+ (was 7.3)
  • Namespace: Calliostro\Discogs\* (was Discogs\*)
  • API changed from Guzzle Services to magic methods
  • Removed Guzzle Services dependencies

Changes

  • 2-class architecture: ClientFactory and DiscogsApiClient
  • Magic method API calls: $client->artistGet(['id' => '123'])
  • 65+ API endpoints supported
  • 100% test coverage (43 tests)
  • PHPStan Level 8
  • Replace PHP CodeSniffer with PHP CS Fixer
  • Enhanced CI workflow
  • Codecov integration

See CHANGELOG.md for migration details.

Complete rewrite with modern architecture and comprehensive testing:

BREAKING CHANGES:
- Requires PHP 8.1+ (was PHP 7.1+)
- New namespace: Calliostro\Discogs (was Discogs)
- Ultra-lightweight 2-class architecture replaces complex service layer
- ClientFactory::create() replaces service configuration
- Magic method calls for all 65+ Discogs API endpoints
- Modern PSR-4 autoloading with src/ directory structure

Features:
- 97.01% code coverage with comprehensive test suite (37 tests)
- PHPStan Level 8 static analysis with full type safety
- Reduced from 86 to 54 dependencies for minimal footprint
- Direct API endpoint mapping with intuitive method names
- OAuth 1.0a and Personal Access Token authentication
- Complete Discogs API coverage: artists, releases, collections, marketplace
- GitHub Actions CI testing across PHP 8.1-8.5
- Comprehensive migration guide and documentation

Quality Assurance:
- PSR-12 code standards via phpcs/phpcbf
- Modern PHPUnit 10.5+ with latest testing practices
- Clean git history with proper .gitignore
- Professional CHANGELOG without marketing bloat
- Zero technical debt and production-ready codebase

Migration: See UPGRADE.md for detailed migration instructions from v2.x
- Change coverage from 'none' to 'xdebug' in test jobs
- Fixes PHPUnit warning 'No code coverage driver available'
- Prevents test failures due to failOnWarning=true setting
- Old package versions (PHPUnit 10.0.0, PHPStan 1.0.0) cause compatibility issues
- 20+ deprecation warnings with modern PHP versions
- Focus on stable dependencies across all PHP 8.1-8.5 versions
- Cleaner, more reliable CI pipeline
- 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
- Ensure coverage metadata requirements are met for all test runs
Copilot AI review requested due to automatic review settings September 8, 2025 16:01
@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request represents a complete rewrite of the php-discogs-api library, transitioning from v2.x to v3.0 with significant architectural changes. The library is now ultra-lightweight with only 2 main classes, supports PHP 8.1+, and provides direct magic method API calls.

Key changes:

  • Complete architectural rewrite from Guzzle Services to magic methods
  • Modernization to PHP 8.1+ with strict typing and enhanced error handling
  • Comprehensive testing with 100% coverage and improved CI/CD pipeline

Reviewed Changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/DiscogsApiClient.php New main API client class with magic method calls and service-based operations
src/ClientFactory.php Simplified factory for creating authenticated and unauthenticated clients
resources/service.php Streamlined service configuration with 65+ API endpoints definitions
tests/ Complete test suite rewrite with unit and integration tests
composer.json Updated dependencies, PHP version requirement, and project metadata
README.md Comprehensive documentation update reflecting new architecture

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


// Test method call with null as parameters (edge case)
// @phpstan-ignore-next-line - Testing edge case
$result = $this->client->search(null);
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing null as parameters could lead to unexpected behavior. The method should explicitly handle null parameters by either rejecting them with a clear error message or treating them as an empty array. Consider adding type validation in the __call method to ensure parameters are always arrays.

Copilot uses AI. Check for mistakes.
*/
public function __call(string $method, array $arguments): array
{
$params = $arguments[0] ?? [];
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method assumes the first argument is always an array but doesn't validate this assumption. If a non-array value is passed (like null in the test), it could cause issues downstream. Consider adding type validation: $params = is_array($arguments[0] ?? []) ? ($arguments[0] ?? []) : [];

Suggested change
$params = $arguments[0] ?? [];
$params = is_array($arguments[0] ?? null) ? $arguments[0] : [];

Copilot uses AI. Check for mistakes.
Comment on lines 445 to 446
// Test with an extremely long method name to potentially trigger edge cases
$longMethodName = str_repeat('A', 1000) . 'Get';
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a 1000-character string in a test may be excessive and could impact test performance. Consider using a smaller but still meaningful size (e.g., 100 characters) that would still test the edge case effectively without unnecessary memory allocation.

Suggested change
// Test with an extremely long method name to potentially trigger edge cases
$longMethodName = str_repeat('A', 1000) . 'Get';
// Test with a long method name (100 characters) to potentially trigger edge cases
$longMethodName = str_repeat('A', 100) . 'Get';

Copilot uses AI. Check for mistakes.
private function convertMethodToOperation(string $method): string
{
// Split a camelCase into parts
$parts = preg_split('/(?=[A-Z])/', $method, -1, PREG_SPLIT_NO_EMPTY);
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preg_split could potentially return false on error, which isn't being handled. While unlikely with this pattern, consider using $parts = preg_split('/(?=[A-Z])/', $method, -1, PREG_SPLIT_NO_EMPTY) ?: [] to ensure $parts is always an array.

Suggested change
$parts = preg_split('/(?=[A-Z])/', $method, -1, PREG_SPLIT_NO_EMPTY);
$parts = preg_split('/(?=[A-Z])/', $method, -1, PREG_SPLIT_NO_EMPTY) ?: [];

Copilot uses AI. Check for mistakes.
Comment on lines +144 to +146
if (!$parts) {
return $method;
}
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preg_split could potentially return false on error, which isn't being handled. While unlikely with this pattern, consider using $parts = preg_split('/(?=[A-Z])/', $method, -1, PREG_SPLIT_NO_EMPTY) ?: [] to ensure $parts is always an array.

Copilot uses AI. Check for mistakes.
- Improve parameter validation in __call method to handle null/non-array inputs
- Add error handling for preg_split operations using null coalescing operator
- Optimize test performance by reducing test string length from 1000 to 100 chars
- Simplify PHPUnit configuration by removing coverage requirements from default config
- Remove xdebug warning for users running composer test without coverage setup
@calliostro calliostro merged commit cf74e85 into main Sep 8, 2025
18 checks passed
@calliostro calliostro deleted the feature/v3.0.0 branch September 8, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants