Skip to content

Commit 504b37a

Browse files
authored
Merge branch 'main' into call-clause
2 parents e74f53d + 099aafa commit 504b37a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+410
-303
lines changed

src/Alias.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace WikibaseSolutions\CypherDSL;
44

5-
use WikibaseSolutions\CypherDSL\Types\AnyType;
65
use function sprintf;
6+
use WikibaseSolutions\CypherDSL\Types\AnyType;
77

88
/**
99
* Represents aliasing an expression or variable.

src/Clauses/CallProcedureClause.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ protected function getSubject(): string
174174
);
175175

176176
return sprintf("%s(%s) YIELD %s", $this->procedure, $arguments, $yieldParameters);
177-
} else {
178-
return sprintf("%s(%s)", $this->procedure, $arguments);
179177
}
178+
179+
return sprintf("%s(%s)", $this->procedure, $arguments);
180180
}
181181
}

src/Clauses/CreateClause.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
namespace WikibaseSolutions\CypherDSL\Clauses;
2323

2424
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
25-
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\StructuralType;
25+
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\NodeType;
26+
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\PathType;
2627

2728
/**
2829
* This class represents a CREATE clause.
@@ -34,18 +35,19 @@ class CreateClause extends Clause
3435
use ErrorTrait;
3536

3637
/**
37-
* @var StructuralType[] The patterns to create
38+
* @var (PathType|NodeType)[] The patterns to create
3839
*/
3940
private array $patterns = [];
4041

