<?php
$c = new \ReflectionClass(\DateTimeImmutable::class);
$methods = array_map(function ($m) {
return $m->getName()
. '(' . implode(',', array_map(function ($p) {
return $p->getType()
. ' $' . $p->getName()
. ($p->isOptional() ? ' = ' . var_export($p->getDefaultValue(), true) : '');
}, $m->getParameters())) . ')' . ($m->getReturnType() ? (': ' . $m->getReturnType()) : '');
}, $c->getMethods());
$properties = array_map(function ($m) {
return $m->getName();
}, $c->getProperties());
var_dump($methods, $properties);
- Output for 8.4.1
- array(25) {
[0]=>
string(68) "__construct(string $datetime = 'now',?DateTimeZone $timezone = NULL)"
[1]=>
string(20) "__serialize(): array"
[2]=>
string(32) "__unserialize(array $data): void"
[3]=>
string(10) "__wakeup()"
[4]=>
string(25) "__set_state(array $array)"
[5]=>
string(80) "createFromFormat(string $format,string $datetime,?DateTimeZone $timezone = NULL)"
[6]=>
string(41) "createFromTimestamp(int|float $timestamp)"
[7]=>
string(15) "getLastErrors()"
[8]=>
string(22) "format(string $format)"
[9]=>
string(13) "getTimezone()"
[10]=>
string(11) "getOffset()"
[11]=>
string(14) "getTimestamp()"
[12]=>
string(21) "getMicrosecond(): int"
[13]=>
string(60) "diff(DateTimeInterface $targetObject,bool $absolute = false)"
[14]=>
string(24) "modify(string $modifier)"
[15]=>
string(27) "add(DateInterval $interval)"
[16]=>
string(27) "sub(DateInterval $interval)"
[17]=>
string(35) "setTimezone(DateTimeZone $timezone)"
[18]=>
string(67) "setTime(int $hour,int $minute,int $second = 0,int $microsecond = 0)"
[19]=>
string(38) "setDate(int $year,int $month,int $day)"
[20]=>
string(50) "setISODate(int $year,int $week,int $dayOfWeek = 1)"
[21]=>
string(28) "setTimestamp(int $timestamp)"
[22]=>
string(40) "setMicrosecond(int $microsecond): static"
[23]=>
string(35) "createFromMutable(DateTime $object)"
[24]=>
string(65) "createFromInterface(DateTimeInterface $object): DateTimeImmutable"
}
array(0) {
}
- Output for 8.2.0 - 8.2.26, 8.3.0 - 8.3.14
- array(22) {
[0]=>
string(68) "__construct(string $datetime = 'now',?DateTimeZone $timezone = NULL)"
[1]=>
string(20) "__serialize(): array"
[2]=>
string(32) "__unserialize(array $data): void"
[3]=>
string(10) "__wakeup()"
[4]=>
string(25) "__set_state(array $array)"
[5]=>
string(80) "createFromFormat(string $format,string $datetime,?DateTimeZone $timezone = NULL)"
[6]=>
string(15) "getLastErrors()"
[7]=>
string(22) "format(string $format)"
[8]=>
string(13) "getTimezone()"
[9]=>
string(11) "getOffset()"
[10]=>
string(14) "getTimestamp()"
[11]=>
string(60) "diff(DateTimeInterface $targetObject,bool $absolute = false)"
[12]=>
string(24) "modify(string $modifier)"
[13]=>
string(27) "add(DateInterval $interval)"
[14]=>
string(27) "sub(DateInterval $interval)"
[15]=>
string(35) "setTimezone(DateTimeZone $timezone)"
[16]=>
string(67) "setTime(int $hour,int $minute,int $second = 0,int $microsecond = 0)"
[17]=>
string(38) "setDate(int $year,int $month,int $day)"
[18]=>
string(50) "setISODate(int $year,int $week,int $dayOfWeek = 1)"
[19]=>
string(28) "setTimestamp(int $timestamp)"
[20]=>
string(35) "createFromMutable(DateTime $object)"
[21]=>
string(65) "createFromInterface(DateTimeInterface $object): DateTimeImmutable"
}
array(0) {
}
- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.31
- array(20) {
[0]=>
string(68) "__construct(string $datetime = 'now',?DateTimeZone $timezone = NULL)"
[1]=>
string(10) "__wakeup()"
[2]=>
string(25) "__set_state(array $array)"
[3]=>
string(80) "createFromFormat(string $format,string $datetime,?DateTimeZone $timezone = NULL)"
[4]=>
string(15) "getLastErrors()"
[5]=>
string(22) "format(string $format)"
[6]=>
string(13) "getTimezone()"
[7]=>
string(11) "getOffset()"
[8]=>
string(14) "getTimestamp()"
[9]=>
string(60) "diff(DateTimeInterface $targetObject,bool $absolute = false)"
[10]=>
string(24) "modify(string $modifier)"
[11]=>
string(27) "add(DateInterval $interval)"
[12]=>
string(27) "sub(DateInterval $interval)"
[13]=>
string(35) "setTimezone(DateTimeZone $timezone)"
[14]=>
string(67) "setTime(int $hour,int $minute,int $second = 0,int $microsecond = 0)"
[15]=>
string(38) "setDate(int $year,int $month,int $day)"
[16]=>
string(50) "setISODate(int $year,int $week,int $dayOfWeek = 1)"
[17]=>
string(28) "setTimestamp(int $timestamp)"
[18]=>
string(35) "createFromMutable(DateTime $object)"
[19]=>
string(65) "createFromInterface(DateTimeInterface $object): DateTimeImmutable"
}
array(0) {
}
- Output for 7.4.0 - 7.4.33
- Fatal error: Uncaught ReflectionException: Cannot determine default value for internal functions in /in/3TGg8:10
Stack trace:
#0 /in/3TGg8(10): ReflectionParameter->getDefaultValue()
#1 [internal function]: {closure}(Object(ReflectionParameter))
#2 /in/3TGg8(11): array_map(Object(Closure), Array)
#3 [internal function]: {closure}(Object(ReflectionMethod))
#4 /in/3TGg8(12): array_map(Object(Closure), Array)
#5 {main}
thrown in /in/3TGg8 on line 10
Process exited with code 255.
preferences:
71.84 ms | 414 KiB | 5 Q