Skip to content

Commit 1f056e4

Browse files
authored
Release/2.1.0 (#11)
1 parent 72ff396 commit 1f056e4

43 files changed

Lines changed: 887 additions & 864 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/tests export-ignore
2+
/vendor export-ignore
3+
4+
/LICENSE export-ignore
5+
/Makefile export-ignore
6+
/README.md export-ignore
7+
/phpmd.xml export-ignore
8+
/phpunit.xml export-ignore
9+
/phpstan.neon.dist export-ignore
10+
/infection.json.dist export-ignore
11+
12+
/.github export-ignore
13+
/.gitignore export-ignore
14+
/.gitattributes export-ignore

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ jobs:
1616
- name: Checkout
1717
uses: actions/checkout@v3
1818

19+
- name: Use PHP 8.2
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: '8.2'
23+
1924
- name: Install dependencies
2025
run: composer update --no-progress --optimize-autoloader
2126

@@ -33,6 +38,11 @@ jobs:
3338
- name: Checkout
3439
uses: actions/checkout@v3
3540

41+
- name: Use PHP 8.2
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: '8.2'
45+
3646
- name: Install dependencies
3747
run: composer update --no-progress --optimize-autoloader
3848

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
DOCKER_RUN = docker run --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.2
22

3-
.PHONY: configure test test-no-coverage review show-reports clean
3+
.PHONY: configure test test-file test-no-coverage review show-reports clean
44

55
configure:
66
@${DOCKER_RUN} composer update --optimize-autoloader
77

8-
test: review
8+
test:
99
@${DOCKER_RUN} composer tests
1010

11-
test-no-coverage: review
11+
test-file:
12+
@${DOCKER_RUN} composer tests-file-no-coverage ${FILE}
13+
14+
test-no-coverage:
1215
@${DOCKER_RUN} composer tests-no-coverage
1316

1417
review:
@@ -19,4 +22,4 @@ show-reports:
1922

2023
clean:
2124
@sudo chown -R ${USER}:${USER} ${PWD}
22-
@rm -rf report vendor
25+
@rm -rf report vendor .phpunit.cache

composer.json

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"vo",
1111
"psr",
1212
"math",
13-
"psr-4",
14-
"psr-12",
1513
"arithmetic",
1614
"big-number",
1715
"tiny-blocks",
@@ -24,6 +22,10 @@
2422
"homepage": "https://github.com/gustavofreze"
2523
}
2624
],
25+
"support": {
26+
"issues": "https://github.com/tiny-blocks/math/issues",
27+
"source": "https://github.com/tiny-blocks/math"
28+
},
2729
"config": {
2830
"sort-packages": true,
2931
"allow-plugins": {
@@ -41,29 +43,32 @@
4143
}
4244
},
4345
"require": {
44-
"php": "^8.1||^8.2",
45-
"tiny-blocks/value-object": "^2.0",
46+
"php": "^8.2",
47+
"tiny-blocks/value-object": "^2",
4648
"ext-bcmath": "*"
4749
},
4850
"require-dev": {
49-
"infection/infection": "^0.26",
50-
"phpmd/phpmd": "^2.13",
51-
"phpunit/phpunit": "^9.6",
52-
"squizlabs/php_codesniffer": "^3.7"
51+
"phpmd/phpmd": "^2.15",
52+
"phpunit/phpunit": "^11",
53+
"phpstan/phpstan": "^1",
54+
"infection/infection": "^0.29",
55+
"squizlabs/php_codesniffer": "^3.10"
5356
},
5457
"suggest": {
5558
"ext-bcmath": "Enables the extension which is an interface to the GNU implementation as a Basic Calculator utility library."
5659
},
5760
"scripts": {
5861
"phpcs": "phpcs --standard=PSR12 --extensions=php ./src",
5962
"phpmd": "phpmd ./src text phpmd.xml --suffixes php --exclude /src/RoundingMode.php --ignore-violations-on-exit",
63+
"phpstan": "phpstan analyse -c phpstan.neon.dist --quiet --no-progress",
6064
"test": "phpunit --log-junit=report/coverage/junit.xml --coverage-xml=report/coverage/coverage-xml --coverage-html=report/coverage/coverage-html tests",
6165
"test-mutation": "infection --only-covered --logger-html=report/coverage/mutation-report.html --coverage=report/coverage --min-msi=100 --min-covered-msi=100 --threads=4",
6266
"test-no-coverage": "phpunit --no-coverage",
6367
"test-mutation-no-coverage": "infection --only-covered --min-msi=100 --threads=4",
6468
"review": [
6569
"@phpcs",
66-
"@phpmd"
70+
"@phpmd",
71+
"@phpstan"
6772
],
6873
"tests": [
6974
"@test",
@@ -72,6 +77,9 @@
7277
"tests-no-coverage": [
7378
"@test-no-coverage",
7479
"@test-mutation-no-coverage"
80+
],
81+
"tests-file-no-coverage": [
82+
"@test-no-coverage"
7583
]
7684
}
7785
}

