New in PHP 8.4: Deprecated Attribute
Scott Keck-Warren • January 19, 2025
One of the new features added to PHP 8.4 is a new attribute that will allow us to easily mark a function as deprecated in userland code. This will trigger a deprecation notice like when the built-in functions are deprecated so we can more easily find where our code has been deprecated (and others).
<?php
#[\Deprecated]
function test() {
}
// output:
// Deprecated: Function test() is deprecated in ...
test();
Want to Know More?
I did a whole article for php[achitect] on fun new features in PHP 8.4 where I got into more details. It's also available in a video version if you're so inclined.