@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | public function build(array $parsedAttributes, UseStatements $useStatements): array |
40 | 40 | { |
41 | 41 | /** @var Property[] $attributes */ |
42 | - $attributes = array_filter($parsedAttributes, static fn ($attribute): bool => $attribute instanceof Property); |
|
42 | + $attributes = array_filter($parsedAttributes, static fn($attribute): bool => $attribute instanceof Property); |
|
43 | 43 | |
44 | - return array_map(function (Property $attribute) use ($useStatements): Attribute { |
|
44 | + return array_map(function(Property $attribute) use ($useStatements): Attribute { |
|
45 | 45 | $variable = new Variable( |
46 | 46 | "\${$attribute->props[0]->name}", |
47 | 47 | $this->typeBuilder->fromAttributeType($attribute->type, $attribute->getDocComment(), $useStatements) |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | { |
61 | 61 | $promotedProperties = array_filter( |
62 | 62 | $constructorParameters, |
63 | - static fn (Node\Param $param) => $param->flags !== 0 |
|
63 | + static fn(Node\Param $param) => $param->flags !== 0 |
|
64 | 64 | ); |
65 | 65 | |
66 | - return array_map(function (Node\Param $param) use ($useStatements): Attribute { |
|
66 | + return array_map(function(Node\Param $param) use ($useStatements): Attribute { |
|
67 | 67 | /** @var Node\Expr\Variable $var */ |
68 | 68 | $var = $param->var; |
69 | 69 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function build(array $methods, UseStatements $useStatements): array |
38 | 38 | { |
39 | 39 | return array_map( |
40 | - fn (ClassMethod $method): Method => $this->buildMethod($method, $useStatements), |
|
40 | + fn(ClassMethod $method): Method => $this->buildMethod($method, $useStatements), |
|
41 | 41 | $this->visibilityFilters->apply($methods) |
42 | 42 | ); |
43 | 43 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $docBlock = $method->getDocComment(); |
50 | 50 | $returnType = $this->typeBuilder->fromMethodReturnType($method->returnType, $docBlock, $useStatements); |
51 | 51 | $parameters = $this->parametersBuilder->build($method->params, $docBlock, $useStatements); |
52 | - return match (true) { |
|
52 | + return match(true) { |
|
53 | 53 | $method->isAbstract() => new Method($name, $visibility, $returnType, $parameters, isAbstract: true), |
54 | 54 | $method->isStatic() => new Method($name, $visibility, $returnType, $parameters, isStatic: true), |
55 | 55 | default => new Method($name, $visibility, $returnType, $parameters), |
@@ -23,18 +23,18 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
97 | 97 | private function fromUnionType(UnionType $type): array |
98 | 98 | { |
99 | 99 | return array_map( |
100 | - static fn (Identifier|Name $name): string => $name instanceof Identifier ? $name->name : (string) $name, |
|
100 | + static fn(Identifier | Name $name): string => $name instanceof Identifier ? $name->name : (string)$name, |
|
101 | 101 | $type->types |
102 | 102 | ); |
103 | 103 | } |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | public function build(array $classAttributes): array |
40 | 40 | { |
41 | 41 | /** @var ClassConst[] $constants */ |
42 | - $constants = array_filter($classAttributes, static fn ($attribute): bool => $attribute instanceof ClassConst); |
|
42 | + $constants = array_filter($classAttributes, static fn($attribute): bool => $attribute instanceof ClassConst); |
|
43 | 43 | |
44 | - return array_map(fn (ClassConst $constant): Constant => new Constant( |
|
45 | - (string) $constant->consts[0]->name, |
|
44 | + return array_map(fn(ClassConst $constant): Constant => new Constant( |
|
45 | + (string)$constant->consts[0]->name, |
|
46 | 46 | TypeDeclaration::from($this->determineType($constant->consts[0])), |
47 | 47 | $this->visibilityBuilder->build($constant) |
48 | 48 | ), $this->visibilityFilters->apply($constants)); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if (property_exists($constant->value, 'value')) { |
54 | 54 | return self::TYPES[\gettype($constant->value->value)]; |
55 | 55 | } |
56 | - if (! $constant->value instanceof ConstFetch) { |
|
56 | + if (!$constant->value instanceof ConstFetch) { |
|
57 | 57 | return null; |
58 | 58 | } |
59 | 59 | return 'bool'; |
@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | public function build(array $parameters, ?Doc $methodDocBlock, UseStatements $useStatements): array |
27 | 27 | { |
28 | - return array_map(function (Param $parameter) use ($methodDocBlock, $useStatements): Parameter { |
|
28 | + return array_map(function(Param $parameter) use ($methodDocBlock, $useStatements) : Parameter { |
|
29 | 29 | /** @var \PhpParser\Node\Expr\Variable $parsedParameter Since the parser throws error by default */ |
30 | 30 | $parsedParameter = $parameter->var; |
31 | 31 |
@@ -20,18 +20,18 @@ discard block |
||
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 |
||
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, (string) $use->name)), $alias); |
|
59 | + return new UseStatement(new Name((string)ParsedName::concat($prefix, (string)$use->name)), $alias); |
|
60 | 60 | } |
61 | 61 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | $useStatements = $this->useStatementsBuilder->build($interface); |
34 | 34 | return new InterfaceDefinition( |
35 | - new InterfaceDefinitionName((string) $interface->namespacedName), |
|
35 | + new InterfaceDefinitionName((string)$interface->namespacedName), |
|
36 | 36 | $this->membersBuilder->methods($interface->getMethods(), $useStatements), |
37 | 37 | $this->membersBuilder->constants($interface->stmts), |
38 | 38 | $this->buildInterfaces($interface->extends) |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | /** @param Name[] $interfaces */ |
48 | 48 | private function resolveExternalInterfaces(array $interfaces, Codebase $codebase): void |
49 | 49 | { |
50 | - array_map(static function (Name $interface) use ($codebase): void { |
|
51 | - if (! $codebase->has($interface)) { |
|
50 | + array_map(static function(Name $interface) use ($codebase): void { |
|
51 | + if (!$codebase->has($interface)) { |
|
52 | 52 | $codebase->add(new InterfaceDefinition($interface)); |
53 | 53 | } |
54 | 54 | }, $interfaces); |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | /** @param Name[] $traits */ |
58 | 58 | private function resolveExternalTraits(array $traits, Codebase $codebase): void |
59 | 59 | { |
60 | - array_map(static function (Name $trait) use ($codebase): void { |
|
61 | - if (! $codebase->has($trait)) { |
|
60 | + array_map(static function(Name $trait) use ($codebase): void { |
|
61 | + if (!$codebase->has($trait)) { |
|
62 | 62 | $codebase->add(new TraitDefinition($trait)); |
63 | 63 | } |
64 | 64 | }, $traits); |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | |
67 | 67 | private function resolveExternalParentClass(ClassDefinition $definition, Codebase $codebase): void |
68 | 68 | { |
69 | - if (! $definition->hasParent()) { |
|
69 | + if (!$definition->hasParent()) { |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | $parent = $definition->parent(); |
73 | - if (! $codebase->has($parent)) { |
|
73 | + if (!$codebase->has($parent)) { |
|
74 | 74 | $codebase->add(new ClassDefinition($parent)); |
75 | 75 | } |
76 | 76 | } |
@@ -24,6 +24,6 @@ |
||
24 | 24 | return $useStatement->fullyQualifiedName($name); |
25 | 25 | } |
26 | 26 | } |
27 | - return (string) $name; |
|
27 | + return (string)$name; |
|
28 | 28 | } |
29 | 29 | } |