Passed
Push — type-resolver ( 5b5dc4...e8ec77 )
by Luis
11:11
created
src/Parser/Code/ExternalDefinitionsResolver.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     {
26 26
         /** @var ClassDefinition|InterfaceDefinition|TraitDefinition $definition */
27 27
         foreach ($codebase->definitions() as $definition) {
28
-            match (true) {
28
+            match(true) {
29 29
                 $definition instanceof ClassDefinition => $this->resolveForClass($definition, $codebase),
30 30
                 $definition instanceof InterfaceDefinition => $this->resolveInterfaces($definition->parents(), $codebase),
31 31
                 default => $this->resolveTraits($definition->traits(), $codebase),
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
     /** @param Name[] $interfaces */
47 47
     private function resolveInterfaces(array $interfaces, Codebase $codebase): void
48 48
     {
49
-        array_map(static function (Name $interface) use ($codebase): void {
50
-            if (! $codebase->has($interface)) {
49
+        array_map(static function(Name $interface) use ($codebase): void {
50
+            if (!$codebase->has($interface)) {
51 51
                 $codebase->add(new InterfaceDefinition($interface));
52 52
             }
53 53
         }, $interfaces);
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
     /** @param Name[] $traits */
57 57
     private function resolveTraits(array $traits, Codebase $codebase): void
58 58
     {
59
-        array_map(static function (Name $trait) use ($codebase): void {
60
-            if (! $codebase->has($trait)) {
59
+        array_map(static function(Name $trait) use ($codebase): void {
60
+            if (!$codebase->has($trait)) {
61 61
                 $codebase->add(new TraitDefinition($trait));
62 62
             }
63 63
         }, $traits);
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 
66 66
     private function resolveExternalParentClass(ClassDefinition $definition, Codebase $codebase): void
67 67
     {
68
-        if (! $definition->hasParent()) {
68
+        if (!$definition->hasParent()) {
69 69
             return;
70 70
         }
71 71
         $parent = $definition->parent();
72
-        if (! $codebase->has($parent)) {
72
+        if (!$codebase->has($parent)) {
73 73
             $codebase->add(new ClassDefinition($parent));
74 74
         }
75 75
     }
Please login to merge, or discard this patch.
src/Parser/Code/Builders/TagType.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function resolve(UseStatements $useStatements): TypeDeclaration
38 38
     {
39
-        return match (true) {
39
+        return match(true) {
40 40
             $this->isNullable => TypeDeclaration::fromNullable($useStatements->fullyQualifiedNameFor($this->types()[0])),
41 41
             count($this->types) === 1 => TypeDeclaration::from($useStatements->fullyQualifiedNameFor($this->types()[0])),
42 42
             default => $this->resolveUnionTypes($useStatements),
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     private function resolveUnionTypes(UseStatements $useStatements): TypeDeclaration
47 47
     {
48 48
         $withFullyQualifiedNames = array_map(
49
-            static fn (Name $type) => $useStatements->fullyQualifiedNameFor($type),
49
+            static fn(Name $type) => $useStatements->fullyQualifiedNameFor($type),
50 50
             $this->types(),
51 51
         );
52 52
         return TypeDeclaration::fromUnionType($withFullyQualifiedNames);
@@ -55,6 +55,6 @@  discard block
 block discarded – undo
55 55
     /** @return Name[] */
56 56
     private function types(): array
57 57
     {
58
-        return array_map(static fn (string $type) => new Name(ltrim($type, characters: '\\')), $this->types);
58
+        return array_map(static fn(string $type) => new Name(ltrim($type, characters: '\\')), $this->types);
59 59
     }
60 60
 }
Please login to merge, or discard this patch.
src/Parser/Code/Builders/MembersBuilder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     public function constants(array $members): array
45 45
     {
46 46
         /** @var ClassConst[] $constants */
47
-        $constants = array_filter($members, static fn ($attribute): bool => $attribute instanceof ClassConst);
47
+        $constants = array_filter($members, static fn($attribute): bool => $attribute instanceof ClassConst);
48 48
 
49 49
         /** @var ClassConst[] $filteredConstants */
50 50
         $filteredConstants = $this->filters->apply($constants);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         }
65 65
 
66 66
         /** @var Property[] $properties */
67
-        $properties = array_filter($members, static fn ($attribute): bool => $attribute instanceof Property);
67
+        $properties = array_filter($members, static fn($attribute): bool => $attribute instanceof Property);
68 68
 
69 69
         /** @var Property[] $filteredAttributes */
70 70
         $filteredAttributes = $this->filters->apply($properties);
Please login to merge, or discard this patch.
src/Parser/Code/Builders/Members/ParsedConstantsBuilder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function build(array $classConstants): array
37 37
     {
38
-        return array_map(fn (ClassConst $constant): Constant => new Constant(
39
-            (string) $constant->consts[0]->name,
38
+        return array_map(fn(ClassConst $constant): Constant => new Constant(
39
+            (string)$constant->consts[0]->name,
40 40
             TypeDeclaration::from($this->determineType($constant->consts[0])),
41 41
             $this->visibilityBuilder->build($constant)
42 42
         ), $classConstants);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         if (property_exists($constant->value, 'value')) {
48 48
             return self::TYPES[\gettype($constant->value->value)];
49 49
         }
50
-        if (! $constant->value instanceof ConstFetch) {
50
+        if (!$constant->value instanceof ConstFetch) {
51 51
             return null;
52 52
         }
53 53
         return 'bool';
Please login to merge, or discard this patch.
src/Parser/Code/Builders/Members/ParsedAttributesBuilder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function build(array $parsedAttributes, UseStatements $useStatements): array
39 39
     {
40
-        return array_map(function (Property $attribute) use ($useStatements): Attribute {
40
+        return array_map(function(Property $attribute) use ($useStatements): Attribute {
41 41
             $variable = new Variable(
42 42
                 "\${$attribute->props[0]->name}",
43 43
                 $this->typeBuilder->fromAttributeType($attribute->type, $attribute->getDocComment(), $useStatements)
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
     {
57 57
         $promotedProperties = array_filter(
58 58
             $constructorParameters,
59
-            static fn (Node\Param $param) => $param->flags !== 0
59
+            static fn(Node\Param $param) => $param->flags !== 0
60 60
         );
61 61
 
62
-        return array_map(function (Node\Param $param) use ($useStatements): Attribute {
62
+        return array_map(function(Node\Param $param) use ($useStatements): Attribute {
63 63
             /** @var Node\Expr\Variable $var */
64 64
             $var = $param->var;
65 65
 
Please login to merge, or discard this patch.
src/Parser/Code/Builders/Members/TypeBuilder.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public function fromMethodParameter(
26
-        Identifier|Name|NullableType|UnionType|null $type,
26
+        Identifier | Name | NullableType | UnionType | null $type,
27 27
         ?Doc $docBlock,
28 28
         string $name,
29 29
         UseStatements $useStatements
30 30
     ): TypeDeclaration {
31
-        $methodComment = $docBlock?->getText();
31
+        $methodComment = $docBlock ? ->getText();
32 32
         if ($type === null) {
33 33
             return $this->typeResolver->resolveForParameter($methodComment, $name, $useStatements);
34 34
         }
35 35
 
36 36
         $typeDeclaration = $this->fromParsedType($type);
37
-        if (! $typeDeclaration->isBuiltInArray()) {
37
+        if (!$typeDeclaration->isBuiltInArray()) {
38 38
             return $typeDeclaration;
39 39
         }
40 40
 
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
     }
45 45
 
46 46
     public function fromMethodReturnType(
47
-        Identifier|Name|NullableType|UnionType|null $type,
47
+        Identifier | Name | NullableType | UnionType | null $type,
48 48
         ?Doc $docBlock,
49 49
         UseStatements $useStatements
50 50
     ): TypeDeclaration {
51
-        $methodComment = $docBlock?->getText();
51
+        $methodComment = $docBlock ? ->getText();
52 52
         if ($type === null) {
53 53
             return $this->typeResolver->resolveForReturn($methodComment, $useStatements);
54 54
         }
55 55
 
56 56
         $typeDeclaration = $this->fromParsedType($type);
57
-        if (! $typeDeclaration->isBuiltInArray()) {
57
+        if (!$typeDeclaration->isBuiltInArray()) {
58 58
             return $typeDeclaration;
59 59
         }
60 60
 
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
     public function fromAttributeType(
67
-        Identifier|Name|NullableType|UnionType|null $type,
67
+        Identifier | Name | NullableType | UnionType | null $type,
68 68
         ?Doc $docBlock,
69 69
         UseStatements $useStatements
70 70
     ): TypeDeclaration {
71
-        $attributeComment = $docBlock?->getText();
71
+        $attributeComment = $docBlock ? ->getText();
72 72
         if ($type === null) {
73 73
             return $this->typeResolver->resolveForAttribute($attributeComment, $useStatements);
74 74
         }
75 75
 
76 76
         $typeDeclaration = $this->fromParsedType($type);
77
-        if (! $typeDeclaration->isBuiltInArray()) {
77
+        if (!$typeDeclaration->isBuiltInArray()) {
78 78
             return $typeDeclaration;
79 79
         }
80 80
 
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
         return $typeFromDocBlock->isPresent() ? $typeFromDocBlock : $typeDeclaration;
84 84
     }
85 85
 
86
-    private function fromParsedType(Identifier|Name|NullableType|UnionType|null $type): TypeDeclaration
86
+    private function fromParsedType(Identifier | Name | NullableType | UnionType | null $type): TypeDeclaration
87 87
     {
88
-        return match (true) {
89
-            $type instanceof NullableType => TypeDeclaration::fromNullable((string) $type->type),
90
-            $type instanceof Name, $type instanceof Identifier => TypeDeclaration::from((string) $type),
88
+        return match(true) {
89
+            $type instanceof NullableType => TypeDeclaration::fromNullable((string)$type->type),
90
+            $type instanceof Name, $type instanceof Identifier => TypeDeclaration::from((string)$type),
91 91
             $type === null => TypeDeclaration::absent(),
92 92
             default => TypeDeclaration::fromUnionType($this->fromUnionType($type)),
93 93
         };
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     private function fromUnionType(UnionType $type): array
98 98
     {
99 99
         return array_map(
100
-            static fn (Identifier|Name $name): string => (string) $name,
100
+            static fn(Identifier | Name $name): string => (string)$name,
101 101
             $type->types
102 102
         );
103 103
     }
Please login to merge, or discard this patch.
src/Parser/Code/Builders/Members/VisibilityFilters.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
     {
44 44
         $members = $definitionMembers;
45 45
         foreach ($this->filters as $filter) {
46
-            $members = array_filter($members, static fn (Stmt $member): bool => $filter->accept($member));
46
+            $members = array_filter($members, static fn(Stmt $member): bool => $filter->accept($member));
47 47
         }
48 48
         return $members;
49 49
     }
Please login to merge, or discard this patch.
src/Parser/Code/Builders/Members/ParsedMethodsBuilder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public function build(array $methods, UseStatements $useStatements): array
37 37
     {
38 38
         return array_map(
39
-            fn (ClassMethod $method): Method => $this->buildMethod($method, $useStatements),
39
+            fn(ClassMethod $method): Method => $this->buildMethod($method, $useStatements),
40 40
             $methods
41 41
         );
42 42
     }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         $docBlock = $method->getDocComment();
49 49
         $returnType = $this->typeBuilder->fromMethodReturnType($method->returnType, $docBlock, $useStatements);
50 50
         $parameters = $this->parametersBuilder->build($method->params, $docBlock, $useStatements);
51
-        return match (true) {
51
+        return match(true) {
52 52
             $method->isAbstract() => new Method($name, $visibility, $returnType, $parameters, isAbstract: true),
53 53
             $method->isStatic() => new Method($name, $visibility, $returnType, $parameters, isStatic: true),
54 54
             default => new Method($name, $visibility, $returnType, $parameters),
Please login to merge, or discard this patch.
src/Parser/Code/Builders/UseStatementsBuilder.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
 
21 21
 final class UseStatementsBuilder
22 22
 {
23
-    public function build(Class_|Interface_|Trait_ $definition): UseStatements
23
+    public function build(Class_ | Interface_ | Trait_ $definition): UseStatements
24 24
     {
25 25
         $uses = [];
26 26
 
27 27
         $previous = $definition->getAttribute('previous');
28 28
         while ($previous instanceof Use_ || $previous instanceof GroupUse) {
29 29
             if ($previous instanceof Use_) {
30
-                $uses[] = array_map(fn (UseUse $use): UseStatement => $this->fromUseStatement($use), $previous->uses);
30
+                $uses[] = array_map(fn(UseUse $use): UseStatement => $this->fromUseStatement($use), $previous->uses);
31 31
             } else {
32
-                $prefix = (string) $previous->prefix;
32
+                $prefix = (string)$previous->prefix;
33 33
                 $uses[] = array_map(
34
-                    fn (UseUse $use): UseStatement => $this->fromGroupedUse($use, $prefix),
34
+                    fn(UseUse $use): UseStatement => $this->fromGroupedUse($use, $prefix),
35 35
                     $previous->uses
36 36
                 );
37 37
             }
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $alias = null;
47 47
         if ($use->alias !== null) {
48
-            $alias = new Name((string) $use->alias);
48
+            $alias = new Name((string)$use->alias);
49 49
         }
50
-        return new UseStatement(new Name((string) $use->name), $alias);
50
+        return new UseStatement(new Name((string)$use->name), $alias);
51 51
     }
52 52
 
53 53
     private function fromGroupedUse(UseUse $use, string $prefix): UseStatement
54 54
     {
55 55
         $alias = null;
56 56
         if ($use->alias !== null) {
57
-            $alias = new Name((string) $use->alias);
57
+            $alias = new Name((string)$use->alias);
58 58
         }
59
-        return new UseStatement(new Name((string) ParsedName::concat($prefix, $use->name)), $alias);
59
+        return new UseStatement(new Name((string)ParsedName::concat($prefix, $use->name)), $alias);
60 60
     }
61 61
 }
Please login to merge, or discard this patch.