Skip to content

Commit bd64590

Browse files
Merge pull request #27 from transistive/quality-of-life
Quality of life improvements
2 parents d2e695e + d7d7f92 commit bd64590

File tree

106 files changed

+2179
-489
lines changed

Some content is hidden

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

106 files changed

+2179
-489
lines changed

src/Addition.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class Addition extends BinaryOperator implements NumeralType
3636
/**
3737
* @inheritDoc
3838
*/
39-
public function __construct(NumeralType $left, NumeralType $right)
39+
public function __construct(NumeralType $left, NumeralType $right, bool $insertParentheses = true)
4040
{
41-
parent::__construct($left, $right);
41+
parent::__construct($left, $right, $insertParentheses);
4242
}
4343

4444
/**

src/AndOperator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class AndOperator extends BinaryOperator implements BooleanType
3636
/**
3737
* @inheritDoc
3838
*/
39-
public function __construct(BooleanType $left, BooleanType $right)
39+
public function __construct(BooleanType $left, BooleanType $right, bool $insertParentheses = true)
4040
{
41-
parent::__construct($left, $right);
41+
parent::__construct($left, $right, $insertParentheses);
4242
}
4343

4444
/**

src/Assignment.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ public function setMutate(bool $mutate = true): self
6565
return $this;
6666
}
6767

68+
/**
69+
* Returns whether the assignment uses property mutation instead of replacement.
70+
*
71+
* @return bool
72+
*/
73+
public function mutates(): bool
74+
{
75+
return $this->mutate;
76+
}
77+
6878
/**
6979
* @inheritDoc
7080
*/

src/BinaryOperator.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,34 @@ public function toQuery(): string
7676
* @return string
7777
*/
7878
abstract protected function getOperator(): string;
79+
80+
/**
81+
* Gets the left-hand of the expression.
82+
*
83+
* @return AnyType
84+
*/
85+
public function getLeft(): AnyType
86+
{
87+
return $this->left;
88+
}
89+
90+
/**
91+
* Gets the right-hand of the expression.
92+
*
93+
* @return AnyType
94+
*/
95+
public function getRight(): AnyType
96+
{
97+
return $this->right;
98+
}
99+
100+
/**
101+
* Returns whether or not the operator inserts parenthesis.
102+
*
103+
* @return bool
104+
*/
105+
public function insertsParentheses(): bool
106+
{
107+
return $this->insertParentheses;
108+
}
79109
}

src/Clauses/CallProcedureClause.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CallProcedureClause extends Clause
3737
/**
3838
* @var string|null The procedure to call
3939
*/
40-
private ?string $procedure;
40+
private ?string $procedure = null;
4141

4242
/**
4343
* @var AnyType[] The arguments passed to the procedure
@@ -66,6 +66,36 @@ public function setProcedure(string $procedure): self
6666
return $this;
6767
}
6868

69+
/**
70+
* Returns the variables to yield.
71+
*
72+
* @return Variable[]
73+
*/
74+
public function getYieldVariables(): array
75+
{
76+
return $this->yieldVariables;
77+
}
78+
79+
/**
80+
* Returns the procedure to call.
81+
*
82+
* @return string|null
83+
*/
84+
public function getProcedure(): ?string
85+
{
86+
return $this->procedure;
87+
}
88+
89+
/**
90+
* Returns the arguments of the procedure.
91+
*
92+
* @return AnyType[]
93+
*/
94+
public function getArguments(): array
95+
{
96+
return $this->arguments;
97+
}
98+
6999
/**
70100
* Sets the arguments to pass to this procedure call. This overwrites any previously passed
71101
* arguments.

src/Clauses/CreateClause.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ public function addPattern($pattern): self
5454
return $this;
5555
}
5656

57+
/**
58+
* Returns the patterns of the create clause.
59+
*
60+
* @return StructuralType[]
61+
*/
62+
public function getPatterns(): array
63+
{
64+
return $this->patterns;
65+
}
66+
5767
/**
5868
* @inheritDoc
5969
*/

src/Clauses/DeleteClause.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ public function addNode(NodeType $node): self
7272
return $this;
7373
}
7474

75+
/**
76+
* Returns whether the deletion detaches the relationships.
77+
*
78+
* @return bool
79+
*/
80+
public function detachesDeletion(): bool
81+
{
82+
return $this->detach;
83+
}
84+
85+
/**
86+
* Returns the nodes to delete.
87+
*
88+
* @return AnyType[]
89+
*/
90+
public function getNodes(): array
91+
{
92+
return $this->nodes;
93+
}
94+
7595
/**
7696
* @inheritDoc
7797
*/

src/Clauses/LimitClause.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ class LimitClause extends Clause
3535
*
3636
* @var NumeralType|null $limit
3737
*/
38-
private ?NumeralType $limit;
38+
private ?NumeralType $limit = null;
39+
40+
/**
41+
* Returns the actual limit of the clause.
42+
*
43+
* @return NumeralType|null
44+
*/
45+
public function getLimit(): ?NumeralType
46+
{
47+
return $this->limit;
48+
}
3949

4050
/**
4151
* Sets the expression that returns the limit.

src/Clauses/MatchClause.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ class MatchClause extends Clause
3939
*/
4040
private array $patterns = [];
4141

42+
/**
43+
* Returns the patterns to match.
44+
*
45+
* @return StructuralType[]
46+
*/
47+
public function getPatterns(): array
48+
{
49+
return $this->patterns;
50+
}
51+
4252
/**
4353
* Add a pattern to the match clause.
4454
*

src/Clauses/MergeClause.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,47 @@ class MergeClause extends Clause
3737
/**
3838
* @var StructuralType|Assignment|null $pattern The pattern to merge
3939
*/
40-
private $pattern;
40+
private $pattern = null;
4141

4242
/**
4343
* @var Clause|null $createClause The clause to execute when the pattern is created
4444
*/
45-
private ?Clause $createClause;
45+
private ?Clause $createClause = null;
4646

4747
/**
4848
* @var Clause|null $matchClause The clause to execute when the pattern is matched
4949
*/
50-
private ?Clause $matchClause;
50+
private ?Clause $matchClause = null;
51+
52+
/**
53+
* Returns the clause to execute when the pattern is matched.
54+
*
55+
* @return Clause|null
56+
*/
57+
public function getOnCreateClause(): ?Clause
58+
{
59+
return $this->createClause;
60+
}
61+
62+
/**
63+
* Returns the clause to execute when the pattern is matched.
64+
*
65+
* @return Clause|null
66+
*/
67+
public function getOnMatchClause(): ?Clause
68+
{
69+
return $this->matchClause;
70+
}
71+
72+
/**
73+
* Returns the pattern to MERGE.
74+
*
75+
* @return StructuralType|null
76+
*/
77+
public function getPattern(): ?StructuralType
78+
{
79+
return $this->pattern;
80+
}
5181

5282
/**
5383
* Sets the pattern to merge.

0 commit comments

Comments
 (0)