3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Manager { #[\NoDiscard] public function save(): int { return random_int(1, 8); } } $manager = new Manager(); // This should not be reported, see: // // https://www.php.net/manual/en/class.nodiscard.php (void) $manager->save(); // This is correctly reported if uncommented $manager->save(); echo $manager->save();
Output for 8.5.3
Warning: The return value of method Manager::save() should either be used or intentionally ignored by casting it as (void) in /in/trE2a on line 18 4

preferences:
43.46 ms | 481 KiB | 4 Q