lob-php
lob-php copied to clipboard
fix: add explicit nullable types to constructor parameters to avoid deprecation notes on PHP 8.4
Summary
Fixes PHP 8.4+ deprecation warnings by adding explicit nullable type hints to constructor parameters across Model and API classes.
Problem
The codebase was generating deprecation warnings like:
PHP Deprecated: OpenAPI\Client\Model\Postcard::__construct(): Implicitly marking parameter $data as nullable is deprecated, the explicit nullable type must be used instead
This occurs because PHP 8.4+ requires explicit nullable type declarations (e.g., ?array $data = null) instead of implicitly nullable parameters (array $data = null).
Solution
- Added explicit nullable type hints
(?array, ?Configuration, ?ClientInterface, ?HeaderSelector)to constructor parameters - Updated corresponding PHPDoc comments to reflect the nullable types
- Maintains backward compatibility while eliminating deprecation warnings
Verify
- [ ] Code runs without errors
- [ ] Tests pass with >=85% line coverage