@@ -28,6 +28,10 @@ |
||
28 | 28 | $this->logger = $logger; |
29 | 29 | $this->useParser = $useParser; |
30 | 30 | } |
31 | + |
|
32 | + /** |
|
33 | + * @param string $badLine |
|
34 | + */ |
|
31 | 35 | public function getContext($badLine, Index $index, Scope $scope = null) |
32 | 36 | { |
33 | 37 | if (empty($scope)) { |
@@ -123,7 +123,7 @@ |
||
123 | 123 | if (strpos($badLine, '<?php') === false |
124 | 124 | || strpos($badLine, '<?') === false |
125 | 125 | ) { |
126 | - $badLine = '<?php ' . $badLine; |
|
126 | + $badLine = '<?php '.$badLine; |
|
127 | 127 | } |
128 | 128 | $badLine = str_replace(['elseif', 'else', 'catch'], '', $badLine); |
129 | 129 | if ($wrapFunctionCall && $badLine[strlen($badLine) - 1] === '(') { |
@@ -145,6 +145,7 @@ |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
148 | + * @param \PhpParser\Node $node |
|
148 | 149 | * @return Chain |
149 | 150 | */ |
150 | 151 | protected function createChain($node) |
@@ -92,7 +92,7 @@ |
||
92 | 92 | $chain = $this->createChain($node); |
93 | 93 | $block = $chain; |
94 | 94 | while ($block instanceof Chain) { |
95 | - $this->logger->debug('looking for type of ' . $block->getName()); |
|
95 | + $this->logger->debug('looking for type of '.$block->getName()); |
|
96 | 96 | $event = new TypeResolveEvent($block, $type); |
97 | 97 | $this->dispatcher->dispatch(self::BLOCK_START, $event); |
98 | 98 | if ($block->getType() === 'var') { |
@@ -93,6 +93,10 @@ |
||
93 | 93 | ); |
94 | 94 | $index->addParsedFile($file); |
95 | 95 | } |
96 | + |
|
97 | + /** |
|
98 | + * @return null|FileScope |
|
99 | + */ |
|
96 | 100 | public function createScopeForFile($file, Index $index, $createCache = true) |
97 | 101 | { |
98 | 102 | $startParser = microtime(1); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $end = microtime(1) - $start; |
67 | 67 | |
68 | 68 | $this->getLogger()->debug("Indexing: [$end]s"); |
69 | - $this->getLogger()->debug("Memory: " . memory_get_usage()); |
|
69 | + $this->getLogger()->debug("Memory: ".memory_get_usage()); |
|
70 | 70 | $globalTime += $end; |
71 | 71 | ++$done; |
72 | 72 | $process = floor($done / $all * 100); |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | $this->getLogger()->debug(sprintf("Processing %s interfaces", count($scope->getInterfaces()))); |
120 | 120 | $this->getLogger()->debug(sprintf("Processing %s functions", count($scope->getFunctions()))); |
121 | 121 | foreach ($scope->getClasses() as $classData) { |
122 | - $this->getLogger()->debug('Processing node ' . $classData->fqcn->toString()); |
|
122 | + $this->getLogger()->debug('Processing node '.$classData->fqcn->toString()); |
|
123 | 123 | $index->addFQCN($classData->fqcn); |
124 | 124 | $index->addClass($classData); |
125 | 125 | } |
126 | 126 | foreach ($scope->getInterfaces() as $interfaceData) { |
127 | - $this->getLogger()->debug('Processing node ' . $interfaceData->fqcn->toString()); |
|
127 | + $this->getLogger()->debug('Processing node '.$interfaceData->fqcn->toString()); |
|
128 | 128 | $index->addFQCN($interfaceData->fqcn); |
129 | 129 | $index->addInterface($interfaceData); |
130 | 130 | } |
131 | 131 | foreach ($scope->getFunctions() as $functionData) { |
132 | - $this->getLogger()->debug('Processing node ' . $functionData->name); |
|
132 | + $this->getLogger()->debug('Processing node '.$functionData->name); |
|
133 | 133 | $index->addFunction($functionData); |
134 | 134 | } |
135 | 135 | } |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Padawan\Framework\Generator; |
4 | 4 | |
5 | -use Padawan\Domain\Project\Node\ClassData; |
|
6 | -use Padawan\Domain\Project\Node\InterfaceData; |
|
7 | 5 | use Padawan\Domain\Event\IndexGenerationEvent; |
8 | 6 | use Padawan\Domain\Project\Index; |
9 | 7 | use Padawan\Domain\Project; |
@@ -88,6 +88,10 @@ |
||
88 | 88 | } |
89 | 89 | return $line >= $startLine; |
90 | 90 | } |
91 | + |
|
92 | + /** |
|
93 | + * @param Node $node |
|
94 | + */ |
|
91 | 95 | public function getNodeLines($node) |
92 | 96 | { |
93 | 97 | $startLine = $endLine = -1; |
@@ -12,7 +12,6 @@ |
||
12 | 12 | use Padawan\Domain\Project\Node\Variable; |
13 | 13 | use Padawan\Domain\Scope; |
14 | 14 | use Padawan\Domain\Scope\FileScope; |
15 | -use Padawan\Domain\Scope\FunctionScope; |
|
16 | 15 | use Padawan\Domain\Scope\MethodScope; |
17 | 16 | use Padawan\Domain\Scope\ClassScope; |
18 | 17 | use Padawan\Domain\Scope\ClosureScope; |
@@ -52,15 +52,13 @@ |
||
52 | 52 | foreach ($node->stmts AS $child) { |
53 | 53 | if ($child instanceof ClassMethod) { |
54 | 54 | $classData->addMethod($this->parseMethod($child)); |
55 | - } |
|
56 | - elseif ($child instanceof Property) { |
|
55 | + } elseif ($child instanceof Property) { |
|
57 | 56 | foreach ($child->props AS $prop) { |
58 | 57 | $classData->addProp( |
59 | 58 | $this->parseProperty($prop, $child->type, $child->getAttribute('comments')) |
60 | 59 | ); |
61 | 60 | } |
62 | - } |
|
63 | - elseif ($child instanceof ClassConst) { |
|
61 | + } elseif ($child instanceof ClassConst) { |
|
64 | 62 | foreach ($child->consts AS $const) { |
65 | 63 | $classData->addConst($const->name); |
66 | 64 | } |
@@ -8,8 +8,7 @@ |
||
8 | 8 | public function parse($content) { |
9 | 9 | try { |
10 | 10 | return parent::parse($content); |
11 | - } |
|
12 | - catch (\Exception $e) { |
|
11 | + } catch (\Exception $e) { |
|
13 | 12 | return $this->semValue; |
14 | 13 | } |
15 | 14 | } |
@@ -12,9 +12,9 @@ |
||
12 | 12 | } |
13 | 13 | public function parse(Param $node) { |
14 | 14 | $param = new MethodParam($node->name); |
15 | - if ($node->type instanceof Name) |
|
16 | - $param->setFQCN($this->useParser->getFQCN($node->type)); |
|
17 | - else { |
|
15 | + if ($node->type instanceof Name) { |
|
16 | + $param->setFQCN($this->useParser->getFQCN($node->type)); |
|
17 | + } else { |
|
18 | 18 | $param->setType($node->type); |
19 | 19 | } |
20 | 20 | return $param; |
@@ -55,8 +55,7 @@ |
||
55 | 55 | if (!$createCache || $oldHash !== $hash || empty($ast)) { |
56 | 56 | try { |
57 | 57 | $ast = $this->parser->parse($content); |
58 | - } |
|
59 | - catch (\Exception $e) { |
|
58 | + } catch (\Exception $e) { |
|
60 | 59 | $this->logger->addError(sprintf("Parsing failed in file %s\n", $file)); |
61 | 60 | $this->logger->error($e); |
62 | 61 | return null; |
@@ -35,6 +35,10 @@ discard block |
||
35 | 35 | $content = $this->path->read($file); |
36 | 36 | return $this->parseContent($file, $content, $uses, $createCache); |
37 | 37 | } |
38 | + |
|
39 | + /** |
|
40 | + * @return \Padawan\Domain\Scope\FileScope |
|
41 | + */ |
|
38 | 42 | public function parseContent($file, $content, Uses $uses = null, $createCache = true) |
39 | 43 | { |
40 | 44 | if ($createCache) { |
@@ -110,6 +114,10 @@ discard block |
||
110 | 114 | } |
111 | 115 | return $nodes; |
112 | 116 | } |
117 | + |
|
118 | + /** |
|
119 | + * @param \Padawan\Domain\Project\Index $index |
|
120 | + */ |
|
113 | 121 | public function setIndex($index) |
114 | 122 | { |
115 | 123 | foreach ($this->walkers as $walker) { |
@@ -8,8 +8,7 @@ |
||
8 | 8 | public function parse($content) { |
9 | 9 | try { |
10 | 10 | return parent::parse($content); |
11 | - } |
|
12 | - catch (\Exception $e) { |
|
11 | + } catch (\Exception $e) { |
|
13 | 12 | return $this->semValue; |
14 | 13 | } |
15 | 14 | } |