-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--TEST-- | ||
Bug GH-8471: Segmentation fault when converting immutable and mutable DateTime instances created using reflection | ||
--FILE-- | ||
<?php | ||
$reflection = new ReflectionClass('\DateTime'); | ||
|
||
$mutable = $reflection->newInstanceWithoutConstructor(); | ||
try { | ||
$immutable = \DateTimeImmutable::createFromMutable($mutable); | ||
} catch (Throwable $t) { | ||
echo $t->getMessage(), "\n"; | ||
} | ||
|
||
|
||
$reflection = new ReflectionClass('\DateTime'); | ||
|
||
$mutable = $reflection->newInstanceWithoutConstructor(); | ||
try { | ||
$immutable = \DateTimeImmutable::createFromInterface($mutable); | ||
} catch (Throwable $t) { | ||
echo $t->getMessage(), "\n"; | ||
} | ||
|
||
|
||
$reflection = new ReflectionClass('\DateTimeImmutable'); | ||
|
||
$immutable = $reflection->newInstanceWithoutConstructor(); | ||
try { | ||
$mutable = \DateTime::createFromImmutable($immutable); | ||
} catch (Throwable $t) { | ||
echo $t->getMessage(), "\n"; | ||
} | ||
|
||
|
||
$reflection = new ReflectionClass('\DateTimeImmutable'); | ||
|
||
$immutable = $reflection->newInstanceWithoutConstructor(); | ||
try { | ||
$mutable = \DateTime::createFromInterface($immutable); | ||
} catch (Throwable $t) { | ||
echo $t->getMessage(), "\n"; | ||
} | ||
|
||
|
||
?> | ||
--EXPECTF-- | ||
The DateTime object has not been correctly initialized by its constructor | ||
The DateTimeInterface object has not been correctly initialized by its constructor | ||
The DateTimeImmutable object has not been correctly initialized by its constructor | ||
The DateTimeInterface object has not been correctly initialized by its constructor |