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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.1, 8.3.3 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
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.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
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:
141.92 ms | 411 KiB | 5 Q