Skip to content

feat: narrow types#114

Merged
BenMorel merged 1 commit into
brick:v0.12from
simPod:narrow-types
Feb 21, 2026
Merged

feat: narrow types#114
BenMorel merged 1 commit into
brick:v0.12from
simPod:narrow-types

Conversation

@simPod
Copy link
Copy Markdown
Contributor

@simPod simPod commented Feb 21, 2026

src/AbstractMoney.php

  • getSign(): @return int@return -1|0|1
  • compareTo(): @return int@return -1|0|1

src/Context.php

  • getStep(): @return int<1, max>@return positive-int

src/Context/CashContext.php

  • $step param: int<1, max>positive-int

src/Context/CustomContext.php

  • $step param: int<1, max>positive-int
  • isValidStepForScale() $step param: int<1, max>positive-int
  • getScale(): added @return non-negative-int

src/Currency.php

  • $numericCode param: intnon-negative-int
  • Added @psalm-suppress DocblockTypeContradiction on $defaultFractionDigits < 0 guard

src/IsoCurrencyProvider.php

  • $currencyData array: narrowed $numericCode position from int to non-negative-int

src/Money.php

  • allocate() $ratios: int[]non-negative-int[], added @psalm-suppress on $ratio < 0 guard
  • allocateWithRemainder() $ratios: int[]non-negative-int[], added @psalm-suppress on $ratio < 0 guard
  • split() $parts: intpositive-int, added @psalm-suppress on $parts < 1 guard
  • splitWithRemainder() $parts: intpositive-int, added @psalm-suppress on $parts < 1 guard

src/MoneyComparator.php

  • compare(): @return int@return -1|0|1

like brick/math#108

@simPod simPod force-pushed the narrow-types branch 2 times, most recently from 68ab6b4 to 1644fcb Compare February 21, 2026 08:49
@simPod simPod changed the base branch from master to v0.12 February 21, 2026 08:49
src/Currency.php:

  - $numericCode param: int → non-negative-int
  - $defaultFractionDigits param: int → non-negative-int
  - getNumericCode() return: added `@return non-negative-int`
  - getDefaultFractionDigits() return: added `@return non-negative-int`

src/Context.php

  - getStep() return: added `@return positive-int`

src/Context/CashContext.php

  - $step param: int → positive-int

src/Context/CustomContext.php

  - $scale param: int → non-negative-int
  - $step param: int → positive-int
  - getScale() return: added `@return non-negative-int`

src/Money.php

  - allocate() / allocateWithRemainder() $ratios param: int[] → non-negative-int[]
  - split() / splitWithRemainder() $parts param: int → positive-int
@simPod simPod marked this pull request as ready for review February 21, 2026 09:06
@BenMorel BenMorel merged commit c976fa8 into brick:v0.12 Feb 21, 2026
8 checks passed
@BenMorel
Copy link
Copy Markdown
Member

Thank you, @simPod!

@simPod simPod deleted the narrow-types branch February 21, 2026 13:48
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.

2 participants