@@ -35,8 +35,8 @@ discard block |
||
| 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 |
||
| 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'; |
@@ -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 => (string) $name, |
|
| 100 | + static fn(Identifier | Name $name): string => (string)$name, |
|
| 101 | 101 | $type->types |
| 102 | 102 | ); |
| 103 | 103 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 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 |
||
| 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), |
@@ -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, $use->name)), $alias); |
|
| 59 | + return new UseStatement(new Name((string)ParsedName::concat($prefix, $use->name)), $alias); |
|
| 60 | 60 | } |
| 61 | 61 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | $params = array_values(array_filter( |
| 33 | 33 | $parameterTags, |
| 34 | 34 | static fn (TagWithType|InvalidTag $parameter) => |
| 35 | - $parameter instanceof Param && "\${$parameter->getVariableName()}" === $parameterName |
|
| 35 | + $parameter instanceof Param && "\${$parameter->getVariableName()}" === $parameterName |
|
| 36 | 36 | )); |
| 37 | 37 | |
| 38 | 38 | if (count($params) < 1) { |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** @var Param[] $params */ |
| 32 | 32 | $params = array_values(array_filter( |
| 33 | 33 | $parameterTags, |
| 34 | - static fn (TagWithType|InvalidTag $parameter) => |
|
| 34 | + static fn(TagWithType | InvalidTag $parameter) => |
|
| 35 | 35 | $parameter instanceof Param && "\${$parameter->getVariableName()}" === $parameterName |
| 36 | 36 | )); |
| 37 | 37 | |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | private function resolveType(?Type $type): ?TagType |
| 86 | 86 | { |
| 87 | - return match (true) { |
|
| 87 | + return match(true) { |
|
| 88 | 88 | $type === null => null, |
| 89 | - $type instanceof Nullable => TagType::nullable((string) $type->getActualType()), |
|
| 89 | + $type instanceof Nullable => TagType::nullable((string)$type->getActualType()), |
|
| 90 | 90 | $type instanceof Compound => TagType::compound(array_map('strval', $type->getIterator()->getArrayCopy())), |
| 91 | - default => TagType::named((string) $type) |
|
| 91 | + default => TagType::named((string)$type) |
|
| 92 | 92 | }; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function constructorParameters(): array |
| 65 | 65 | { |
| 66 | - $constructors = array_filter($this->methods, static fn (Method $method): bool => $method->isConstructor()); |
|
| 66 | + $constructors = array_filter($this->methods, static fn(Method $method): bool => $method->isConstructor()); |
|
| 67 | 67 | $constructor = reset($constructors); |
| 68 | 68 | |
| 69 | 69 | return $constructor === false ? [] : $constructor->parameters(); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | return \count(array_filter( |
| 80 | 80 | $this->attributes, |
| 81 | - static fn (Attribute $attribute): bool => $attribute->hasVisibility($modifier) |
|
| 81 | + static fn(Attribute $attribute): bool => $attribute->hasVisibility($modifier) |
|
| 82 | 82 | )); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | return \count(array_filter( |
| 93 | 93 | $this->attributes, |
| 94 | - static fn (Attribute $attribute): bool => |
|
| 94 | + static fn(Attribute $attribute): bool => |
|
| 95 | 95 | $attribute->hasTypeDeclaration() && $attribute->hasVisibility($modifier) |
| 96 | 96 | )); |
| 97 | 97 | } |
@@ -149,6 +149,6 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function isAbstract(): bool |
| 151 | 151 | { |
| 152 | - return array_filter($this->methods(), static fn (Method $method): bool => $method->isAbstract()) !== []; |
|
| 152 | + return array_filter($this->methods(), static fn(Method $method): bool => $method->isAbstract()) !== []; |
|
| 153 | 153 | } |
| 154 | 154 | } |
@@ -19,16 +19,16 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | final class PrivateVisibilityFilter implements VisibilityFilter |
| 21 | 21 | { |
| 22 | - public function accept(Stmt|Param $member): bool |
|
| 22 | + public function accept(Stmt | Param $member): bool |
|
| 23 | 23 | { |
| 24 | 24 | if ($member instanceof ClassConst |
| 25 | 25 | || $member instanceof ClassMethod |
| 26 | 26 | || $member instanceof Property) { |
| 27 | - return ! $member->isPrivate(); |
|
| 27 | + return !$member->isPrivate(); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | if ($member instanceof Param) { |
| 31 | - return ! (bool) ($member->flags & Class_::MODIFIER_PRIVATE); |
|
| 31 | + return !(bool)($member->flags & Class_::MODIFIER_PRIVATE); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | return false; |
@@ -12,5 +12,5 @@ |
||
| 12 | 12 | |
| 13 | 13 | interface VisibilityFilter |
| 14 | 14 | { |
| 15 | - public function accept(Stmt|Param $member): bool; |
|
| 15 | + public function accept(Stmt | Param $member): bool; |
|
| 16 | 16 | } |
@@ -19,16 +19,16 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | final class ProtectedVisibilityFilter implements VisibilityFilter |
| 21 | 21 | { |
| 22 | - public function accept(Stmt|Param $member): bool |
|
| 22 | + public function accept(Stmt | Param $member): bool |
|
| 23 | 23 | { |
| 24 | 24 | if ($member instanceof ClassConst |
| 25 | 25 | || $member instanceof ClassMethod |
| 26 | 26 | || $member instanceof Property) { |
| 27 | - return ! $member->isProtected(); |
|
| 27 | + return !$member->isProtected(); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | if ($member instanceof Param) { |
| 31 | - return ! (bool) ($member->flags & Class_::MODIFIER_PROTECTED); |
|
| 31 | + return !(bool)($member->flags & Class_::MODIFIER_PROTECTED); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | return false; |