I've just upgraded from PHP 7.4 & Xdebug 3.0 to PHP 8.1 & Xdebug 3.2. I never had this issue with earlier versions.
This is my php.ini:
[Xdebug]
zend_extension=php_xdebug-3.2.0RC2-8.1-vs16-x86_64.dll
xdebug.mode=debug
xdebug.start_with_request=trigger
And for some reason, even if I don't send a XDEBUG_SESSION=VSCODE
cookie, the warnings still appear.
Disabling Xdebug disables the errors.
I want to keep Xdebug enabled but I don't want to see pointless warnings about unused variables.
EDIT - Sorry. Kept seeing 'unused' instead of 'undefined'... My bad!
These warnings are not caused by Xdebug's step debugger, but rather through your PHP's own error handler (and configured level). Xdebug only shows these when plain PHP would also have done so.
You should also fix these warnings in your code, as they indicate that you're having some sort of logic flaw, or a potential one.