3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); abstract class SomeAbstractClass { private bool $someValue = true; /** * @phpstan-assert-if-true static $other */ public function equals(?self $other): bool { return $other instanceof static && $this->someValue === $other->someValue; } } class SomeConcreteClass extends SomeAbstractClass { public function __construct( private bool $someOtherValue, ) {} public function equals(?SomeAbstractClass $other): bool { return parent::equals($other) && $this->someOtherValue === $other->someOtherValue; } } $a = new SomeConcreteClass(true); $b = new SomeConcreteClass(false); var_dump($a->equals($b), $b->equals($b));
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
bool(false) bool(true)

preferences:
60.01 ms | 972 KiB | 4 Q