Skip to content

Commit 4b4cd16

Browse files
authored
Merge pull request #22 from 123inkt/Update-package-versions
Update package versions
2 parents 82f1975 + fe3723a commit 4b4cd16

26 files changed

+136
-444
lines changed

.gitattributes

+9
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,12 @@
5353
*.ttf -text diff
5454
*.woff -text diff
5555
*.woff2 -text diff
56+
57+
# Exclude directories/files from composer vendor package
58+
/tests export-ignore
59+
/.* export-ignore
60+
/php*.json export-ignore
61+
/php*.xml export-ignore
62+
/php*.dist export-ignore
63+
/php*.neon export-ignore
64+
/renovate.json export-ignore

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
php-versions: ['8.1', '8.2']
18+
php-versions: ['8.1', '8.2', '8.3']
1919
composer-flags: ['', '--prefer-lowest']
2020
steps:
2121
- uses: actions/checkout@v4
@@ -54,7 +54,7 @@ jobs:
5454
run: php -dpcov.enabled=1 -dpcov.exclude="~vendor~" vendor/bin/phpunit --testsuite unit --coverage-clover ./.coverage/coverage.xml
5555

5656
- name: Check coverage
57-
run: php vendor/bin/phpfci inspect ./.coverage/coverage.xml ./.coverage/phpfci.xml --exit-code-on-failure
57+
run: test ! -f ./.coverage/coverage.xml || php vendor/bin/phpfci inspect ./.coverage/coverage.xml --exit-code-on-failure --reportText
5858

5959
quality:
6060
name: Quality checks

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/vendor
33
/composer.lock
44
/phpunit.xml
5-
/.phpunit.result.cache
5+
/.phpunit.cache

composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
}
2929
},
3030
"require-dev": {
31-
"digitalrevolution/phpunit-file-coverage-inspection": "^v1.0",
32-
"digitalrevolution/accessorpair-constraint": "2.1.7",
31+
"digitalrevolution/phpunit-file-coverage-inspection": "^v2.0.0",
32+
"digitalrevolution/accessorpair-constraint": "^v2.1.18",
3333
"roave/security-advisories": "dev-latest",
3434
"squizlabs/php_codesniffer": "^3.6",
35-
"phpmd/phpmd": "@stable",
36-
"phpunit/phpunit": "^9.5",
37-
"phpstan/phpstan": "^1.4",
38-
"phpstan/phpstan-phpunit": "^1.0",
39-
"phpstan/phpstan-strict-rules": "^1.1",
40-
"phpstan/extension-installer": "^1.1"
35+
"phpmd/phpmd": "^2.14",
36+
"phpunit/phpunit": "^10.5.1",
37+
"phpstan/phpstan": "^1.10",
38+
"phpstan/phpstan-phpunit": "^1.3",
39+
"phpstan/phpstan-strict-rules": "^1.5",
40+
"phpstan/extension-installer": "^1.3"
4141
},
4242
"scripts": {
4343
"check": ["@check:phpstan", "@check:phpmd", "@check:phpcs"],

phpunit.xml.dist

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
forceCoversAnnotation="true"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
64
failOnRisky="true"
75
failOnWarning="true"
6+
failOnDeprecation="true"
87
beStrictAboutChangesToGlobalState="true"
98
beStrictAboutOutputDuringTests="true"
10-
beStrictAboutResourceUsageDuringSmallTests="true"
11-
beStrictAboutTodoAnnotatedTests="true"
129
executionOrder="defects"
13-
>
10+
cacheDirectory=".phpunit.cache"
11+
requireCoverageMetadata="true">
1412
<testsuites>
1513
<testsuite name="unit">
1614
<directory>tests/Unit</directory>
1715
</testsuite>
1816
</testsuites>
19-
<coverage processUncoveredFiles="true">
17+
<source>
2018
<include>
21-
<directory suffix=".php">src</directory>
19+
<directory>src</directory>
2220
</include>
23-
</coverage>
21+
</source>
2422
</phpunit>

src/PhoneNumber/PhoneNumberFormatOptions.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
declare(strict_types=1);
33

4-
54
namespace DR\Internationalization\PhoneNumber;
65

76
use libphonenumber\PhoneNumberFormat;
@@ -37,6 +36,7 @@ class PhoneNumberFormatOptions
3736
public const FORMAT_INTERNATIONAL_DIAL = 4;
3837

3938
private ?string $defaultCountryCode = null;
39+
/** @phpstan-var ?Format */
4040
private ?int $format = null;
4141

4242
public function getDefaultCountryCode(): ?string
@@ -51,6 +51,9 @@ public function setDefaultCountryCode(?string $defaultCountryCode): self
5151
return $this;
5252
}
5353

