@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function build(array $parsedAttributes): array |
39 | 39 | { |
40 | - $attributes = array_filter($parsedAttributes, static fn ($attribute): bool => $attribute instanceof Property); |
|
40 | + $attributes = array_filter($parsedAttributes, static fn($attribute): bool => $attribute instanceof Property); |
|
41 | 41 | |
42 | - return array_map(function (Property $attribute): Attribute { |
|
42 | + return array_map(function(Property $attribute): Attribute { |
|
43 | 43 | $variable = new Variable( |
44 | 44 | "\${$attribute->props[0]->name}", |
45 | 45 | $this->typeBuilder->fromAttributeType($attribute->type, $attribute->getDocComment()) |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function fromPromotedProperties(array $constructorParameters): array |
58 | 58 | { |
59 | - $promotedProperties = array_filter($constructorParameters, fn (Node\Param $param) => $param->flags !== 0); |
|
59 | + $promotedProperties = array_filter($constructorParameters, fn(Node\Param $param) => $param->flags !== 0); |
|
60 | 60 | |
61 | - return array_map(function (Node\Param $param): Attribute { |
|
61 | + return array_map(function(Node\Param $param): Attribute { |
|
62 | 62 | /** @var Node\Expr\Variable $var */ |
63 | 63 | $var = $param->var; |
64 | 64 |
@@ -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, true), |
53 | 53 | $method->isStatic() => new Method($name, $visibility, $returnType, $parameters, false, true), |
54 | 54 | default => new Method($name, $visibility, $returnType, $parameters), |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | final class TypeBuilder |
20 | 20 | { |
21 | 21 | public function fromMethodParameter( |
22 | - Identifier|Name|NullableType|UnionType|null $type, |
|
22 | + Identifier | Name | NullableType | UnionType | null $type, |
|
23 | 23 | ?Doc $docBlock, |
24 | 24 | string $name |
25 | 25 | ): TypeDeclaration { |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | $typeDeclaration = $this->fromParsedType($type); |
32 | - if (! $typeDeclaration->isBuiltInArray()) { |
|
32 | + if (!$typeDeclaration->isBuiltInArray()) { |
|
33 | 33 | return $typeDeclaration; |
34 | 34 | } |
35 | - if (! $methodDocBlock->hasTypeOfParameter($name)) { |
|
35 | + if (!$methodDocBlock->hasTypeOfParameter($name)) { |
|
36 | 36 | return $typeDeclaration; |
37 | 37 | } |
38 | 38 | return $methodDocBlock->typeOfParameter($name); |
39 | 39 | } |
40 | 40 | |
41 | 41 | public function fromMethodReturnType( |
42 | - Identifier|Name|NullableType|UnionType|null $type, |
|
42 | + Identifier | Name | NullableType | UnionType | null $type, |
|
43 | 43 | ?Doc $docBlock |
44 | 44 | ): TypeDeclaration { |
45 | 45 | $methodDocBlock = new MethodDocBlock($docBlock === null ? null : $docBlock->getText()); |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | $typeDeclaration = $this->fromParsedType($type); |
51 | - if (! $typeDeclaration->isBuiltInArray()) { |
|
51 | + if (!$typeDeclaration->isBuiltInArray()) { |
|
52 | 52 | return $typeDeclaration; |
53 | 53 | } |
54 | - if (! $methodDocBlock->hasReturnType()) { |
|
54 | + if (!$methodDocBlock->hasReturnType()) { |
|
55 | 55 | return $typeDeclaration; |
56 | 56 | } |
57 | 57 | return $methodDocBlock->returnType(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | public function fromAttributeType( |
61 | - Identifier|Name|NullableType|UnionType|null $type, |
|
61 | + Identifier | Name | NullableType | UnionType | null $type, |
|
62 | 62 | ?Doc $docBlock |
63 | 63 | ): TypeDeclaration { |
64 | 64 | $attributeDocBlock = new AttributeDocBlock($docBlock === null ? null : $docBlock->getText()); |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | $typeDeclaration = $this->fromParsedType($type); |
70 | - if (! $typeDeclaration->isBuiltInArray()) { |
|
70 | + if (!$typeDeclaration->isBuiltInArray()) { |
|
71 | 71 | return $typeDeclaration; |
72 | 72 | } |
73 | - if (! $attributeDocBlock->hasAttributeType()) { |
|
73 | + if (!$attributeDocBlock->hasAttributeType()) { |
|
74 | 74 | return $typeDeclaration; |
75 | 75 | } |
76 | 76 | return $attributeDocBlock->attributeType(); |
77 | 77 | } |
78 | 78 | |
79 | - private function fromParsedType(Identifier|Name|NullableType|UnionType|null $type): TypeDeclaration |
|
79 | + private function fromParsedType(Identifier | Name | NullableType | UnionType | null $type): TypeDeclaration |
|
80 | 80 | { |
81 | - return match (true) { |
|
82 | - $type instanceof NullableType => TypeDeclaration::fromNullable((string) $type->type), |
|
81 | + return match(true) { |
|
82 | + $type instanceof NullableType => TypeDeclaration::fromNullable((string)$type->type), |
|
83 | 83 | $type instanceof Name => TypeDeclaration::from($type->getLast()), |
84 | - $type instanceof Identifier => TypeDeclaration::from((string) $type), |
|
84 | + $type instanceof Identifier => TypeDeclaration::from((string)$type), |
|
85 | 85 | $type === null => TypeDeclaration::absent(), |
86 | 86 | default => throw UnsupportedType::declaredAs($type), |
87 | 87 | }; |
@@ -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,10 +52,10 @@ 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 | - if (! \in_array($constant->value->name->parts[0], ['true', 'false'], true)) { |
|
58 | + if (!\in_array($constant->value->name->parts[0], ['true', 'false'], true)) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | return 'bool'; // It's an expression |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | |
16 | 16 | final class VisibilityBuilder |
17 | 17 | { |
18 | - public function build(Property|ClassMethod|ClassConst $member): Visibility |
|
18 | + public function build(Property | ClassMethod | ClassConst $member): Visibility |
|
19 | 19 | { |
20 | - return match (true) { |
|
20 | + return match(true) { |
|
21 | 21 | $member->isPublic() => Visibility::public(), |
22 | 22 | $member->isPrivate() => Visibility::private(), |
23 | 23 | default => Visibility::protected(), |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | |
27 | 27 | public function fromFlags(int $flags): Visibility |
28 | 28 | { |
29 | - return match (true) { |
|
30 | - (bool) ($flags & Class_::MODIFIER_PUBLIC) => Visibility::public(), |
|
31 | - (bool) ($flags & Class_::MODIFIER_PROTECTED) => Visibility::protected(), |
|
32 | - (bool) ($flags & Class_::MODIFIER_PRIVATE) => Visibility::private(), |
|
29 | + return match(true) { |
|
30 | + (bool)($flags & Class_::MODIFIER_PUBLIC) => Visibility::public(), |
|
31 | + (bool)($flags & Class_::MODIFIER_PROTECTED) => Visibility::protected(), |
|
32 | + (bool)($flags & Class_::MODIFIER_PRIVATE) => Visibility::private(), |
|
33 | 33 | default => throw UnknownVisibilityFlag::withValue($flags) |
34 | 34 | }; |
35 | 35 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | public function leaveNode(Node $node) |
26 | 26 | { |
27 | - if (! $node instanceof Class_) { |
|
27 | + if (!$node instanceof Class_) { |
|
28 | 28 | return null; |
29 | 29 | } |
30 | 30 | if ($node->isAnonymous()) { |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | private function resolveExternalAttributes(ClassDefinition $definition, Codebase $codebase): void |
41 | 41 | { |
42 | - array_map(function (Attribute $attribute) use ($codebase): void { |
|
43 | - if (! $attribute->isAReference()) { |
|
42 | + array_map(function(Attribute $attribute) use ($codebase): void { |
|
43 | + if (!$attribute->isAReference()) { |
|
44 | 44 | return; |
45 | 45 | } |
46 | 46 | if ($codebase->has($attribute->referenceName())) { |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | private function resolveExternalConstructorParameters(ClassDefinition $definition, Codebase $codebase): void |
54 | 54 | { |
55 | - array_map(function (Parameter $parameter) use ($codebase): void { |
|
56 | - if (! $parameter->isAReference()) { |
|
55 | + array_map(function(Parameter $parameter) use ($codebase): void { |
|
56 | + if (!$parameter->isAReference()) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | if ($codebase->has($parameter->referenceName())) { |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | public function __construct(string $name) |
18 | 18 | { |
19 | - if (! \in_array($name, self::NAMES, true)) { |
|
19 | + if (!\in_array($name, self::NAMES, true)) { |
|
20 | 20 | throw UnknownImageProcessor::named($name, self::NAMES); |
21 | 21 | } |
22 | 22 | $this->name = $name; |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function isBuiltIn(): bool |
60 | 60 | { |
61 | - $type = (string) $this->name; |
|
61 | + $type = (string)$this->name; |
|
62 | 62 | if ($this->isArray()) { |
63 | 63 | $type = $this->removeArraySuffix(); |
64 | 64 | } |
65 | - if (! $this->isPresent()) { |
|
65 | + if (!$this->isPresent()) { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | return \in_array($type, self::BUILT_IN_TYPES, true); |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | |
71 | 71 | public function isBuiltInArray(): bool |
72 | 72 | { |
73 | - return (string) $this->name === 'array'; |
|
73 | + return (string)$this->name === 'array'; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public function isArray(): bool |
77 | 77 | { |
78 | - return strpos((string) $this->name, '[]') === \strlen((string) $this->name) - 2; |
|
78 | + return strpos((string)$this->name, '[]') === \strlen((string)$this->name) - 2; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function isNullable(): bool |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | public function removeArraySuffix(): string |
87 | 87 | { |
88 | - return substr((string) $this->name, 0, -2); |
|
88 | + return substr((string)$this->name, 0, -2); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | public function __toString(): string |