How to fix interceptors generation on `bin/magento setup:di:compile` in Magento ≥ 2.2 in Windows?

The problem method is Magento\Setup\Module\Di\Code\Reader\ClassesScanner::getList().

How to fix:

Replace the line:

with the following one:

$realPath = str_replace(DIRECTORY_SEPARATOR, '/', realpath($path));

See also: windows-filesystem tagged topics.

The issue still exists in Magento 2.4.7-beta1:

My fix still works correctly.

How do I install Magento 2.4 to Windows?