Fix PSR-4 autoload classmap generator

`autoload_classmap.php` file does not contain PSR-4 classes when we use `--optimize` option.

Fix #2625 and replace #2655.