Skip to content

Commit fd79318

Browse files
WebMambafabpot
authored andcommitted
Ban DateTime from the codebase
1 parent b0638da commit fd79318

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Tests/Compiler/CheckTypeDeclarationsPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,12 @@ public function testProcessFactoryCallbackSuccessOnValidType()
497497
{
498498
$container = new ContainerBuilder();
499499

500-
$container->register('bar', \DateTime::class)
501-
->setFactory('date_create');
500+
$container->register('bar', \DateTimeImmutable::class)
501+
->setFactory('date_create_immutable');
502502

503503
(new CheckTypeDeclarationsPass(true))->process($container);
504504

505-
$this->assertInstanceOf(\DateTime::class, $container->get('bar'));
505+
$this->assertInstanceOf(\DateTimeImmutable::class, $container->get('bar'));
506506
}
507507

508508
public function testProcessDoesNotLoadCodeByDefault()

Tests/Compiler/ResolveClassPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function provideInvalidClassId()
5656
{
5757
yield [\stdClass::class];
5858
yield ['bar'];
59-
yield [\DateTime::class];
59+
yield [\DateTimeImmutable::class];
6060
}
6161

6262
public function testNonFqcnChildDefinition()

Tests/ContainerBuilderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,20 +1296,20 @@ public function testClassFromId()
12961296
public function testNoClassFromGlobalNamespaceClassId()
12971297
{
12981298
$this->expectException(RuntimeException::class);
1299-
$this->expectExceptionMessage('The definition for "DateTime" has no class attribute, and appears to reference a class or interface in the global namespace.');
1299+
$this->expectExceptionMessage('The definition for "DateTimeImmutable" has no class attribute, and appears to reference a class or interface in the global namespace.');
13001300
$container = new ContainerBuilder();
13011301

1302-
$container->register(\DateTime::class);
1302+
$container->register(\DateTimeImmutable::class);
13031303
$container->compile();
13041304
}
13051305

13061306
public function testNoClassFromGlobalNamespaceClassIdWithLeadingSlash()
13071307
{
13081308
$this->expectException(RuntimeException::class);
1309-
$this->expectExceptionMessage('The definition for "\DateTime" has no class attribute, and appears to reference a class or interface in the global namespace.');
1309+
$this->expectExceptionMessage('The definition for "\DateTimeImmutable" has no class attribute, and appears to reference a class or interface in the global namespace.');
13101310
$container = new ContainerBuilder();
13111311

1312-
$container->register('\\'.\DateTime::class);
1312+
$container->register('\\'.\DateTimeImmutable::class);
13131313
$container->compile();
13141314
}
13151315

0 commit comments

Comments
 (0)