@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function getGuard(): GuardInterface |
29 | 29 | { |
30 | 30 | $container = ContainerScope::getContainer(); |
31 | - if (empty($container) || !$container->has(GuardInterface::class)) { |
|
31 | + if (empty($container) || !$container->has(GuardInterface::class)){ |
|
32 | 32 | throw new ScopeException( |
33 | 33 | 'Unable to get `GuardInterface`, binding is missing or container scope is not set' |
34 | 34 | ); |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function resolvePermission(string $permission): string |
67 | 67 | { |
68 | - if (defined('static::GUARD_NAMESPACE')) { |
|
68 | + if (defined('static::GUARD_NAMESPACE')){ |
|
69 | 69 | // Yay! Isolation |
70 | - $permission = constant(get_called_class() . '::' . 'GUARD_NAMESPACE') . '.' . $permission; |
|
70 | + $permission = constant(get_called_class().'::'.'GUARD_NAMESPACE').'.'.$permission; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $permission; |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | public function getGuard(): GuardInterface |
29 | 29 | { |
30 | 30 | $container = ContainerScope::getContainer(); |
31 | - if (empty($container) || !$container->has(GuardInterface::class)) { |
|
31 | + if (empty($container) || !$container->has(GuardInterface::class)) |
|
32 | + { |
|
32 | 33 | throw new ScopeException( |
33 | 34 | 'Unable to get `GuardInterface`, binding is missing or container scope is not set' |
34 | 35 | ); |
@@ -65,7 +66,8 @@ discard block |
||
65 | 66 | */ |
66 | 67 | protected function resolvePermission(string $permission): string |
67 | 68 | { |
68 | - if (defined('static::GUARD_NAMESPACE')) { |
|
69 | + if (defined('static::GUARD_NAMESPACE')) |
|
70 | + { |
|
69 | 71 | // Yay! Isolation |
70 | 72 | $permission = constant(get_called_class() . '::' . 'GUARD_NAMESPACE') . '.' . $permission; |
71 | 73 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function addElement(DeclarationInterface $element): FileDeclaration |
107 | 107 | { |
108 | 108 | $this->elements->add($element); |
109 | - if ($element instanceof DependedInterface) { |
|
109 | + if ($element instanceof DependedInterface){ |
|
110 | 110 | $this->addUses($element->getDependencies()); |
111 | 111 | } |
112 | 112 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | { |
133 | 133 | $result = "<?php\n"; |
134 | 134 | |
135 | - if (!$this->docComment->isEmpty()) { |
|
136 | - $result .= $this->docComment->render($indentLevel) . "\n"; |
|
135 | + if (!$this->docComment->isEmpty()){ |
|
136 | + $result .= $this->docComment->render($indentLevel)."\n"; |
|
137 | 137 | } |
138 | 138 | |
139 | - if ($this->directives !== null && !empty($this->directives->render())) { |
|
140 | - $result .= $this->directives->render() . "\n\n"; |
|
139 | + if ($this->directives !== null && !empty($this->directives->render())){ |
|
140 | + $result .= $this->directives->render()."\n\n"; |
|
141 | 141 | } |
142 | 142 | |
143 | - if (!empty($this->namespace)) { |
|
144 | - if ($this->docComment->isEmpty()) { |
|
143 | + if (!empty($this->namespace)){ |
|
144 | + if ($this->docComment->isEmpty()){ |
|
145 | 145 | $result .= "\n"; |
146 | 146 | } |
147 | 147 | $result .= "namespace {$this->namespace};\n\n"; |
148 | 148 | } |
149 | 149 | |
150 | - if (!empty($this->uses)) { |
|
151 | - $result .= $this->renderUses($indentLevel) . "\n\n"; |
|
150 | + if (!empty($this->uses)){ |
|
151 | + $result .= $this->renderUses($indentLevel)."\n\n"; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $result .= $this->elements->render($indentLevel); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | use Spiral\Debug\Dumper; |
13 | 13 | |
14 | -if (!function_exists('dump')) { |
|
14 | +if (!function_exists('dump')){ |
|
15 | 15 | /** |
16 | 16 | * Dump value. |
17 | 17 | * |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function dump($value, int $output = Dumper::OUTPUT): ?string |
24 | 24 | { |
25 | - if (!class_exists(\Spiral\Core\ContainerScope::class)) { |
|
25 | + if (!class_exists(\Spiral\Core\ContainerScope::class)){ |
|
26 | 26 | return (new Dumper())->dump($value, $output); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $container = \Spiral\Core\ContainerScope::getContainer(); |
30 | - if (is_null($container) || !$container->has(Dumper::class)) { |
|
30 | + if (is_null($container) || !$container->has(Dumper::class)){ |
|
31 | 31 | $dumper = new Dumper(); |
32 | 32 | |
33 | 33 | return $dumper->dump($value, $output); |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | |
12 | 12 | use Spiral\Debug\Dumper; |
13 | 13 | |
14 | -if (!function_exists('dump')) { |
|
14 | +if (!function_exists('dump')) |
|
15 | +{ |
|
15 | 16 | /** |
16 | 17 | * Dump value. |
17 | 18 | * |
@@ -22,12 +23,14 @@ discard block |
||
22 | 23 | */ |
23 | 24 | function dump($value, int $output = Dumper::OUTPUT): ?string |
24 | 25 | { |
25 | - if (!class_exists(\Spiral\Core\ContainerScope::class)) { |
|
26 | + if (!class_exists(\Spiral\Core\ContainerScope::class)) |
|
27 | + { |
|
26 | 28 | return (new Dumper())->dump($value, $output); |
27 | 29 | } |
28 | 30 | |
29 | 31 | $container = \Spiral\Core\ContainerScope::getContainer(); |
30 | - if (is_null($container) || !$container->has(Dumper::class)) { |
|
32 | + if (is_null($container) || !$container->has(Dumper::class)) |
|
33 | + { |
|
31 | 34 | $dumper = new Dumper(); |
32 | 35 | |
33 | 36 | return $dumper->dump($value, $output); |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | $schema = $this->constant('SCHEMA')->getValue(); |
61 | 61 | $validates = $this->constant('VALIDATES')->getValue(); |
62 | 62 | |
63 | - if (!isset($this->mapping[$type])) { |
|
64 | - $schema[$field] = ($source ?? self::DEFAULT_SOURCE) . ':' . ($origin ?: $field); |
|
63 | + if (!isset($this->mapping[$type])){ |
|
64 | + $schema[$field] = ($source ?? self::DEFAULT_SOURCE).':'.($origin ?: $field); |
|
65 | 65 | |
66 | 66 | $this->constant('SCHEMA')->setValue($schema); |
67 | 67 | |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | |
73 | 73 | //Source can depend on type |
74 | 74 | $source = $source ?? $definition['source']; |
75 | - $schema[$field] = $source . ':' . ($origin ?: $field); |
|
75 | + $schema[$field] = $source.':'.($origin ?: $field); |
|
76 | 76 | |
77 | - if (!empty($definition['validates'])) { |
|
77 | + if (!empty($definition['validates'])){ |
|
78 | 78 | //Pre-defined validation |
79 | 79 | $validates[$field] = $definition['validates']; |
80 | 80 | } |
@@ -60,7 +60,8 @@ discard block |
||
60 | 60 | $schema = $this->constant('SCHEMA')->getValue(); |
61 | 61 | $validates = $this->constant('VALIDATES')->getValue(); |
62 | 62 | |
63 | - if (!isset($this->mapping[$type])) { |
|
63 | + if (!isset($this->mapping[$type])) |
|
64 | + { |
|
64 | 65 | $schema[$field] = ($source ?? self::DEFAULT_SOURCE) . ':' . ($origin ?: $field); |
65 | 66 | |
66 | 67 | $this->constant('SCHEMA')->setValue($schema); |
@@ -74,7 +75,8 @@ discard block |
||
74 | 75 | $source = $source ?? $definition['source']; |
75 | 76 | $schema[$field] = $source . ':' . ($origin ?: $field); |
76 | 77 | |
77 | - if (!empty($definition['validates'])) { |
|
78 | + if (!empty($definition['validates'])) |
|
79 | + { |
|
78 | 80 | //Pre-defined validation |
79 | 81 | $validates[$field] = $definition['validates']; |
80 | 82 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $prototypeBootloader->initAnnotations($this->container, true); |
34 | 34 | |
35 | 35 | $dependencies = $this->registry->getPropertyBindings(); |
36 | - if ($dependencies === []) { |
|
36 | + if ($dependencies === []){ |
|
37 | 37 | $this->writeln('<comment>No prototyped shortcuts found.</comment>'); |
38 | 38 | return; |
39 | 39 | } |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | |
43 | 43 | $trait = new \ReflectionClass(PrototypeTrait::class); |
44 | 44 | $docComment = $trait->getDocComment(); |
45 | - if ($docComment === false) { |
|
45 | + if ($docComment === false){ |
|
46 | 46 | $this->write('<fg=reg>DOCComment is missing</fg=red>'); |
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $filename = $trait->getFileName(); |
51 | 51 | |
52 | - try { |
|
52 | + try{ |
|
53 | 53 | file_put_contents( |
54 | 54 | $filename, |
55 | 55 | str_replace( |
@@ -58,17 +58,17 @@ discard block |
||
58 | 58 | file_get_contents($filename) |
59 | 59 | ) |
60 | 60 | ); |
61 | - } catch (\Throwable $e) { |
|
62 | - $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n"); |
|
61 | + }catch (\Throwable $e){ |
|
62 | + $this->write('<fg=red>'.$e->getMessage()."</fg=red>\n"); |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | 66 | $this->write("<fg=green>complete</fg=green>\n"); |
67 | 67 | |
68 | - if ($this->isVerbose()) { |
|
68 | + if ($this->isVerbose()){ |
|
69 | 69 | $grid = $this->table(['Property:', 'Target:']); |
70 | 70 | |
71 | - foreach ($dependencies as $dependency) { |
|
71 | + foreach ($dependencies as $dependency){ |
|
72 | 72 | $grid->addRow([$dependency->var, $dependency->type->fullName]); |
73 | 73 | } |
74 | 74 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ); |
89 | 89 | $an->lines[] = new Annotation\Line(''); |
90 | 90 | |
91 | - foreach ($dependencies as $dependency) { |
|
91 | + foreach ($dependencies as $dependency){ |
|
92 | 92 | $an->lines[] = new Annotation\Line( |
93 | 93 | sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var), |
94 | 94 | 'property' |
@@ -33,7 +33,8 @@ discard block |
||
33 | 33 | $prototypeBootloader->initAnnotations($this->container, true); |
34 | 34 | |
35 | 35 | $dependencies = $this->registry->getPropertyBindings(); |
36 | - if ($dependencies === []) { |
|
36 | + if ($dependencies === []) |
|
37 | + { |
|
37 | 38 | $this->writeln('<comment>No prototyped shortcuts found.</comment>'); |
38 | 39 | return; |
39 | 40 | } |
@@ -42,14 +43,16 @@ discard block |
||
42 | 43 | |
43 | 44 | $trait = new \ReflectionClass(PrototypeTrait::class); |
44 | 45 | $docComment = $trait->getDocComment(); |
45 | - if ($docComment === false) { |
|
46 | + if ($docComment === false) |
|
47 | + { |
|
46 | 48 | $this->write('<fg=reg>DOCComment is missing</fg=red>'); |
47 | 49 | return; |
48 | 50 | } |
49 | 51 | |
50 | 52 | $filename = $trait->getFileName(); |
51 | 53 | |
52 | - try { |
|
54 | + try |
|
55 | + { |
|
53 | 56 | file_put_contents( |
54 | 57 | $filename, |
55 | 58 | str_replace( |
@@ -58,17 +61,21 @@ discard block |
||
58 | 61 | file_get_contents($filename) |
59 | 62 | ) |
60 | 63 | ); |
61 | - } catch (\Throwable $e) { |
|
64 | + } |
|
65 | + catch (\Throwable $e) |
|
66 | + { |
|
62 | 67 | $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n"); |
63 | 68 | return; |
64 | 69 | } |
65 | 70 | |
66 | 71 | $this->write("<fg=green>complete</fg=green>\n"); |
67 | 72 | |
68 | - if ($this->isVerbose()) { |
|
73 | + if ($this->isVerbose()) |
|
74 | + { |
|
69 | 75 | $grid = $this->table(['Property:', 'Target:']); |
70 | 76 | |
71 | - foreach ($dependencies as $dependency) { |
|
77 | + foreach ($dependencies as $dependency) |
|
78 | + { |
|
72 | 79 | $grid->addRow([$dependency->var, $dependency->type->fullName]); |
73 | 80 | } |
74 | 81 | |
@@ -88,7 +95,8 @@ discard block |
||
88 | 95 | ); |
89 | 96 | $an->lines[] = new Annotation\Line(''); |
90 | 97 | |
91 | - foreach ($dependencies as $dependency) { |
|
98 | + foreach ($dependencies as $dependency) |
|
99 | + { |
|
92 | 100 | $an->lines[] = new Annotation\Line( |
93 | 101 | sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var), |
94 | 102 | 'property' |
@@ -50,13 +50,13 @@ |
||
50 | 50 | $node instanceof Node\Expr\PropertyFetch && |
51 | 51 | $node->var instanceof Node\Expr\Variable && |
52 | 52 | $node->var->name === 'this' |
53 | - ) { |
|
53 | + ){ |
|
54 | 54 | $this->requested[$node->name->name] = $node->name->name; |
55 | 55 | } |
56 | 56 | |
57 | - if ($node instanceof Node\Stmt\Property) { |
|
58 | - foreach ($node->props as $prop) { |
|
59 | - if ($prop instanceof Node\Stmt\PropertyProperty) { |
|
57 | + if ($node instanceof Node\Stmt\Property){ |
|
58 | + foreach ($node->props as $prop){ |
|
59 | + if ($prop instanceof Node\Stmt\PropertyProperty){ |
|
60 | 60 | $this->properties[$prop->name->name] = $prop->name->name; |
61 | 61 | } |
62 | 62 | } |
@@ -54,9 +54,12 @@ |
||
54 | 54 | $this->requested[$node->name->name] = $node->name->name; |
55 | 55 | } |
56 | 56 | |
57 | - if ($node instanceof Node\Stmt\Property) { |
|
58 | - foreach ($node->props as $prop) { |
|
59 | - if ($prop instanceof Node\Stmt\PropertyProperty) { |
|
57 | + if ($node instanceof Node\Stmt\Property) |
|
58 | + { |
|
59 | + foreach ($node->props as $prop) |
|
60 | + { |
|
61 | + if ($prop instanceof Node\Stmt\PropertyProperty) |
|
62 | + { |
|
60 | 63 | $this->properties[$prop->name->name] = $prop->name->name; |
61 | 64 | } |
62 | 65 | } |
@@ -27,17 +27,17 @@ |
||
27 | 27 | */ |
28 | 28 | public function leaveNode(Node $node) |
29 | 29 | { |
30 | - if (!$node instanceof Node\Stmt\Use_) { |
|
30 | + if (!$node instanceof Node\Stmt\Use_){ |
|
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | |
34 | - foreach ($node->uses as $index => $use) { |
|
35 | - if ($use->name->toString() === PrototypeTrait::class) { |
|
34 | + foreach ($node->uses as $index => $use){ |
|
35 | + if ($use->name->toString() === PrototypeTrait::class){ |
|
36 | 36 | unset($node->uses[$index]); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - if (empty($node->uses)) { |
|
40 | + if (empty($node->uses)){ |
|
41 | 41 | return NodeTraverser::REMOVE_NODE; |
42 | 42 | } |
43 | 43 |
@@ -27,17 +27,21 @@ |
||
27 | 27 | */ |
28 | 28 | public function leaveNode(Node $node) |
29 | 29 | { |
30 | - if (!$node instanceof Node\Stmt\Use_) { |
|
30 | + if (!$node instanceof Node\Stmt\Use_) |
|
31 | + { |
|
31 | 32 | return null; |
32 | 33 | } |
33 | 34 | |
34 | - foreach ($node->uses as $index => $use) { |
|
35 | - if ($use->name->toString() === PrototypeTrait::class) { |
|
35 | + foreach ($node->uses as $index => $use) |
|
36 | + { |
|
37 | + if ($use->name->toString() === PrototypeTrait::class) |
|
38 | + { |
|
36 | 39 | unset($node->uses[$index]); |
37 | 40 | } |
38 | 41 | } |
39 | 42 | |
40 | - if (empty($node->uses)) { |
|
43 | + if (empty($node->uses)) |
|
44 | + { |
|
41 | 45 | return NodeTraverser::REMOVE_NODE; |
42 | 46 | } |
43 | 47 |
@@ -27,15 +27,15 @@ |
||
27 | 27 | */ |
28 | 28 | public function leaveNode(Node $node) |
29 | 29 | { |
30 | - if (!$node instanceof Node\Stmt\Class_) { |
|
30 | + if (!$node instanceof Node\Stmt\Class_){ |
|
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | |
34 | 34 | $placementID = 0; |
35 | - foreach ($node->stmts as $index => $child) { |
|
35 | + foreach ($node->stmts as $index => $child){ |
|
36 | 36 | $placementID = $index; |
37 | - if ($child instanceof Node\Stmt\ClassMethod) { |
|
38 | - if ($child->name->name === '__construct') { |
|
37 | + if ($child instanceof Node\Stmt\ClassMethod){ |
|
38 | + if ($child->name->name === '__construct'){ |
|
39 | 39 | $node->setAttribute('constructor', $child); |
40 | 40 | |
41 | 41 | return null; |
@@ -27,15 +27,19 @@ |
||
27 | 27 | */ |
28 | 28 | public function leaveNode(Node $node) |
29 | 29 | { |
30 | - if (!$node instanceof Node\Stmt\Class_) { |
|
30 | + if (!$node instanceof Node\Stmt\Class_) |
|
31 | + { |
|
31 | 32 | return null; |
32 | 33 | } |
33 | 34 | |
34 | 35 | $placementID = 0; |
35 | - foreach ($node->stmts as $index => $child) { |
|
36 | + foreach ($node->stmts as $index => $child) |
|
37 | + { |
|
36 | 38 | $placementID = $index; |
37 | - if ($child instanceof Node\Stmt\ClassMethod) { |
|
38 | - if ($child->name->name === '__construct') { |
|
39 | + if ($child instanceof Node\Stmt\ClassMethod) |
|
40 | + { |
|
41 | + if ($child->name->name === '__construct') |
|
42 | + { |
|
39 | 43 | $node->setAttribute('constructor', $child); |
40 | 44 | |
41 | 45 | return null; |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function enterNode($node, VisitorContext $ctx) |
35 | 35 | { |
36 | - if ($node instanceof Tag) { |
|
36 | + if ($node instanceof Tag){ |
|
37 | 37 | return $this->makeBlock($node); |
38 | 38 | } |
39 | 39 | |
40 | - if ($node instanceof Inline) { |
|
40 | + if ($node instanceof Inline){ |
|
41 | 41 | $block = new Block($node->name, $node->getContext()); |
42 | - if ($node->value !== null) { |
|
42 | + if ($node->value !== null){ |
|
43 | 43 | $block->nodes[] = new Raw($node->value); |
44 | 44 | } |
45 | 45 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | private function makeBlock(Tag $node): ?NodeInterface |
66 | 66 | { |
67 | 67 | $name = null; |
68 | - foreach ($this->prefix as $prefix) { |
|
69 | - if (strpos($node->name, $prefix) === 0) { |
|
68 | + foreach ($this->prefix as $prefix){ |
|
69 | + if (strpos($node->name, $prefix) === 0){ |
|
70 | 70 | $name = substr($node->name, strlen($prefix)); |
71 | 71 | break; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - if ($name === null) { |
|
75 | + if ($name === null){ |
|
76 | 76 | return null; |
77 | 77 | } |
78 | 78 |
@@ -33,13 +33,16 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function enterNode($node, VisitorContext $ctx) |
35 | 35 | { |
36 | - if ($node instanceof Tag) { |
|
36 | + if ($node instanceof Tag) |
|
37 | + { |
|
37 | 38 | return $this->makeBlock($node); |
38 | 39 | } |
39 | 40 | |
40 | - if ($node instanceof Inline) { |
|
41 | + if ($node instanceof Inline) |
|
42 | + { |
|
41 | 43 | $block = new Block($node->name, $node->getContext()); |
42 | - if ($node->value !== null) { |
|
44 | + if ($node->value !== null) |
|
45 | + { |
|
43 | 46 | $block->nodes[] = new Raw($node->value); |
44 | 47 | } |
45 | 48 | |
@@ -65,14 +68,17 @@ discard block |
||
65 | 68 | private function makeBlock(Tag $node): ?NodeInterface |
66 | 69 | { |
67 | 70 | $name = null; |
68 | - foreach ($this->prefix as $prefix) { |
|
69 | - if (strpos($node->name, $prefix) === 0) { |
|
71 | + foreach ($this->prefix as $prefix) |
|
72 | + { |
|
73 | + if (strpos($node->name, $prefix) === 0) |
|
74 | + { |
|
70 | 75 | $name = substr($node->name, strlen($prefix)); |
71 | 76 | break; |
72 | 77 | } |
73 | 78 | } |
74 | 79 | |
75 | - if ($name === null) { |
|
80 | + if ($name === null) |
|
81 | + { |
|
76 | 82 | return null; |
77 | 83 | } |
78 | 84 |