This RFC from Tim Düsterhus adds a #[\NonExhaustive] attribute for enums. It marks an enum that might gain new cases in a later version, which tells anyone writing code against that enum to plan for cases they haven't seen yet.
How it works
The attribute can only go on an enum, and it doesn't change what PHP executes. It's a signal: a match() on a marked enum should include a default arm, so that a newly added case doesn't break your code.
Here is the RFC's example:
enum FileError { case NotFound; case PermissionDenied; } function getHumanMessage(FileError $error): string { return match ($error) { FileError::NotFound => "The file could not be found", FileError::PermissionDenied => "Insufficient permissions to access the file", // Handle new error cases, e.g. "IsDirectory". default => "Failed to interact with the file", }; }
If PHP later adds a case like IsDirectory, the default arm catches it instead of the match throwing an error.
The RFC says PHP's bundled extensions should add the attribute to their enums where it fits. It also leaves room for allowing the attribute on other kinds of declarations in future versions.
What it means for existing code
The page hasn't filled in its backward compatibility section yet. The proposal only adds a new attribute class named NonExhaustive in the global namespace.
Where it stands
It's a draft targeting PHP 8.6. Much of the page is still the empty RFC template, and no patch is linked yet. The vote on the page is a placeholder with no votes cast.