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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.1, 8.3.3 - 8.3.14
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:
64.87 ms | 410 KiB | 5 Q