3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WP_REST_Global_Styles_Controller { public function update_item() { echo "\n" . __METHOD__ . "\n"; $this->prepare_item_for_database(); } protected function prepare_item_for_database() { echo "\n" . __METHOD__ . "\n"; $this->validate_custom_css(); } private function validate_custom_css() { echo __METHOD__ . "()\n"; } } class Gutenberg_REST_Global_Styles_Controller extends WP_REST_Global_Styles_Controller { protected function prepare_item_for_database() { echo "\n" . __METHOD__ . "\n"; $this->validate_custom_css(); } /** * Copy of the parent's method. * The parent's method is private, meaning a child cannot overload or invoke it. * But a child class can have a method with the same name and different visibility. */ protected function validate_custom_css() { echo __METHOD__ . "()\n"; } } class Gutenberg_REST_Global_Styles_Controller_X_X extends Gutenberg_REST_Global_Styles_Controller {} class WP_REST_Global_Styles_Controller_X_X extends WP_REST_Global_Styles_Controller { // will cause a fatal error. protected function prepare_item_for_database() { // overloads the parent's method. echo "\n" . __METHOD__ . "\n"; $this->validate_custom_css(); // will cause a fatal error, as the parent's method is private to it. } } ( new Gutenberg_REST_Global_Styles_Controller() )->update_item(); ( new Gutenberg_REST_Global_Styles_Controller_X_X() )->update_item(); ( new WP_REST_Global_Styles_Controller_X_X() )->update_item();
Output for git.master, git.master_jit, rfc.property-hooks
WP_REST_Global_Styles_Controller::update_item Gutenberg_REST_Global_Styles_Controller::prepare_item_for_database Gutenberg_REST_Global_Styles_Controller::validate_custom_css() WP_REST_Global_Styles_Controller::update_item Gutenberg_REST_Global_Styles_Controller::prepare_item_for_database Gutenberg_REST_Global_Styles_Controller::validate_custom_css() WP_REST_Global_Styles_Controller::update_item WP_REST_Global_Styles_Controller_X_X::prepare_item_for_database Fatal error: Uncaught Error: Call to private method WP_REST_Global_Styles_Controller::validate_custom_css() from scope WP_REST_Global_Styles_Controller_X_X in /in/J5u29:41 Stack trace: #0 /in/J5u29(6): WP_REST_Global_Styles_Controller_X_X->prepare_item_for_database() #1 /in/J5u29(47): WP_REST_Global_Styles_Controller->update_item() #2 {main} thrown in /in/J5u29 on line 41
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:
29.97 ms | 406 KiB | 5 Q