Skip to content

Commit

Permalink
Merge pull request #634 from Ocramius/feature/quick-money
Browse files Browse the repository at this point in the history
Quick money (butchering this library for the glory of satan, and CPU cycles)
  • Loading branch information
frederikbosch authored May 2, 2021
2 parents a44e2f2 + 8df0b26 commit 4f9c4fa
Show file tree
Hide file tree
Showing 134 changed files with 11,017 additions and 4,109 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
/.php_cs.dist export-ignore
/.scrutinizer.yml export-ignore
Dockerfile export-ignore
/benchmark/ export-ignore
/hack/ export-ignore
/phpspec.ci.yml export-ignore
/phpbench.json export-ignore
/phpspec.yml.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon.dist export-ignore
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Checks

on:
push:
branches:
- master
pull_request:

jobs:
Expand All @@ -13,7 +11,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Install
uses: docker://composer
Expand All @@ -36,7 +34,7 @@ jobs:

# steps:
# - name: Checkout code
# uses: actions/checkout@v1
# uses: actions/checkout@v2

# - name: Roave BC Check
# uses: docker://nyholm/roave-bc-check-ga
72 changes: 58 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,45 @@ name: CI

on:
push:
branches:
- master
pull_request:

jobs:
build-lowest-version:
lowest-version-tests:
name: Build lowest version
runs-on: ubuntu-latest

steps:
- name: Set up PHP
uses: shivammathur/setup-php@1.7.0
uses: shivammathur/setup-php@v2
with:
php-version: '5.6'
php-version: '8.0'
extensions: bcmath, gmp, intl, dom, mbstring

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Set up locales
run: ./hack/setup-locales.sh

- name: Download dependencies
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest --prefer-lowest
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest --prefer-lowest --classmap-authoritative

- name: Run tests
run: composer test

build:
tests:
name: Build
runs-on: ubuntu-latest
strategy:
max-parallel: 10
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
php: ['8.0']

steps:
- name: Set up PHP
uses: shivammathur/setup-php@1.6.2
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: bcmath, gmp, intl, dom, mbstring
Expand All @@ -52,17 +49,64 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Set up locales
run: ./hack/setup-locales.sh

- name: Download dependencies
run: composer update --no-ansi --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest
run: composer install --classmap-authoritative

- name: Run tests
run: composer test

psalm:
name: Psalm
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: bcmath, gmp, intl, dom, mbstring

- name: Download dependencies
run: composer install --classmap-authoritative

- name: Psalm
run: vendor/bin/psalm

mutation-tests:
name: Infection
runs-on: ubuntu-latest
needs:
- tests
- psalm

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: bcmath, gmp, intl, dom, mbstring
coverage: pcov

- name: Set up locales
run: ./hack/setup-locales.sh

- name: Download dependencies
run: composer install --classmap-authoritative

- name: Psalm
run: vendor/bin/roave-infection-static-analysis-plugin

docs:
name: Docs
runs-on: ubuntu-latest
Expand All @@ -74,7 +118,7 @@ jobs:
architecture: 'x64'

- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Install dependencies
run: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/phpstan.entrypoint

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/psalm.entrypoint

This file was deleted.

53 changes: 10 additions & 43 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,25 @@ name: Static analysis

on:
push:
branches:
- master
pull_request:

jobs:
phpstan:
name: PHPStan
phpcs:
name: PHP-CodeSniffer
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Install
uses: docker://composer
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
args: install --ignore-platform-reqs --no-ansi --no-suggest
php-version: '8.0'
extensions: bcmath, gmp, intl, dom, mbstring

- name: PHPStan
uses: docker://oskarstark/phpstan-ga:0.12.28
with:
entrypoint: ./.github/workflows/phpstan.entrypoint
args: analyze --no-progress

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:2.16.3.1
with:
args: --dry-run --diff-format udiff

psalm:
name: Psalm
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Install
uses: docker://composer
with:
args: install --ignore-platform-reqs --no-ansi --no-suggest
- name: Download dependencies
run: composer install --classmap-authoritative

- name: Psalm
uses: docker://vimeo/psalm-github-actions
with:
entrypoint: ./.github/workflows/psalm.entrypoint
args: --threads=8 --diff --diff-methods
run: vendor/bin/phpcs
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/.phpbench
.php_cs
.php_cs.cache
.phpunit.result.cache
/build/
/composer.lock
/phpspec.yml
/phpunit.xml
/vendor/
Expand Down
17 changes: 0 additions & 17 deletions .php_cs.dist

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.2-cli
FROM php:8.0-cli

RUN set -xe \
&& apt-get update \
Expand Down
53 changes: 53 additions & 0 deletions benchmark/MoneyInstantiationBench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace Benchmark\Money;

use Money\Currency;
use Money\Money;
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;

/**
* @BeforeMethods({"setUp"})
*/
final class MoneyInstantiationBench
{
/** @var Currency */
private $currency;

public function setUp(): void
{
$this->currency = new Currency('EUR');
}

public function benchConstructorWithZeroIntegerAmount(): void
{
new Money(0, $this->currency);
}

public function benchConstructorWithPositiveIntegerAmount(): void
{
new Money(1234567890, $this->currency);
}

public function benchConstructorWithNegativeIntegerAmount(): void
{
new Money(-1234567890, $this->currency);
}

public function benchConstructorWithZeroStringAmount(): void
{
new Money('0', $this->currency);
}

public function benchConstructorWithPositiveStringAmount(): void
{
new Money('1234567890', $this->currency);
}

public function benchConstructorWithNegativeStringAmount(): void
{
new Money('-1234567890', $this->currency);
}
}
Loading

0 comments on commit 4f9c4fa

Please sign in to comment.