Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class not found errors #12

Closed
staabm opened this issue Aug 3, 2023 · 1 comment
Closed

Class not found errors #12

staabm opened this issue Aug 3, 2023 · 1 comment

Comments

@staabm
Copy link
Contributor

staabm commented Aug 3, 2023

the tools analyzes source code by calling is_a on found class names.

since is_a is a runtime-concept it kicks in autoloading and currently there is no way to define a autoloader.

this means when code is found which declares classes which cannot be found the analysis results in something like

$ vendor/bin/class-leak check application/ library/
    0/2296 [>---------------------------]   0%
 2296/2296 [============================] 100%PHP Fatal error:  Uncaught Error: Class "ApplicationController" not found in C:\dvl\Workspace\daiber\library\clxProductNet\application\Rocket\Controllers\AccountController.php:11
Stack trace:
#0 C:\dvl\Workspace\daiber\vendor\composer\ClassLoader.php(576): include()
Stack trace:
#0 C:\dvl\Workspace\daiber\vendor\composer\ClassLoader.php(576): include()
#1 C:\dvl\Workspace\daiber\vendor\composer\ClassLoader.php(427): Composer\Autoload\{closure}()
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#3 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\app\Filtering\PossiblyUnusedClassesFilter.php(71): is_a()
#4 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\app\Filtering\PossiblyUnusedClassesFilter.php(60): TomasVotruba\ClassLeak\Filtering\PossiblyUnusedClassesFilter->isClassSkipped()
#5 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\app\Console\Commands\CheckCommand.php(80): TomasVotruba\ClassLeak\Filtering\PossiblyUnusedClassesFilter->filter()
#6 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\vendor\symfony\console\Command\Command.php(325): TomasVotruba\ClassLeak\Console\Commands\CheckCommand->execute()
#7 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\vendor\symfony\console\Application.php(944): ClassLeak202307\Symfony\Component\Console\Command\Command->run()
#8 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\vendor\symfony\console\Application.php(326): ClassLeak202307\Symfony\Component\Console\Application->doRunCommand()
#9 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\vendor\symfony\console\Application.php(212): ClassLeak202307\Symfony\Component\Console\Application->doRun()
#10 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\bin\class-leak.php(25): ClassLeak202307\Symfony\Component\Console\Application->run()
#11 C:\dvl\Workspace\daiber\vendor\tomasvotruba\class-leak\bin\class-leak(5): require('...')
#12 C:\dvl\Workspace\daiber\vendor\bin\class-leak(119): include('...')
#13 {main}
  thrown in C:\dvl\Workspace\daiber\library\clxProductNet\application\Rocket\Controllers\AccountController.php on line 11

@TomasVotruba
Copy link
Owner

The autoload is the requirement here to keep concept simple and fast. Also this makes sure composer can be relied on 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants