Skip to content

Commit 09f5e7d

Browse files
committed
resolve some issues
1 parent e287267 commit 09f5e7d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/Clause.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ class Clause
110110
* @param array $props
111111
* @return $this
112112
*/
113-
protected function fresh($props = [])
113+
public function fresh($props = [])
114114
{
115115
$properties = [
116116
'_data' => [],
117-
'_baseData' => [],
117+
'_original' => [],
118118
'_select' => [],
119119
'_isProcessed' => false,
120120
'_node' => '',
@@ -145,9 +145,11 @@ protected function fresh($props = [])
145145
*/
146146
public function collect($data)
147147
{
148+
$this->reProcess();
149+
$this->fresh();
150+
148151
$this->_data = deep_copy($data);
149152
$this->_original = deep_copy($data);
150-
$this->_isProcessed = false;
151153

152154
return $this;
153155
}
@@ -453,9 +455,10 @@ protected function makeResult($data, $newInstance = false)
453455
protected function instanceWithValue($value, $meta = [])
454456
{
455457
$instance = new static();
458+
$instance = $instance->collect($value);
456459
$instance->fresh($meta);
457460

458-
return $instance->collect($value);
461+
return $instance;
459462
}
460463

461464
/**

src/QueryEngine.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,13 @@ public function valid()
197197
public function copy($fresh = false)
198198
{
199199
if ($fresh) {
200-
$this->fresh();
200+
$this->fresh([
201+
'_data' => $this->_data,
202+
'_original' => $this->_original,
203+
'_traveler' => $this->_traveler,
204+
]);
201205
}
206+
202207
return deep_copy($this);
203208
}
204209

@@ -283,8 +288,6 @@ public function reset($data = null, $fresh = false)
283288

284289
$this->collect($data);
285290

286-
$this->reProcess();
287-
288291
return $this;
289292
}
290293

@@ -844,7 +847,7 @@ public function keys()
844847
{
845848
$this->prepare();
846849

847-
return array_keys($this->_data);
850+
return $this->makeResult(array_keys($this->_data));
848851
}
849852

850853
/**

0 commit comments

Comments
 (0)