@@ -16,15 +16,15 @@ |
||
16 | 16 | { |
17 | 17 | public function leaveNode(Node $node): ?Node |
18 | 18 | { |
19 | - if (!$node instanceof Node\Stmt\Class_) { |
|
19 | + if (!$node instanceof Node\Stmt\Class_){ |
|
20 | 20 | return null; |
21 | 21 | } |
22 | 22 | |
23 | 23 | $placementID = 0; |
24 | - foreach ($node->stmts as $index => $child) { |
|
24 | + foreach ($node->stmts as $index => $child){ |
|
25 | 25 | $placementID = $index; |
26 | - if ($child instanceof Node\Stmt\ClassMethod) { |
|
27 | - if ($child->name->name === '__construct') { |
|
26 | + if ($child instanceof Node\Stmt\ClassMethod){ |
|
27 | + if ($child->name->name === '__construct'){ |
|
28 | 28 | $node->setAttribute('constructor', $child); |
29 | 29 | |
30 | 30 | return null; |
@@ -16,15 +16,19 @@ |
||
16 | 16 | { |
17 | 17 | public function leaveNode(Node $node): ?Node |
18 | 18 | { |
19 | - if (!$node instanceof Node\Stmt\Class_) { |
|
19 | + if (!$node instanceof Node\Stmt\Class_) |
|
20 | + { |
|
20 | 21 | return null; |
21 | 22 | } |
22 | 23 | |
23 | 24 | $placementID = 0; |
24 | - foreach ($node->stmts as $index => $child) { |
|
25 | + foreach ($node->stmts as $index => $child) |
|
26 | + { |
|
25 | 27 | $placementID = $index; |
26 | - if ($child instanceof Node\Stmt\ClassMethod) { |
|
27 | - if ($child->name->name === '__construct') { |
|
28 | + if ($child instanceof Node\Stmt\ClassMethod) |
|
29 | + { |
|
30 | + if ($child->name->name === '__construct') |
|
31 | + { |
|
28 | 32 | $node->setAttribute('constructor', $child); |
29 | 33 | |
30 | 34 | return null; |
@@ -12,18 +12,18 @@ |
||
12 | 12 | { |
13 | 13 | private array $vars = []; |
14 | 14 | |
15 | - public function enterNode(Node $node): int|Node\Stmt\ClassMethod|null |
|
15 | + public function enterNode(Node $node): int | Node\Stmt\ClassMethod | null |
|
16 | 16 | { |
17 | - if ($node instanceof Node\Stmt\Class_) { |
|
18 | - foreach ($node->stmts as $stmt) { |
|
19 | - if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') { |
|
17 | + if ($node instanceof Node\Stmt\Class_){ |
|
18 | + foreach ($node->stmts as $stmt){ |
|
19 | + if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct'){ |
|
20 | 20 | return $stmt; |
21 | 21 | } |
22 | 22 | } |
23 | 23 | return NodeTraverser::DONT_TRAVERSE_CHILDREN; |
24 | 24 | } |
25 | 25 | |
26 | - if ($node instanceof Node\Expr\Variable) { |
|
26 | + if ($node instanceof Node\Expr\Variable){ |
|
27 | 27 | $this->vars[] = $node->name; |
28 | 28 | } |
29 | 29 |
@@ -14,16 +14,20 @@ |
||
14 | 14 | |
15 | 15 | public function enterNode(Node $node): int|Node\Stmt\ClassMethod|null |
16 | 16 | { |
17 | - if ($node instanceof Node\Stmt\Class_) { |
|
18 | - foreach ($node->stmts as $stmt) { |
|
19 | - if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') { |
|
17 | + if ($node instanceof Node\Stmt\Class_) |
|
18 | + { |
|
19 | + foreach ($node->stmts as $stmt) |
|
20 | + { |
|
21 | + if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') |
|
22 | + { |
|
20 | 23 | return $stmt; |
21 | 24 | } |
22 | 25 | } |
23 | 26 | return NodeTraverser::DONT_TRAVERSE_CHILDREN; |
24 | 27 | } |
25 | 28 | |
26 | - if ($node instanceof Node\Expr\Variable) { |
|
29 | + if ($node instanceof Node\Expr\Variable) |
|
30 | + { |
|
27 | 31 | $this->vars[] = $node->name; |
28 | 32 | } |
29 | 33 |
@@ -16,8 +16,8 @@ |
||
16 | 16 | |
17 | 17 | public function enterNode(Node $node): void |
18 | 18 | { |
19 | - if ($node instanceof Node\Stmt\Use_) { |
|
20 | - foreach ($node->uses as $use) { |
|
19 | + if ($node instanceof Node\Stmt\Use_){ |
|
20 | + foreach ($node->uses as $use){ |
|
21 | 21 | $this->imports[] = [ |
22 | 22 | 'name' => \implode('\\', $use->name->parts), |
23 | 23 | 'alias' => $use->alias->name ?? null, |
@@ -16,8 +16,10 @@ |
||
16 | 16 | |
17 | 17 | public function enterNode(Node $node): void |
18 | 18 | { |
19 | - if ($node instanceof Node\Stmt\Use_) { |
|
20 | - foreach ($node->uses as $use) { |
|
19 | + if ($node instanceof Node\Stmt\Use_) |
|
20 | + { |
|
21 | + foreach ($node->uses as $use) |
|
22 | + { |
|
21 | 23 | $this->imports[] = [ |
22 | 24 | 'name' => \implode('\\', $use->name->parts), |
23 | 25 | 'alias' => $use->alias->name ?? null, |
@@ -15,11 +15,11 @@ |
||
15 | 15 | |
16 | 16 | public function enterNode(Node $node): ?int |
17 | 17 | { |
18 | - if ($node instanceof Node\Stmt\Namespace_) { |
|
18 | + if ($node instanceof Node\Stmt\Namespace_){ |
|
19 | 19 | $this->namespace = \implode('\\', $node->name->parts); |
20 | 20 | } |
21 | 21 | |
22 | - if ($node instanceof Node\Stmt\Class_) { |
|
22 | + if ($node instanceof Node\Stmt\Class_){ |
|
23 | 23 | $this->class = $node->name->name; |
24 | 24 | |
25 | 25 | return NodeTraverser::STOP_TRAVERSAL; |
@@ -15,11 +15,13 @@ |
||
15 | 15 | |
16 | 16 | public function enterNode(Node $node): ?int |
17 | 17 | { |
18 | - if ($node instanceof Node\Stmt\Namespace_) { |
|
18 | + if ($node instanceof Node\Stmt\Namespace_) |
|
19 | + { |
|
19 | 20 | $this->namespace = \implode('\\', $node->name->parts); |
20 | 21 | } |
21 | 22 | |
22 | - if ($node instanceof Node\Stmt\Class_) { |
|
23 | + if ($node instanceof Node\Stmt\Class_) |
|
24 | + { |
|
23 | 25 | $this->class = $node->name->name; |
24 | 26 | |
25 | 27 | return NodeTraverser::STOP_TRAVERSAL; |
@@ -15,28 +15,28 @@ |
||
15 | 15 | */ |
16 | 16 | final class RemoveTrait extends NodeVisitorAbstract |
17 | 17 | { |
18 | - public function leaveNode(Node $node): int|Node|null |
|
18 | + public function leaveNode(Node $node): int | Node | null |
|
19 | 19 | { |
20 | - if (!$node instanceof Node\Stmt\TraitUse) { |
|
20 | + if (!$node instanceof Node\Stmt\TraitUse){ |
|
21 | 21 | return null; |
22 | 22 | } |
23 | 23 | |
24 | - foreach ($node->traits as $index => $use) { |
|
25 | - if ($use instanceof Node\Name) { |
|
24 | + foreach ($node->traits as $index => $use){ |
|
25 | + if ($use instanceof Node\Name){ |
|
26 | 26 | $name = $this->trimSlashes(\implode('\\', $use->parts)); |
27 | 27 | if ( |
28 | 28 | \in_array($name, [ |
29 | 29 | $this->trimSlashes(PrototypeTrait::class), |
30 | 30 | Utils::shortName(PrototypeTrait::class), |
31 | 31 | ], true) |
32 | - ) { |
|
32 | + ){ |
|
33 | 33 | unset($node->traits[$index]); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | 38 | $node->traits = \array_values($node->traits); |
39 | - if (empty($node->traits)) { |
|
39 | + if (empty($node->traits)){ |
|
40 | 40 | return NodeTraverser::REMOVE_NODE; |
41 | 41 | } |
42 | 42 |
@@ -17,12 +17,15 @@ discard block |
||
17 | 17 | { |
18 | 18 | public function leaveNode(Node $node): int|Node|null |
19 | 19 | { |
20 | - if (!$node instanceof Node\Stmt\TraitUse) { |
|
20 | + if (!$node instanceof Node\Stmt\TraitUse) |
|
21 | + { |
|
21 | 22 | return null; |
22 | 23 | } |
23 | 24 | |
24 | - foreach ($node->traits as $index => $use) { |
|
25 | - if ($use instanceof Node\Name) { |
|
25 | + foreach ($node->traits as $index => $use) |
|
26 | + { |
|
27 | + if ($use instanceof Node\Name) |
|
28 | + { |
|
26 | 29 | $name = $this->trimSlashes(\implode('\\', $use->parts)); |
27 | 30 | if ( |
28 | 31 | \in_array($name, [ |
@@ -36,7 +39,8 @@ discard block |
||
36 | 39 | } |
37 | 40 | |
38 | 41 | $node->traits = \array_values($node->traits); |
39 | - if (empty($node->traits)) { |
|
42 | + if (empty($node->traits)) |
|
43 | + { |
|
40 | 44 | return NodeTraverser::REMOVE_NODE; |
41 | 45 | } |
42 | 46 |
@@ -14,19 +14,19 @@ |
||
14 | 14 | */ |
15 | 15 | final class RemoveUse extends NodeVisitorAbstract |
16 | 16 | { |
17 | - public function leaveNode(Node $node): int|Node|null |
|
17 | + public function leaveNode(Node $node): int | Node | null |
|
18 | 18 | { |
19 | - if (!$node instanceof Node\Stmt\Use_) { |
|
19 | + if (!$node instanceof Node\Stmt\Use_){ |
|
20 | 20 | return null; |
21 | 21 | } |
22 | 22 | |
23 | - foreach ($node->uses as $index => $use) { |
|
24 | - if ($use->name->toString() === PrototypeTrait::class) { |
|
23 | + foreach ($node->uses as $index => $use){ |
|
24 | + if ($use->name->toString() === PrototypeTrait::class){ |
|
25 | 25 | unset($node->uses[$index]); |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | - if (empty($node->uses)) { |
|
29 | + if (empty($node->uses)){ |
|
30 | 30 | return NodeTraverser::REMOVE_NODE; |
31 | 31 | } |
32 | 32 |
@@ -16,17 +16,21 @@ |
||
16 | 16 | { |
17 | 17 | public function leaveNode(Node $node): int|Node|null |
18 | 18 | { |
19 | - if (!$node instanceof Node\Stmt\Use_) { |
|
19 | + if (!$node instanceof Node\Stmt\Use_) |
|
20 | + { |
|
20 | 21 | return null; |
21 | 22 | } |
22 | 23 | |
23 | - foreach ($node->uses as $index => $use) { |
|
24 | - if ($use->name->toString() === PrototypeTrait::class) { |
|
24 | + foreach ($node->uses as $index => $use) |
|
25 | + { |
|
26 | + if ($use->name->toString() === PrototypeTrait::class) |
|
27 | + { |
|
25 | 28 | unset($node->uses[$index]); |
26 | 29 | } |
27 | 30 | } |
28 | 31 | |
29 | - if (empty($node->uses)) { |
|
32 | + if (empty($node->uses)) |
|
33 | + { |
|
30 | 34 | return NodeTraverser::REMOVE_NODE; |
31 | 35 | } |
32 | 36 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | public function __construct( |
20 | 20 | private readonly ContainerInterface $container |
21 | - ) { |
|
21 | + ){ |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -40,18 +40,18 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * Resolves the name of prototype dependency into target class name. |
42 | 42 | */ |
43 | - public function resolveProperty(string $name): Dependency|ContainerExceptionInterface|null |
|
43 | + public function resolveProperty(string $name): Dependency | ContainerExceptionInterface | null |
|
44 | 44 | { |
45 | 45 | $dependency = $this->dependencies[$name] ?? null; |
46 | - if ($dependency === null) { |
|
46 | + if ($dependency === null){ |
|
47 | 47 | return null; |
48 | 48 | } |
49 | 49 | |
50 | - try { |
|
50 | + try{ |
|
51 | 51 | $this->container->get($dependency->type->name()); |
52 | 52 | |
53 | 53 | return $dependency; |
54 | - } catch (ContainerExceptionInterface $e) { |
|
54 | + }catch (ContainerExceptionInterface $e){ |
|
55 | 55 | return $e; |
56 | 56 | } |
57 | 57 | } |
@@ -43,15 +43,19 @@ |
||
43 | 43 | public function resolveProperty(string $name): Dependency|ContainerExceptionInterface|null |
44 | 44 | { |
45 | 45 | $dependency = $this->dependencies[$name] ?? null; |
46 | - if ($dependency === null) { |
|
46 | + if ($dependency === null) |
|
47 | + { |
|
47 | 48 | return null; |
48 | 49 | } |
49 | 50 | |
50 | - try { |
|
51 | + try |
|
52 | + { |
|
51 | 53 | $this->container->get($dependency->type->name()); |
52 | 54 | |
53 | 55 | return $dependency; |
54 | - } catch (ContainerExceptionInterface $e) { |
|
56 | + } |
|
57 | + catch (ContainerExceptionInterface $e) |
|
58 | + { |
|
55 | 59 | return $e; |
56 | 60 | } |
57 | 61 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function __get(string $name): mixed |
24 | 24 | { |
25 | 25 | $container = ContainerScope::getContainer(); |
26 | - if ($container === null || !$container->has(PrototypeRegistry::class)) { |
|
26 | + if ($container === null || !$container->has(PrototypeRegistry::class)){ |
|
27 | 27 | throw new ScopeException( |
28 | 28 | \sprintf('Unable to resolve prototyped dependency `%s`, invalid container scope', $name) |
29 | 29 | ); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $target === null || |
38 | 38 | $target instanceof \Throwable || |
39 | 39 | $target->type->fullName === null |
40 | - ) { |
|
40 | + ){ |
|
41 | 41 | throw new PrototypeException( |
42 | 42 | \sprintf('Undefined prototype property `%s`', $name), |
43 | 43 | 0, |
@@ -23,7 +23,8 @@ |
||
23 | 23 | public function __get(string $name): mixed |
24 | 24 | { |
25 | 25 | $container = ContainerScope::getContainer(); |
26 | - if ($container === null || !$container->has(PrototypeRegistry::class)) { |
|
26 | + if ($container === null || !$container->has(PrototypeRegistry::class)) |
|
27 | + { |
|
27 | 28 | throw new ScopeException( |
28 | 29 | \sprintf('Unable to resolve prototyped dependency `%s`, invalid container scope', $name) |
29 | 30 | ); |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | private function __construct( |
14 | 14 | public readonly string $shortName, |
15 | 15 | public readonly ?string $fullName = null, |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public static function create(string $name): Type |
20 | 20 | { |
21 | 21 | $fullName = null; |
22 | - if (Utils::hasShortName($name)) { |
|
22 | + if (Utils::hasShortName($name)){ |
|
23 | 23 | $fullName = $name; |
24 | 24 | $name = Utils::shortName($name); |
25 | 25 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function getSlashedShortName(bool $builtIn): string |
36 | 36 | { |
37 | 37 | $type = $this->shortName; |
38 | - if (!$builtIn && !$this->fullName) { |
|
38 | + if (!$builtIn && !$this->fullName){ |
|
39 | 39 | $type = "\\$type"; |
40 | 40 | } |
41 | 41 |
@@ -19,7 +19,8 @@ discard block |
||
19 | 19 | public static function create(string $name): Type |
20 | 20 | { |
21 | 21 | $fullName = null; |
22 | - if (Utils::hasShortName($name)) { |
|
22 | + if (Utils::hasShortName($name)) |
|
23 | + { |
|
23 | 24 | $fullName = $name; |
24 | 25 | $name = Utils::shortName($name); |
25 | 26 | } |
@@ -35,7 +36,8 @@ discard block |
||
35 | 36 | public function getSlashedShortName(bool $builtIn): string |
36 | 37 | { |
37 | 38 | $type = $this->shortName; |
38 | - if (!$builtIn && !$this->fullName) { |
|
39 | + if (!$builtIn && !$this->fullName) |
|
40 | + { |
|
39 | 41 | $type = "\\$type"; |
40 | 42 | } |
41 | 43 |