Skip to content

Commit cb35035

Browse files
authored
Merge pull request #32 from macocci7/update_phpunit_to_10
Update phpunit to 10
2 parents a45d14c + 861c7ab commit cb35035

18 files changed

Lines changed: 168 additions & 3232 deletions

.github/workflows/tag_meged_pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
tools: composer:v2
2424

2525
- name: Checkout code
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2727
with:
2828
fetch-depth: 0
2929

.github/workflows/test_pull_request.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
tools: composer:v2
1616

1717
- name: Checkout code
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

@@ -63,12 +63,12 @@ jobs:
6363
tools: composer:v2
6464

6565
- name: Set up Node
66-
uses: actions/setup-node@v3
66+
uses: actions/setup-node@v4
6767
with:
6868
node-version: '14.x'
6969

7070
- name: Checkout code
71-
uses: actions/checkout@v3
71+
uses: actions/checkout@v4
7272
with:
7373
fetch-depth: 0
7474

@@ -126,25 +126,25 @@ jobs:
126126
tools: composer:v2
127127

128128
- name: Set up Node
129-
uses: actions/setup-node@v3
129+
uses: actions/setup-node@v4
130130
with:
131131
node-version: '14.x'
132132

133133
- name: Checkout code
134-
uses: actions/checkout@v3
134+
uses: actions/checkout@v4
135135
with:
136136
fetch-depth: 0
137137

138138
- name: Run Composer
139139
run: composer install --no-interaction
140140

141141
- name: Update PHPUnit for Code Coverage
142-
run: composer require phpunit/phpunit:^9.6 phploc/phploc:* sebastian/version:* --with-all-dependencies
142+
run: composer require phpunit/phpunit:^10.5 sebastian/version:* --with-all-dependencies
143143

144144
- name: PHP Lint
145145
run: ./vendor/bin/parallel-lint src tests examples
146146

147147
- name: Unit tests
148148
run: |
149149
mkdir -p build/logs
150-
./vendor/bin/phpunit ./tests/ --coverage-clover build/logs/clover.xml
150+
./vendor/bin/phpunit ./tests/ --coverage-clover build/logs/clover.xml --coverage-filter=./src/

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/vendor/
2+
composer.lock
3+
.php-version

.php-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,40 +149,47 @@ This class treats basic matters of primes.
149149
// judge if all of $n are prime or not
150150
$n = [ 2, 3, 5, ];
151151
echo sprintf(
152-
"Are all of [%s] prime? - %s.\n",
152+
"Are all of [%s] prime? - %s.\n\n",
153153
implode(', ', $n),
154154
$p->isPrimeAll($n) ? 'Yes' : 'No'
155155
);
156156

157+
// a prime previous to $n
158+
$n = 5;
159+
echo sprintf("A prime previous to %d is %d.\n", $n, $p->previous($n));
160+
157161
// a prime next to $n
158162
$n = 5;
159-
echo sprintf("A prime next to %d is %d.\n", $n, $p->next($n));
163+
echo sprintf("A prime next to %d is %d.\n\n", $n, $p->next($n));
160164

161165
// primes between $a and $b
162166
$a = 6;
163167
$b = 14;
164168
echo sprintf(
165-
"Primes between %d and %d are [%s].\n",
169+
"Primes between %d and %d are [%s].\n\n",
166170
$a,
167171
$b,
168172
implode(', ', $p->between($a, $b))
169173
);
170174

171175
// factorize
172176
$n = 1234567890;
173-
echo sprintf("Factorize %d:\n", $n);
177+
echo sprintf("Factorize %d:\n\n", $n);
178+
174179
$r = $p->factorize($n);
175180
$l1 = $p->numberOfDigits(max(array_column($r, 0)));
176181
$l2 = $p->numberOfDigits(max(array_column($r, 1)));
177182
$s = str_repeat(' ', $l1 + 1);
178183
$b = $s . str_repeat('-', $l2);
184+
179185
foreach ($r as $f) {
180186
echo (
181187
$f[0]
182188
? sprintf("%" . $l1 . "d)%" . $l2 . "d\n%s\n", $f[0], $f[1], $b)
183189
: sprintf("%s%" . $l2 . "d\n", $s, $f[1])
184190
);
185191
}
192+
echo "\n";
186193

187194
// Factorized formula
188195
echo $n . " = " . $p->factorizedFormula($n)['formula'] . "\n";
@@ -193,9 +200,14 @@ This class treats basic matters of primes.
193200
```
194201
Is 3 prime? - Yes.
195202
Are all of [2, 3, 5] prime? - Yes.
203+
204+
A prime previous to 5 is 3.
196205
A prime next to 5 is 7.
206+
197207
Primes between 6 and 14 are [7, 11, 13].
208+
198209
Factorize 1234567890:
210+
199211
2)1234567890
200212
----------
201213
3) 617283945
@@ -207,6 +219,7 @@ This class treats basic matters of primes.
207219
3607) 13717421
208220
----------
209221
3803
222+
210223
1234567890 = 2 * 3 ^ 2 * 5 * 3607 * 3803
211224
```
212225

@@ -216,6 +229,7 @@ This class treats basic matters of primes.
216229
|:---|:---|
217230
|`isPrime(int $n)`|judges if the param is prime or not|
218231
|`isPrimeAll(array $elements)`|judges if all of the param are prime or not|
232+
|`previous(int $n)`|returns a prime previous to the param|
219233
|`next(int $n)`|returns a prime next to the param|
220234
|`between(int $a, int $b)`|returns array of primes between the params|
221235
|`factorize(int $n)`|factorize the param and returns the process as an array|
@@ -593,6 +607,6 @@ This class treats basic matters of Bezout's Identity.
593607

594608
*Document Created: 2023/10/19*
595609

596-
*Document Updated: 2024/03/16*
610+
*Document Updated: 2024/04/17*
597611

598612
Copyright 2023 - 2024 macocci7

bin/TestAndLint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ test_and_lint() {
5555
echo "-----------------------------------------------------------"
5656
echo "[PHP $1][phpunit]"
5757
./vendor/bin/phpunit ./tests/ \
58-
--color auto
58+
--color=auto
5959
echo "-----------------------------------------------------------"
6060
}
6161

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "macocci7/php-math-integer",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "PHP Math Library of the subjects of number theory(only natural number).",
55
"type": "library",
66
"license": "MIT",
@@ -18,10 +18,9 @@
1818
"minimum-stability": "stable",
1919
"require-dev": {
2020
"squizlabs/php_codesniffer": "^3.7",
21-
"phpunit/phpunit": "^9.6",
21+
"phpunit/phpunit": "^10.5",
2222
"phpmd/phpmd": "^2.15",
2323
"phpstan/phpstan": "^1.10",
24-
"phploc/phploc": "^7.0",
2524
"php-parallel-lint/php-parallel-lint": "^1.3"
2625
}
2726
}

0 commit comments

Comments
 (0)