Skip to content

Commit 4dff40b

Browse files
committed
Updated PHPStan, refactor getter syntax for consistency and clarity
Updated multiple getter methods to use explicit `get` blocks for improved readability and maintainability. This change ensures a uniform style across all getters, reducing ambiguity and potential future errors. Additionally, upgraded PHPStan to version 2.1.0 in the composer.lock file.
1 parent 5c676eb commit 4dff40b

File tree

5 files changed

+43
-28
lines changed

5 files changed

+43
-28
lines changed

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Contexts/ClassContext.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ final private function __construct(
5757
}
5858

5959
public bool $hasComputedProperties {
60-
get => count(
61-
array_filter(
62-
$this->properties,
63-
static fn (PropertyContext $property) => $property->isComputed
64-
)
65-
) > 0;
60+
get {
61+
return count(
62+
array_filter(
63+
$this->properties,
64+
static fn (PropertyContext $property) => $property->isComputed
65+
)
66+
) > 0;
67+
}
6668
}
6769

6870
/**

src/Contexts/Concerns/HasTypes.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ trait HasTypes
1616

1717
/** @var list<Type> */
1818
public array $types {
19-
get => array_map(
20-
static fn (TypeContext $typeContext): Type => $typeContext->type,
21-
$this->typeContexts
22-
);
19+
get {
20+
return array_map(
21+
static fn (TypeContext $typeContext): Type => $typeContext->type,
22+
$this->typeContexts
23+
);
24+
}
2325
}
2426

2527
/**

src/Contexts/PropertyContext.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,31 @@ final private function __construct(
7272
}
7373

7474
public string $propertyName {
75-
get => $this->reflection->getName();
75+
get {
76+
return $this->reflection->getName();
77+
}
7678
}
7779

7880
public string $className {
79-
get => $this->reflection->getDeclaringClass()->getName();
81+
get {
82+
return $this->reflection->getDeclaringClass()->getName();
83+
}
8084
}
8185

8286
/** @var list<TypeContext<Type>> $arrayTypeContexts */
8387
public array $arrayTypeContexts {
84-
get => array_reduce(
85-
$this->typeContexts ?? [],
86-
static fn (array $typeContexts, TypeContext $context) => $context->type === Type::ARRAY
87-
? [...$typeContexts, ...$context->subTypeContexts]
88-
: [],
89-
[]
90-
);
88+
get {
89+
/** @var list<TypeContext<Type>> $typeContexts */
90+
$typeContexts = [];
91+
92+
foreach ($this->typeContexts ?? [] as $typeContext) {
93+
if ($typeContext->type === Type::ARRAY && $typeContext->subTypeContexts) {
94+
$typeContexts = [...$typeContexts, ...$typeContext->subTypeContexts];
95+
}
96+
}
97+
98+
return $typeContexts;
99+
}
91100
}
92101

93102
/**

src/Contexts/TypeContext.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ class TypeContext
4343

4444
/** @var list<Type> $arrayElementTypes */
4545
public array $arrayElementTypes {
46-
get => array_map(
47-
static fn (TypeContext $context) => $context->type,
48-
$this->subTypeContexts ?? []
49-
);
46+
get {
47+
return array_map(
48+
static fn (TypeContext $context) => $context->type,
49+
$this->subTypeContexts ?? []
50+
);
51+
}
5052
}
5153

5254
/**

0 commit comments

Comments
 (0)