@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Imanghafoori\LaravelMicroscope\Refactors; |
4 | 4 | |
5 | -use Imanghafoori\LaravelMicroscope\Analyzers\Refactor; |
|
6 | 5 | use Imanghafoori\LaravelMicroscope\Analyzers\FunctionCall; |
6 | +use Imanghafoori\LaravelMicroscope\Analyzers\Refactor; |
|
7 | 7 | |
8 | 8 | class EarlyReturns |
9 | 9 | { |
@@ -71,6 +71,9 @@ |
||
71 | 71 | return [$tokens, $changes]; |
72 | 72 | } |
73 | 73 | |
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
74 | 77 | private static function getKeyword($token) |
75 | 78 | { |
76 | 79 | return self::scopeKeywords[$token]; |
@@ -20,6 +20,10 @@ |
||
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
23 | + /** |
|
24 | + * @param integer $elseCount |
|
25 | + * @param integer $ifBody |
|
26 | + */ |
|
23 | 27 | private static function shouldBeFlipped($elseCount, $ifBody) |
24 | 28 | { |
25 | 29 | $ifIsLonger = ($elseCount + 10) < $ifBody; |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Imanghafoori\LaravelMicroscope\Refactors; |
4 | 4 | |
5 | -use Imanghafoori\LaravelMicroscope\Analyzers\Ifs; |
|
6 | 5 | use Imanghafoori\LaravelMicroscope\Analyzers\FunctionCall; |
6 | +use Imanghafoori\LaravelMicroscope\Analyzers\Ifs; |
|
7 | 7 | |
8 | 8 | class SyntaxNormalizer |
9 | 9 | { |
@@ -58,6 +58,9 @@ |
||
58 | 58 | return $stringOutput; |
59 | 59 | } |
60 | 60 | |
61 | + /** |
|
62 | + * @param \Closure $refactor |
|
63 | + */ |
|
61 | 64 | private static function recursiveRefactor($tokens, $refactor) |
62 | 65 | { |
63 | 66 | $i = $changes = 0; |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Imanghafoori\LaravelMicroscope\Checks; |
4 | 4 | |
5 | -use Illuminate\Support\Str; |
|
6 | 5 | use Illuminate\Support\Facades\View; |
6 | +use Illuminate\Support\Str; |
|
7 | 7 | use Imanghafoori\LaravelMicroscope\Analyzers\FunctionCall; |
8 | 8 | |
9 | 9 | class ExtractBladePartial |
@@ -72,6 +72,9 @@ discard block |
||
72 | 72 | return $tokens; |
73 | 73 | } |
74 | 74 | |
75 | + /** |
|
76 | + * @param string $name |
|
77 | + */ |
|
75 | 78 | public static function find($name) |
76 | 79 | { |
77 | 80 | if (self::hasHintInformation($name = \trim($name))) { |
@@ -88,6 +91,9 @@ discard block |
||
88 | 91 | }, ['blade.php']); |
89 | 92 | } |
90 | 93 | |
94 | + /** |
|
95 | + * @param string $name |
|
96 | + */ |
|
91 | 97 | protected static function findNamespacedView($name) |
92 | 98 | { |
93 | 99 | [$namespace, $view] = self::parseNamespaceSegments($name); |
@@ -122,11 +128,17 @@ discard block |
||
122 | 128 | } |
123 | 129 | } |
124 | 130 | |
131 | + /** |
|
132 | + * @param string $name |
|
133 | + */ |
|
125 | 134 | public static function hasHintInformation($name) |
126 | 135 | { |
127 | 136 | return strpos($name, '::') > 0; |
128 | 137 | } |
129 | 138 | |
139 | + /** |
|
140 | + * @param string $message |
|
141 | + */ |
|
130 | 142 | public static function forceFilePutContents($filepath, $message){ |
131 | 143 | try { |
132 | 144 | $isInFolder = preg_match("/^(.*)\/([^\/]+)$/", $filepath, $filepathMatches); |
@@ -60,6 +60,9 @@ |
||
60 | 60 | return 'Error on route '.$msg; |
61 | 61 | } |
62 | 62 | |
63 | + /** |
|
64 | + * @param ErrorPrinter $errorPrinter |
|
65 | + */ |
|
63 | 66 | private function checkRouteDefinitions($errorPrinter, $routes) |
64 | 67 | { |
65 | 68 | foreach ($routes as $route) { |
@@ -3,15 +3,15 @@ |
||
3 | 3 | namespace Imanghafoori\LaravelMicroscope\Commands; |
4 | 4 | |
5 | 5 | use Exception; |
6 | -use Illuminate\Support\Str; |
|
7 | -use Illuminate\Routing\Router; |
|
8 | 6 | use Illuminate\Console\Command; |
9 | -use Imanghafoori\LaravelMicroscope\Psr4Classes; |
|
7 | +use Illuminate\Routing\Router; |
|
8 | +use Illuminate\Support\Str; |
|
10 | 9 | use Imanghafoori\LaravelMicroscope\BladeFiles; |
11 | -use Imanghafoori\LaravelMicroscope\Traits\LogsErrors; |
|
12 | -use Imanghafoori\LaravelMicroscope\Checks\CheckRouteCalls; |
|
13 | 10 | use Imanghafoori\LaravelMicroscope\Checks\ActionsComments; |
11 | +use Imanghafoori\LaravelMicroscope\Checks\CheckRouteCalls; |
|
14 | 12 | use Imanghafoori\LaravelMicroscope\ErrorReporters\ErrorPrinter; |
13 | +use Imanghafoori\LaravelMicroscope\Psr4Classes; |
|
14 | +use Imanghafoori\LaravelMicroscope\Traits\LogsErrors; |
|
15 | 15 | |
16 | 16 | class CheckRoutes extends Command |
17 | 17 | { |
@@ -3,8 +3,8 @@ |
||
3 | 3 | namespace Imanghafoori\LaravelMicroscope\Commands; |
4 | 4 | |
5 | 5 | use Exception; |
6 | -use Illuminate\Support\Str; |
|
7 | 6 | use Illuminate\Console\Command; |
7 | +use Illuminate\Support\Str; |
|
8 | 8 | |
9 | 9 | class PrettyPrintRoutes extends Command |
10 | 10 | { |
@@ -35,6 +35,9 @@ discard block |
||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | + /** |
|
39 | + * @param \Illuminate\Routing\Route $route |
|
40 | + */ |
|
38 | 41 | private function writeIt($route, $filename) |
39 | 42 | { |
40 | 43 | try { |
@@ -57,6 +60,9 @@ discard block |
||
57 | 60 | } |
58 | 61 | } |
59 | 62 | |
63 | + /** |
|
64 | + * @param string $value |
|
65 | + */ |
|
60 | 66 | private function deduceRoute($value) |
61 | 67 | { |
62 | 68 | if (Str::containsAll($value, ['@', '\\'])) { |
@@ -68,6 +74,9 @@ discard block |
||
68 | 74 | return $route; |
69 | 75 | } |
70 | 76 | |
77 | + /** |
|
78 | + * @param \Illuminate\Routing\Route $route |
|
79 | + */ |
|
71 | 80 | private function printIt($route) |
72 | 81 | { |
73 | 82 | try { |
@@ -80,6 +89,10 @@ discard block |
||
80 | 89 | } |
81 | 90 | } |
82 | 91 | |
92 | + /** |
|
93 | + * @param string $action |
|
94 | + * @param string $middlewareSection |
|
95 | + */ |
|
83 | 96 | private function getMovableRoute($route, $methods, $action, $middlewareSection) |
84 | 97 | { |
85 | 98 | if ($action == '\Illuminate\Routing\ViewController::class') { |
@@ -117,6 +130,9 @@ discard block |
||
117 | 130 | return ($middlewares ? '->middleware(['.$middlewares."])" : ''); |
118 | 131 | } |
119 | 132 | |
133 | + /** |
|
134 | + * @param Exception $e |
|
135 | + */ |
|
120 | 136 | private function handleRouteProblem($e) |
121 | 137 | { |
122 | 138 | $this->info('The route has some problem.'); |
@@ -124,6 +140,9 @@ discard block |
||
124 | 140 | $this->info($e->getFile()); |
125 | 141 | } |
126 | 142 | |
143 | + /** |
|
144 | + * @param string $middlewares |
|
145 | + */ |
|
127 | 146 | private function prettyPrintInConsole($route, $middlewares) |
128 | 147 | { |
129 | 148 | $this->getOutput()->writeln('---------------------------------------------------'); |
@@ -3,13 +3,13 @@ |
||
3 | 3 | namespace Imanghafoori\LaravelMicroscope\Commands; |
4 | 4 | |
5 | 5 | use Illuminate\Console\Command; |
6 | -use Imanghafoori\LaravelMicroscope\Analyzers\Ifs; |
|
6 | +use Imanghafoori\LaravelMicroscope\Analyzers\ComposerJson; |
|
7 | 7 | use Imanghafoori\LaravelMicroscope\Analyzers\FilePath; |
8 | -use Imanghafoori\LaravelMicroscope\SpyClasses\RoutePaths; |
|
9 | 8 | use Imanghafoori\LaravelMicroscope\Analyzers\FunctionCall; |
10 | -use Imanghafoori\LaravelMicroscope\Analyzers\ComposerJson; |
|
9 | +use Imanghafoori\LaravelMicroscope\Analyzers\Ifs; |
|
11 | 10 | use Imanghafoori\LaravelMicroscope\ErrorReporters\ErrorPrinter; |
12 | 11 | use Imanghafoori\LaravelMicroscope\ErrorTypes\CompactCall; |
12 | +use Imanghafoori\LaravelMicroscope\SpyClasses\RoutePaths; |
|
13 | 13 | |
14 | 14 | class CheckCompact extends Command |
15 | 15 | { |
@@ -3,9 +3,9 @@ |
||
3 | 3 | namespace Imanghafoori\LaravelMicroscope\Commands; |
4 | 4 | |
5 | 5 | use Illuminate\Console\Command; |
6 | +use Imanghafoori\LaravelMicroscope\Analyzers\ComposerJson; |
|
6 | 7 | use Imanghafoori\LaravelMicroscope\Analyzers\FilePath; |
7 | 8 | use Imanghafoori\LaravelMicroscope\Analyzers\Refactor; |
8 | -use Imanghafoori\LaravelMicroscope\Analyzers\ComposerJson; |
|
9 | 9 | use Imanghafoori\LaravelMicroscope\ErrorReporters\ErrorPrinter; |
10 | 10 | |
11 | 11 | class CheckEarlyReturns extends Command |
@@ -56,6 +56,9 @@ discard block |
||
56 | 56 | return app(ErrorPrinter::class)->hasErrors() ? 1 : 0; |
57 | 57 | } |
58 | 58 | |
59 | + /** |
|
60 | + * @param integer $tries |
|
61 | + */ |
|
59 | 62 | private function fix($filePath, $tokens, $tries) |
60 | 63 | { |
61 | 64 | Refactor::saveTokens($filePath, $tokens, $this->option('test')); |
@@ -73,6 +76,9 @@ discard block |
||
73 | 76 | return [$fixes, $tokens]; |
74 | 77 | } |
75 | 78 | |
79 | + /** |
|
80 | + * @param integer $fixed |
|
81 | + */ |
|
76 | 82 | private function printFinalMsg($fixed) |
77 | 83 | { |
78 | 84 | if ($fixed > 0) { |