|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Imanghafoori\LaravelMicroscope; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\View; |
|
6
|
|
|
use Imanghafoori\LaravelMicroscope\SpyClasses\ViewsData; |
|
7
|
|
|
use Symfony\Component\Finder\Finder; |
|
8
|
|
|
|
|
9
|
|
|
class BladeFiles |
|
10
|
|
|
{ |
|
11
|
|
|
public static $checkedFilesNum = 0; |
|
12
|
|
|
|
|
13
|
|
|
public static function check($checkers) |
|
14
|
|
|
{ |
|
15
|
|
|
$compiler = app('microscope.blade.compiler'); |
|
16
|
|
|
method_exists($compiler, 'withoutComponentTags') && $compiler->withoutComponentTags(); |
|
17
|
|
|
|
|
18
|
|
|
$hints = self::getNamespacedPaths(); |
|
19
|
|
|
$hints['random_key_69471'] = View::getFinder()->getPaths(); |
|
20
|
|
|
|
|
21
|
|
|
foreach ($hints as $paths) { |
|
22
|
|
|
self::checkPaths($paths, $checkers); |
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
private static function getNamespacedPaths() |
|
27
|
|
|
{ |
|
28
|
|
|
$hints = View::getFinder()->getHints(); |
|
29
|
|
|
unset($hints['notifications'], $hints['pagination']); |
|
30
|
|
|
|
|
31
|
|
|
return $hints; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public static function checkPaths($paths, $checkers) |
|
35
|
|
|
{ |
|
36
|
|
|
foreach ($paths as $path) { |
|
37
|
|
|
if (! is_dir($path)) { |
|
38
|
|
|
continue; |
|
39
|
|
|
} |
|
40
|
|
|
$files = (new Finder())->name('*.blade.php')->files()->in($path); |
|
41
|
|
|
|
|
42
|
|
|
foreach ($files as $blade) { |
|
43
|
|
|
self::$checkedFilesNum++; |
|
44
|
|
|
/** |
|
45
|
|
|
* @var \Symfony\Component\Finder\SplFileInfo $blade |
|
46
|
|
|
*/ |
|
47
|
|
|
$tokens = ViewsData::getBladeTokens($blade->getPathname()); |
|
48
|
|
|
foreach ($checkers as $checkerClass) { |
|
49
|
|
|
call_user_func_array([$checkerClass, 'check'], [$tokens, $blade->getPathname()]); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|