Skip to content
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

Quick money (butchering this library for the glory of satan, and CPU cycles) #634

Merged
merged 48 commits into from
May 2, 2021

Commits on Apr 13, 2021

  1. This patch attempts to make quick money out of moneyphp/money

    In this change, we bumped relevant dependencies to stick to `php:^7.3` as minimum
    supported `php` version (since `7.2` is EOL'd and no longer covered by security fixes).
    
    To do that, we upgraded all dependencies, upgraded spec files to comply with newest phpspec.
    
    This currently means that we have a few broken scenarios and failures:
    
    ```
    ----  failed examples
    
            Money/Parser/DecimalMoneyParser
      47  ✘ throws an exception when money includes currency symbol
            expected exception of class "Money\Exception\ParserExc...", but got
            [exc:PhpSpec\Exception\Example\ErrorException("16384: Passing a currency as string is deprecated since 3.1 and
            will be removed in 4.0. Please pass a Money\Currency instance instead. in
            /home/ocramius/Documents/moneyphp/money/src/Parser/DecimalMoneyParser.php line 50")].
    
            Money/Parser/DecimalMoneyParser
      52  ✘ throws an exception when money is not a valid decimal
            expected exception of class "Money\Exception\ParserExc...", but got
            [exc:PhpSpec\Exception\Example\ErrorException("16384: Passing a currency as string is deprecated since 3.1 and
            will be removed in 4.0. Please pass a Money\Currency instance instead. in
            /home/ocramius/Documents/moneyphp/money/src/Parser/DecimalMoneyParser.php line 50")].
    
    ----  broken examples
    
            Money/Exchange/ExchangerExchange
      27  ! is initializable
            could not reflect class Exchanger\Exchanger as it is marked final.
    
            Money/Exchange/ExchangerExchange
      32  ! is an exchange
            could not reflect class Exchanger\Exchanger as it is marked final.
    
            Money/Exchange/ExchangerExchange
      37  ! exchanges currencies
            could not reflect class Exchanger\Exchanger as it is marked final.
    
            Money/Exchange/ExchangerExchange
      53  ! throws an exception when cannot exchange currencies
            could not reflect class Exchanger\Exchanger as it is marked final.
    
            Money/Parser/DecimalMoneyParser
      31  ! parses money
            16384: Passing a currency as string is deprecated since 3.1 and will be removed in 4.0. Please pass a Money\Currency
            instance instead. in /home/ocramius/Documents/moneyphp/money/src/Parser/DecimalMoneyParser.php line 50
    
    29 specs
    185 examples (178 passed, 2 failed, 5 broken)
    146ms
    ```
    Ocramius committed Apr 13, 2021
    Configuration menu
    Copy the full SHA
    8eda988 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5b39800 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    df44eed View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d9c6238 View commit details
    Browse the repository at this point in the history
  5. Compatibility with PHPUnit 9.5+ - if we expect deprecations to be rai…

    …sed, then they should be raised
    
    No suppressing them, since otherwise they effectively go unnoticed. Having a suppressed `trigger_error()` means
    that only side-effects get run, instead of proper exception conversion.
    Ocramius committed Apr 13, 2021
    Configuration menu
    Copy the full SHA
    4eafa82 View commit details
    Browse the repository at this point in the history
  6. Added simplistic benchmarks about money instantiation, comparison and…

    … number operations
    
    These benchmarks cover the "most used" functionality of `Money`, and should highlight any
    computational complexity overhead.
    Ocramius committed Apr 13, 2021
    Configuration menu
    Copy the full SHA
    8d25eb5 View commit details
    Browse the repository at this point in the history
  7. Added benchmarks for Money::sum(), Money::min(), Money::max() a…

    …nd `Money::avg()`
    Ocramius committed Apr 13, 2021
    Configuration menu
    Copy the full SHA
    f004690 View commit details
    Browse the repository at this point in the history

Commits on Apr 15, 2021

  1. Configuration menu
    Copy the full SHA
    ca05b46 View commit details
    Browse the repository at this point in the history
  2. Run benchmarks as part of composer test, to avoid them bit-rotting …

    …and becoming unusable later on
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    fa42867 View commit details
    Browse the repository at this point in the history
  3. Imported global functions to allow OpCache to optimize away well-know…

    …n internal functions
    
    Overall really hard to tell if the results are legit, but there are some improvements:
    
    ```
    ❯ php -dopcache.enable_cli=1 ./vendor/bin/phpbench run --ref=original --retry-threshold=5 --iterations=10
    PHPBench @git_tag@ running benchmarks...
    with configuration file: /home/ocramius/Documents/moneyphp/money/phpbench.json
    with PHP version 8.0.3, xdebug ❌, opcache ✔
    
    \Benchmark\Money\NumberInstantiationBench
    
        benchConstructorWithZeroIntegerAmount...R1 I0 - [Mo575.630μs vs Mo591.581μs] -2.70% (±2.20%)
        benchConstructorWithPositiveIntegerAmou.R7 I9 - [Mo551.930μs vs Mo550.683μs] +0.23% (±3.02%)
        benchConstructorWithNegativeIntegerAmou.R1 I1 - [Mo554.108μs vs Mo580.812μs] -4.60% (±1.80%)
        benchConstructorWithZeroAndFractionalAm.R1 I3 - [Mo543.759μs vs Mo595.014μs] -8.61% (±1.77%)
        benchConstructorWithFractionalAmount....R1 I1 - [Mo589.360μs vs Mo611.898μs] -3.68% (±1.92%)
        benchConstructorWithNegativeFractionalA.R1 I0 - [Mo573.149μs vs Mo580.123μs] -1.20% (±2.22%)
    
    \Benchmark\Money\MoneyOperationBench
    
        benchAdd................................R1 I6 - [Mo999.123μs vs Mo987.689μs] +1.16% (±2.42%)
        benchSubtract...........................R1 I9 - [Mo985.683μs vs Mo936.192μs] +5.29% (±1.70%)
        benchMultiply...........................R1 I7 - [Mo1.003ms vs Mo1.057ms] -5.11% (±2.00%)
        benchDivide.............................R1 I9 - [Mo946.427μs vs Mo1.031ms] -8.19% (±3.11%)
        benchRatioOf............................R1 I2 - [Mo985.380μs vs Mo989.503μs] -0.42% (±2.17%)
        benchMod................................R2 I5 - [Mo391.671μs vs Mo401.023μs] -2.33% (±2.37%)
        benchIsSameCurrency.....................R1 I4 - [Mo2.000μs vs Mo2.000μs] 0.00% (±0.00%)
        benchIsZero.............................R10 I9 - [Mo384.644μs vs Mo426.642μs] -9.84% (±1.56%)
        benchAbsolute...........................R2 I9 - [Mo423.309μs vs Mo396.644μs] +6.72% (±2.35%)
        benchNegative...........................R6 I9 - [Mo981.397μs vs Mo983.110μs] -0.17% (±2.55%)
        benchIsPositive.........................R3 I9 - [Mo386.301μs vs Mo392.182μs] -1.50% (±2.37%)
        benchCompare............................R7 I8 - [Mo387.603μs vs Mo397.301μs] -2.44% (±3.22%)
        benchLessThan...........................R3 I9 - [Mo407.575μs vs Mo390.164μs] +4.46% (±2.31%)
        benchLessThanOrEqual....................R1 I9 - [Mo425.425μs vs Mo430.164μs] -1.10% (±1.34%)
        benchEquals.............................R1 I7 - [Mo2.000μs vs Mo3.000μs] -33.33% (±0.00%)
        benchGreaterThan........................R1 I7 - [Mo390.366μs vs Mo390.450μs] -0.02% (±2.10%)
        benchGreaterThanOrEqual.................R2 I9 - [Mo412.262μs vs Mo411.738μs] +0.13% (±1.99%)
    
    \Benchmark\Money\MoneyInstantiationBench
    
        benchConstructorWithZeroIntegerAmount...R2 I4 - [Mo904.501μs vs Mo898.483μs] +0.67% (±2.20%)
        benchConstructorWithPositiveIntegerAmou.R1 I8 - [Mo915.419μs vs Mo937.671μs] -2.37% (±2.11%)
        benchConstructorWithNegativeIntegerAmou.R1 I5 - [Mo896.722μs vs Mo909.286μs] -1.38% (±1.30%)
        benchConstructorWithZeroStringAmount....R2 I4 - [Mo908.315μs vs Mo933.039μs] -2.65% (±2.32%)
        benchConstructorWithPositiveStringAmoun.R1 I8 - [Mo890.975μs vs Mo857.589μs] +3.89% (±1.99%)
        benchConstructorWithNegativeStringAmoun.R1 I2 - [Mo858.750μs vs Mo904.536μs] -5.06% (±2.54%)
    
    Subjects: 29, Assertions: 0, Failures: 0, Errors: 0
    ```
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    809b12d View commit details
    Browse the repository at this point in the history
  4. Enforcing Currency#__construct() to require a string as argument,…

    … removing useless test related to that
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    e094533 View commit details
    Browse the repository at this point in the history
  5. Inlined fetching of Calculator inside Money to avoid calling `get…

    …Calculator()` all the time
    
    This is a minimal improvement on a very hot execution path
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    b009ce2 View commit details
    Browse the repository at this point in the history
  6. Removed the need to create a Number instance in `BcMathCalculator#m…

    …ultiply()` and `#divide()`
    
    Also here, no noticeable improvements other than a massive jump in `benchRatioOf`:
    
    ```
    ❯ php -dopcache.enable_cli=1 ./vendor/bin/phpbench run --ref=original --retry-threshold=5 --iterations=10
    PHPBench @git_tag@ running benchmarks...
    with configuration file: /home/ocramius/Documents/moneyphp/money/phpbench.json
    with PHP version 8.0.3, xdebug ❌, opcache ✔
    
    \Benchmark\Money\NumberInstantiationBench
    
        benchConstructorWithZeroIntegerAmount...R1 I0 - [Mo569.571μs vs Mo591.581μs] -3.72% (±1.94%)
        benchConstructorWithPositiveIntegerAmou.R2 I8 - [Mo599.841μs vs Mo550.683μs] +8.93% (±2.41%)
        benchConstructorWithNegativeIntegerAmou.R1 I4 - [Mo621.906μs vs Mo580.812μs] +7.08% (±2.40%)
        benchConstructorWithZeroAndFractionalAm.R1 I9 - [Mo570.344μs vs Mo595.014μs] -4.15% (±2.62%)
        benchConstructorWithFractionalAmount....R2 I3 - [Mo600.387μs vs Mo611.898μs] -1.88% (±2.04%)
        benchConstructorWithNegativeFractionalA.R1 I2 - [Mo590.276μs vs Mo580.123μs] +1.75% (±1.99%)
    
    \Benchmark\Money\MoneyOperationBench
    
        benchAdd................................R1 I3 - [Mo999.916μs vs Mo987.689μs] +1.24% (±1.97%)
        benchSubtract...........................R1 I9 - [Mo924.575μs vs Mo936.192μs] -1.24% (±2.18%)
        benchMultiply...........................R3 I8 - [Mo992.857μs vs Mo1.057ms] -6.09% (±2.46%)
        benchDivide.............................R1 I1 - [Mo1.015ms vs Mo1.031ms] -1.54% (±2.58%)
        benchRatioOf............................R5 I8 - [Mo381.761μs vs Mo989.503μs] -61.42% (±1.89%)
        benchMod................................R1 I9 - [Mo396.292μs vs Mo401.023μs] -1.18% (±2.16%)
        benchIsSameCurrency.....................R2 I8 - [Mo4.000μs vs Mo2.000μs] +100.00% (±0.00%)
        benchIsZero.............................R1 I3 - [Mo393.902μs vs Mo426.642μs] -7.67% (±1.72%)
        benchAbsolute...........................R1 I4 - [Mo379.667μs vs Mo396.644μs] -4.28% (±2.79%)
        benchNegative...........................R1 I3 - [Mo979.540μs vs Mo983.110μs] -0.36% (±2.10%)
        benchIsPositive.........................R1 I4 - [Mo408.442μs vs Mo392.182μs] +4.15% (±2.21%)
        benchCompare............................R1 I8 - [Mo381.159μs vs Mo397.301μs] -4.06% (±1.87%)
        benchLessThan...........................R1 I6 - [Mo391.462μs vs Mo390.164μs] +0.33% (±1.71%)
        benchLessThanOrEqual....................R4 I6 - [Mo416.380μs vs Mo430.164μs] -3.20% (±2.67%)
        benchEquals.............................R3 I4 - [Mo4.000μs vs Mo3.000μs] +33.33% (±0.00%)
        benchGreaterThan........................R1 I5 - [Mo382.789μs vs Mo390.450μs] -1.96% (±1.71%)
        benchGreaterThanOrEqual.................R1 I1 - [Mo379.530μs vs Mo411.738μs] -7.82% (±1.33%)
    
    \Benchmark\Money\MoneyInstantiationBench
    
        benchConstructorWithZeroIntegerAmount...R2 I9 - [Mo945.877μs vs Mo898.483μs] +5.27% (±2.50%)
        benchConstructorWithPositiveIntegerAmou.R1 I7 - [Mo887.787μs vs Mo937.671μs] -5.32% (±2.63%)
        benchConstructorWithNegativeIntegerAmou.R3 I7 - [Mo958.738μs vs Mo909.286μs] +5.44% (±2.60%)
        benchConstructorWithZeroStringAmount....R1 I0 - [Mo954.548μs vs Mo933.039μs] +2.31% (±2.40%)
        benchConstructorWithPositiveStringAmoun.R3 I9 - [Mo931.642μs vs Mo857.589μs] +8.64% (±2.42%)
        benchConstructorWithNegativeStringAmoun.R1 I2 - [Mo943.121μs vs Mo904.536μs] +4.27% (±1.88%)
    
    Subjects: 29, Assertions: 0, Failures: 0, Errors: 0
    ```
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    f16dbd3 View commit details
    Browse the repository at this point in the history
  7. Removed newInstance private constructor: can be inlined where relevant

    Also added an `is_int()` special case to the constructor, since we often deal with
    integer values when constructing a `Money` instance, so we don't need to check for
    a more expensive `filter_var()` operation.
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    9bcc47e View commit details
    Browse the repository at this point in the history
  8. Simplified Money#equals() to only check currency equality when amou…

    …nt equality is also non-matching
    
    This moves away a function call that is otherwise repeated very often, and which can lead to a lot
    of runtime overhead for no reason.
    
    Instead, we do this comparison only when the amount is the same (direct equality, faster for the engine).
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    25602b9 View commit details
    Browse the repository at this point in the history
  9. Directly checking equality of two currencies at engine level

    While calling `Currency#equals(Currency)` may indeed look better from a domain perspective,
    `Currency` is `final`, and currency comparison is one of the most frequent operations performed
    on `Money` (for internal assertions).
    
    Therefore, removing the method call is both feasible and beneficial for performance:
    
    ```
    ❯ php -dopcache.enable_cli=1 ./vendor/bin/phpbench run --ref=original --retry-threshold=5 --iterations=10
    PHPBench @git_tag@ running benchmarks...
    with configuration file: /home/ocramius/Documents/moneyphp/money/phpbench.json
    with PHP version 8.0.3, xdebug ❌, opcache ✔
    
    \Benchmark\Money\NumberInstantiationBench
    
        benchConstructorWithZeroIntegerAmount...R3 I7 - [Mo561.632μs vs Mo591.581μs] -5.06% (±3.01%)
        benchConstructorWithPositiveIntegerAmou.R1 I7 - [Mo542.669μs vs Mo550.683μs] -1.46% (±1.00%)
        benchConstructorWithNegativeIntegerAmou.R1 I2 - [Mo579.585μs vs Mo580.812μs] -0.21% (±1.60%)
        benchConstructorWithZeroAndFractionalAm.R3 I8 - [Mo574.055μs vs Mo595.014μs] -3.52% (±1.86%)
        benchConstructorWithFractionalAmount....R1 I9 - [Mo580.926μs vs Mo611.898μs] -5.06% (±2.09%)
        benchConstructorWithNegativeFractionalA.R2 I8 - [Mo587.192μs vs Mo580.123μs] +1.22% (±2.55%)
    
    \Benchmark\Money\MoneyOperationBench
    
        benchAdd................................R1 I8 - [Mo985.200μs vs Mo987.689μs] -0.25% (±2.61%)
        benchSubtract...........................R1 I8 - [Mo985.114μs vs Mo936.192μs] +5.23% (±2.70%)
        benchMultiply...........................R1 I0 - [Mo988.329μs vs Mo1.057ms] -6.52% (±2.69%)
        benchDivide.............................R1 I7 - [Mo933.611μs vs Mo1.031ms] -9.43% (±0.93%)
        benchRatioOf............................R4 I4 - [Mo392.845μs vs Mo989.503μs] -60.30% (±1.70%)
        benchMod................................R1 I3 - [Mo421.904μs vs Mo401.023μs] +5.21% (±1.72%)
        benchIsSameCurrency.....................R2 I6 - [Mo1.000μs vs Mo2.000μs] -50.00% (±0.00%)
        benchIsZero.............................R1 I7 - [Mo400.636μs vs Mo426.642μs] -6.10% (±1.00%)
        benchAbsolute...........................R10 I9 - [Mo397.953μs vs Mo396.644μs] +0.33% (±2.76%)
        benchNegative...........................R1 I6 - [Mo955.247μs vs Mo983.110μs] -2.83% (±2.45%)
        benchIsPositive.........................R1 I0 - [Mo405.106μs vs Mo392.182μs] +3.30% (±2.71%)
        benchCompare............................R3 I9 - [Mo401.284μs vs Mo397.301μs] +1.00% (±2.12%)
        benchLessThan...........................R1 I9 - [Mo390.481μs vs Mo390.164μs] +0.08% (±1.84%)
        benchLessThanOrEqual....................R1 I5 - [Mo395.329μs vs Mo430.164μs] -8.10% (±2.53%)
        benchEquals.............................R10 I9 - [Mo1.000μs vs Mo3.000μs] -66.67% (±0.00%)
        benchGreaterThan........................R1 I0 - [Mo414.980μs vs Mo390.450μs] +6.28% (±2.71%)
        benchGreaterThanOrEqual.................R1 I1 - [Mo385.041μs vs Mo411.738μs] -6.48% (±2.64%)
    
    \Benchmark\Money\MoneyInstantiationBench
    
        benchConstructorWithZeroIntegerAmount...R1 I9 - [Mo954.935μs vs Mo898.483μs] +6.28% (±1.18%)
        benchConstructorWithPositiveIntegerAmou.R1 I3 - [Mo913.027μs vs Mo937.671μs] -2.63% (±2.09%)
        benchConstructorWithNegativeIntegerAmou.R1 I0 - [Mo926.714μs vs Mo909.286μs] +1.92% (±2.25%)
        benchConstructorWithZeroStringAmount....R2 I9 - [Mo998.900μs vs Mo933.039μs] +7.06% (±2.79%)
        benchConstructorWithPositiveStringAmoun.R2 I4 - [Mo927.877μs vs Mo857.589μs] +8.20% (±2.17%)
        benchConstructorWithNegativeStringAmoun.R2 I9 - [Mo951.571μs vs Mo904.536μs] +5.20% (±2.64%)
    
    Subjects: 29, Assertions: 0, Failures: 0, Errors: 0
    ```
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    8c8639c View commit details
    Browse the repository at this point in the history
  10. Removed func_num_args() magic method logic, replaced by inlined `co…

    …unt()` operation that can be optimized by opcache
    
    ```
    ❯ php -dopcache.enable_cli=1 ./vendor/bin/phpbench run --ref=original --retry-threshold=5 --iterations=100 --filter=Avg
    PHPBench @git_tag@ running benchmarks...
    with configuration file: /home/ocramius/Documents/moneyphp/money/phpbench.json
    with PHP version 8.0.3, xdebug ❌, opcache ✔
    
    \Benchmark\Money\MoneyOperationBench
    
        benchAvg................................R1 I63 - [Mo399.867μs vs Mo404.221μs] -1.08% (±2.29%)
    
    Subjects: 1, Assertions: 0, Failures: 0, Errors: 0
    ```
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    ecdce7d View commit details
    Browse the repository at this point in the history
  11. In BcMathCalculator, removing the need to cast to a Number when r…

    …eading from `bcadd()` and `bcsub()` operations
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    57bb76f View commit details
    Browse the repository at this point in the history
  12. Correctly referencing self::parseFractionalPart() from within `Numb…

    …er#__construct()` code, adjusted ctor parameter types
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    b582575 View commit details
    Browse the repository at this point in the history
  13. When the engine supports an integer value, use a simple `(string) (in…

    …t)` comparison to see if two strings are equivalent
    
    This simplifies checking for the validity of `Number` input values
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    1f838b7 View commit details
    Browse the repository at this point in the history
  14. Removed assertOperand(), since we can ensure that a `numeric-string…

    …` will be given as a parameter
    
    Overall, this means that we can remove some assertions from all multiplications/divisions, therefore slimming down the code even further
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    8cdbb66 View commit details
    Browse the repository at this point in the history
  15. Removed assertRoundingMode(), which can be enforced at type level, …

    …rather than being checked at runtime
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    5298583 View commit details
    Browse the repository at this point in the history
  16. Simplified Number::fromString() to internally use explode() inste…

    …ad of `strpos()` and `substr()`
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    48e765f View commit details
    Browse the repository at this point in the history
  17. Bumping to PHP 8 minimum as per convo with @frederikbosch @ moneyphp#…

    …634 (comment)
    
    This will allow us to add native type declarations everywhere within the library, to the benefit of
    runtime checks, static analysis, as well as OpCache optimizations (where the engine understands them).
    
    Ref: moneyphp#634 (comment)
    Ref: moneyphp#634 (comment)
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    e1e091c View commit details
    Browse the repository at this point in the history
  18. Upgraded sources to PHP 8 type declarations, reworked internal number…

    … logic to always work on `string` values
    
    Here we introduce a lot of BC breaks in type signatures, specifically calculators. Values that used to have `float`
    as acceptable state are now generally changed to `numeric-string`, although not everywhere (yet).
    This is not yet the final form of the codebase, but we need an atomic state where:
    
     * we are at a newer/better CS level (specifically psalm type declarations and native type declarations)
     * we have a passing PHPUnit/PHPSpec test suite
    
    By changing this, we gain a lot of internal consistency that we can leverage to easier refactor components
    that need to do a lot of intensive performance-oriented math operations.
    
    Note that we are also introducing a lot of type contradiction (stricter types, but we still check for input
    value shape): that is because we did not yet upgrade `vimeo/psalm`, and therefore we haven't yet tackled
    any of these, but rather based our changes on the existing test suite instead.
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    7462d54 View commit details
    Browse the repository at this point in the history
  19. Brought type inference to 100% of the codebase (tests still missing)

    Here we change the philosophy of the library radically: instead of doing runtime
    validation for inputs, we leave those up to the user (yes, really! endorsing a type-checker
    will need to be part of this patch), and instead we expect correct values to be passed
    in as type-checked upfront.
    
    This way, we get rid of a number of runtime validation tests that are completely avoidable.
    Ocramius committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    a2c2554 View commit details
    Browse the repository at this point in the history

Commits on Apr 16, 2021

  1. Commit current composer.lock to make builds more stable

    PHPCS, PHPStan, Psalm and similar tools are too unstable to lock at minor/major release,
    therefore we need a `composer.lock` to keep things frozen during builds.
    
    This will be a massive improvement for contributors, while for maintainers it means that
    `composer.lock` will need regular, slow and incremental upgrades over time.
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    0d1ec59 View commit details
    Browse the repository at this point in the history
  2. Applied detailed type-checking to the unit test suite

    This allows for hunting down mis-uses of the library at type level
    also when refactoring/restricting type signatures
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    f2890ba View commit details
    Browse the repository at this point in the history
  3. Stricter type checks around invalid operands, hunting down unused/red…

    …undant code
    
    Since phpspec is no longer first-class citizen of the library, hereby we converted some
    of the specs into unit tests, and ensured that all of the API of the library is not
    unused (means there's at least another symbol or test relying on it).
    
    In addition to that, operations such as mixed `float/int`, `string/int`, etc math
    are now generally removed from allowed code.
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    0c7d705 View commit details
    Browse the repository at this point in the history
  4. Applied automated CS fixes, improved github actions setup to run psal…

    …m/phpunit/phpcs from locally installed version
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    796bd9c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6cc8a20 View commit details
    Browse the repository at this point in the history
  6. Added roave/infection-static-analysis-plugin and configured a minim…

    …um mutation score threshold
    
    By using this plugin and enforcing a minimum threshold, we ensure that we are not lowering the quality
    of the library by:
    
     * reducing type-safety
     * reducing code-coverage
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    b815e26 View commit details
    Browse the repository at this point in the history
  7. Hunted down a few easy-fix mutants that were just about migrating php…

    …spec scenarios to PHPUnit tests
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    6a5dcd1 View commit details
    Browse the repository at this point in the history
  8. Made calculators completely inflexible and static

    Calculators are well defined within a fixed algebra, and therefore
    do not need to be configured.
    
    Considering that, we:
    
     * made all `Calculator` implementations `static` and `@psalm-pure`
     * removed all runtime configuration flags from `Calculator`
     * removed `Calculator` discovery: the default `Calculator` is now `BcMathCalculator`
     * added `ext-bcmath` as a mandatory dependency: not a massive dependency for the
       amount of simplicity and improvements gained from this
     * removed `Calculator::supported()`, since it is now up to the user to pick a custom
       `Calculator` implementation, should one be required (if at all)
     * marked the `PhpCalculator` internal, since it is not supposed to ever be used in
       a production environment
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    2d359ac View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    6504e33 View commit details
    Browse the repository at this point in the history
  10. Sorted scripts section in composer.json to comply with `ergebnis/…

    …composer-normalize` rules
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    6fb8f8c View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    61fa7b4 View commit details
    Browse the repository at this point in the history
  12. Updated MoneyFactory static methods to require numeric-string|int

    … rather than `string|int`
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    0689d3c View commit details
    Browse the repository at this point in the history
  13. Restricted test coverage to individual tested units of code

    While this reduces overall coverage, it also reduces the amount of noise produced
    by accidental coverage during mutation tests, and forces single tests to be much
    more precise about what we are testing and covering, leading to more aimed
    regression prevention and better SUT quality.
    
    Also, this fixes the CI run, where infection couldn't run due to missing system
    locale setup.
    Ocramius committed Apr 16, 2021
    Configuration menu
    Copy the full SHA
    7876b8f View commit details
    Browse the repository at this point in the history

Commits on Apr 22, 2021

  1. Configuration menu
    Copy the full SHA
    dc3ce62 View commit details
    Browse the repository at this point in the history
  2. Removed is_int() check on $amount passed to Money constructor

    This check was mostly detrimental to performance, and didn't bring in much.
    
    Ref: moneyphp#634 (comment)
    Ocramius committed Apr 22, 2021
    Configuration menu
    Copy the full SHA
    9758d5f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7790e52 View commit details
    Browse the repository at this point in the history
  4. Removed unused Money::fromFloat(), since we no longer operate with …

    …`float` anyware within the codebase
    
    Ref: moneyphp#634 (comment)
    Ocramius committed Apr 22, 2021
    Configuration menu
    Copy the full SHA
    eb32c53 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    9496d09 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    91c8091 View commit details
    Browse the repository at this point in the history

Commits on Apr 23, 2021

  1. Revert removal of Money::fromFloat()

    Reverts eb32c53
    Reverts 91c8091
    Ocramius committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    756649c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8e0630f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8df0b26 View commit details
    Browse the repository at this point in the history