Skip to content

Commit 50c8d75

Browse files
committed
fix merge
1 parent cbdb1c9 commit 50c8d75

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/Model/Scope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function addCondition($field, $operator = null, $value = null)
8989
return $this;
9090
}
9191

92-
protected function setSystem($system = true)
92+
protected function setSystem(bool $system = true)
9393
{
9494
foreach ($this->elements as $nestedCondition) {
9595
$nestedCondition->setSystem($system && $this->isAnd());

src/Model/Scope/AbstractScope.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ protected function init(): void
3434
$this->_init();
3535

3636
// always set system flag if condition added to another condition
37-
$this->setSystem($this->owner instanceof RootScope);
37+
$this->setSystem($owner instanceof RootScope);
3838

3939
$this->onChangeModel();
4040
}
4141

4242
abstract protected function onChangeModel(): void;
4343

44-
abstract protected function setSystem($system = true);
44+
/**
45+
* @return $this
46+
*/
47+
abstract protected function setSystem(bool $system = true);
4548

4649
/**
4750
* Get the model this condition is associated with.

src/Model/Scope/Condition.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Condition extends AbstractScope
2626
/** @var mixed */
2727
public $value;
2828

29-
protected $system = false;
29+
protected bool $system = false;
3030

3131
public const OPERATOR_EQUALS = '=';
3232
public const OPERATOR_DOESNOT_EQUAL = '!=';
@@ -151,7 +151,7 @@ public function __construct($key, $operator = null, $value = null)
151151
}
152152
}
153153

154-
protected function setSystem($system = true)
154+
protected function setSystem(bool $system = true)
155155
{
156156
$this->system = $system;
157157

@@ -165,7 +165,7 @@ protected function onChangeModel(): void
165165
// if we have a definitive equal condition set the value as default value for field
166166
// new records will automatically get this value assigned for the field
167167
// TODO: fix when condition is part of OR scope
168-
if ($this->system && $this->setsDefiniteValue()) {
168+
if ($this->system && $this->isDefiniteValue()) {
169169
// key containing '/' means chained references and it is handled in toQueryArguments method
170170
$field = $this->key;
171171
if (is_string($field) && !str_contains($field, '/')) {
@@ -271,9 +271,11 @@ public function isEmpty(): bool
271271
/**
272272
* Checks if condition sets a definitive scalar value for a field.
273273
*/
274-
protected function setsDefiniteValue(): bool
274+
protected function isDefiniteValue(): bool
275275
{
276-
return $this->operator === self::OPERATOR_EQUALS && !is_object($this->value) && !is_array($this->value);
276+
return $this->operator === self::OPERATOR_EQUALS && !is_array($this->value)
277+
&& !$this->value instanceof Expressionable
278+
&& !$this->value instanceof Persistence\Array_\Action; // needed to pass hintable tests
277279
}
278280

279281
public function clear()

0 commit comments

Comments
 (0)