php bin/magento setup:di:compile Fatal Error

For a while now I have been trying to find a fix for my Magento admin panel, when I want to change some settings it dosent allow me to change anything, for example, "Use system value" boxes are locked and when I hover over them I get a red circle indicating I am unable to change the value.

I found this tutorial: https://community.magento.com/t5/Magento-2-x-Technical-Issues/Unlock-configuration/m-p/95209#M5084

But when I try to run setup:di:compile, I get this error:

"Application code generator... 3/9 [=========>------------------] 33% 5 secs 246.0 MiBPHP Fatal error: Uncaught TypeError: rtrim() expects parameter 1 to be string, bool given in /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php:95 Stack trace: #0 /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php(95): rtrim() #1 /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php(286): Magento\Setup\Module\Di\Code\Scanner\PhpScanner->getSourceClassName() #2 /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php(152): Magento\Setup\Module\Di\Code\Scanner\PhpScanner->shouldGenerateClass() #3 /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php(184): Magento\Setup\Module\Di\Code\Scanner\PhpScanner->_fetchMissingExtensionAttributesClasses() #4 /var/www/html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php(77): Magento\Setup\Module\Di\Code\Scanner\PhpScanner->collectEntities() #5 /var/www/html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): Magento\Setup\Module\Di\App\T in /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php on line 95

Fatal error: Uncaught TypeError: rtrim() expects parameter 1 to be string, bool given in /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php:95 Stack trace: #0 /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php(95): rtrim() #1 /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php(286): Magento\Setup\Module\Di\Code\Scanner\PhpScanner->getSourceClassName() #2 /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php(152): Magento\Setup\Module\Di\Code\Scanner\PhpScanner->shouldGenerateClass() #3 /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php(184): Magento\Setup\Module\Di\Code\Scanner\PhpScanner->_fetchMissingExtensionAttributesClasses() #4 /var/www/html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php(77): Magento\Setup\Module\Di\Code\Scanner\PhpScanner->collectEntities() #5 /var/www/html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): Magento\Setup\Module\Di\App\T in /var/www/html/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php on line 95"

I have tried composer install and update, but that didn't seem to help...

My php version is 7.4.20.

Any help appreciated!

Read Entire Article