Skip to content

Commit

Permalink
Fix collectionProxy overloading methods when baseCollection change be…
Browse files Browse the repository at this point in the history
…haviour based on func_num_args()
  • Loading branch information
RemiCollin committed Feb 24, 2018
1 parent 9612cfd commit ef5e537
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions src/System/Proxies/CollectionProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,14 @@ public function contains($key, $operator = null, $value = null)

$parent = $this->toBaseCollection();

return $parent->contains($key, $operator, $value);
switch (func_num_args()) {
case 1:
return $parent->contains($key);
case 2:
return $parent->contains($key, $operator);
case 3:
return $parent->contains($key, $operator, $value);
}
}

/**
Expand All @@ -183,7 +190,12 @@ public function containsStrict($key, $value = null)
{
$this->initializeProxy();

return parent::containsStrict($key, $value);
switch (func_num_args()) {
case 1:
return parent::containsStrict($key);
case 2:
return parent::containsStrict($key, $value);
}
}

/**
Expand Down Expand Up @@ -265,7 +277,14 @@ public function every($key, $operator = null, $value = null)

$parent = $this->toBaseCollection();

return $parent->every($key, $operator, $value);
switch (func_num_args()) {
case 1:
return $parent->every($key);
case 2:
return $parent->every($key, $operator);
case 3:
return $parent->every($key, $operator, $value);
}
}

/**
Expand Down Expand Up @@ -769,7 +788,14 @@ public function partition($callback, $operator = null, $value = null)

$parent = $this->toBaseCollection();

return $parent->partition($callback);
switch(func_num_args()) {
case 1:
return $parent->partition($callback);
case 2:
return $parent->partition($callback, $operator);
case 3:
return $parent->partition($callback, $operator, $value);
}
}

/**
Expand Down Expand Up @@ -848,7 +874,7 @@ public function put($key, $value)
/**
* {@inheritdoc}
*/
public function random($amount = 1)
public function random($amount = null)
{
// TODO : we could optimize this by only
// fetching the keys from the database
Expand Down Expand Up @@ -997,7 +1023,14 @@ public function splice($offset, $length = null, $replacement = [])

$parent = $this->toBaseCollection();

return $parent->splice($offset, $length, $replacement);
switch(func_num_args()) {
case 1:
$parent->splice($offset);
case 2:
$parent->splice($offset, $length);
case 3:
$parent->splice($offset, $length, $replacement);
}
}

/**
Expand Down

0 comments on commit ef5e537

Please sign in to comment.