infection.json.dist

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
{
22
"timeout": 10,
33
"testFramework": "phpunit",
4-
"tmpDir": "report/",
4+
"tmpDir": "report/infection/",
55
"source": {
66
"directories": [
77
"src"
88
]
99
},
1010
"logs": {
11-
"text": "report/logs/infection-text.log",
12-
"summary": "report/logs/infection-summary.log"
11+
"text": "report/infection/logs/infection-text.log",
12+
"summary": "report/infection/logs/infection-summary.log"
1313
},
1414
"mutators": {
1515
"@default": true,
1616
"Minus": false,
1717
"BCMath": false,
18+
"CastInt": false,
1819
"Ternary": false,
19-
"MBString": false,
20-
"UnwrapTrim": false,
21-
"UnwrapSubstr": false,
22-
"AssignmentEqual": false,
23-
"IncrementInteger": false,
24-
"PublicVisibility": false,
25-
"MethodCallRemoval": false,
26-
"ProtectedVisibility": false
20+
"MethodCallRemoval": false
2721
},
2822
"phpUnit": {
2923
"configDir": "",
3024
"customPath": "./vendor/bin/phpunit"
3125
}
32-
}
26+
}

phpstan.neon.dist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
parameters:
2+
paths:
3+
- src
4+
level: 9
5+
tmpDir: report/phpstan
6+
ignoreErrors:
7+
- '#Binary operation#'
8+
- '#of function sprintf expects#'
9+
- '#Access to an undefined property#'
10+
- '#expects TinyBlocks\\Math\\BigNumber#'
11+
- '#type specified in iterable type array#'
12+
reportUnmatchedIgnoredErrors: false

phpunit.xml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
bootstrap="vendor/autoload.php"
4-
cacheResultFile="report/.phpunit.result.cache"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
74
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
11-
processIsolation="false"
12-
stopOnFailure="false"
13-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
5+
bootstrap="vendor/autoload.php"
6+
failOnRisky="true"
7+
failOnWarning="true"
8+
cacheDirectory=".phpunit.cache"
9+
beStrictAboutOutputDuringTests="true">
10+
11+
<source>
12+
<include>
13+
<directory>src</directory>
14+
</include>
15+
</source>
16+
1417
<testsuites>
1518
<testsuite name="default">
16-
<directory suffix="Test.php">tests</directory>
19+
<directory>tests</directory>
1720
</testsuite>
1821
</testsuites>
1922

2023
<coverage>
21-
<include>
22-
<directory suffix=".php">src</directory>
23-
</include>
24+
<report>
25+
<text outputFile="report/coverage.txt"/>
26+
<html outputDirectory="report/html/"/>
27+
<clover outputFile="report/coverage-clover.xml"/>
28+
</report>
2429
</coverage>
30+
31+
<logging>
32+
<junit outputFile="report/execution-result.xml"/>
33+
</logging>
34+
2535
</phpunit>

src/BigDecimal.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace TinyBlocks\Math;
46

57
use TinyBlocks\Math\Internal\BigNumberAdapter;
@@ -12,13 +14,11 @@ final class BigDecimal extends BigNumberAdapter implements BigNumber, ValueObjec
1214
{
1315
use ValueObjectAdapter;
1416

15-
private function __construct(float|string $value, ?int $scale)
16-
{
17-
parent::__construct(number: new Number(value: $value), scale: new Scale(value: $scale));
18-
}
19-
2017
public static function from(float|string $value, ?int $scale = BigNumber::AUTOMATIC_SCALE): BigDecimal
2118
{
22-
return new BigDecimal(value: $value, scale: $scale);
19+
$scale = new Scale(value: $scale);
20+
$number = Number::from(value: $value);
21+
22+
return new BigDecimal(number: $number, scale: $scale);
2323
}
2424
}

0 commit comments

Comments
 (0)