Skip to content

Conversation

@Naoray
Copy link
Collaborator

@Naoray Naoray commented Jan 7, 2026

Documentation Improvements

  • Added API documentation links (@see) to all request classes (56 files)
  • Created request reference documentation (docs/request-reference.md)
  • Updated documentation with best practices and examples using named parameters

New Convenience Methods

Money class

  • Added convenience methods for all 29 Mollie supported currencies
  • Extracted currency convenience methods into HasCurrencyConvenienceMethods trait
  • Removed fromString() method based on feedback

Supported 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.

Money::euro('10.00');  // Instead of new Money('EUR', '10.00')
Money::usd('10.00');   // Instead of new Money('USD', '10.00')
Money::gbp('10.00');   // Instead of new Money('GBP', '10.00')
// ... and all other supported currencies

- 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:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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',
Copy link
Collaborator

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

Copy link
Collaborator

@sandervanhooft sandervanhooft left a 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)
Copy link

@bartgloudemans bartgloudemans Jan 16, 2026

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!

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.

4 participants