3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WP_Widget { public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {} } class WP_Widget_Text extends WP_Widget { public function __construct() { $widget_ops = array( 'classname' => 'widget_text', 'description' => 'Arbitrary text.', 'customize_selective_refresh' => true, 'show_instance_in_rest' => true, ); $control_ops = array( 'width' => 400, 'height' => 350, ); parent::__construct( 'text', 'Text', $widget_ops, $control_ops ); } } class Text_Widget extends WP_Widget { // Notice it does not have a constructor, which is doing it wrong. } class WP_Widget_Factory { public $widgets = array(); public function register( $widget ) { if ( $widget instanceof WP_Widget ) { $this->widgets[ spl_object_hash( $widget ) ] = $widget; } else { $this->widgets[ $widget ] = new $widget(); } } } $factory = new WP_Widget_Factory(); $factory->register( 'Text_Widget' );
Output for git.master_jit, git.master, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct(), 0 passed in /in/uPrIn on line 34 and at least 2 expected in /in/uPrIn:4 Stack trace: #0 /in/uPrIn(34): WP_Widget->__construct() #1 /in/uPrIn(40): WP_Widget_Factory->register('Text_Widget') #2 {main} thrown in /in/uPrIn on line 4
Process exited with code 255.

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