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

9.0 TASK: remove string union types in filters, to increase type safety #4094

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function create(): self
return new self(null);
}

public static function referenceName(ReferenceName|string $referenceName): self
public static function referenceName(ReferenceName $referenceName): self
{
return self::create()->with(referenceName: $referenceName);
}
Expand All @@ -42,11 +42,8 @@ public static function referenceName(ReferenceName|string $referenceName): self
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
*/
public function with(
ReferenceName|string $referenceName = null,
ReferenceName $referenceName = null,
): self {
if (is_string($referenceName)) {
$referenceName = ReferenceName::fromString($referenceName);
}
return new self(
$referenceName ?? $this->referenceName,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function create(): self
return new self(null, null, null);
}

public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeConstraints): self
public static function nodeTypeConstraints(NodeTypeConstraints $nodeTypeConstraints): self
{
return self::create()->withNodeTypeConstraints($nodeTypeConstraints);
}
Expand All @@ -44,21 +44,18 @@ public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeC
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
*/
public function with(
NodeTypeConstraints|string $nodeTypeConstraints = null,
NodeTypeConstraints $nodeTypeConstraints = null,
int $limit = null,
int $offset = null
): self {
if (is_string($nodeTypeConstraints)) {
$nodeTypeConstraints = NodeTypeConstraints::fromFilterString($nodeTypeConstraints);
}
return new self(
$nodeTypeConstraints ?? $this->nodeTypeConstraints,
$limit ?? $this->limit,
$offset ?? $this->offset,
);
}

public function withNodeTypeConstraints(NodeTypeConstraints|string $nodeTypeConstraints): self
public function withNodeTypeConstraints(NodeTypeConstraints $nodeTypeConstraints): self
{
return $this->with(nodeTypeConstraints: $nodeTypeConstraints);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function create(): self
return new self(null, null);
}

public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeConstraints): self
public static function nodeTypeConstraints(NodeTypeConstraints $nodeTypeConstraints): self
{
return self::create()->with(nodeTypeConstraints: $nodeTypeConstraints);
}
Expand All @@ -44,22 +44,16 @@ public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeC
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
*/
public function with(
NodeTypeConstraints|string $nodeTypeConstraints = null,
SearchTerm|string $searchTerm = null,
NodeTypeConstraints $nodeTypeConstraints = null,
SearchTerm $searchTerm = null,
): self {
if (is_string($nodeTypeConstraints)) {
$nodeTypeConstraints = NodeTypeConstraints::fromFilterString($nodeTypeConstraints);
}
if (is_string($searchTerm)) {
$searchTerm = SearchTerm::fulltext($searchTerm);
}
return new self(
$nodeTypeConstraints ?? $this->nodeTypeConstraints,
$searchTerm ?? $this->searchTerm,
);
}

public function withSearchTerm(SearchTerm|string $searchTerm): self
public function withSearchTerm(SearchTerm $searchTerm): self
{
return $this->with(searchTerm: $searchTerm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function create(): self
return new self(null, null, null);
}

public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeConstraints): self
public static function nodeTypeConstraints(NodeTypeConstraints $nodeTypeConstraints): self
{
return self::create()->with(nodeTypeConstraints: $nodeTypeConstraints);
}
Expand All @@ -44,13 +44,10 @@ public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeC
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
*/
public function with(
NodeTypeConstraints|string $nodeTypeConstraints = null,
NodeTypeConstraints $nodeTypeConstraints = null,
int $limit = null,
int $offset = null,
): self {
if (is_string($nodeTypeConstraints)) {
$nodeTypeConstraints = NodeTypeConstraints::fromFilterString($nodeTypeConstraints);
}
return new self(
$nodeTypeConstraints ?? $this->nodeTypeConstraints,
$limit ?? $this->limit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function create(): self
return new self(null);
}

public static function referenceName(ReferenceName|string $referenceName): self
public static function referenceName(ReferenceName $referenceName): self
{
return self::create()->with(referenceName: $referenceName);
}
Expand All @@ -43,11 +43,8 @@ public static function referenceName(ReferenceName|string $referenceName): self
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
*/
public function with(
ReferenceName|string $referenceName = null,
ReferenceName $referenceName = null,
): self {
if (is_string($referenceName)) {
$referenceName = ReferenceName::fromString($referenceName);
}
return new self(
$referenceName ?? $this->referenceName,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function create(): self
return new self(null, null);
}

public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeConstraints): self
public static function nodeTypeConstraints(NodeTypeConstraints $nodeTypeConstraints): self
{
return self::create()->with(nodeTypeConstraints: $nodeTypeConstraints);
}
Expand All @@ -43,12 +43,9 @@ public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeC
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
*/
public function with(
NodeTypeConstraints|string $nodeTypeConstraints = null,
NodeTypeConstraints $nodeTypeConstraints = null,
int $maximumLevels = null,
): self {
if (is_string($nodeTypeConstraints)) {
$nodeTypeConstraints = NodeTypeConstraints::fromFilterString($nodeTypeConstraints);
}
return new self(
$nodeTypeConstraints ?? $this->nodeTypeConstraints,
$maximumLevels ?? $this->maximumLevels,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function create(): self
return new self(null, null, null);
}

public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeConstraints): self
public static function nodeTypeConstraints(NodeTypeConstraints $nodeTypeConstraints): self
{
return self::create()->with(nodeTypeConstraints: $nodeTypeConstraints);
}
Expand All @@ -44,13 +44,10 @@ public static function nodeTypeConstraints(NodeTypeConstraints|string $nodeTypeC
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
*/
public function with(
NodeTypeConstraints|string $nodeTypeConstraints = null,
NodeTypeConstraints $nodeTypeConstraints = null,
int $limit = null,
int $offset = null,
): self {
if (is_string($nodeTypeConstraints)) {
$nodeTypeConstraints = NodeTypeConstraints::fromFilterString($nodeTypeConstraints);
}
return new self(
$nodeTypeConstraints ?? $this->nodeTypeConstraints,
$limit ?? $this->limit,
Expand Down