4142
/**
4243
* Add a pattern to create.
4344
*
44-
* @param StructuralType $pattern The pattern to create
45+
* @param PathType|NodeType $pattern The pattern to create
4546
* @return CreateClause
4647
*/
47-
public function addPattern(StructuralType $pattern): self
48+
public function addPattern($pattern): self
4849
{
50+
$this->assertClass('pattern', [PathType::class, NodeType::class], $pattern);
4951
$this->patterns[] = $pattern;
5052

5153
return $this;
@@ -54,7 +56,7 @@ public function addPattern(StructuralType $pattern): self
5456
/**
5557
* Returns the patterns of the create clause.
5658
*
57-
* @return StructuralType[]
59+
* @return (PathType|NodeType)[]
5860
*/
5961
public function getPatterns(): array
6062
{

src/Clauses/DeleteClause.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
namespace WikibaseSolutions\CypherDSL\Clauses;
2323

24-
use WikibaseSolutions\CypherDSL\Types\AnyType;
25-
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\NodeType;
24+
use WikibaseSolutions\CypherDSL\Variable;
2625

2726
/**
2827
* This class represents a DELETE clause.
@@ -39,11 +38,11 @@ class DeleteClause extends Clause
3938
private bool $detach = false;
4039

4140
/**
42-
* The nodes that needs to be deleted.
41+
* The variables that needs to be deleted.
4342
*
44-
* @var AnyType[] $nodes
43+
* @var Variable[] $variables
4544
*/
46-
private array $nodes = [];
45+
private array $variables = [];
4746

4847
/**
4948
* Sets the clause to DETACH DELETE. Without DETACH DELETE, all relationships need to be explicitly
@@ -60,14 +59,14 @@ public function setDetach(bool $detach = true): self
6059
}
6160

6261
/**
63-
* Add the node to be deleted. The expression must return a node when evaluated.
62+
* Add the variable to be deleted. The expression must return a node when evaluated.
6463
*
65-
* @param NodeType $node Expression that returns the node to be deleted
64+
* @param Variable $variable The name of the object that should be deleted
6665
* @return DeleteClause
6766
*/
68-
public function addNode(NodeType $node): self
67+
public function addVariable(Variable $variable): self
6968
{
70-
$this->nodes[] = $node;
69+
$this->variables[] = $variable;
7170

7271
return $this;
7372
}
@@ -83,13 +82,13 @@ public function detachesDeletion(): bool
8382
}
8483

8584
/**
86-
* Returns the nodes to delete.
85+
* Returns the variables to delete.
8786
*
88-
* @return AnyType[]
87+
* @return Variable[]
8988
*/
90-
public function getNodes(): array
89+
public function getVariables(): array
9190
{
92-
return $this->nodes;
91+
return $this->variables;
9392
}
9493

9594
/**
@@ -111,7 +110,7 @@ protected function getSubject(): string
111110
{
112111
return implode(
113112
", ",
114-
array_map(fn (NodeType $node) => $node->toQuery(), $this->nodes)
113+
array_map(fn (Variable $variable) => $variable->toQuery(), $this->variables)
115114
);
116115
}
117116
}

src/Clauses/MatchClause.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
namespace WikibaseSolutions\CypherDSL\Clauses;
2323

2424
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
25-
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\StructuralType;
25+
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\NodeType;
26+
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\PathType;
2627

2728
/**
2829
* This class represents a MATCH clause.
@@ -34,14 +35,14 @@ class MatchClause extends Clause
3435
use ErrorTrait;
3536

3637
/**
37-
* @var StructuralType[] List of patterns
38+
* @var (PathType|NodeType)[] List of patterns
3839
*/
3940
private array $patterns = [];
4041

4142
/**
4243
* Returns the patterns to match.
4344
*
44-
* @return StructuralType[]
45+
* @return (PathType|NodeType)[]
4546
*/
4647
public function getPatterns(): array
4748
{
@@ -51,11 +52,12 @@ public function getPatterns(): array
5152
/**
5253
* Add a pattern to the match clause.
5354
*
54-
* @param StructuralType $pattern
55+
* @param PathType|NodeType $pattern
5556
* @return MatchClause
5657
*/
57-
public function addPattern(StructuralType $pattern): self
58+
public function addPattern($pattern): self
5859
{
60+
$this->assertClass('pattern', [PathType::class, NodeType::class], $pattern);
5961
$this->patterns[] = $pattern;
6062

6163
return $this;

src/Clauses/MergeClause.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
namespace WikibaseSolutions\CypherDSL\Clauses;
2323

2424
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
25+
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\NodeType;
26+
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\PathType;
2527
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\StructuralType;
2628

2729
/**
@@ -34,7 +36,7 @@ class MergeClause extends Clause
3436
use ErrorTrait;
3537

3638
/**
37-
* @var StructuralType|null $pattern The pattern to merge
39+
* @var PathType|NodeType|null $pattern The pattern to merge
3840
*/
3941
private ?StructuralType $pattern = null;
4042

@@ -71,7 +73,7 @@ public function getOnMatchClause(): ?Clause
7173
/**
7274
* Returns the pattern to MERGE.
7375
*
74-
* @return StructuralType|null
76+
* @return PathType|NodeType|null
7577
*/
7678
public function getPattern(): ?StructuralType
7779
{
@@ -81,11 +83,12 @@ public function getPattern(): ?StructuralType
8183
/**
8284
* Sets the pattern to merge.
8385
*
84-
* @param StructuralType $pattern The pattern to merge
86+
* @param PathType|NodeType $pattern The pattern to merge
8587
* @return MergeClause
8688
*/
87-
public function setPattern(StructuralType $pattern): self
89+
public function setPattern($pattern): self
8890
{
91+
$this->assertClass('pattern', [PathType::class, NodeType::class], $pattern);
8992
$this->pattern = $pattern;
9093

9194
return $this;

src/Clauses/OptionalMatchClause.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
namespace WikibaseSolutions\CypherDSL\Clauses;
2323

2424
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
25-
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\StructuralType;
25+
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\NodeType;
26+
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\PathType;
2627

2728
/**
2829
* This class represents an OPTIONAL MATCH clause.
@@ -34,14 +35,14 @@ class OptionalMatchClause extends Clause
3435
use ErrorTrait;
3536

3637
/**
37-
* @var StructuralType[] List of patterns
38+
* @var (PathType|NodeType)[] List of patterns
3839
*/
3940
private array $patterns = [];
4041

4142
/**
4243
* Returns the patterns to optionally match.
4344
*
44-
* @return StructuralType[]
45+
* @return (PathType|NodeType)[]
4546
*/
4647
public function getPatterns(): array
4748
{
@@ -51,11 +52,12 @@ public function getPatterns(): array
5152
/**
5253
* Add a pattern to the optional match clause.
5354
*
54-
* @param StructuralType $pattern
55+
* @param PathType|NodeType $pattern
5556
* @return OptionalMatchClause
5657
*/
57-
public function addPattern(StructuralType $pattern): self
58+
public function addPattern($pattern): self
5859
{
60+
$this->assertClass('pattern', [NodeType::class, PathType::class], $pattern);
5961
$this->patterns[] = $pattern;
6062

6163
return $this;

src/Clauses/RemoveClause.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
namespace WikibaseSolutions\CypherDSL\Clauses;
2323

24-
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
2524
use WikibaseSolutions\CypherDSL\Label;
2625
use WikibaseSolutions\CypherDSL\Property;
2726
use WikibaseSolutions\CypherDSL\QueryConvertable;
27+
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
2828

2929
/**
3030
* This class represents a REMOVE clause.

src/Clauses/SetClause.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
namespace WikibaseSolutions\CypherDSL\Clauses;
2323

2424
use WikibaseSolutions\CypherDSL\Assignment;
25-
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
2625
use WikibaseSolutions\CypherDSL\Label;
2726
use WikibaseSolutions\CypherDSL\QueryConvertable;
27+
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
2828

2929
/**
3030
* This class represents a SET clause.

src/Exists.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public function toQuery(): string
8484
{
8585
if (isset($this->where)) {
8686
return sprintf("EXISTS { %s %s }", $this->match->toQuery(), $this->where->toQuery());
87-
} else {
88-
return sprintf("EXISTS { %s }", $this->match->toQuery());
8987
}
88+
89+
return sprintf("EXISTS { %s }", $this->match->toQuery());
9090
}
9191
}

0 commit comments

Comments
 (0)