-
Notifications
You must be signed in to change notification settings - Fork 202
Chore/enhance sdk with docs and convenience methods #855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Chore/enhance sdk with docs and convenience methods #855
Conversation
- Extract all currency convenience methods to HasCurrencyConvenienceMethods trait - Remove fromString method from Money class - Update tests to cover all supported currencies - Remove fromString tests
- Remove fromString method reference - Add link to Mollie's multicurrency documentation - Update currency list to include all supported currencies
Change return type from 'static' to 'self' for PHP 7.4 compatibility. The 'static' return type was introduced in PHP 8.0.
|
|
||
| ## Parameter Ordering Notes | ||
|
|
||
| Some request classes have optional parameters before required parameters in their constructors. This can trigger PHP 8+ deprecation warnings when using positional arguments. To avoid this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Some request classes have optional parameters before required parameters in their constructors. This can trigger PHP 8+ deprecation warnings when using positional arguments. To avoid this: | |
| For legacy reasons, some request classes have optional parameters before required parameters in their constructors. This can trigger PHP 8+ deprecation warnings when using positional arguments. To avoid this: |
| $object = PaymentDetails::fromArray($data = [ | ||
| 'source' => 'banktransfer', | ||
| 'sourceDescription' => 'Bank Transfer', | ||
| 'sourceReference' => 'Bank Transfer', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a test here to ensure legacy support
sandervanhooft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I've left some minor comments. Feel free to address these, release at your convenience @Naoray .
| /** | ||
| * @deprecated When using positional arguments, this triggers a PHP 8+ deprecation warning | ||
| * because optional parameter $description comes before required parameter $amount. | ||
| * Use named parameters instead: new CreatePaymentRefundRequest(paymentId: $id, amount: $amount, description: $desc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP 8.4 has a known issue where deprecation warnings are (erroneously) converted to Errors.
Using named parameters doesn't change the fact that the constructor arguments have a deprecated structure.
Thus in PHP 8.4 this remains a breaking issue and the CreatePaymentRefundRequest cannot be instantiated.
I presume also the factory method suffers from this issue.
The fix here would be to let the the arguments description and amount swap places. Which is a breaking change.
Or assign $amount = null and validate in runtime in the constructor whether it is set. (ugly of course)
I think I'm wrong here, it seems it has something to do with our custom way of error handling. Sorry!
Documentation Improvements
@see) to all request classes (56 files)docs/request-reference.md)New Convenience Methods
Money class
HasCurrencyConvenienceMethodstraitfromString()method based on feedbackSupported currencies: AED, AUD, BGN, BRL, CAD, CHF, CZK, DKK, EUR, GBP, HKD, HUF, ILS, ISK, JPY, MXN, MYR, NOK, NZD, PHP, PLN, RON, RUB, SEK, SGD, THB, TWD, USD, ZAR
See Mollie's multicurrency documentation for the complete list.