| @@ -21,7 +21,7 @@ discard block | ||
| 21 | 21 | |
| 22 | 22 | public function setUp(): void | 
| 23 | 23 |      { | 
| 24 | -        if ((string)ini_get('zend.assertions') === 1) { | |
| 24 | +        if ((string)ini_get('zend.assertions') === 1){ | |
| 25 | 25 |              ini_set('zend.assertions', 0); | 
| 26 | 26 | } | 
| 27 | 27 | } | 
| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 |      { | 
| 35 | 35 | $i = new Injector(); | 
| 36 | 36 | |
| 37 | - $filename = __DIR__ . '/Fixtures/TestClass.php'; | |
| 37 | + $filename = __DIR__.'/Fixtures/TestClass.php'; | |
| 38 | 38 | $printed = $i->injectDependencies( | 
| 39 | 39 | file_get_contents($filename), | 
| 40 | 40 | $this->getDefinition($filename, ['testClass' => TestClass::class]) | 
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 |      { | 
| 48 | 48 | $i = new Injector(); | 
| 49 | 49 | |
| 50 | - $filename = __DIR__ . '/Fixtures/WithPromotedProperty.php'; | |
| 50 | + $filename = __DIR__.'/Fixtures/WithPromotedProperty.php'; | |
| 51 | 51 | $printed = $i->injectDependencies( | 
| 52 | 52 | file_get_contents($filename), | 
| 53 | 53 | $this->getDefinition($filename, ['two' => InjectionTwo::class]) | 
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 |      { | 
| 68 | 68 | $i = new Injector(); | 
| 69 | 69 | |
| 70 | - $filename = __DIR__ . '/Fixtures/TestEmptyClass.php'; | |
| 70 | + $filename = __DIR__.'/Fixtures/TestEmptyClass.php'; | |
| 71 | 71 | $content = file_get_contents($filename); | 
| 72 | 72 | $printed = $i->injectDependencies( | 
| 73 | 73 | file_get_contents($filename), | 
| @@ -85,7 +85,7 @@ discard block | ||
| 85 | 85 |      { | 
| 86 | 86 | $i = new Injector(); | 
| 87 | 87 | |
| 88 | - $filename = __DIR__ . '/Fixtures/TestClass.php'; | |
| 88 | + $filename = __DIR__.'/Fixtures/TestClass.php'; | |
| 89 | 89 | $r = $i->injectDependencies( | 
| 90 | 90 | file_get_contents($filename), | 
| 91 | 91 | $this->getDefinition($filename, ['testClass' => TestClass::class]) | 
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 |      { | 
| 111 | 111 | $i = new Injector(); | 
| 112 | 112 | |
| 113 | - $filename = __DIR__ . '/Fixtures/ChildClass.php'; | |
| 113 | + $filename = __DIR__.'/Fixtures/ChildClass.php'; | |
| 114 | 114 | $r = $i->injectDependencies( | 
| 115 | 115 | file_get_contents($filename), | 
| 116 | 116 | $this->getDefinition($filename, ['testClass' => TestClass::class]) | 
| @@ -128,7 +128,7 @@ discard block | ||
| 128 | 128 |      { | 
| 129 | 129 | $i = new Injector(); | 
| 130 | 130 | |
| 131 | - $filename = __DIR__ . '/Fixtures/ChildWithConstructorClass.php'; | |
| 131 | + $filename = __DIR__.'/Fixtures/ChildWithConstructorClass.php'; | |
| 132 | 132 | $r = $i->injectDependencies( | 
| 133 | 133 | file_get_contents($filename), | 
| 134 | 134 | $this->getDefinition($filename, ['testClass' => TestClass::class]) | 
| @@ -144,7 +144,7 @@ discard block | ||
| 144 | 144 | */ | 
| 145 | 145 | public function testModifyConstructor(): void | 
| 146 | 146 |      { | 
| 147 | - $filename = __DIR__ . '/Fixtures/WithConstructor.php'; | |
| 147 | + $filename = __DIR__.'/Fixtures/WithConstructor.php'; | |
| 148 | 148 | $extractor = new Traverse\Extractor(); | 
| 149 | 149 | |
| 150 | 150 | $parameters = $extractor->extractFromFilename($filename); | 
| @@ -170,7 +170,7 @@ discard block | ||
| 170 | 170 | */ | 
| 171 | 171 | public function testPriorOptionalConstructorParameters(): void | 
| 172 | 172 |      { | 
| 173 | - $filename = __DIR__ . '/Fixtures/OptionalConstructorArgsClass.php'; | |
| 173 | + $filename = __DIR__.'/Fixtures/OptionalConstructorArgsClass.php'; | |
| 174 | 174 | $extractor = new Traverse\Extractor(); | 
| 175 | 175 | |
| 176 | 176 | $parameters = $extractor->extractFromFilename($filename); | 
| @@ -201,7 +201,7 @@ discard block | ||
| 201 | 201 |      { | 
| 202 | 202 | $i = new Injector(); | 
| 203 | 203 | |
| 204 | - $filename = __DIR__ . '/ClassNode/ConflictResolver/Fixtures/ChildClass.php'; | |
| 204 | + $filename = __DIR__.'/ClassNode/ConflictResolver/Fixtures/ChildClass.php'; | |
| 205 | 205 | $printed = $i->injectDependencies( | 
| 206 | 206 | file_get_contents($filename), | 
| 207 | 207 | $this->getDefinition( | 
| @@ -21,7 +21,8 @@ | ||
| 21 | 21 | |
| 22 | 22 | public function setUp(): void | 
| 23 | 23 |      { | 
| 24 | -        if ((string)ini_get('zend.assertions') === 1) { | |
| 24 | +        if ((string)ini_get('zend.assertions') === 1) | |
| 25 | +        { | |
| 25 | 26 |              ini_set('zend.assertions', 0); | 
| 26 | 27 | } | 
| 27 | 28 | } | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | public function __construct( | 
| 29 | 29 | Lexer $lexer = null, | 
| 30 | 30 | private readonly PrettyPrinterAbstract $printer = new Standard() | 
| 31 | -    ) { | |
| 31 | +    ){ | |
| 32 | 32 | $this->lexer = $lexer ?? new Lexer\Emulative([ | 
| 33 | 33 | 'usedAttributes' => [ | 
| 34 | 34 | 'comments', | 
| @@ -51,8 +51,8 @@ discard block | ||
| 51 | 51 | */ | 
| 52 | 52 | public function injectDependencies(string $code, ClassNode $node, bool $removeTrait = false): string | 
| 53 | 53 |      { | 
| 54 | -        if (empty($node->dependencies)) { | |
| 55 | -            if ($removeTrait) { | |
| 54 | +        if (empty($node->dependencies)){ | |
| 55 | +            if ($removeTrait){ | |
| 56 | 56 | $tr = new NodeTraverser(); | 
| 57 | 57 | $tr->addVisitor(new RemoveUse()); | 
| 58 | 58 | $tr->addVisitor(new RemoveTrait()); | 
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | $tr = new NodeTraverser(); | 
| 67 | 67 | $tr->addVisitor(new AddUse($node)); | 
| 68 | 68 | |
| 69 | -        if ($removeTrait) { | |
| 69 | +        if ($removeTrait){ | |
| 70 | 70 | $tr->addVisitor(new RemoveUse()); | 
| 71 | 71 | $tr->addVisitor(new RemoveTrait()); | 
| 72 | 72 | } | 
| @@ -51,8 +51,10 @@ discard block | ||
| 51 | 51 | */ | 
| 52 | 52 | public function injectDependencies(string $code, ClassNode $node, bool $removeTrait = false): string | 
| 53 | 53 |      { | 
| 54 | -        if (empty($node->dependencies)) { | |
| 55 | -            if ($removeTrait) { | |
| 54 | + if (empty($node->dependencies)) | |
| 55 | +        { | |
| 56 | + if ($removeTrait) | |
| 57 | +            { | |
| 56 | 58 | $tr = new NodeTraverser(); | 
| 57 | 59 | $tr->addVisitor(new RemoveUse()); | 
| 58 | 60 | $tr->addVisitor(new RemoveTrait()); | 
| @@ -66,7 +68,8 @@ discard block | ||
| 66 | 68 | $tr = new NodeTraverser(); | 
| 67 | 69 | $tr->addVisitor(new AddUse($node)); | 
| 68 | 70 | |
| 69 | -        if ($removeTrait) { | |
| 71 | + if ($removeTrait) | |
| 72 | +        { | |
| 70 | 73 | $tr->addVisitor(new RemoveUse()); | 
| 71 | 74 | $tr->addVisitor(new RemoveTrait()); | 
| 72 | 75 | } | 
| @@ -20,18 +20,18 @@ discard block | ||
| 20 | 20 |  { | 
| 21 | 21 | public function __construct( | 
| 22 | 22 | private readonly ClassNode $definition | 
| 23 | -    ) { | |
| 23 | +    ){ | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | - public function leaveNode(Node $node): int|Node|null | |
| 26 | + public function leaveNode(Node $node): int | Node | null | |
| 27 | 27 |      { | 
| 28 | -        if (!$node instanceof Node\Stmt\Class_) { | |
| 28 | +        if (!$node instanceof Node\Stmt\Class_){ | |
| 29 | 29 | return null; | 
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | 32 | $constructor = $this->getConstructorAttribute($node); | 
| 33 | 33 | $this->addDependencies($constructor); | 
| 34 | -        if (!$this->definition->hasConstructor && $this->definition->constructorParams) { | |
| 34 | +        if (!$this->definition->hasConstructor && $this->definition->constructorParams){ | |
| 35 | 35 | $this->addParentConstructorCall($constructor); | 
| 36 | 36 | } | 
| 37 | 37 | |
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | */ | 
| 44 | 44 | private function addDependencies(Node\Stmt\ClassMethod $constructor): void | 
| 45 | 45 |      { | 
| 46 | -        foreach ($this->definition->dependencies as $dependency) { | |
| 46 | +        foreach ($this->definition->dependencies as $dependency){ | |
| 47 | 47 | \array_unshift($constructor->params, $this->buildConstructorParam($dependency)); | 
| 48 | 48 | } | 
| 49 | 49 | } | 
| @@ -60,34 +60,34 @@ discard block | ||
| 60 | 60 | private function addParentConstructorCall(Node\Stmt\ClassMethod $constructor): void | 
| 61 | 61 |      { | 
| 62 | 62 | $parentConstructorDependencies = []; | 
| 63 | -        foreach ($this->definition->constructorParams as $param) { | |
| 63 | +        foreach ($this->definition->constructorParams as $param){ | |
| 64 | 64 | $parentConstructorDependencies[] = new Node\Arg(new Node\Expr\Variable($param->name)); | 
| 65 | 65 | |
| 66 | 66 | $cp = new Param($param->name); | 
| 67 | -            if (!empty($param->type)) { | |
| 67 | +            if (!empty($param->type)){ | |
| 68 | 68 | $type = $this->getParamType($param); | 
| 69 | -                if ($param->nullable) { | |
| 69 | +                if ($param->nullable){ | |
| 70 | 70 |                      $type = \sprintf('?%s', $type); | 
| 71 | 71 | } | 
| 72 | 72 | |
| 73 | 73 | $cp->setType(new Node\Name($type)); | 
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | -            if ($param->byRef) { | |
| 76 | +            if ($param->byRef){ | |
| 77 | 77 | $cp->makeByRef(); | 
| 78 | 78 | } | 
| 79 | 79 | |
| 80 | -            if ($param->isVariadic) { | |
| 80 | +            if ($param->isVariadic){ | |
| 81 | 81 | $cp->makeVariadic(); | 
| 82 | 82 | } | 
| 83 | 83 | |
| 84 | -            if ($param->hasDefault) { | |
| 84 | +            if ($param->hasDefault){ | |
| 85 | 85 | $cp->setDefault($param->default); | 
| 86 | 86 | } | 
| 87 | 87 | $constructor->params[] = $cp->getNode(); | 
| 88 | 88 | } | 
| 89 | 89 | |
| 90 | -        if ($parentConstructorDependencies !== []) { | |
| 90 | +        if ($parentConstructorDependencies !== []){ | |
| 91 | 91 | \array_unshift( | 
| 92 | 92 | $constructor->stmts, | 
| 93 | 93 | new Node\Stmt\Expression( | 
| @@ -115,18 +115,18 @@ discard block | ||
| 115 | 115 | |
| 116 | 116 | $params = []; | 
| 117 | 117 | |
| 118 | -        foreach ($this->definition->dependencies as $dependency) { | |
| 118 | +        foreach ($this->definition->dependencies as $dependency){ | |
| 119 | 119 | $params[] = new Annotation\Line( | 
| 120 | 120 |                  \sprintf('%s $%s', $this->getPropertyType($dependency), $dependency->var), | 
| 121 | 121 | 'param' | 
| 122 | 122 | ); | 
| 123 | 123 | } | 
| 124 | 124 | |
| 125 | -        if (!$this->definition->hasConstructor) { | |
| 126 | -            foreach ($this->definition->constructorParams as $param) { | |
| 127 | -                if (!empty($param->type)) { | |
| 125 | +        if (!$this->definition->hasConstructor){ | |
| 126 | +            foreach ($this->definition->constructorParams as $param){ | |
| 127 | +                if (!empty($param->type)){ | |
| 128 | 128 | $type = $this->getParamType($param); | 
| 129 | -                    if ($param->nullable) { | |
| 129 | +                    if ($param->nullable){ | |
| 130 | 130 |                          $type = \sprintf('%s|null', $type); | 
| 131 | 131 | } | 
| 132 | 132 | |
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 | \sprintf($param->isVariadic ? '%s ...$%s' : '%s $%s', $type, $param->name), | 
| 135 | 135 | 'param' | 
| 136 | 136 | ); | 
| 137 | -                } else { | |
| 137 | +                }else{ | |
| 138 | 138 | $params[] = new Annotation\Line( | 
| 139 | 139 |                          \sprintf('$%s', $param->name), | 
| 140 | 140 | 'param' | 
| @@ -145,12 +145,12 @@ discard block | ||
| 145 | 145 | |
| 146 | 146 | $placementID = 0; | 
| 147 | 147 | $previous = null; | 
| 148 | -        foreach ($an->lines as $index => $line) { | |
| 148 | +        foreach ($an->lines as $index => $line){ | |
| 149 | 149 | // always next node | 
| 150 | 150 | $placementID = $index + 1; | 
| 151 | 151 | |
| 152 | 152 | // inject before this parameters | 
| 153 | -            if ($line->is(['throws', 'return'])) { | |
| 153 | +            if ($line->is(['throws', 'return'])){ | |
| 154 | 154 | // insert before given node | 
| 155 | 155 | $placementID--; | 
| 156 | 156 | break; | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 | $previous = $line; | 
| 160 | 160 | } | 
| 161 | 161 | |
| 162 | -        if ($previous !== null && !$previous->isEmpty()) { | |
| 162 | +        if ($previous !== null && !$previous->isEmpty()){ | |
| 163 | 163 | $placementID++; | 
| 164 | 164 | } | 
| 165 | 165 | |
| @@ -170,8 +170,8 @@ discard block | ||
| 170 | 170 | |
| 171 | 171 | private function getPropertyType(Dependency $dependency): string | 
| 172 | 172 |      { | 
| 173 | -        foreach ($this->definition->getStmts() as $stmt) { | |
| 174 | -            if ($stmt->name === $dependency->type->fullName && $stmt->alias) { | |
| 173 | +        foreach ($this->definition->getStmts() as $stmt){ | |
| 174 | +            if ($stmt->name === $dependency->type->fullName && $stmt->alias){ | |
| 175 | 175 | return $stmt->alias; | 
| 176 | 176 | } | 
| 177 | 177 | } | 
| @@ -181,13 +181,13 @@ discard block | ||
| 181 | 181 | |
| 182 | 182 | private function getParamType(ClassNode\ConstructorParam $param): string | 
| 183 | 183 |      { | 
| 184 | -        foreach ($this->definition->getStmts() as $stmt) { | |
| 185 | -            if ($stmt->name === $param->type->fullName && $stmt->alias) { | |
| 184 | +        foreach ($this->definition->getStmts() as $stmt){ | |
| 185 | +            if ($stmt->name === $param->type->fullName && $stmt->alias){ | |
| 186 | 186 | return $stmt->alias; | 
| 187 | 187 | } | 
| 188 | 188 | } | 
| 189 | 189 | |
| 190 | -        if ($param->type->alias) { | |
| 190 | +        if ($param->type->alias){ | |
| 191 | 191 | return $param->type->alias; | 
| 192 | 192 | } | 
| 193 | 193 | |
| @@ -25,13 +25,15 @@ discard block | ||
| 25 | 25 | |
| 26 | 26 | public function leaveNode(Node $node): int|Node|null | 
| 27 | 27 |      { | 
| 28 | -        if (!$node instanceof Node\Stmt\Class_) { | |
| 28 | + if (!$node instanceof Node\Stmt\Class_) | |
| 29 | +        { | |
| 29 | 30 | return null; | 
| 30 | 31 | } | 
| 31 | 32 | |
| 32 | 33 | $constructor = $this->getConstructorAttribute($node); | 
| 33 | 34 | $this->addDependencies($constructor); | 
| 34 | -        if (!$this->definition->hasConstructor && $this->definition->constructorParams) { | |
| 35 | + if (!$this->definition->hasConstructor && $this->definition->constructorParams) | |
| 36 | +        { | |
| 35 | 37 | $this->addParentConstructorCall($constructor); | 
| 36 | 38 | } | 
| 37 | 39 | |
| @@ -43,7 +45,8 @@ discard block | ||
| 43 | 45 | */ | 
| 44 | 46 | private function addDependencies(Node\Stmt\ClassMethod $constructor): void | 
| 45 | 47 |      { | 
| 46 | -        foreach ($this->definition->dependencies as $dependency) { | |
| 48 | + foreach ($this->definition->dependencies as $dependency) | |
| 49 | +        { | |
| 47 | 50 | \array_unshift($constructor->params, $this->buildConstructorParam($dependency)); | 
| 48 | 51 | } | 
| 49 | 52 | } | 
| @@ -60,34 +63,41 @@ discard block | ||
| 60 | 63 | private function addParentConstructorCall(Node\Stmt\ClassMethod $constructor): void | 
| 61 | 64 |      { | 
| 62 | 65 | $parentConstructorDependencies = []; | 
| 63 | -        foreach ($this->definition->constructorParams as $param) { | |
| 66 | + foreach ($this->definition->constructorParams as $param) | |
| 67 | +        { | |
| 64 | 68 | $parentConstructorDependencies[] = new Node\Arg(new Node\Expr\Variable($param->name)); | 
| 65 | 69 | |
| 66 | 70 | $cp = new Param($param->name); | 
| 67 | -            if (!empty($param->type)) { | |
| 71 | + if (!empty($param->type)) | |
| 72 | +            { | |
| 68 | 73 | $type = $this->getParamType($param); | 
| 69 | -                if ($param->nullable) { | |
| 74 | + if ($param->nullable) | |
| 75 | +                { | |
| 70 | 76 |                      $type = \sprintf('?%s', $type); | 
| 71 | 77 | } | 
| 72 | 78 | |
| 73 | 79 | $cp->setType(new Node\Name($type)); | 
| 74 | 80 | } | 
| 75 | 81 | |
| 76 | -            if ($param->byRef) { | |
| 82 | + if ($param->byRef) | |
| 83 | +            { | |
| 77 | 84 | $cp->makeByRef(); | 
| 78 | 85 | } | 
| 79 | 86 | |
| 80 | -            if ($param->isVariadic) { | |
| 87 | + if ($param->isVariadic) | |
| 88 | +            { | |
| 81 | 89 | $cp->makeVariadic(); | 
| 82 | 90 | } | 
| 83 | 91 | |
| 84 | -            if ($param->hasDefault) { | |
| 92 | + if ($param->hasDefault) | |
| 93 | +            { | |
| 85 | 94 | $cp->setDefault($param->default); | 
| 86 | 95 | } | 
| 87 | 96 | $constructor->params[] = $cp->getNode(); | 
| 88 | 97 | } | 
| 89 | 98 | |
| 90 | -        if ($parentConstructorDependencies !== []) { | |
| 99 | + if ($parentConstructorDependencies !== []) | |
| 100 | +        { | |
| 91 | 101 | \array_unshift( | 
| 92 | 102 | $constructor->stmts, | 
| 93 | 103 | new Node\Stmt\Expression( | 
| @@ -115,18 +125,23 @@ discard block | ||
| 115 | 125 | |
| 116 | 126 | $params = []; | 
| 117 | 127 | |
| 118 | -        foreach ($this->definition->dependencies as $dependency) { | |
| 128 | + foreach ($this->definition->dependencies as $dependency) | |
| 129 | +        { | |
| 119 | 130 | $params[] = new Annotation\Line( | 
| 120 | 131 |                  \sprintf('%s $%s', $this->getPropertyType($dependency), $dependency->var), | 
| 121 | 132 | 'param' | 
| 122 | 133 | ); | 
| 123 | 134 | } | 
| 124 | 135 | |
| 125 | -        if (!$this->definition->hasConstructor) { | |
| 126 | -            foreach ($this->definition->constructorParams as $param) { | |
| 127 | -                if (!empty($param->type)) { | |
| 136 | + if (!$this->definition->hasConstructor) | |
| 137 | +        { | |
| 138 | + foreach ($this->definition->constructorParams as $param) | |
| 139 | +            { | |
| 140 | + if (!empty($param->type)) | |
| 141 | +                { | |
| 128 | 142 | $type = $this->getParamType($param); | 
| 129 | -                    if ($param->nullable) { | |
| 143 | + if ($param->nullable) | |
| 144 | +                    { | |
| 130 | 145 |                          $type = \sprintf('%s|null', $type); | 
| 131 | 146 | } | 
| 132 | 147 | |
| @@ -134,7 +149,9 @@ discard block | ||
| 134 | 149 | \sprintf($param->isVariadic ? '%s ...$%s' : '%s $%s', $type, $param->name), | 
| 135 | 150 | 'param' | 
| 136 | 151 | ); | 
| 137 | -                } else { | |
| 152 | + } | |
| 153 | + else | |
| 154 | +                { | |
| 138 | 155 | $params[] = new Annotation\Line( | 
| 139 | 156 |                          \sprintf('$%s', $param->name), | 
| 140 | 157 | 'param' | 
| @@ -145,12 +162,14 @@ discard block | ||
| 145 | 162 | |
| 146 | 163 | $placementID = 0; | 
| 147 | 164 | $previous = null; | 
| 148 | -        foreach ($an->lines as $index => $line) { | |
| 165 | + foreach ($an->lines as $index => $line) | |
| 166 | +        { | |
| 149 | 167 | // always next node | 
| 150 | 168 | $placementID = $index + 1; | 
| 151 | 169 | |
| 152 | 170 | // inject before this parameters | 
| 153 | -            if ($line->is(['throws', 'return'])) { | |
| 171 | + if ($line->is(['throws', 'return'])) | |
| 172 | +            { | |
| 154 | 173 | // insert before given node | 
| 155 | 174 | $placementID--; | 
| 156 | 175 | break; | 
| @@ -159,7 +178,8 @@ discard block | ||
| 159 | 178 | $previous = $line; | 
| 160 | 179 | } | 
| 161 | 180 | |
| 162 | -        if ($previous !== null && !$previous->isEmpty()) { | |
| 181 | + if ($previous !== null && !$previous->isEmpty()) | |
| 182 | +        { | |
| 163 | 183 | $placementID++; | 
| 164 | 184 | } | 
| 165 | 185 | |
| @@ -170,8 +190,10 @@ discard block | ||
| 170 | 190 | |
| 171 | 191 | private function getPropertyType(Dependency $dependency): string | 
| 172 | 192 |      { | 
| 173 | -        foreach ($this->definition->getStmts() as $stmt) { | |
| 174 | -            if ($stmt->name === $dependency->type->fullName && $stmt->alias) { | |
| 193 | + foreach ($this->definition->getStmts() as $stmt) | |
| 194 | +        { | |
| 195 | + if ($stmt->name === $dependency->type->fullName && $stmt->alias) | |
| 196 | +            { | |
| 175 | 197 | return $stmt->alias; | 
| 176 | 198 | } | 
| 177 | 199 | } | 
| @@ -181,13 +203,16 @@ discard block | ||
| 181 | 203 | |
| 182 | 204 | private function getParamType(ClassNode\ConstructorParam $param): string | 
| 183 | 205 |      { | 
| 184 | -        foreach ($this->definition->getStmts() as $stmt) { | |
| 185 | -            if ($stmt->name === $param->type->fullName && $stmt->alias) { | |
| 206 | + foreach ($this->definition->getStmts() as $stmt) | |
| 207 | +        { | |
| 208 | + if ($stmt->name === $param->type->fullName && $stmt->alias) | |
| 209 | +            { | |
| 186 | 210 | return $stmt->alias; | 
| 187 | 211 | } | 
| 188 | 212 | } | 
| 189 | 213 | |
| 190 | -        if ($param->type->alias) { | |
| 214 | + if ($param->type->alias) | |
| 215 | +        { | |
| 191 | 216 | return $param->type->alias; | 
| 192 | 217 | } | 
| 193 | 218 | |
| @@ -39,13 +39,13 @@ discard block | ||
| 39 | 39 | $node->var instanceof Node\Expr\Variable && | 
| 40 | 40 | $node->var->name === 'this' && | 
| 41 | 41 | $node->name instanceof Node\Identifier | 
| 42 | -        ) { | |
| 42 | +        ){ | |
| 43 | 43 | $this->requested[$node->name->name] = $node->name->name; | 
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | -        if ($node instanceof Node\Stmt\Property) { | |
| 47 | -            foreach ($node->props as $prop) { | |
| 48 | -                if ($prop instanceof Node\Stmt\PropertyProperty) { | |
| 46 | +        if ($node instanceof Node\Stmt\Property){ | |
| 47 | +            foreach ($node->props as $prop){ | |
| 48 | +                if ($prop instanceof Node\Stmt\PropertyProperty){ | |
| 49 | 49 | $this->properties[$prop->name->name] = $prop->name->name; | 
| 50 | 50 | } | 
| 51 | 51 | } | 
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 | |
| 57 | 57 | private function promotedProperties(Node $node): void | 
| 58 | 58 |      { | 
| 59 | -        if (!$node instanceof Node\Param || !$node->var instanceof Node\Expr\Variable) { | |
| 59 | +        if (!$node instanceof Node\Param || !$node->var instanceof Node\Expr\Variable){ | |
| 60 | 60 | return; | 
| 61 | 61 | } | 
| 62 | 62 | |
| @@ -64,7 +64,7 @@ discard block | ||
| 64 | 64 | $node->flags === Node\Stmt\Class_::MODIFIER_PUBLIC || | 
| 65 | 65 | $node->flags === Node\Stmt\Class_::MODIFIER_PROTECTED || | 
| 66 | 66 | $node->flags === Node\Stmt\Class_::MODIFIER_PRIVATE | 
| 67 | -        ) { | |
| 67 | +        ){ | |
| 68 | 68 | $this->properties[$node->var->name] = $node->var->name; | 
| 69 | 69 | } | 
| 70 | 70 | } | 
| @@ -43,9 +43,12 @@ discard block | ||
| 43 | 43 | $this->requested[$node->name->name] = $node->name->name; | 
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | -        if ($node instanceof Node\Stmt\Property) { | |
| 47 | -            foreach ($node->props as $prop) { | |
| 48 | -                if ($prop instanceof Node\Stmt\PropertyProperty) { | |
| 46 | + if ($node instanceof Node\Stmt\Property) | |
| 47 | +        { | |
| 48 | + foreach ($node->props as $prop) | |
| 49 | +            { | |
| 50 | + if ($prop instanceof Node\Stmt\PropertyProperty) | |
| 51 | +                { | |
| 49 | 52 | $this->properties[$prop->name->name] = $prop->name->name; | 
| 50 | 53 | } | 
| 51 | 54 | } | 
| @@ -56,7 +59,8 @@ discard block | ||
| 56 | 59 | |
| 57 | 60 | private function promotedProperties(Node $node): void | 
| 58 | 61 |      { | 
| 59 | -        if (!$node instanceof Node\Param || !$node->var instanceof Node\Expr\Variable) { | |
| 62 | + if (!$node instanceof Node\Param || !$node->var instanceof Node\Expr\Variable) | |
| 63 | +        { | |
| 60 | 64 | return; | 
| 61 | 65 | } | 
| 62 | 66 | |
| @@ -21,7 +21,7 @@ discard block | ||
| 21 | 21 |      { | 
| 22 | 22 | $i = new Injector(); | 
| 23 | 23 | |
| 24 | - $filename = __DIR__ . '/Fixtures/TestClass.php'; | |
| 24 | + $filename = __DIR__.'/Fixtures/TestClass.php'; | |
| 25 | 25 | $r = $i->injectDependencies( | 
| 26 | 26 | file_get_contents($filename), | 
| 27 | 27 | $this->getDefinition( | 
| @@ -34,10 +34,10 @@ discard block | ||
| 34 | 34 | ) | 
| 35 | 35 | ); | 
| 36 | 36 | |
| 37 | - $this->assertStringContainsString(Fixtures\Some::class . ';', $r); | |
| 38 | - $this->assertStringContainsString(Fixtures\SubFolder\Some::class . ' as Some2;', $r); | |
| 39 | - $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class . ';', $r); | |
| 40 | - $this->assertStringContainsString(Fixtures\ATest3::class . ';', $r); | |
| 37 | + $this->assertStringContainsString(Fixtures\Some::class.';', $r); | |
| 38 | + $this->assertStringContainsString(Fixtures\SubFolder\Some::class.' as Some2;', $r); | |
| 39 | + $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class.';', $r); | |
| 40 | + $this->assertStringContainsString(Fixtures\ATest3::class.';', $r); | |
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | 43 | /** | 
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 |      { | 
| 48 | 48 | $i = new Injector(); | 
| 49 | 49 | |
| 50 | - $filename = __DIR__ . '/Fixtures/TestClassWithImports.php'; | |
| 50 | + $filename = __DIR__.'/Fixtures/TestClassWithImports.php'; | |
| 51 | 51 | $r = $i->injectDependencies( | 
| 52 | 52 | file_get_contents($filename), | 
| 53 | 53 | $this->getDefinition( | 
| @@ -60,12 +60,12 @@ discard block | ||
| 60 | 60 | ) | 
| 61 | 61 | ); | 
| 62 | 62 | |
| 63 | - $this->assertStringContainsString(Fixtures\Some::class . ' as FTest;', $r); | |
| 64 | - $this->assertStringNotContainsString(Fixtures\Some::class . ';', $r); | |
| 65 | - $this->assertStringContainsString(Fixtures\SubFolder\Some::class . ' as TestAlias;', $r); | |
| 66 | - $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class . ';', $r); | |
| 67 | - $this->assertStringContainsString(Fixtures\ATest3::class . ' as ATest;', $r); | |
| 68 | - $this->assertStringNotContainsString(Fixtures\ATest3::class . ';', $r); | |
| 63 | + $this->assertStringContainsString(Fixtures\Some::class.' as FTest;', $r); | |
| 64 | + $this->assertStringNotContainsString(Fixtures\Some::class.';', $r); | |
| 65 | + $this->assertStringContainsString(Fixtures\SubFolder\Some::class.' as TestAlias;', $r); | |
| 66 | + $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class.';', $r); | |
| 67 | + $this->assertStringContainsString(Fixtures\ATest3::class.' as ATest;', $r); | |
| 68 | + $this->assertStringNotContainsString(Fixtures\ATest3::class.';', $r); | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 | /** | 
| @@ -75,7 +75,7 @@ discard block | ||
| 75 | 75 |      { | 
| 76 | 76 | $i = new Injector(); | 
| 77 | 77 | |
| 78 | - $filename = __DIR__ . '/Fixtures/ChildClass.php'; | |
| 78 | + $filename = __DIR__.'/Fixtures/ChildClass.php'; | |
| 79 | 79 | $r = $i->injectDependencies( | 
| 80 | 80 | file_get_contents($filename), | 
| 81 | 81 | $this->getDefinition( | 
| @@ -88,18 +88,18 @@ discard block | ||
| 88 | 88 | ) | 
| 89 | 89 | ); | 
| 90 | 90 | |
| 91 | - $this->assertStringContainsString(Fixtures\Some::class . ';', $r); | |
| 92 | - $this->assertStringContainsString(Fixtures\SubFolder\Some::class . ' as Some2;', $r); | |
| 93 | - $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class . ';', $r); | |
| 94 | - $this->assertStringContainsString(Fixtures\ATest3::class . ' as ATestAlias;', $r); | |
| 95 | - $this->assertStringNotContainsString(Fixtures\ATest3::class . ';', $r); | |
| 91 | + $this->assertStringContainsString(Fixtures\Some::class.';', $r); | |
| 92 | + $this->assertStringContainsString(Fixtures\SubFolder\Some::class.' as Some2;', $r); | |
| 93 | + $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class.';', $r); | |
| 94 | + $this->assertStringContainsString(Fixtures\ATest3::class.' as ATestAlias;', $r); | |
| 95 | + $this->assertStringNotContainsString(Fixtures\ATest3::class.';', $r); | |
| 96 | 96 | } | 
| 97 | 97 | |
| 98 | 98 | public function testDuplicateProperty(): void | 
| 99 | 99 |      { | 
| 100 | 100 | $i = new Injector(); | 
| 101 | 101 | |
| 102 | - $filename = __DIR__ . '/Fixtures/DuplicatePropertyClass.php'; | |
| 102 | + $filename = __DIR__.'/Fixtures/DuplicatePropertyClass.php'; | |
| 103 | 103 | $r = $i->injectDependencies( | 
| 104 | 104 | file_get_contents($filename), | 
| 105 | 105 | $this->getDefinition( | 
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 | ) | 
| 111 | 111 | ); | 
| 112 | 112 | |
| 113 | - $this->assertStringContainsString(Fixtures\Some::class . ';', $r); | |
| 113 | + $this->assertStringContainsString(Fixtures\Some::class.';', $r); | |
| 114 | 114 |          $this->assertStringContainsString('__construct(private readonly Some $test)', $r); | 
| 115 | 115 | } | 
| 116 | 116 | |