Skip to content

Commit bc6b9f7

Browse files
authored
Fixes execution of composer scripts and updates dependencies. (#10)
* fix: Fixes execution of composer scripts and updates dependencies.
1 parent 0fab019 commit bc6b9f7

File tree

10 files changed

+59
-42
lines changed

10 files changed

+59
-42
lines changed

.github/workflows/auto-assign.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
name: Auto assign issues
1+
name: Auto assign issues and pull requests
22

33
on:
44
issues:
55
types:
66
- opened
7+
pull_request:
8+
types:
9+
- opened
710

811
jobs:
912
run:
@@ -12,11 +15,11 @@ jobs:
1215
issues: write
1316
pull-requests: write
1417
steps:
15-
- name: Assign issues
16-
uses: gustavofreze/auto-assign@1.0.0
18+
- name: Assign issues and pull requests
19+
uses: gustavofreze/auto-assign@1.1.4
1720
with:
1821
assignees: '${{ secrets.ASSIGNEES }}'
1922
github_token: '${{ secrets.GITHUB_TOKEN }}'
2023
allow_self_assign: 'true'
2124
allow_no_assignees: 'true'
22-
assignment_options: 'ISSUE'
25+
assignment_options: 'ISSUE,PULL_REQUEST'

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: CI
22

33
on:
4-
push:
54
pull_request:
65

76
permissions:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022-2024 Tiny Blocks
3+
Copyright (c) 2022-2025 Tiny Blocks
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
DOCKER_RUN = docker run --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.3
1+
ifeq ($(OS),Windows_NT)
2+
PWD := $(shell cd)
3+
else
4+
PWD := $(shell pwd -L)
5+
endif
6+
7+
ARCH := $(shell uname -m)
8+
PLATFORM :=
9+
10+
ifeq ($(ARCH),arm64)
11+
PLATFORM := --platform=linux/amd64
12+
endif
13+
14+
DOCKER_RUN = docker run ${PLATFORM} --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.3
215

316
.PHONY: configure test test-file test-no-coverage review show-reports clean
417

@@ -9,7 +22,7 @@ test:
922
@${DOCKER_RUN} composer tests
1023

1124
test-file:
12-
@${DOCKER_RUN} composer tests-file-no-coverage ${FILE}
25+
@${DOCKER_RUN} composer test-file ${FILE}
1326

1427
test-no-coverage:
1528
@${DOCKER_RUN} composer tests-no-coverage
@@ -22,4 +35,4 @@ show-reports:
2235

2336
clean:
2437
@sudo chown -R ${USER}:${USER} ${PWD}
25-
@rm -rf report vendor .phpunit.cache
38+
@rm -rf report vendor .phpunit.cache *.lock

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,28 @@
4747
"phpmd/phpmd": "^2.15",
4848
"phpunit/phpunit": "^11",
4949
"phpstan/phpstan": "^1",
50-
"infection/infection": "^0.29",
50+
"infection/infection": "^0",
5151
"squizlabs/php_codesniffer": "^3.11"
5252
},
5353
"suggest": {
5454
"ext-bcmath": "Enables the extension which is an interface to the GNU implementation as a Basic Calculator utility library."
5555
},
5656
"scripts": {
57+
"test": "phpunit -d memory_limit=2G --configuration phpunit.xml tests",
5758
"phpcs": "phpcs --standard=PSR12 --extensions=php ./src",
5859
"phpmd": "phpmd ./src text phpmd.xml --suffixes php --ignore-violations-on-exit",
5960
"phpstan": "phpstan analyse -c phpstan.neon.dist --quiet --no-progress",
60-
"test": "phpunit --log-junit=report/coverage/junit.xml --coverage-xml=report/coverage/coverage-xml --coverage-html=report/coverage/coverage-html tests",
61-
"test-mutation": "infection --only-covered --logger-html=report/coverage/mutation-report.html --coverage=report/coverage --min-msi=100 --min-covered-msi=100 --threads=4",
62-
"test-no-coverage": "phpunit --no-coverage",
61+
"test-file": "phpunit --configuration phpunit.xml --no-coverage --filter",
62+
"mutation-test": "infection --only-covered --threads=max --logger-html=report/coverage/mutation-report.html --coverage=report/coverage",
63+
"test-no-coverage": "phpunit --configuration phpunit.xml --no-coverage tests",
6364
"review": [
6465
"@phpcs",
6566
"@phpmd",
6667
"@phpstan"
6768
],
6869
"tests": [
6970
"@test",
70-
"@test-mutation"
71+
"@mutation-test"
7172
],
7273
"tests-no-coverage": [
7374
"@test-no-coverage"

infection.json.dist

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
{
2-
"timeout": 30,
3-
"testFramework": "phpunit",
2+
"logs": {
3+
"text": "report/infection/logs/infection-text.log",
4+
"summary": "report/infection/logs/infection-summary.log"
5+
},
46
"tmpDir": "report/infection/",
7+
"minMsi": 100,
8+
"timeout": 30,
59
"source": {
610
"directories": [
711
"src"
812
]
913
},
10-
"logs": {
11-
"text": "report/infection/logs/infection-text.log",
12-
"summary": "report/infection/logs/infection-summary.log"
14+
"phpUnit": {
15+
"configDir": "",
16+
"customPath": "./vendor/bin/phpunit"
1317
},
1418
"mutators": {
1519
"@default": true,
@@ -18,12 +22,9 @@
1822
"Increment": false,
1923
"GreaterThan": false,
2024
"UnwrapSubstr": false,
21-
"UnwrapStrToLower": false,
2225
"LogicalAndNegation": false,
2326
"LogicalAndAllSubExprNegation": false
2427
},
25-
"phpUnit": {
26-
"configDir": "",
27-
"customPath": "./vendor/bin/phpunit"
28-
}
28+
"minCoveredMsi": 100,
29+
"testFramework": "phpunit"
2930
}

phpunit.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
failOnRisky="true"
77
failOnWarning="true"
88
cacheDirectory=".phpunit.cache"
9+
executionOrder="random"
910
beStrictAboutOutputDuringTests="true">
1011

1112
<source>
@@ -22,14 +23,15 @@
2223

2324
<coverage>
2425
<report>
26+
<xml outputDirectory="report/coverage/coverage-xml"/>
27+
<html outputDirectory="report/coverage/coverage-html"/>
2528
<text outputFile="report/coverage.txt"/>
26-
<html outputDirectory="report/html/"/>
2729
<clover outputFile="report/coverage-clover.xml"/>
2830
</report>
2931
</coverage>
3032

3133
<logging>
32-
<junit outputFile="report/execution-result.xml"/>
34+
<junit outputFile="report/coverage/junit.xml"/>
3335
</logging>
3436

3537
</phpunit>

src/Base62.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
final readonly class Base62 implements Encoder
1212
{
13-
public const int BASE62_RADIX = 62;
1413
private const int BASE62_CHARACTER_LENGTH = 1;
1514

15+
public const string BASE62_RADIX = '62';
1616
private const string BASE62_ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
1717

1818
private function __construct(private string $value)
@@ -58,7 +58,7 @@ public function decode(): string
5858
return str_repeat("\x00", $bytes);
5959
}
6060

61-
$decimal = Decimal::fromBase62(number: $value, alphabet: self::BASE62_ALPHABET);
61+
$decimal = Decimal::from(number: $value, alphabet: self::BASE62_ALPHABET, baseRadix: self::BASE62_RADIX);
6262
$hexadecimal = Hexadecimal::from(value: $decimal->toHexadecimal())
6363
->fillWithZeroIfNecessary()
6464
->toString();

src/Internal/Decimal.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@
44

55
namespace TinyBlocks\Encoder\Internal;
66

7-
use TinyBlocks\Encoder\Base62;
8-
97
final readonly class Decimal
108
{
119
private function __construct(private string $value)
1210
{
1311
}
1412

15-
public static function fromBase62(string $number, string $alphabet): Decimal
13+
public static function from(string $number, string $alphabet, string $baseRadix): Decimal
1614
{
1715
$value = '0';
1816
$length = strlen($number);
1917

2018
for ($index = 0; $index < $length; $index++) {
21-
$digit = strpos($alphabet, $number[$index]);
22-
$value = bcmul($value, (string)Base62::BASE62_RADIX);
23-
$value = bcadd($value, (string)$digit);
19+
$digit = (string)strpos($alphabet, $number[$index]);
20+
$value = bcmul($value, $baseRadix);
21+
$value = bcadd($value, $digit);
2422
}
2523

2624
return new Decimal(value: $value);
@@ -32,8 +30,8 @@ public function toHexadecimal(): string
3230
$hexadecimalValue = '';
3331

3432
while (bccomp($value, '0') > 0) {
35-
$remainder = bcmod($value, Hexadecimal::HEXADECIMAL_RADIX);
36-
$hexadecimalValue = sprintf('%s%s', Hexadecimal::HEXADECIMAL_ALPHABET[(int)$remainder], $hexadecimalValue);
33+
$remainder = (int)bcmod($value, Hexadecimal::HEXADECIMAL_RADIX);
34+
$hexadecimalValue = sprintf('%s%s', Hexadecimal::HEXADECIMAL_ALPHABET[$remainder], $hexadecimalValue);
3735
$value = bcdiv($value, Hexadecimal::HEXADECIMAL_RADIX);
3836
}
3937

src/Internal/Hexadecimal.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,24 @@ public function isEmpty(): bool
5959
return empty($this->value);
6060
}
6161

62-
public function toBase(int $base): string
62+
public function toBase(string $base): string
6363
{
6464
$length = strlen($this->value);
6565
$decimalValue = '0';
6666

6767
for ($index = 0; $index < $length; $index++) {
68-
$digit = strpos(self::HEXADECIMAL_ALPHABET, strtolower($this->value[$index]));
68+
$digit = (string)strpos(self::HEXADECIMAL_ALPHABET, $this->value[$index]);
6969
$decimalValue = bcmul($decimalValue, self::HEXADECIMAL_RADIX);
70-
$decimalValue = bcadd($decimalValue, (string)$digit);
70+
$decimalValue = bcadd($decimalValue, $digit);
7171
}
7272

7373
$digits = $this->alphabet;
7474
$result = '';
7575

7676
while (bccomp($decimalValue, '0') > 0) {
77-
$remainder = bcmod($decimalValue, (string)$base);
78-
$result = sprintf('%s%s', $digits[(int)$remainder], $result);
79-
$decimalValue = bcdiv($decimalValue, (string)$base);
77+
$remainder = (int)bcmod($decimalValue, $base);
78+
$result = sprintf('%s%s', $digits[$remainder], $result);
79+
$decimalValue = bcdiv($decimalValue, $base);
8080
}
8181

8282
return $result ?: '0';

0 commit comments

Comments
 (0)