var/www/magento# bin/magento setup:di:compile
Compilation was started.
Repositories code generation... 1/9 [===>------------------------] 11% 1 sec 127.0 MiB
In FileClassScanner.php line 185:
Namespace not defined properly
Cache types config flushed successfully
Cache cleared successfully
File system cleanup::
Deprecated Functionality: version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated in /var/www/magento/setup/src/Magento/Setup/Model/Installer.php on line 1054
Magento 2.4.5-p1 using PHP 8.1 and the version_compare() function is made more strict with the operator parameter. you need to integrate it with PHP 8.1. ref: https://php.watch/versions/8.1/version_compare-operator-restrictions
I got solution , my setup folder and lib folder on root were not up to date.
Hence i was getting error.
I updated it with latest code and it resolved issue.