Skip to content

Commit 9499076

Browse files
authored
Merge pull request #3 from Sygic/chore/update-dev-dependencies
chore: update dev dependencies and clean up assertions
2 parents ff1a865 + abf2527 commit 9499076

File tree

6 files changed

+38
-105
lines changed

6 files changed

+38
-105
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 29 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -6,105 +6,60 @@ on:
66
branches:
77
- master
88

9+
env:
10+
default_php: 8.4
11+
912
jobs:
1013
coding-standards:
1114
name: Coding Standards
1215
runs-on: ubuntu-latest
1316
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v2
16-
17-
- name: Setup PHP
18-
uses: shivammathur/setup-php@v2
17+
- uses: actions/[email protected]
18+
- uses: shivammathur/[email protected]
1919
with:
20-
php-version: 8.4
20+
php-version: ${{ env.default_php }}
2121
coverage: none
22-
23-
- name: Get composer cache directory
24-
id: composer-cache
25-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
26-
27-
- name: Cache dependencies
28-
uses: actions/cache@v2
29-
with:
30-
path: ${{ steps.composer-cache.outputs.dir }}
31-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
32-
restore-keys: ${{ runner.os }}-composer-
33-
34-
- name: Install dependencies
35-
run: composer install --no-interaction --no-progress --prefer-dist
36-
37-
- name: Run the linter
38-
run: composer lint
39-
40-
- name: Check coding standards
41-
run: composer cs-check
22+
- uses: ramsey/composer-install@v3
23+
- run: composer lint
24+
- run: composer cs-check
4225

4326
static-analysis:
4427
name: Static Analysis
4528
runs-on: ubuntu-latest
46-
4729
steps:
48-
- name: Checkout code
49-
uses: actions/checkout@v2
50-
51-
- name: Setup PHP
52-
uses: shivammathur/setup-php@v2
30+
- uses: actions/[email protected]
31+
- uses: shivammathur/[email protected]
5332
with:
5433
coverage: none
55-
php-version: 8.4
56-
57-
- name: Get composer cache directory
58-
id: composer-cache
59-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
60-
61-
- name: Cache dependencies
62-
uses: actions/cache@v2
63-
with:
64-
path: ${{ steps.composer-cache.outputs.dir }}
65-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
66-
restore-keys: ${{ runner.os }}-composer-
67-
68-
- name: Install dependencies
69-
run: composer update --no-interaction --no-progress --prefer-dist
70-
71-
- name: Run static analysis
72-
run: php vendor/bin/phpstan analyse
34+
php-version: ${{ env.default_php }}
35+
- uses: ramsey/composer-install@v3
36+
- run: php vendor/bin/phpstan analyse
7337

7438
unit-tests:
7539
name: Unit Tests
7640
runs-on: ubuntu-latest
77-
7841
strategy:
7942
matrix:
8043
php-versions: ['8.3', '8.4']
8144

8245
steps:
83-
- name: Checkout code
84-
uses: actions/checkout@v2
85-
86-
- name: Setup PHP
87-
uses: shivammathur/setup-php@v2
46+
- uses: actions/[email protected]
47+
- uses: shivammathur/[email protected]
8848
with:
8949
php-version: "${{ matrix.php-versions }}"
9050
coverage: xdebug
51+
- uses: ramsey/composer-install@v3
52+
- run: ./vendor/bin/phpunit
53+
- uses: codecov/codecov-action@v1
9154

92-
- name: Get composer cache directory
93-
id: composer-cache
94-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
95-
96-
- name: Cache dependencies
97-
uses: actions/cache@v2
55+
rector:
56+
runs-on: ubuntu-latest
57+
name: Run Rector on PHP
58+
steps:
59+
- uses: actions/[email protected]
60+
- uses: shivammathur/[email protected]
9861
with:
99-
path: ${{ steps.composer-cache.outputs.dir }}
100-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
101-
restore-keys: ${{ runner.os }}-composer-
102-
103-
- name: Install dependencies
104-
run: composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader
105-
106-
- name: Run unit tests
107-
run: ./vendor/bin/phpunit
108-
109-
- name: Publish coverage report to Codecov
110-
uses: codecov/codecov-action@v1
62+
php-version: ${{ env.default_php }}
63+
tools: composer
64+
- uses: ramsey/composer-install@v3
65+
- run: composer rector

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
},
3030
"require-dev": {
3131
"php-parallel-lint/php-parallel-lint": "^1.3",
32-
"phpstan/extension-installer": "^1.2",
33-
"phpstan/phpstan": "^1.9",
34-
"phpstan/phpstan-phpunit": "^1.3",
35-
"phpunit/phpunit": "^11.0.0",
36-
"rector/rector": "^1.2",
37-
"squizlabs/php_codesniffer": "^3.7"
32+
"phpstan/extension-installer": "^1.4.3",
33+
"phpstan/phpstan": "^2.0",
34+
"phpstan/phpstan-phpunit": "^2.0",
35+
"phpunit/phpunit": "^12.0",
36+
"rector/rector": "^2.0",
37+
"squizlabs/php_codesniffer": "^4.0"
3838
},
3939
"suggest": {
4040
"pauci/datetime-doctrine": "Allows the use of pauci/datetime value objects as Doctrine field types."

src/DateTime.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ public static function now(): DateTimeInterface
4444
*/
4545
public static function fromString(string $time, ?DateTimeZone $timezone = null): static
4646
{
47-
$dateTime = parent::createFromInterface(new \DateTime($time, $timezone));
48-
\assert($dateTime instanceof static);
49-
50-
return $dateTime;
47+
return parent::createFromInterface(new \DateTime($time, $timezone));
5148
}
5249

5350
/**
@@ -100,10 +97,7 @@ public static function createFromMutable(\DateTime $object): static
10097
#[\Override]
10198
public static function createFromInterface(\DateTimeInterface $object): static
10299
{
103-
$dateTime = parent::createFromInterface($object);
104-
\assert($dateTime instanceof static);
105-
106-
return $dateTime;
100+
return parent::createFromInterface($object);
107101
}
108102

109103
/**

src/FrozenClock.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public function set(DateTime $now): void
1818
public function modify(string $modifier): void
1919
{
2020
$now = $this->now->modify($modifier);
21-
\assert($now instanceof DateTime);
2221

2322
$this->now = $now;
2423
}

tests/src/DateIntervalTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public function testFromDateInterval(string $intervalSpec, array $parts): void
3636
{
3737
$interval = DateInterval::fromDateInterval(new \DateInterval($intervalSpec));
3838

39-
self::assertInstanceOf(DateInterval::class, $interval);
40-
4139
self::assertEquals($parts[0], $interval->y);
4240
self::assertEquals($parts[1], $interval->m);
4341
self::assertEquals($parts[2], $interval->d);
@@ -57,9 +55,7 @@ public function testFromDateIntervalBetweenWinterAndDst(): void
5755

5856
$interval = DateInterval::fromDateInterval($phpInterval);
5957

60-
$expected = PHP_VERSION_ID >= 80100 ? 'P2M30DT23H' : 'P3MT-1H';
61-
62-
self::assertEquals($expected, (string) $interval);
58+
self::assertEquals('P2M30DT23H', (string) $interval);
6359
}
6460

6561
/**

tests/src/DateTimeTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public function testFromString(): void
4545
{
4646
$dateTime = DateTime::fromString('2017-12-02 02:20:03');
4747

48-
self::assertInstanceOf(DateTime::class, $dateTime);
4948
self::assertEquals('2017-12-02T02:20:03+01:00', (string) $dateTime);
5049
}
5150

@@ -83,7 +82,6 @@ public function testCreateFromMutable(): void
8382
{
8483
$dateTime = DateTime::createFromMutable(new \DateTime('2016-05-16 14:09:10'));
8584

86-
self::assertInstanceOf(DateTime::class, $dateTime);
8785
self::assertEquals('2016-05-16T14:09:10+02:00', (string) $dateTime);
8886

8987
$dateTime = DateTime::createFromMutable(new \DateTime('2016-05-16 14:09:10-04:00'));
@@ -120,7 +118,6 @@ public function testCreateFromInterface(): void
120118
$phpDateTime = new \DateTime('2016-05-16 14:32:51.678991');
121119
$dateTime = DateTime::createFromInterface($phpDateTime);
122120

123-
self::assertInstanceOf(DateTime::class, $dateTime);
124121
self::assertEquals('2016-05-16T14:32:51.678991+02:00', (string) $dateTime);
125122
}
126123

@@ -154,7 +151,6 @@ public function testAdd(): void
154151

155152
$dateTime2 = $dateTime1->add($interval);
156153

157-
self::assertInstanceOf(DateTime::class, $dateTime2);
158154
self::assertEquals('2016-05-13T22:37:46+02:00', (string) $dateTime2);
159155

160156
// Immutability check
@@ -168,7 +164,6 @@ public function testSub(): void
168164

169165
$dateTime2 = $dateTime1->sub($interval);
170166

171-
self::assertInstanceOf(DateTime::class, $dateTime2);
172167
self::assertEquals('2016-05-11T22:37:46+02:00', (string) $dateTime2);
173168

174169
// Immutability check
@@ -180,7 +175,6 @@ public function testModify(): void
180175
$dateTime1 = DateTime::fromString('2016-05-12 22:37:46+02:00');
181176
$dateTime2 = $dateTime1->modify('+1 day');
182177

183-
self::assertInstanceOf(DateTime::class, $dateTime2);
184178
self::assertEquals('2016-05-13T22:37:46+02:00', (string) $dateTime2);
185179

186180
// Immutability check
@@ -201,7 +195,6 @@ public function testSetDate(): void
201195
$dateTime1 = DateTime::fromString('2016-05-12 22:37:46+02:00');
202196
$dateTime2 = $dateTime1->setDate(2011, 10, 22);
203197

204-
self::assertInstanceOf(DateTime::class, $dateTime2);
205198
self::assertEquals('2011-10-22T22:37:46+02:00', (string) $dateTime2);
206199

207200
// Immutability check
@@ -213,7 +206,6 @@ public function testSetISODate(): void
213206
$dateTime1 = DateTime::fromString('2016-05-12 22:37:46+02:00');
214207
$dateTime2 = $dateTime1->setISODate(2011, 42, 6);
215208

216-
self::assertInstanceOf(DateTime::class, $dateTime2);
217209
self::assertEquals('2011-10-22T22:37:46+02:00', (string) $dateTime2);
218210

219211
// Immutability check
@@ -225,7 +217,6 @@ public function testSetTime(): void
225217
$dateTime1 = DateTime::fromString('2016-05-12 22:37:46.123456+02:00');
226218
$dateTime2 = $dateTime1->setTime(12, 10, 15, 98765);
227219

228-
self::assertInstanceOf(DateTime::class, $dateTime2);
229220
self::assertEquals('2016-05-12T12:10:15.098765+02:00', (string) $dateTime2);
230221

231222
// Immutability check
@@ -237,7 +228,6 @@ public function testSetTimestamp(): void
237228
$dateTime1 = DateTime::fromString('2016-05-12 22:37:46+02:00');
238229
$dateTime2 = $dateTime1->setTimestamp(1463490311);
239230

240-
self::assertInstanceOf(DateTime::class, $dateTime2);
241231
self::assertEquals('2016-05-17T15:05:11+02:00', (string) $dateTime2);
242232

243233
// Immutability check
@@ -249,7 +239,6 @@ public function testSetTimezone(): void
249239
$dateTime1 = DateTime::fromString('2016-05-12 22:37:46+02:00');
250240
$dateTime2 = $dateTime1->setTimezone(new \DateTimeZone('America/New_York'));
251241

252-
self::assertInstanceOf(DateTime::class, $dateTime2);
253242
self::assertEquals('2016-05-12T16:37:46-04:00', (string) $dateTime2);
254243

255244
// Immutability check

0 commit comments

Comments
 (0)