Skip to content

Commit 302b82d

Browse files
committed
psalm
1 parent 4430851 commit 302b82d

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/ColumnSetting.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ColumnSetting
3030
private ?array $headerStyle;
3131
private ?array $dataStyle;
3232

33-
/** @var callable|string name of the get method (like getId) or a callable taking the object an argument */
33+
/** @var string|callable|null name of the get method (like getId) or a callable taking the object an argument */
3434
private $getter;
3535

3636

@@ -109,19 +109,12 @@ public function setFormat(string $format): ColumnSetting
109109
return $this;
110110
}
111111

112-
/**
113-
* @return string|callable
114-
*/
115-
public function getGetter()
112+
public function getGetter(): string|callable|null
116113
{
117114
return $this->getter;
118115
}
119116

120-
/**
121-
* @param string|callable $getter
122-
* @return $this
123-
*/
124-
public function setGetter($getter): self
117+
public function setGetter(string|callable|null $getter): self
125118
{
126119
$this->getter = $getter;
127120

src/DataConverter.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public function convertEntityToArray(array $entities, array $cols): array
2525
//apply custom order of columns
2626
$getters = [];
2727
foreach ($cols as $col) {
28-
if (!$col->getGetter()) {
28+
$getter = $col->getGetter();
29+
if (null === $getter || '' === $getter) {
2930
throw new Exception(
3031
sprintf(
3132
"All getters need to be set in the ColumnSettings when using entities. Missing getter for column '%s'",
@@ -34,7 +35,7 @@ public function convertEntityToArray(array $entities, array $cols): array
3435
);
3536
}
3637

37-
$getters[] = $col->getGetter();
38+
$getters[] = $getter;
3839
}
3940

4041
//call all getters

0 commit comments

Comments
 (0)