3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ProductBase {} class Product extends ProductBase {} class ProductBlank extends ProductBase {} abstract class QuantityLineProductBase { /** * Contract: will always return some kind of ProductBase */ abstract public function getProduct(): ProductBase; } class QuantityLineProductProduct extends QuantityLineProductBase { private Product $product; /** * Constructor doesn't need to obey substitution principles */ public function __construct(Product $product) { $this->product = $product; } /** * Covariance of output; no violation */ public function getProduct(): Product { return $this->product; } } class QuantityLineProductBlank extends QuantityLineProductBase { private ProductBlank $product; /** * Constructor accepting a different type; no violation */ public function __construct(ProductBlank $product) { $this->product = $product; } /** * Covariance of output; no violation */ public function getProduct(): ProductBlank { return $this->product; } }
Output for git.master, git.master_jit, rfc.property-hooks

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:
125.92 ms | 405 KiB | 5 Q