@@ -21,6 +21,6 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function allows(ActorInterface $actor, string $permission, array $context): bool |
| 23 | 23 | { |
| 24 | - return (bool) ($this->callable)($actor, $permission, $context); |
|
| 24 | + return (bool)($this->callable)($actor, $permission, $context); |
|
| 25 | 25 | } |
| 26 | 26 | } |
@@ -43,7 +43,8 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function addRole(string $role): PermissionManager |
| 45 | 45 | { |
| 46 | - if ($this->hasRole($role)) { |
|
| 46 | + if ($this->hasRole($role)) |
|
| 47 | + { |
|
| 47 | 48 | throw new RoleException(\sprintf("Role '%s' already exists", $role)); |
| 48 | 49 | } |
| 49 | 50 | |
@@ -56,7 +57,8 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | public function removeRole(string $role): PermissionManager |
| 58 | 59 | { |
| 59 | - if (!$this->hasRole($role)) { |
|
| 60 | + if (!$this->hasRole($role)) |
|
| 61 | + { |
|
| 60 | 62 | throw new RoleException(\sprintf("Undefined role '%s'", $role)); |
| 61 | 63 | } |
| 62 | 64 | |
@@ -72,7 +74,8 @@ discard block |
||
| 72 | 74 | |
| 73 | 75 | public function getPermissions(string $role): array |
| 74 | 76 | { |
| 75 | - if (!$this->hasRole($role)) { |
|
| 77 | + if (!$this->hasRole($role)) |
|
| 78 | + { |
|
| 76 | 79 | throw new RoleException(\sprintf("Undefined role '%s'", $role)); |
| 77 | 80 | } |
| 78 | 81 | |
@@ -81,7 +84,8 @@ discard block |
||
| 81 | 84 | |
| 82 | 85 | public function getRule(string $role, string $permission): RuleInterface |
| 83 | 86 | { |
| 84 | - if (!$this->hasRole($role)) { |
|
| 87 | + if (!$this->hasRole($role)) |
|
| 88 | + { |
|
| 85 | 89 | throw new RoleException(\sprintf("Undefined role '%s'", $role)); |
| 86 | 90 | } |
| 87 | 91 | |
@@ -91,11 +95,13 @@ discard block |
||
| 91 | 95 | |
| 92 | 96 | public function associate(string $role, string $permission, string $rule = AllowRule::class): PermissionManager |
| 93 | 97 | { |
| 94 | - if (!$this->hasRole($role)) { |
|
| 98 | + if (!$this->hasRole($role)) |
|
| 99 | + { |
|
| 95 | 100 | throw new RoleException(\sprintf("Undefined role '%s'", $role)); |
| 96 | 101 | } |
| 97 | 102 | |
| 98 | - if (!$this->rules->has($rule)) { |
|
| 103 | + if (!$this->rules->has($rule)) |
|
| 104 | + { |
|
| 99 | 105 | throw new PermissionException(\sprintf("Undefined rule '%s'", $rule)); |
| 100 | 106 | } |
| 101 | 107 | |
@@ -121,14 +127,17 @@ discard block |
||
| 121 | 127 | */ |
| 122 | 128 | private function findRule(string $role, string $permission): string |
| 123 | 129 | { |
| 124 | - if (isset($this->permissions[$role][$permission])) { |
|
| 130 | + if (isset($this->permissions[$role][$permission])) |
|
| 131 | + { |
|
| 125 | 132 | //O(1) check |
| 126 | 133 | return $this->permissions[$role][$permission]; |
| 127 | 134 | } |
| 128 | 135 | |
| 129 | 136 | //Matching using star syntax |
| 130 | - foreach ($this->permissions[$role] as $pattern => $rule) { |
|
| 131 | - if ($this->matcher->matches($permission, $pattern)) { |
|
| 137 | + foreach ($this->permissions[$role] as $pattern => $rule) |
|
| 138 | + { |
|
| 139 | + if ($this->matcher->matches($permission, $pattern)) |
|
| 140 | + { |
|
| 132 | 141 | return $rule; |
| 133 | 142 | } |
| 134 | 143 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public function __construct( |
| 35 | 35 | private readonly RulesInterface $rules, |
| 36 | 36 | private readonly string $defaultRule = ForbidRule::class, |
| 37 | - ) { |
|
| 37 | + ){ |
|
| 38 | 38 | $this->matcher = new Matcher(); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function addRole(string $role): PermissionManager |
| 47 | 47 | { |
| 48 | - if ($this->hasRole($role)) { |
|
| 48 | + if ($this->hasRole($role)){ |
|
| 49 | 49 | throw new RoleException(\sprintf("Role '%s' already exists", $role)); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function removeRole(string $role): PermissionManager |
| 60 | 60 | { |
| 61 | - if (!$this->hasRole($role)) { |
|
| 61 | + if (!$this->hasRole($role)){ |
|
| 62 | 62 | throw new RoleException(\sprintf("Undefined role '%s'", $role)); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function getPermissions(string $role): array |
| 76 | 76 | { |
| 77 | - if (!$this->hasRole($role)) { |
|
| 77 | + if (!$this->hasRole($role)){ |
|
| 78 | 78 | throw new RoleException(\sprintf("Undefined role '%s'", $role)); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | public function getRule(string $role, string $permission): RuleInterface |
| 85 | 85 | { |
| 86 | - if (!$this->hasRole($role)) { |
|
| 86 | + if (!$this->hasRole($role)){ |
|
| 87 | 87 | throw new RoleException(\sprintf("Undefined role '%s'", $role)); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | public function associate(string $role, string $permission, string $rule = AllowRule::class): PermissionManager |
| 95 | 95 | { |
| 96 | - if (!$this->hasRole($role)) { |
|
| 96 | + if (!$this->hasRole($role)){ |
|
| 97 | 97 | throw new RoleException(\sprintf("Undefined role '%s'", $role)); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if (!$this->rules->has($rule)) { |
|
| 100 | + if (!$this->rules->has($rule)){ |
|
| 101 | 101 | throw new PermissionException(\sprintf("Undefined rule '%s'", $rule)); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -122,14 +122,14 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | private function findRule(string $role, string $permission): string |
| 124 | 124 | { |
| 125 | - if (isset($this->permissions[$role][$permission])) { |
|
| 125 | + if (isset($this->permissions[$role][$permission])){ |
|
| 126 | 126 | //O(1) check |
| 127 | 127 | return $this->permissions[$role][$permission]; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | //Matching using star syntax |
| 131 | - foreach ($this->permissions[$role] as $pattern => $rule) { |
|
| 132 | - if ($this->matcher->matches($permission, $pattern)) { |
|
| 131 | + foreach ($this->permissions[$role] as $pattern => $rule){ |
|
| 132 | + if ($this->matcher->matches($permission, $pattern)){ |
|
| 133 | 133 | return $rule; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $role = $this->argument('role'); |
| 30 | 30 | |
| 31 | - if ($role !== null && !$rbac->hasRole($role)) { |
|
| 31 | + if ($role !== null && !$rbac->hasRole($role)){ |
|
| 32 | 32 | throw new CommandException('Unknown role provided'); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ($role !== null) { |
|
| 35 | + if ($role !== null){ |
|
| 36 | 36 | $rows = $this->getRolePermissions($role, $rbac); |
| 37 | - } else { |
|
| 37 | + }else{ |
|
| 38 | 38 | $rows = []; |
| 39 | 39 | |
| 40 | - foreach ($rbac->getRoles() as $role) { |
|
| 40 | + foreach ($rbac->getRoles() as $role){ |
|
| 41 | 41 | /** @noinspection SlowArrayOperationsInLoopInspection */ |
| 42 | 42 | $rows = \array_merge( |
| 43 | 43 | $this->getRolePermissions($role, $rbac), |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | $permissions = []; |
| 65 | 65 | |
| 66 | - foreach ($rbac->getPermissions($role) as $permission => $rule) { |
|
| 66 | + foreach ($rbac->getPermissions($role) as $permission => $rule){ |
|
| 67 | 67 | $permissions[] = [ |
| 68 | 68 | 'role' => $role, |
| 69 | 69 | 'permission' => $permission, |
@@ -28,16 +28,21 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $role = $this->argument('role'); |
| 30 | 30 | |
| 31 | - if ($role !== null && !$rbac->hasRole($role)) { |
|
| 31 | + if ($role !== null && !$rbac->hasRole($role)) |
|
| 32 | + { |
|
| 32 | 33 | throw new CommandException('Unknown role provided'); |
| 33 | 34 | } |
| 34 | 35 | |
| 35 | - if ($role !== null) { |
|
| 36 | + if ($role !== null) |
|
| 37 | + { |
|
| 36 | 38 | $rows = $this->getRolePermissions($role, $rbac); |
| 37 | - } else { |
|
| 39 | + } |
|
| 40 | + else |
|
| 41 | + { |
|
| 38 | 42 | $rows = []; |
| 39 | 43 | |
| 40 | - foreach ($rbac->getRoles() as $role) { |
|
| 44 | + foreach ($rbac->getRoles() as $role) |
|
| 45 | + { |
|
| 41 | 46 | /** @noinspection SlowArrayOperationsInLoopInspection */ |
| 42 | 47 | $rows = \array_merge( |
| 43 | 48 | $this->getRolePermissions($role, $rbac), |
@@ -63,7 +68,8 @@ discard block |
||
| 63 | 68 | { |
| 64 | 69 | $permissions = []; |
| 65 | 70 | |
| 66 | - foreach ($rbac->getPermissions($role) as $permission => $rule) { |
|
| 71 | + foreach ($rbac->getPermissions($role) as $permission => $rule) |
|
| 72 | + { |
|
| 67 | 73 | $permissions[] = [ |
| 68 | 74 | 'role' => $role, |
| 69 | 75 | 'permission' => $permission, |
@@ -22,13 +22,17 @@ |
||
| 22 | 22 | |
| 23 | 23 | public function getHandler(string $jobType): HandlerInterface |
| 24 | 24 | { |
| 25 | - try { |
|
| 25 | + try |
|
| 26 | + { |
|
| 26 | 27 | $handler = $this->container->get($this->className($jobType)); |
| 27 | - } catch (ContainerException $e) { |
|
| 28 | + } |
|
| 29 | + catch (ContainerException $e) |
|
| 30 | + { |
|
| 28 | 31 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
| 29 | 32 | } |
| 30 | 33 | |
| 31 | - if (!$handler instanceof HandlerInterface) { |
|
| 34 | + if (!$handler instanceof HandlerInterface) |
|
| 35 | + { |
|
| 32 | 36 | throw new JobException(\sprintf('Unable to resolve job handler for `%s`', $jobType)); |
| 33 | 37 | } |
| 34 | 38 | |
@@ -16,19 +16,19 @@ |
||
| 16 | 16 | |
| 17 | 17 | public function __construct( |
| 18 | 18 | private readonly ContainerInterface $container, |
| 19 | - ) { |
|
| 19 | + ){ |
|
| 20 | 20 | $this->inflector = (new InflectorFactory())->build(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function getHandler(string $jobType): HandlerInterface |
| 24 | 24 | { |
| 25 | - try { |
|
| 25 | + try{ |
|
| 26 | 26 | $handler = $this->container->get($this->className($jobType)); |
| 27 | - } catch (ContainerException $e) { |
|
| 27 | + }catch (ContainerException $e){ |
|
| 28 | 28 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if (!$handler instanceof HandlerInterface) { |
|
| 31 | + if (!$handler instanceof HandlerInterface){ |
|
| 32 | 32 | throw new JobException(\sprintf('Unable to resolve job handler for `%s`', $jobType)); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -58,11 +58,13 @@ discard block |
||
| 58 | 58 | $declarator = new DeclareClass(); |
| 59 | 59 | $this->traverse($filename, $declarator); |
| 60 | 60 | |
| 61 | - if (empty($declarator->getClass())) { |
|
| 61 | + if (empty($declarator->getClass())) |
|
| 62 | + { |
|
| 62 | 63 | throw new ClassNotDeclaredException($filename); |
| 63 | 64 | } |
| 64 | 65 | |
| 65 | - if ($declarator->getNamespace()) { |
|
| 66 | + if ($declarator->getNamespace()) |
|
| 67 | + { |
|
| 66 | 68 | return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace()); |
| 67 | 69 | } |
| 68 | 70 | |
@@ -73,7 +75,8 @@ discard block |
||
| 73 | 75 | { |
| 74 | 76 | $tr = new NodeTraverser(); |
| 75 | 77 | |
| 76 | - foreach ($visitors as $visitor) { |
|
| 78 | + foreach ($visitors as $visitor) |
|
| 79 | + { |
|
| 77 | 80 | $tr->addVisitor($visitor); |
| 78 | 81 | } |
| 79 | 82 | |
@@ -82,7 +85,8 @@ discard block |
||
| 82 | 85 | |
| 83 | 86 | private function fillStmts(ClassNode $definition, array $imports): void |
| 84 | 87 | { |
| 85 | - foreach ($imports as $import) { |
|
| 88 | + foreach ($imports as $import) |
|
| 89 | + { |
|
| 86 | 90 | $definition->addImportUsage($import['name'], $import['alias']); |
| 87 | 91 | } |
| 88 | 92 | } |
@@ -95,10 +99,12 @@ discard block |
||
| 95 | 99 | $reflection = new \ReflectionClass(\sprintf('%s\%s', $definition->namespace, $definition->class)); |
| 96 | 100 | |
| 97 | 101 | $constructor = $reflection->getConstructor(); |
| 98 | - if ($constructor !== null) { |
|
| 102 | + if ($constructor !== null) |
|
| 103 | + { |
|
| 99 | 104 | $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName(); |
| 100 | 105 | |
| 101 | - foreach ($reflection->getConstructor()->getParameters() as $parameter) { |
|
| 106 | + foreach ($reflection->getConstructor()->getParameters() as $parameter) |
|
| 107 | + { |
|
| 102 | 108 | $definition->addParam($parameter); |
| 103 | 109 | } |
| 104 | 110 | } |
@@ -110,8 +116,10 @@ discard block |
||
| 110 | 116 | */ |
| 111 | 117 | private function fillConstructorVars(array $vars, ClassNode $definition): void |
| 112 | 118 | { |
| 113 | - foreach ($vars as $k => $var) { |
|
| 114 | - if (isset($definition->constructorParams[$var])) { |
|
| 119 | + foreach ($vars as $k => $var) |
|
| 120 | + { |
|
| 121 | + if (isset($definition->constructorParams[$var])) |
|
| 122 | + { |
|
| 115 | 123 | unset($vars[$k]); |
| 116 | 124 | } |
| 117 | 125 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | private readonly ConflictResolver\Names $namesResolver, |
| 26 | 26 | private readonly ConflictResolver\Namespaces $namespacesResolver, |
| 27 | 27 | ?Parser $parser = null, |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | $this->parser = $parser ?? (new ParserFactory())->create(ParserFactory::ONLY_PHP7); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | $declarator = new DeclareClass(); |
| 59 | 59 | $this->traverse($filename, $declarator); |
| 60 | 60 | |
| 61 | - if (empty($declarator->getClass())) { |
|
| 61 | + if (empty($declarator->getClass())){ |
|
| 62 | 62 | throw new ClassNotDeclaredException($filename); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ($declarator->getNamespace()) { |
|
| 65 | + if ($declarator->getNamespace()){ |
|
| 66 | 66 | return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace()); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $tr = new NodeTraverser(); |
| 75 | 75 | |
| 76 | - foreach ($visitors as $visitor) { |
|
| 76 | + foreach ($visitors as $visitor){ |
|
| 77 | 77 | $tr->addVisitor($visitor); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | private function fillStmts(ClassNode $definition, array $imports): void |
| 84 | 84 | { |
| 85 | - foreach ($imports as $import) { |
|
| 85 | + foreach ($imports as $import){ |
|
| 86 | 86 | $definition->addImportUsage($import['name'], $import['alias']); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | $reflection = new \ReflectionClass(\sprintf('%s\%s', $definition->namespace, $definition->class)); |
| 96 | 96 | |
| 97 | 97 | $constructor = $reflection->getConstructor(); |
| 98 | - if ($constructor !== null) { |
|
| 98 | + if ($constructor !== null){ |
|
| 99 | 99 | $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName(); |
| 100 | 100 | |
| 101 | - foreach ($reflection->getConstructor()->getParameters() as $parameter) { |
|
| 101 | + foreach ($reflection->getConstructor()->getParameters() as $parameter){ |
|
| 102 | 102 | $definition->addParam($parameter); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | private function fillConstructorVars(array $vars, ClassNode $definition): void |
| 112 | 112 | { |
| 113 | - foreach ($vars as $k => $var) { |
|
| 114 | - if (isset($definition->constructorParams[$var])) { |
|
| 113 | + foreach ($vars as $k => $var){ |
|
| 114 | + if (isset($definition->constructorParams[$var])){ |
|
| 115 | 115 | unset($vars[$k]); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -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; |