Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4af252f

Browse files
authored
"Replace mb_* functions with equivalent non-multibyte functions" (#578)
This commit replaces mb_* functions with non-multibyte equivalent functions, which don't require mbstring extension. It also adjusts the required PHP version in composer.json from 8.3 to 8.2. This change reduces dependencies and broadens compatibility without impacting functionality. It is part of an overall code simplification and optimization effort.
1 parent 57c78f2 commit 4af252f

File tree

64 files changed

+199
-181
lines changed

Some content is hidden

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

64 files changed

+199
-181
lines changed

‎.github/workflows/integrate.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
operating-system:
6969
- "ubuntu-latest"
7070
php-version:
71+
- "8.2"
7172
- "8.3"
7273
dependencies:
7374
- "lowest"
@@ -196,7 +197,7 @@ jobs:
196197
- name: "Install dependencies"
197198
uses: "ramsey/composer-install@v3"
198199
with:
199-
dependency-versions: "highest"
200+
dependency-versions: "lowest"
200201
composer-options: "--optimize-autoloader"
201202

202203
- name: "Execute Rector"

‎castor.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,13 @@ function cs(
7777
}
7878

7979
#[AsTask(description: 'Running PHPStan')]
80-
function stan(): void
80+
function stan(bool$baseline = false): void
8181
{
8282
io()->title('Running PHPStan');
8383
$command = ['php', 'vendor/bin/phpstan', 'analyse'];
84+
if ($baseline) {
85+
$command[] = '--generate-baseline';
86+
}
8487
$environment = [
8588
'XDEBUG_MODE' => 'off',
8689
];

‎composer.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@
4646
}
4747
},
4848
"require": {
49-
"php": ">=8.3",
49+
"php": ">=8.2",
5050
"ext-json": "*",
51-
"ext-mbstring": "*",
5251
"ext-openssl": "*",
5352
"brick/math": "^0.12",
5453
"psr/clock": "^1.0",

‎phpstan-baseline.neon‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,11 @@ parameters:
12251225
count: 1
12261226
path: src/Library/Core/JWKSet.php
12271227

1228+
-
1229+
message: "#^Parameter \\#2 \\$mode of function count expects 0\\|1, int given\\.$#"
1230+
count: 1
1231+
path: src/Library/Core/JWKSet.php
1232+
12281233
-
12291234
message: "#^Property Jose\\\\Component\\\\Core\\\\JWKSet\\:\\:\\$keys type has no value type specified in iterable type array\\.$#"
12301235
count: 1
@@ -1346,12 +1351,12 @@ parameters:
13461351
path: src/Library/Encryption/Algorithm/ContentEncryption/AESCBCHS.php
13471352

13481353
-
1349-
message: "#^Parameter \\#3 \\$length of function mb_substr expects int\\|null, float\\|int\\<1, max\\> given\\.$#"
1354+
message: "#^Parameter \\#3 \\$length of function substr expects int\\|null, float\\|int\\<1, max\\> given\\.$#"
13501355
count: 1
13511356
path: src/Library/Encryption/Algorithm/ContentEncryption/AESCBCHS.php
13521357

13531358
-
1354-
message: "#^Parameter \\#3 \\$length of function mb_substr expects int\\|null, float\\|int\\<min, \\-1\\> given\\.$#"
1359+
message: "#^Parameter \\#3 \\$length of function substr expects int\\|null, float\\|int\\<min, \\-1\\> given\\.$#"
13551360
count: 1
13561361
path: src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php
13571362

@@ -1761,7 +1766,7 @@ parameters:
17611766
path: src/Library/KeyManagement/JWKFactory.php
17621767

17631768
-
1764-
message: "#^Parameter \\#3 \\$length of function mb_substr expects int\\|null, float\\|int\\<min, \\-1\\> given\\.$#"
1769+
message: "#^Parameter \\#3 \\$length of function substr expects int\\|null, float\\|int\\<min, \\-1\\> given\\.$#"
17651770
count: 1
17661771
path: src/Library/KeyManagement/JWKFactory.php
17671772

‎rector.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
return static function (RectorConfig $config): void {
1515
$config->import(SetList::DEAD_CODE);
16-
$config->import(LevelSetList::UP_TO_PHP_83);
16+
$config->import(LevelSetList::UP_TO_PHP_82);
1717
$config->import(SymfonySetList::SYMFONY_64);
1818
$config->import(SymfonySetList::SYMFONY_50_TYPES);
1919
$config->import(SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES);
@@ -38,7 +38,7 @@
3838
__DIR__ . '/src/Bundle/JoseFramework/DependencyInjection/Source/KeyManagement/JWKSource.php',
3939
__DIR__ . '/src/Bundle/JoseFramework/DependencyInjection/Source/KeyManagement/JWKSetSource.php',
4040
]);
41-
$config->phpVersion(PhpVersion::PHP_83);
41+
$config->phpVersion(PhpVersion::PHP_82);
4242
$config->parallel();
4343
$config->importNames();
4444
$config->importShortClasses();

