From 9413c4089c9a68a7e9428de524113a001948836f Mon Sep 17 00:00:00 2001 From: Iman Ghafoori Date: Wed, 7 Dec 2022 21:05:58 +0330 Subject: [PATCH] Bug fix for view counts --- src/Checks/CheckViewFilesExistence.php | 2 +- src/Commands/CheckViews.php | 6 +----- src/LaravelMicroscopeServiceProvider.php | 4 +++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Checks/CheckViewFilesExistence.php b/src/Checks/CheckViewFilesExistence.php index 8b3a5a37..88652909 100644 --- a/src/Checks/CheckViewFilesExistence.php +++ b/src/Checks/CheckViewFilesExistence.php @@ -17,8 +17,8 @@ public static function check($tokens, $absPath) } $viewName = \trim($tokens[$i + 4][1], '\'\"'); + CheckView::$checkedCallsNum++; if (! View::exists($viewName)) { - CheckViews::$checkedCallsNum++; self::error($tokens, $absPath, $i); } $i = $i + 5; diff --git a/src/Commands/CheckViews.php b/src/Commands/CheckViews.php index c05ed271..f1500b15 100644 --- a/src/Commands/CheckViews.php +++ b/src/Commands/CheckViews.php @@ -12,10 +12,6 @@ class CheckViews extends Command { - public static $checkedCallsNum = 0; - - public static $skippedCallsNum = 0; - protected $signature = 'check:views {--detailed : Show files being checked} {--f|file=} {--d|folder=}'; protected $description = 'Checks the validity of blade files'; @@ -33,7 +29,7 @@ public function handle(ErrorPrinter $errorPrinter) ForPsr4LoadedClasses::check([CheckView::class], [], $fileName, $folder); $this->checkBladeFiles(); - $this->getOutput()->writeln(' - '.self::$checkedCallsNum.' view references were checked to exist. ('.self::$skippedCallsNum.' skipped)'); + $this->getOutput()->writeln(' - '.CheckView::$checkedCallsNum.' view references were checked to exist. ('.CheckView::$skippedCallsNum.' skipped)'); event('microscope.finished.checks', [$this]); return $errorPrinter->hasErrors() ? 1 : 0; diff --git a/src/LaravelMicroscopeServiceProvider.php b/src/LaravelMicroscopeServiceProvider.php index 37c47f20..d5498814 100644 --- a/src/LaravelMicroscopeServiceProvider.php +++ b/src/LaravelMicroscopeServiceProvider.php @@ -13,6 +13,7 @@ use Illuminate\Support\Str; use Illuminate\View\View; use Imanghafoori\LaravelMicroscope\Checks\CheckClassReferences; +use Imanghafoori\LaravelMicroscope\Checks\CheckView; use Imanghafoori\LaravelMicroscope\Commands\CheckViews; use Imanghafoori\LaravelMicroscope\ErrorReporters\ConsolePrinterInstaller; use Imanghafoori\LaravelMicroscope\ErrorReporters\ErrorPrinter; @@ -212,7 +213,8 @@ private function registerCompiler() private function resetCountersOnFinish() { Event::listen('microscope.finished.checks', function () { - CheckViews::$checkedCallsNum = 0; + CheckView::$checkedCallsNum = 0; + CheckView::$skippedCallsNum = 0; CheckClassReferences::$refCount = 0; ForPsr4LoadedClasses::$checkedFilesNum = 0; });