Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidatedTerm: Accept null as label #171

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Control/SearchBar/ValidatedOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function setSearchValue(string $searchValue): ValidatedTerm
throw new LogicException('Operators cannot be changed');
}

public function setLabel(string $label): ValidatedTerm
public function setLabel(?string $label): ValidatedTerm
{
throw new LogicException('Operators cannot be changed');
}
Expand Down
24 changes: 12 additions & 12 deletions src/Control/SearchBar/ValidatedTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ abstract class ValidatedTerm
/** @var string The default validation constraint */
const DEFAULT_PATTERN = '^\s*(?!%s\b).*\s*$';

/** @var mixed The search value */
/** @var string The search value */
protected $searchValue;

/** @var string The label */
/** @var ?string The label */
protected $label;

/** @var string The validation message */
/** @var ?string The validation message */
protected $message;

/** @var string The validation constraint */
/** @var ?string The validation constraint */
protected $pattern;

/** @var bool Whether the term has been adjusted */
Expand All @@ -27,10 +27,10 @@ abstract class ValidatedTerm
/**
* Create a new ValidatedTerm
*
* @param mixed $searchValue The search value
* @param string $searchValue The search value
* @param ?string $label The label
*/
public function __construct($searchValue, $label = null)
public function __construct(string $searchValue, ?string $label = null)
{
$this->searchValue = $searchValue;
$this->label = $label;
Expand Down Expand Up @@ -106,13 +106,13 @@ public function getLabel(): ?string
/**
* Set the label
*
* @param string $label
* @param ?string $label
*
* @return $this
*/
public function setLabel(string $label): self
public function setLabel(?string $label): self
{
$this->label = (string) $label;
$this->label = $label;
$this->changed = true;

return $this;
Expand All @@ -121,7 +121,7 @@ public function setLabel(string $label): self
/**
* Get the validation message
*
* @return string
* @return ?string
*/
public function getMessage(): ?string
{
Expand All @@ -131,7 +131,7 @@ public function getMessage(): ?string
/**
* Set the validation message
*
* @param ?string $message
* @param string $message
*
* @return $this
*/
Expand Down Expand Up @@ -167,7 +167,7 @@ public function getPattern(): string
*/
public function setPattern(string $pattern): self
{
$this->pattern = (string) $pattern;
$this->pattern = $pattern;

return $this;
}
Expand Down
Loading