Skip to content

Commit

Permalink
Bug fix for view counts
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed Dec 7, 2022
1 parent 9d3f533 commit 9413c40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Checks/CheckViewFilesExistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions src/Commands/CheckViews.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/LaravelMicroscopeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
});
Expand Down

0 comments on commit 9413c40

Please sign in to comment.