moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.63k stars 441 forks source link

Apply uppercase to currency #639

Closed frederikbosch closed 3 years ago

frederikbosch commented 3 years ago

Fixes #637 #638

Ocramius commented 3 years ago

I think this can be improved in the psalm stubs

On Sun, May 2, 2021, 11:42 Frederik Bosch @.***> wrote:

@.**** commented on this pull request.

In src/Currency.php https://github.com/moneyphp/money/pull/639#discussion_r624664830:

@@ -25,7 +27,7 @@ final class Currency implements JsonSerializable /* @psalm-param non-empty-string $code / public function __construct(string $code) {

  • $this->code = $code;
  • $this->code = strtoupper($code);

@Ocramius https://github.com/Ocramius Are you willing to explain me why psalm is not OK with this? Only if I add assert(! empty($code)) is allows it. I would expect it to be allowed anyway since the non-emptiness is already checked during construction via the non-empty-string param, no?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/moneyphp/money/pull/639#pullrequestreview-649897930, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABFVEBZHW4JC5OWW3HVBP3TLUNB3ANCNFSM437G2S5Q .