3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait WithFinalPrivate { public function test() { $this->privateNonOverloadable(); $this->nonFinal(); self::privateNonOverloadable(); self::nonFinal(); } final private function privateNonOverloadable() { echo __TRAIT__, '::', __FUNCTION__, PHP_EOL; } private function nonFinal() { echo __TRAIT__, '::', __FUNCTION__, PHP_EOL; } } class Child { use WithFinalPrivate; public function childTest() { $this->privateNonOverloadable(); $this->nonFinal(); self::privateNonOverloadable(); self::nonFinal(); } private function privateNonOverloadable() { echo __CLASS__, '::', __FUNCTION__, PHP_EOL; } private function nonFinal() { echo __CLASS__, '::', __FUNCTION__, PHP_EOL; } } $obj = new Child; $obj->childTest(); $obj->test();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.1, 8.3.3 - 8.3.15, 8.4.1 - 8.4.2
Warning: Private methods cannot be final as they are never overridden by other classes in /in/VOPVj on line 11 Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal
Output for 8.3.2
Warning: Private methods cannot be final as they are never overridden by other classes in /in/VOPVj on line 11 Warning: Private methods cannot be final as they are never overridden by other classes in /in/VOPVj on line 19 Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal Child::privateNonOverloadable Child::nonFinal

preferences:
93.65 ms | 409 KiB | 5 Q