3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); final class CreateStatementRequest { private ?DateTimeImmutable $startDate, $endDate; public function __construct( DateTimeImmutable $startDate = null, DateTimeImmutable $endDate = null ) { $this->startDate = $startDate; $this->endDate = $endDate; // error: Property CreateStatementRequest::$endDate (DateTimeImmutable) does not accept DateTimeImmutable|null. } public function hasFilterStartDate(): bool { return $this->startDate !== null; } public function getFilterStartDate(): DateTimeImmutable { if ($this->startDate === null) { throw new RuntimeException('The start date filter is not defined.'); } return $this->startDate; } public function hasFilterEndDate(): bool { return $this->endDate !== null; } public function getFilterEndDate(): DateTimeImmutable { if ($this->endDate === null) { // error: Strict comparison using === between DateTimeImmutable and null will always evaluate to false. throw new RuntimeException('The end date filter is not defined.'); } return $this->endDate; } } $ref = new \ReflectionClass(CreateStatementRequest::class); foreach ($ref->getProperties() as $refProperty) { var_dump($refProperty->getName()); $refType = $refProperty->getType(); var_dump($refType->getName()); var_dump($refType->allowsNull()); var_dump('---'); }
Output for git.master, git.master_jit, rfc.property-hooks
string(9) "startDate" string(17) "DateTimeImmutable" bool(true) string(3) "---" string(7) "endDate" string(17) "DateTimeImmutable" bool(true) string(3) "---"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
80.56 ms | 401 KiB | 8 Q