Search code examples
phpstaticphpstan

Class object was not found while trying to analyse it - discovering symbols is probably not configured properly


I'm using PHP Stan on lvl 0 to analyse my code. I could fix everything except those 2 errors. I checked everything but the files are fine, also checked every use and the file itself. In the same folder there are like 100 more files with the same namespace and structure. Do you have any idea what else I can test or is this a bug?

Error: Class object was not found while trying to analyse it - discovering symbols is probably not configured properly.

Error: Class object was not found while trying to analyse it - discovering symbols is probably not configured properly.


Line tool/tool/classes/Results.class.php


     Class object was not found while trying to analyse it - discovering  
     symbols is probably not configured properly.                         
     💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
     ✏️  tool/tool/classes/Results.class.php                              


Line tool/tool/classes/TrainingManager.class.php


     Class object was not found while trying to analyse it - discovering  
     symbols is probably not configured properly.                         
     💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
     ✏️  tool/tool/classes/TrainingManager.class.php                      


Solution

  • This is a weird error, especially because object is a PHP reserved keyword and there can be no class with that name. PHPStan understands that.

    How does the code look like that reports this error?

    I suspect you might have something like \object instead of object in your PHPDoc.

    Also maybe some custom rules might be the reason why this error is reported.