3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Contains { /** * @var string */ private $comparedValue; /** * Creates the expression. * * @param string $comparedValue The compared value. */ public function __construct($comparedValue) { $this->comparedValue = $comparedValue; } /** * Returns the accepted suffix. * * @return string The accepted suffix. */ public function getComparedValue() { return $this->comparedValue; } public function equivalentTo(Expression $other) { // Since this class is final, we can check with instanceof return $other instanceof $this && $this->comparedValue == $other->comparedValue; } } $a = new Contains('foobar'); $b = new Contains(0); var_dump($a->equivalentTo($b));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: Contains::equivalentTo(): Argument #1 ($other) must be of type Expression, Contains given, called in /in/GeKPX on line 39 and defined in /in/GeKPX:28 Stack trace: #0 /in/GeKPX(39): Contains->equivalentTo(Object(Contains)) #1 {main} thrown in /in/GeKPX on line 28
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to Contains::equivalentTo() must be an instance of Expression, instance of Contains given, called in /in/GeKPX on line 39 and defined in /in/GeKPX:28 Stack trace: #0 /in/GeKPX(39): Contains->equivalentTo(Object(Contains)) #1 {main} thrown in /in/GeKPX on line 28
Process exited with code 255.
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Catchable fatal error: Argument 1 passed to Contains::equivalentTo() must be an instance of Expression, instance of Contains given, called in /in/GeKPX on line 39 and defined in /in/GeKPX on line 28
Process exited with code 255.

preferences:
218.99 ms | 402 KiB | 227 Q