‎src/Bundle/Helper/ConfigurationHelper.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final readonly class ConfigurationHelper
1111
{
12-
final public const stringBUNDLE_ALIAS = 'jose';
12+
final public const BUNDLE_ALIAS = 'jose';
1313

1414
/**
1515
* @param string[] $signatureAlgorithms

‎src/Bundle/Serializer/JWEEncoder.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Throwable;
1818
use function in_array;
1919
use function is_int;
20-
use function mb_strtolower;
2120

2221
final readonly class JWEEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface
2322
{
@@ -54,7 +53,7 @@ public function encode(mixed $data, string $format, array $context = []): string
5453

5554
try {
5655
return $this->serializerManager->serialize(
57-
mb_strtolower($format),
56+
strtolower($format),
5857
$data,
5958
$this->getRecipientIndex($context)
6059
);
@@ -91,6 +90,6 @@ private function getRecipientIndex(array $context): int
9190
private function formatSupported(?string $format): bool
9291
{
9392
return $format !== null
94-
&& in_array(mb_strtolower($format), $this->serializerManager->names(), true);
93+
&& in_array(strtolower($format), $this->serializerManager->names(), true);
9594
}
9695
}

‎src/Bundle/Serializer/JWESerializer.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
use Override;
1212
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
1313
use function in_array;
14-
use function mb_strtolower;
1514

1615
final readonly class JWESerializer implements DenormalizerInterface
1716
{
18-
private readonlyJWESerializerManager $serializerManager;
17+
private JWESerializerManager $serializerManager;
1918

2019
public function __construct(
2120
JWESerializerManagerFactory $serializerManagerFactory,
@@ -63,6 +62,6 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
6362
private function formatSupported(?string $format): bool
6463
{
6564
return $format !== null
66-
&& in_array(mb_strtolower($format), $this->serializerManager->names(), true);
65+
&& in_array(strtolower($format), $this->serializerManager->names(), true);
6766
}
6867
}

‎src/Bundle/Serializer/JWSEncoder.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
1717
use function in_array;
1818
use function is_int;
19-
use function mb_strtolower;
2019

2120
final readonly class JWSEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface
2221
{
@@ -53,7 +52,7 @@ public function encode($data, $format, array $context = []): string
5352

5453
try {
5554
return $this->serializerManager->serialize(
56-
mb_strtolower($format),
55+
strtolower($format),
5756
$data,
5857
$this->getSignatureIndex($context)
5958
);
@@ -90,6 +89,6 @@ private function getSignatureIndex(array $context): int
9089
private function formatSupported(?string $format): bool
9190
{
9291
return $format !== null
93-
&& in_array(mb_strtolower($format), $this->serializerManager->list(), true);
92+
&& in_array(strtolower($format), $this->serializerManager->list(), true);
9493
}
9594
}

‎src/Bundle/Serializer/JWSSerializer.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Override;
1212
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
1313
use function in_array;
14-
use function mb_strtolower;
1514

1615
final readonly class JWSSerializer implements DenormalizerInterface
1716
{
@@ -63,6 +62,6 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
6362
private function formatSupported(?string $format): bool
6463
{
6564
return $format !== null
66-
&& in_array(mb_strtolower($format), $this->serializerManager->list(), true);
65+
&& in_array(strtolower($format), $this->serializerManager->list(), true);
6766
}
6867
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /