Skip to content

Commit 690e2b5

Browse files
Remove legacy code paths that rely on feature checks
1 parent 67ded31 commit 690e2b5

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

Caster/SymfonyCaster.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\VarDumper\Caster;
1313

1414
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\Uid\TimeBasedUidInterface;
1516
use Symfony\Component\Uid\Ulid;
1617
use Symfony\Component\Uid\Uuid;
1718
use Symfony\Component\VarDumper\Cloner\Stub;
@@ -102,8 +103,7 @@ public static function castUuid(Uuid $uuid, array $a, Stub $stub, bool $isNested
102103
$a[Caster::PREFIX_VIRTUAL.'toBase58'] = $uuid->toBase58();
103104
$a[Caster::PREFIX_VIRTUAL.'toBase32'] = $uuid->toBase32();
104105

105-
// symfony/uid >= 5.3
106-
if (method_exists($uuid, 'getDateTime')) {
106+
if ($uuid instanceof TimeBasedUidInterface) {
107107
$a[Caster::PREFIX_VIRTUAL.'time'] = $uuid->getDateTime()->format('Y-m-d H:i:s.u \U\T\C');
108108
}
109109

@@ -115,8 +115,7 @@ public static function castUlid(Ulid $ulid, array $a, Stub $stub, bool $isNested
115115
$a[Caster::PREFIX_VIRTUAL.'toBase58'] = $ulid->toBase58();
116116
$a[Caster::PREFIX_VIRTUAL.'toRfc4122'] = $ulid->toRfc4122();
117117

118-
// symfony/uid >= 5.3
119-
if (method_exists($ulid, 'getDateTime')) {
118+
if ($ulid instanceof TimeBasedUidInterface) {
120119
$a[Caster::PREFIX_VIRTUAL.'time'] = $ulid->getDateTime()->format('Y-m-d H:i:s.v \U\T\C');
121120
}
122121

Tests/Caster/SymfonyCasterTest.php

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,29 @@ public function testCastUuid()
3434
$this->assertDumpEquals($expectedDump, $uuid);
3535

3636
$uuid = new UuidV6('1ebc50e9-8a23-6704-ad6f-59afd5cda7e5');
37-
if (method_exists($uuid, 'getDateTime')) {
38-
$expectedDump = <<<EODUMP
37+
$expectedDump = <<<EODUMP
3938
Symfony\Component\Uid\UuidV6 {
4039
#uid: "1ebc50e9-8a23-6704-ad6f-59afd5cda7e5"
4140
toBase58: "4o8c5m6v4L8h5teww36JDa"
4241
toBase32: "0YQH8EK2H3CW2ATVTSNZAWV9Z5"
4342
time: "2021-06-04 08:26:44.591386 UTC"
4443
}
4544
EODUMP;
46-
} else {
47-
$expectedDump = <<<EODUMP
48-
Symfony\Component\Uid\UuidV6 {
49-
#uid: "1ebc50e9-8a23-6704-ad6f-59afd5cda7e5"
50-
toBase58: "4o8c5m6v4L8h5teww36JDa"
51-
toBase32: "0YQH8EK2H3CW2ATVTSNZAWV9Z5"
52-
}
53-
EODUMP;
54-
}
5545

5646
$this->assertDumpEquals($expectedDump, $uuid);
5747
}
5848

5949
public function testCastUlid()
6050
{
6151
$ulid = new Ulid('01F7B252SZQGTSQGYSGACASAW6');
62-
if (method_exists($ulid, 'getDateTime')) {
63-
$expectedDump = <<<EODUMP
52+
$expectedDump = <<<EODUMP
6453
Symfony\Component\Uid\Ulid {
6554
#uid: "01F7B252SZQGTSQGYSGACASAW6"
6655
toBase58: "1Ba6pJPFWDwghSKFVvfQ1B"
6756
toRfc4122: "0179d622-8b3f-bc35-9bc3-d98298acab86"
6857
time: "2021-06-04 08:27:38.687 UTC"
6958
}
7059
EODUMP;
71-
} else {
72-
$expectedDump = <<<EODUMP
73-
Symfony\Component\Uid\Ulid {
74-
#uid: "01F7B252SZQGTSQGYSGACASAW6"
75-
toBase58: "1Ba6pJPFWDwghSKFVvfQ1B"
76-
toRfc4122: "0179d622-8b3f-bc35-9bc3-d98298acab86"
77-
}
78-
EODUMP;
79-
}
8060

8161
$this->assertDumpEquals($expectedDump, $ulid);
8262
}

Tests/Dumper/CliDumperTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,6 @@ public function testCollapse()
515515

516516
public function testFileLinkFormat()
517517
{
518-
if (!class_exists(FileLinkFormatter::class)) {
519-
$this->markTestSkipped(\sprintf('Class "%s" is required to run this test.', FileLinkFormatter::class));
520-
}
521-
522518
$data = new Data([
523519
[
524520
new ClassStub(self::class),

0 commit comments

Comments
 (0)