54+
/**
55+
* @phpstan-return ?Format
56+
*/
5457
public function getFormat(): ?int
5558
{
5659
return $this->format;

tests/Unit/Currency/CurrencyFormatOptionsTest.php

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,14 @@
66
use DigitalRevolution\AccessorPairConstraint\AccessorPairAsserter;
77
use DigitalRevolution\AccessorPairConstraint\Constraint\ConstraintConfig;
88
use DR\Internationalization\Currency\CurrencyFormatOptions;
9+
use PHPUnit\Framework\Attributes\CoversClass;
910
use PHPUnit\Framework\TestCase;
1011

11-
/**
12-
* @coversDefaultClass \DR\Internationalization\Currency\CurrencyFormatOptions
13-
*/
12+
#[CoversClass(CurrencyFormatOptions::class)]
1413
class CurrencyFormatOptionsTest extends TestCase
1514
{
1615
use AccessorPairAsserter;
1716

18-
/**
19-
* @covers ::setSymbol
20-
* @covers ::hasSymbol
21-
* @covers ::setCurrencyCode
22-
* @covers ::getCurrencyCode
23-
*/
2417
public function testAccessors(): void
2518
{
2619
$config = new ConstraintConfig();
@@ -31,9 +24,6 @@ public function testAccessors(): void
3124
static::assertAccessorPairs(CurrencyFormatOptions::class, $config);
3225
}
3326

34-
/**
35-
* @covers ::__toString
36-
*/
3727
public function testToString(): void
3828
{
3929
$options = new CurrencyFormatOptions();

tests/Unit/Currency/CurrencyFormatterFactoryTest.php

+2-35
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,22 @@
66
use DR\Internationalization\Currency\CurrencyFormatOptions;
77
use DR\Internationalization\Currency\CurrencyFormatterFactory;
88
use InvalidArgumentException;
9+
use PHPUnit\Framework\Attributes\CoversClass;
910
use PHPUnit\Framework\TestCase;
1011

11-
/**
12-
* @coversDefaultClass \DR\Internationalization\Currency\CurrencyFormatterFactory
13-
* @covers ::__construct
14-
*/
12+
#[CoversClass(CurrencyFormatterFactory::class)]
1513
class CurrencyFormatterFactoryTest extends TestCase
1614
{
1715
private const MINUS = "\xE2\x88\x92";
1816
private const NBSP = "\xC2\xA0";
1917

20-
/**
21-
* @covers ::create
22-
*/
2318
public function testCreateLocaleIsRequired(): void
2419
{
2520
$this->expectException(InvalidArgumentException::class);
2621
$this->expectExceptionMessage('unable to format currency without a locale');
2722
(new CurrencyFormatterFactory(new CurrencyFormatOptions()))->create(new CurrencyFormatOptions());
2823
}
2924

30-
/**
31-
* @covers ::create
32-
* @covers ::applyCurrencyFormatOptions
33-
*/
3425
public function testCreateWithDefaults(): void
3526
{
3627
$defaultOptions = (new CurrencyFormatOptions())->setLocale('nl_NL');
@@ -50,10 +41,6 @@ public function testCreateWithDefaults(): void
5041
static::assertSame('-2.005,56', $formatter->format(-2005.555));
5142
}
5243

53-
/**
54-
* @covers ::create
55-
* @covers ::applyCurrencyFormatOptions
56-
*/
5744
public function testCreateDefaultCurrencyWithCustomSettings(): void
5845
{
5946
$defaultOptions = (new CurrencyFormatOptions())->setLocale('nl_NL');
@@ -63,10 +50,6 @@ public function testCreateDefaultCurrencyWithCustomSettings(): void
6350
static::assertSame('-2.005,1235', $formatter->format(-2005.123456));
6451
}
6552

66-
/**
67-
* @covers ::create
68-
* @covers ::applyCurrencyFormatOptions
69-
*/
7053
public function testCreateSwedishCurrencyWithSymbol(): void
7154
{
7255
$defaultOptions = (new CurrencyFormatOptions())->setLocale('sv_SE');
@@ -78,10 +61,6 @@ public function testCreateSwedishCurrencyWithSymbol(): void
7861
static::assertSame(self::MINUS . '2' . self::NBSP . '005,56' . self::NBSP . 'kr', $formatter->format(-2005.555));
7962
}
8063

81-
/**
82-
* @covers ::create
83-
* @covers ::applyCurrencyFormatOptions
84-
*/
8564
public function testCreateSwedishCurrencyWithoutSymbol(): void
8665
{
8766
$defaultOptions = (new CurrencyFormatOptions())->setLocale('sv_SE')->setCurrencyCode('SEK');
@@ -94,10 +73,6 @@ public function testCreateSwedishCurrencyWithoutSymbol(): void
9473
static::assertSame(self::MINUS . '2' . self::NBSP . '005,56', $formatter->format(-2005.555));
9574
}
9675

97-
/**
98-
* @covers ::create
99-
* @covers ::applyCurrencyFormatOptions
100-
*/
10176
public function testCreateIrishCurrency(): void
10277
{
10378
$defaultOptions = (new CurrencyFormatOptions())->setLocale('en_IE')->setCurrencyCode('EUR');
@@ -108,10 +83,6 @@ public function testCreateIrishCurrency(): void
10883
static::assertSame("" . '2,005.56', $formatter->format(2005.555));
10984
}
11085

111-
/**
112-
* @covers ::create
113-
* @covers ::applyCurrencyFormatOptions
114-
*/
11586
public function testCreateForeignCurrencyWithoutSymbolOrGrouping(): void
11687
{
11788
$defaultOptions = (new CurrencyFormatOptions())->setLocale('nl_NL')->setCurrencyCode('SEK');
@@ -125,10 +96,6 @@ public function testCreateForeignCurrencyWithoutSymbolOrGrouping(): void
12596
static::assertSame('-2005,56', $formatter->format(-2005.555));
12697
}
12798

128-
/**
129-
* @covers ::create
130-
* @covers ::applyCurrencyFormatOptions
131-
*/
13299
public function testCreateForeignCurrencyWithSymbol(): void
133100
{
134101
$defaultOptions = (new CurrencyFormatOptions())->setLocale('nl_NL')->setCurrencyCode('SEK');

tests/Unit/Date/DayOfTheWeekFormatterTest.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
use DR\Internationalization\Date\DayOfTheWeekFormatter;
77
use Exception;
88
use InvalidArgumentException;
9+
use PHPUnit\Framework\Attributes\CoversClass;
10+
use PHPUnit\Framework\Attributes\DataProvider;
911
use PHPUnit\Framework\TestCase;
1012

1113
/**
1214
* @phpstan-import-type DayOfTheWeek from DayOfTheWeekFormatter
13-
* @coversDefaultClass \DR\Internationalization\Date\DayOfTheWeekFormatter
14-
* @covers ::__construct
1515
*/
16+
#[CoversClass(DayOfTheWeekFormatter::class)]
1617
class DayOfTheWeekFormatterTest extends TestCase
1718
{
1819
/**
1920
* @phpstan-param DayOfTheWeek $dayOfWeek
20-
* @dataProvider formatDayOfTheWeekDataProvider
21-
* @covers ::format
2221
* @throws Exception
2322
*/
23+
#[DataProvider('formatDayOfTheWeekDataProvider')]
2424
public function testFormat(string $locale, int $dayOfWeek, string $expected): void
2525
{
2626
$formatter = new DayOfTheWeekFormatter($locale);
@@ -29,10 +29,9 @@ public function testFormat(string $locale, int $dayOfWeek, string $expected): vo
2929

3030
/**
3131
* @phpstan-param DayOfTheWeek $dayOfWeek
32-
* @dataProvider formatDayOfTheWeekInvalidDataProvider
33-
* @covers ::format
3432
* @throws Exception
3533
*/
34+
#[DataProvider('formatDayOfTheWeekInvalidDataProvider')]
3635
public function testFormatInvalid(int $dayOfWeek, string $expectedMessage): void
3736
{
3837
$formatter = new DayOfTheWeekFormatter('en_GB');
@@ -42,10 +41,9 @@ public function testFormatInvalid(int $dayOfWeek, string $expectedMessage): void
4241
}
4342

4443
/**
45-
* @dataProvider formatDayOfTheWeekInvalidDataProvider
46-
* @covers ::format
4744
* @throws Exception
4845
*/
46+
#[DataProvider('formatDayOfTheWeekInvalidDataProvider')]
4947
public function testFormatInvalidCustomLocale(): void
5048
{
5149
$formatter = new DayOfTheWeekFormatter('en_GB');
@@ -55,7 +53,7 @@ public function testFormatInvalidCustomLocale(): void
5553
/**
5654
* @return array<string, array>
5755
*/
58-
public function formatDayOfTheWeekDataProvider(): array
56+
public static function formatDayOfTheWeekDataProvider(): array
5957
{
6058
return [
6159
'EN-Mon' => ['en_GB', DayOfTheWeekFormatter::MONDAY, 'Monday'],
@@ -103,7 +101,7 @@ public function formatDayOfTheWeekDataProvider(): array
103101
/**
104102
* @return array[]
105103
*/
106-
public function formatDayOfTheWeekInvalidDataProvider(): array
104+
public static function formatDayOfTheWeekInvalidDataProvider(): array
107105
{
108106
return [
109107
[0, '0 is not a valid ISO-8601 numeric representation of the day of the week.'],

tests/Unit/DateFormatServiceTest.php

+7-15
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33

44
namespace DR\Internationalization\Tests\Unit;
55

6+
use DateTime;
67
use DR\Internationalization\DateFormatService;
78
use Generator;
9+
use PHPUnit\Framework\Attributes\CoversClass;
10+
use PHPUnit\Framework\Attributes\DataProvider;
811
use PHPUnit\Framework\TestCase;
912

10-
/**
11-
* @coversDefaultClass \DR\Internationalization\DateFormatService
12-
* @covers ::__construct
13-
*/
13+
#[CoversClass(DateFormatService::class)]
1414
class DateFormatServiceTest extends TestCase
1515
{
16-
/**
17-
* @covers ::format
18-
* @covers ::getDateFormatter
19-
* @dataProvider dataProviderDateFormats
20-
*/
16+
#[DataProvider('dataProviderDateFormats')]
2117
public function testFormat($locale, $timeZone, $value, $format, $expectedValue): void
2218
{
2319
$formatService = new DateFormatService($locale, $timeZone);
@@ -27,11 +23,11 @@ public function testFormat($locale, $timeZone, $value, $format, $expectedValue):
2723
/**
2824
* @return Generator<string, array<string>>
2925
*/
30-
public function dataProviderDateFormats(): Generator
26+
public static function dataProviderDateFormats(): Generator
3127
{
3228
yield 'nl_NL, Y-M-d' => ['nl_NL', 'Europe/Amsterdam', 2222222222, 'Y-M-d', '2040-6-2'];
3329
yield 'nl_NL, string input' => ['nl_NL', 'Europe/Amsterdam', '2022-08-16 + 1 day', 'Y-M-d', '2022-8-17'];
34-
yield 'nl_NL, DateTime input' => ['nl_NL', 'Europe/Amsterdam', new \DateTime('2022-08-16 + 1 day'), 'Y-M-d', '2022-8-17'];
30+
yield 'nl_NL, DateTime input' => ['nl_NL', 'Europe/Amsterdam', new DateTime('2022-08-16 + 1 day'), 'Y-M-d', '2022-8-17'];
3531
yield 'nl_NL, long format' => [
3632
'nl_NL',
3733
'Europe/Amsterdam',
@@ -56,10 +52,6 @@ public function dataProviderDateFormats(): Generator
5652
];
5753
}
5854

59-
/**
60-
* @covers ::format
61-
* @covers ::getDateFormatter
62-
*/
6355
public function testFormatDuplicateFormat(): void
6456
{
6557
$formatService = new DateFormatService('nl_NL', 'Europe/Amsterdam');

0 commit comments

Comments
 (0)