Skip to content

Commit 03246a1

Browse files
committed
correctly forwared insertparentheses for string types
1 parent f1e734b commit 03246a1

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/Regex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Regex extends BinaryOperator implements BooleanType
3737
/**
3838
* @inheritDoc
3939
*/
40-
public function __construct(StringType $left, StringType $right)
40+
public function __construct(StringType $left, StringType $right, bool $insertParentheses = true)
4141
{
4242
parent::__construct($left, $right);
4343
}

src/Traits/StringTypeTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ public function startsWith(StringType $right, bool $insertParentheses = true): S
7474
* Perform a regex comparison with the given expression.
7575
*
7676
* @param StringType $right
77+
* @param bool $insertParentheses
7778
* @return Regex
7879
*/
79-
public function regex(StringType $right): Regex
80+
public function regex(StringType $right, bool $insertParentheses = true): Regex
8081
{
81-
return new Regex($this, $right);
82+
return new Regex($this, $right, $insertParentheses);
8283
}
8384
}

src/Types/PropertyTypes/StringType.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,35 @@ interface StringType extends PropertyType
3535
* Check whether this expression the given expression.
3636
*
3737
* @param StringType $right
38+
* @param bool $insertParentheses
3839
* @return Contains
3940
*/
40-
public function contains(StringType $right): Contains;
41+
public function contains(StringType $right, bool $insertParentheses = true): Contains;
4142

4243
/**
4344
* Perform a suffix string search with the given expression.
4445
*
4546
* @param StringType $right
47+
* @param bool $insertParentheses
4648
* @return EndsWith
4749
*/
48-
public function endsWith(StringType $right): EndsWith;
50+
public function endsWith(StringType $right, bool $insertParentheses = true): EndsWith;
4951

5052
/**
5153
* Perform a prefix string search with the given expression.
5254
*
5355
* @param StringType $right
56+
* @param bool $insertParentheses
5457
* @return StartsWith
5558
*/
56-
public function startsWith(StringType $right): StartsWith;
59+
public function startsWith(StringType $right, bool $insertParentheses = true): StartsWith;
5760

5861
/**
5962
* Perform a regex comparison with the given expression.
6063
*
6164
* @param StringType $right
65+
* @param bool $insertParentheses
6266
* @return Regex
6367
*/
64-
public function regex(StringType $right): Regex;
68+
public function regex(StringType $right, bool $insertParentheses = true): Regex;
6569
}

0 commit comments

Comments
 (0)