Skip to content

Commit 7ddd9c1

Browse files
fix CS issues
1 parent 4af1cc4 commit 7ddd9c1

File tree

3 files changed

+64
-64
lines changed

3 files changed

+64
-64
lines changed

src/Form/Field/BlocksField.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use Kirby\Data\Json;
1212
use Kirby\Exception\InvalidArgumentException;
1313
use Kirby\Exception\NotFoundException;
14-
use Kirby\Form\Fields;
1514
use Kirby\Form\FieldClass;
15+
use Kirby\Form\Fields;
1616
use Kirby\Form\Form;
1717
use Kirby\Form\Mixin\EmptyState;
1818
use Kirby\Form\Mixin\Max;
@@ -294,7 +294,8 @@ protected function setDefault(mixed $default = null): void
294294
parent::setDefault($default);
295295
}
296296

297-
protected function setFieldsets(string|array|null $fieldsets): void {
297+
protected function setFieldsets(string|array|null $fieldsets): void
298+
{
298299
if (is_string($fieldsets) === true) {
299300
$fieldsets = [];
300301
}

src/Reflection/DocComment.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@
99

1010
class DocComment
1111
{
12-
public function __construct(
13-
protected string $comment,
14-
) {
15-
}
12+
public function __construct(
13+
protected string $comment,
14+
) {
15+
}
1616

17-
public static function from(
18-
ReflectionClass|ReflectionFunction|ReflectionMethod|ReflectionProperty|null $object
19-
) {
20-
return new static($object?->getDocComment() ?? '');
21-
}
17+
public static function from(
18+
ReflectionClass|ReflectionFunction|ReflectionMethod|ReflectionProperty|null $object
19+
) {
20+
return new static($object?->getDocComment() ?? '');
21+
}
2222

23-
/**
24-
* Returns the cleaned docblock text of the given property.
25-
*/
26-
public function description(): string|null
27-
{
28-
$comment = preg_replace(['#^/\*\*#', '#\*/$#'], '', $this->comment);
29-
$lines = preg_split('/\R/', (string)$comment) ?: [];
30-
$lines = array_map(static fn(string $line): string => ltrim(trim($line), "* \t"), $lines);
31-
$lines = array_filter(
32-
$lines,
33-
static fn(string $line): bool => $line !== '' && str_starts_with($line, '@') === false
34-
);
23+
/**
24+
* Returns the cleaned docblock text of the given property.
25+
*/
26+
public function description(): string|null
27+
{
28+
$comment = preg_replace(['#^/\*\*#', '#\*/$#'], '', $this->comment);
29+
$lines = preg_split('/\R/', (string)$comment) ?: [];
30+
$lines = array_map(static fn (string $line): string => ltrim(trim($line), "* \t"), $lines);
31+
$lines = array_filter(
32+
$lines,
33+
static fn (string $line): bool => $line !== '' && str_starts_with($line, '@') === false
34+
);
3535

36-
return implode(' ', $lines);
37-
}
36+
return implode(' ', $lines);
37+
}
3838
}

src/Reflection/Field.php

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,45 @@
44

55
use Kirby\Form\FieldClass;
66
use ReflectionClass;
7-
use ReflectionProperty;
87

98
class Field
109
{
11-
protected Constructor $constructor;
12-
protected ReflectionClass $class;
13-
14-
public function __construct(
15-
protected FieldClass $field
16-
) {
17-
$this->class = new ReflectionClass($field);
18-
$this->constructor = new Constructor($field);
19-
}
20-
21-
/**
22-
* Returns field properties based on the constructor signature.
23-
*/
24-
public function props(): array
25-
{
26-
$props = [];
27-
$ignore = ['model', 'siblings', 'props'];
28-
29-
foreach ($this->constructor->getParameters() as $parameter) {
30-
$name = $parameter->getName();
31-
32-
if (in_array($name, $ignore) === true) {
33-
continue;
34-
}
35-
36-
$property = $this->class->hasProperty($name) ? $this->class->getProperty($name) : null;
37-
$comment = DocComment::from($property);
38-
39-
$props[$name] = [
40-
'name' => $name,
41-
'type' => (string)$parameter->getType(),
42-
'default' => $parameter->getDefaultValue(),
43-
'description' => $comment->description()
44-
];
45-
}
46-
47-
return $props;
48-
}
10+
protected Constructor $constructor;
11+
protected ReflectionClass $class;
12+
13+
public function __construct(
14+
protected FieldClass $field
15+
) {
16+
$this->class = new ReflectionClass($field);
17+
$this->constructor = new Constructor($field);
18+
}
19+
20+
/**
21+
* Returns field properties based on the constructor signature.
22+
*/
23+
public function props(): array
24+
{
25+
$props = [];
26+
$ignore = ['model', 'siblings', 'props'];
27+
28+
foreach ($this->constructor->getParameters() as $parameter) {
29+
$name = $parameter->getName();
30+
31+
if (in_array($name, $ignore) === true) {
32+
continue;
33+
}
34+
35+
$property = $this->class->hasProperty($name) ? $this->class->getProperty($name) : null;
36+
$comment = DocComment::from($property);
37+
38+
$props[$name] = [
39+
'name' => $name,
40+
'type' => (string)$parameter->getType(),
41+
'default' => $parameter->getDefaultValue(),
42+
'description' => $comment->description()
43+
];
44+
}
45+
46+
return $props;
47+
}
4948
}

0 commit comments

Comments
 (0)