@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $edges = []; |
| 60 | 60 | foreach ($variables as $parameter) { |
| 61 | - if (! $this->needAssociation($class, $parameter)) { |
|
| 61 | + if (!$this->needAssociation($class, $parameter)) { |
|
| 62 | 62 | continue; |
| 63 | 63 | } |
| 64 | 64 | $edges[] = $this->addAssociations($class, $parameter, $codebase); |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | $this->markAssociationResolvedFor($class, $attribute); |
| 73 | 73 | |
| 74 | 74 | return array_map( |
| 75 | - fn (Name $reference): Edge => Edge::association($codebase->get($reference), $class), |
|
| 75 | + fn(Name $reference): Edge => Edge::association($codebase->get($reference), $class), |
|
| 76 | 76 | $attribute->references() |
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | private function needAssociation(ClassDefinition $class, HasType $attribute): bool |
| 81 | 81 | { |
| 82 | - return ! $this->isAssociationResolved($class, $attribute); |
|
| 82 | + return !$this->isAssociationResolved($class, $attribute); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | private function isAssociationResolved(ClassDefinition $class, HasType $attribute): bool |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | private function extractReturnType(?string $comment): void |
| 53 | 53 | { |
| 54 | - if (preg_match(self::RETURN_EXPRESSION, (string) $comment, $matches) === 1) { |
|
| 54 | + if (preg_match(self::RETURN_EXPRESSION, (string)$comment, $matches) === 1) { |
|
| 55 | 55 | $this->returnType = TypeDeclaration::from($matches[1]); |
| 56 | 56 | return; |
| 57 | 57 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | private function extractParametersTypes(?string $comment): void |
| 63 | 63 | { |
| 64 | - if (preg_match_all(self::PARAMETER_EXPRESSION, (string) $comment, $matches) < 1) { |
|
| 64 | + if (preg_match_all(self::PARAMETER_EXPRESSION, (string)$comment, $matches) < 1) { |
|
| 65 | 65 | $this->parametersTypes = []; |
| 66 | 66 | return; |
| 67 | 67 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | private function extractType(?string $comment): void |
| 37 | 37 | { |
| 38 | - if (preg_match(self::VAR_EXPRESSION, (string) $comment, $matches) === 1) { |
|
| 38 | + if (preg_match(self::VAR_EXPRESSION, (string)$comment, $matches) === 1) { |
|
| 39 | 39 | $this->attributeType = TypeDeclaration::from($matches[1]); |
| 40 | 40 | return; |
| 41 | 41 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | /** @param string[] $types */ |
| 49 | 49 | public static function fromUnionType(array $types): TypeDeclaration |
| 50 | 50 | { |
| 51 | - return new TypeDeclaration(array_map(static fn (string $type) => new Name($type), $types)); |
|
| 51 | + return new TypeDeclaration(array_map(static fn(string $type) => new Name($type), $types)); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function isPresent(): bool |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | /** @return Name[] */ |
| 60 | 60 | public function references(): array |
| 61 | 61 | { |
| 62 | - if (! $this->isPresent()) { |
|
| 62 | + if (!$this->isPresent()) { |
|
| 63 | 63 | return []; |
| 64 | 64 | } |
| 65 | 65 | if ($this->isBuiltIn()) { |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | return [$this->isArray() ? new Name($this->removeArraySuffix()) : $this->names[0]]; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $typesFromUnion = array_map(fn (Name $name) => TypeDeclaration::from((string) $name), $this->names); |
|
| 73 | - $references = array_filter($typesFromUnion, fn (TypeDeclaration $type) => ! $type->isBuiltIn()); |
|
| 72 | + $typesFromUnion = array_map(fn(Name $name) => TypeDeclaration::from((string)$name), $this->names); |
|
| 73 | + $references = array_filter($typesFromUnion, fn(TypeDeclaration $type) => !$type->isBuiltIn()); |
|
| 74 | 74 | |
| 75 | 75 | return array_map( |
| 76 | - fn (TypeDeclaration $reference) => $reference->isArray() |
|
| 76 | + fn(TypeDeclaration $reference) => $reference->isArray() |
|
| 77 | 77 | ? new Name($reference->removeArraySuffix()) |
| 78 | 78 | : $reference->names[0], |
| 79 | 79 | $references |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function isBuiltIn(): bool |
| 88 | 88 | { |
| 89 | - if (! $this->isRegularType()) { |
|
| 89 | + if (!$this->isRegularType()) { |
|
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | - $type = (string) $this->names[0]; |
|
| 92 | + $type = (string)$this->names[0]; |
|
| 93 | 93 | if ($this->isArray()) { |
| 94 | 94 | $type = $this->removeArraySuffix(); |
| 95 | 95 | } |
@@ -99,20 +99,20 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | private function removeArraySuffix(): string |
| 101 | 101 | { |
| 102 | - return substr((string) $this->names[0], 0, -2); |
|
| 102 | + return substr((string)$this->names[0], 0, -2); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public function isBuiltInArray(): bool |
| 106 | 106 | { |
| 107 | 107 | if ($this->isRegularType()) { |
| 108 | - return (string) $this->names[0] === 'array'; |
|
| 108 | + return (string)$this->names[0] === 'array'; |
|
| 109 | 109 | } |
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | private function isArray(): bool |
| 114 | 114 | { |
| 115 | - return strpos((string) $this->names[0], '[]') === strlen((string) $this->names[0]) - 2; |
|
| 115 | + return strpos((string)$this->names[0], '[]') === strlen((string)$this->names[0]) - 2; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function isNullable(): bool |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function build(array $classAttributes): array |
| 40 | 40 | { |
| 41 | - $constants = array_filter($classAttributes, static fn ($attribute): bool => $attribute instanceof ClassConst); |
|
| 41 | + $constants = array_filter($classAttributes, static fn($attribute): bool => $attribute instanceof ClassConst); |
|
| 42 | 42 | |
| 43 | - return array_map(fn (ClassConst $constant): Constant => new Constant( |
|
| 44 | - (string) $constant->consts[0]->name, |
|
| 43 | + return array_map(fn(ClassConst $constant): Constant => new Constant( |
|
| 44 | + (string)$constant->consts[0]->name, |
|
| 45 | 45 | TypeDeclaration::from($this->determineType($constant->consts[0])), |
| 46 | 46 | $this->visibilityBuilder->build($constant) |
| 47 | 47 | ), $this->visibilityFilters->apply($constants)); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | if (property_exists($constant->value, 'value')) { |
| 53 | 53 | return self::TYPES[\gettype($constant->value->value)]; |
| 54 | 54 | } |
| 55 | - if (! $constant->value instanceof ConstFetch) { |
|
| 55 | + if (!$constant->value instanceof ConstFetch) { |
|
| 56 | 56 | return null; |
| 57 | 57 | } |
| 58 | 58 | return 'bool'; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public function build(array $methods): array |
| 37 | 37 | { |
| 38 | 38 | return array_map( |
| 39 | - fn (ClassMethod $method): Method => $this->buildMethod($method), |
|
| 39 | + fn(ClassMethod $method): Method => $this->buildMethod($method), |
|
| 40 | 40 | $this->visibilityFilters->apply($methods) |
| 41 | 41 | ); |
| 42 | 42 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $docBlock = $method->getDocComment(); |
| 49 | 49 | $returnType = $this->typeBuilder->fromMethodReturnType($method->returnType, $docBlock); |
| 50 | 50 | $parameters = $this->parametersBuilder->build($method->params, $docBlock); |
| 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), |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | final class TypeBuilder |
| 21 | 21 | { |
| 22 | 22 | public function fromMethodParameter( |
| 23 | - Identifier|Name|NullableType|UnionType|null $type, |
|
| 23 | + Identifier | Name | NullableType | UnionType | null $type, |
|
| 24 | 24 | ?Doc $docBlock, |
| 25 | 25 | string $name |
| 26 | 26 | ): TypeDeclaration { |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | $typeDeclaration = $this->fromParsedType($type); |
| 33 | - if (! $typeDeclaration->isBuiltInArray()) { |
|
| 33 | + if (!$typeDeclaration->isBuiltInArray()) { |
|
| 34 | 34 | return $typeDeclaration; |
| 35 | 35 | } |
| 36 | - if (! $methodDocBlock->hasTypeOfParameter($name)) { |
|
| 36 | + if (!$methodDocBlock->hasTypeOfParameter($name)) { |
|
| 37 | 37 | return $typeDeclaration; |
| 38 | 38 | } |
| 39 | 39 | return $methodDocBlock->typeOfParameter($name); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function fromMethodReturnType( |
| 43 | - Identifier|Name|NullableType|UnionType|null $type, |
|
| 43 | + Identifier | Name | NullableType | UnionType | null $type, |
|
| 44 | 44 | ?Doc $docBlock |
| 45 | 45 | ): TypeDeclaration { |
| 46 | 46 | $methodDocBlock = new MethodDocBlock($docBlock === null ? null : $docBlock->getText()); |
@@ -49,17 +49,17 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $typeDeclaration = $this->fromParsedType($type); |
| 52 | - if (! $typeDeclaration->isBuiltInArray()) { |
|
| 52 | + if (!$typeDeclaration->isBuiltInArray()) { |
|
| 53 | 53 | return $typeDeclaration; |
| 54 | 54 | } |
| 55 | - if (! $methodDocBlock->hasReturnType()) { |
|
| 55 | + if (!$methodDocBlock->hasReturnType()) { |
|
| 56 | 56 | return $typeDeclaration; |
| 57 | 57 | } |
| 58 | 58 | return $methodDocBlock->returnType(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function fromAttributeType( |
| 62 | - Identifier|Name|NullableType|UnionType|null $type, |
|
| 62 | + Identifier | Name | NullableType | UnionType | null $type, |
|
| 63 | 63 | ?Doc $docBlock |
| 64 | 64 | ): TypeDeclaration { |
| 65 | 65 | $attributeDocBlock = new AttributeDocBlock($docBlock === null ? null : $docBlock->getText()); |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $typeDeclaration = $this->fromParsedType($type); |
| 71 | - if (! $typeDeclaration->isBuiltInArray()) { |
|
| 71 | + if (!$typeDeclaration->isBuiltInArray()) { |
|
| 72 | 72 | return $typeDeclaration; |
| 73 | 73 | } |
| 74 | - if (! $attributeDocBlock->hasAttributeType()) { |
|
| 74 | + if (!$attributeDocBlock->hasAttributeType()) { |
|
| 75 | 75 | return $typeDeclaration; |
| 76 | 76 | } |
| 77 | 77 | return $attributeDocBlock->attributeType(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - private function fromParsedType(Identifier|Name|NullableType|UnionType|null $type): TypeDeclaration |
|
| 80 | + private function fromParsedType(Identifier | Name | NullableType | UnionType | null $type): TypeDeclaration |
|
| 81 | 81 | { |
| 82 | - return match (true) { |
|
| 83 | - $type instanceof NullableType => TypeDeclaration::fromNullable((string) $type->type), |
|
| 82 | + return match(true) { |
|
| 83 | + $type instanceof NullableType => TypeDeclaration::fromNullable((string)$type->type), |
|
| 84 | 84 | $type instanceof Name => TypeDeclaration::from($type->getLast()), |
| 85 | - $type instanceof Identifier => TypeDeclaration::from((string) $type), |
|
| 85 | + $type instanceof Identifier => TypeDeclaration::from((string)$type), |
|
| 86 | 86 | $type === null => TypeDeclaration::absent(), |
| 87 | 87 | default => TypeDeclaration::fromUnionType($this->fromUnionType($type)), |
| 88 | 88 | }; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** @return string[] */ |
| 92 | 92 | private function fromUnionType(UnionType $type): array |
| 93 | 93 | { |
| 94 | - return array_map(function (Identifier|NodeName $name): string { |
|
| 94 | + return array_map(function(Identifier | NodeName $name): string { |
|
| 95 | 95 | return $name instanceof Identifier ? $name->name : $name->getLast(); |
| 96 | 96 | }, $type->types); |
| 97 | 97 | } |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | private function resolveExternalAttributes(ClassDefinition $definition, Codebase $codebase): void |
| 42 | 42 | { |
| 43 | - array_map(function (Attribute $attribute) use ($codebase): void { |
|
| 43 | + array_map(function(Attribute $attribute) use ($codebase): void { |
|
| 44 | 44 | $this->resolveExternalAssociationsFromTypeNames($attribute->references(), $codebase); |
| 45 | 45 | }, $definition->attributes()); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | private function resolveExternalConstructorParameters(ClassDefinition $definition, Codebase $codebase): void |
| 49 | 49 | { |
| 50 | - array_map(function (Parameter $parameter) use ($codebase): void { |
|
| 50 | + array_map(function(Parameter $parameter) use ($codebase): void { |
|
| 51 | 51 | $this->resolveExternalAssociationsFromTypeNames($parameter->references(), $codebase); |
| 52 | 52 | }, $definition->constructorParameters()); |
| 53 | 53 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** @param Name[] $references */ |
| 56 | 56 | private function resolveExternalAssociationsFromTypeNames(array $references, Codebase $codebase): void |
| 57 | 57 | { |
| 58 | - array_map(static function (Name $reference) use ($codebase): void { |
|
| 58 | + array_map(static function(Name $reference) use ($codebase): void { |
|
| 59 | 59 | if ($codebase->has($reference)) { |
| 60 | 60 | return; |
| 61 | 61 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** @param mixed[] $options */ |
| 15 | 15 | public function __construct(array $options) |
| 16 | 16 | { |
| 17 | - $this->recursive = (bool) ($options['recursive'] ?? false); |
|
| 17 | + $this->recursive = (bool)($options['recursive'] ?? false); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function recursive(): bool |