Skip to content

Commit

Permalink
Ensure setterMethod is always a string
Browse files Browse the repository at this point in the history
  • Loading branch information
fwolfsjaeger committed Oct 18, 2023
1 parent f86b03b commit 46e3b15
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/Mapping/Annotation/Blameable.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class Blameable implements GedmoAnnotation
public $field;
/** @var mixed */
public $value;
/** @var string|null */
/** @var string */
public $setterMethod;

/**
Expand All @@ -45,7 +45,7 @@ public function __construct(
string $on = 'update',
$field = null,
$value = null,
?string $setterMethod = null
string $setterMethod = ''
) {
if ([] !== $data) {
@trigger_error(sprintf(
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/Annotation/IpTraceable.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class IpTraceable implements GedmoAnnotation
public $field;
/** @var mixed */
public $value;
/** @var string|null */
/** @var string */
public $setterMethod;

/**
Expand All @@ -45,7 +45,7 @@ public function __construct(
string $on = 'update',
$field = null,
$value = null,
?string $setterMethod = null
string $setterMethod = ''
) {
if ([] !== $data) {
@trigger_error(sprintf(
Expand Down
11 changes: 8 additions & 3 deletions src/Mapping/Annotation/SoftDeleteable.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ final class SoftDeleteable implements GedmoAnnotation
/** @var bool */
public $hardDelete = true;

/** @var string|null */
/** @var string */
public $setterMethod;

/**
* @param array<string, mixed> $data
*/
public function __construct(array $data = [], string $fieldName = 'deletedAt', bool $timeAware = false, bool $hardDelete = true, ?string $setterMethod = null)
{
public function __construct(
array $data = [],
string $fieldName = 'deletedAt',
bool $timeAware = false,
bool $hardDelete = true,
string $setterMethod = ''
) {
if ([] !== $data) {
@trigger_error(sprintf(
'Passing an array as first argument to "%s()" is deprecated. Use named arguments instead.',
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/Annotation/Timestampable.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class Timestampable implements GedmoAnnotation
public $field;
/** @var mixed */
public $value;
/** @var string|null */
/** @var string */
public $setterMethod;

/**
Expand All @@ -45,7 +45,7 @@ public function __construct(
string $on = 'update',
$field = null,
$value = null,
?string $setterMethod = null
string $setterMethod = ''
) {
if ([] !== $data) {
@trigger_error(sprintf(
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/Driver/AbstractAnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ protected function getRelatedClassName($metadata, $name)
/**
* Set the setter method for the given field.
*/
protected function setSetterMethod(string $field, ?string $method, array &$config): void
protected function setSetterMethod(string $field, string $method, array &$config): void
{
if (empty($method)) {
if ('' === $method) {
return;
}

Expand Down

0 comments on commit 46e3b15

Please sign in to comment.