Skip to content

Commit

Permalink
fixed regression in api
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrawley committed Sep 26, 2016
1 parent 4fa860b commit 71e01d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 57 deletions.
37 changes: 3 additions & 34 deletions lib/CallSilencer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ final class CallSilencer implements CallSilencerInterface
* Constructor allows for setting main closure or validation closure.
*
* @param \Closure|null $invokableInst Main invokable called in an error-silenced environment
* @param object $invokableBind Binding for main invokable closure call
* @param \Closure|null $validatorInst Validation checker that determines return value validity
* @param object $invokableBind Binding for main invokable closure call
* @param object $validatorBind Binding for result validation closure
*/
public function __construct(\Closure $invokableInst = null, $invokableBind = null, \Closure $validatorInst = null, $validatorBind = null)
public function __construct(\Closure $invokableInst = null, \Closure $validatorInst = null, $invokableBind = null, $validatorBind = null)
{
$this->setInvokable($invokableInst, $invokableBind);
$this->setValidator($validatorInst, $validatorBind);
Expand All @@ -98,7 +98,7 @@ public function __construct(\Closure $invokableInst = null, $invokableBind = nul
*/
public static function create(\Closure $invokableInst = null, \Closure $validatorInst = null) : CallSilencerInterface
{
return new static($invokableInst, null, $validatorInst, null);
return new static($invokableInst, $validatorInst);
}

/**
Expand All @@ -124,21 +124,6 @@ public function disableSilencerRestoration() : CallSilencerInterface
public function setInvokable(\Closure $invokableInst = null, $invokableBind = null) : CallSilencerInterface
{
$this->invokableInst = $invokableInst;
$this->setInvokableBind($invokableBind);

return $this;
}

/**
* Assign an alternate binding context/scope for main invokable closure. By default it is not re-bound
* and will have the context/scope of the object it was originally defined in.
*
* @param null|object $invokableBind Bind to apply to main invokable closure
*
* @return CallSilencerInterface
*/
public function setInvokableBind($invokableBind = null) : CallSilencerInterface
{
$this->invokableBind = $invokableBind ?: $this->invokableBind;

return $this;
Expand All @@ -156,22 +141,6 @@ public function setInvokableBind($invokableBind = null) : CallSilencerInterface
public function setValidator(\Closure $validatorInst = null, $validatorBind = null) : CallSilencerInterface
{
$this->validatorInst = $validatorInst;
$this->setValidatorBind($validatorBind);

return $this;
}

/**
* Assign an alternate binding context/scope for validation closure. By default it is bound
* to the silencer instance itself, allowing it to access the array of helper methods regarding
* return values and errors.
*
* @param null|object $validatorBind Bind to apply to result validation closure
*
* @return CallSilencerInterface
*/
public function setValidatorBind($validatorBind = null) : CallSilencerInterface
{
$this->validatorBind = $validatorBind ?: $this->validatorBind;

return $this;
Expand Down
25 changes: 2 additions & 23 deletions lib/CallSilencerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ interface CallSilencerInterface
* Constructor allows for setting main closure or validation closure.
*
* @param \Closure|null $invokableInst Main invokable called in an error-silenced environment
* @param object $invokableBind Binding for main invokable closure call
* @param \Closure|null $validatorInst Validation checker that determines return value validity
* @param object $invokableBind Binding for main invokable closure call
* @param object $validatorBind Binding for result validation closure
*/
public function __construct(\Closure $invokableInst = null, $invokableBind = null, \Closure $validatorInst = null, $validatorBind = self::class);
public function __construct(\Closure $invokableInst = null, \Closure $validatorInst = null, $invokableBind = null, $validatorBind = self::class);

/**
* Static method constructs method using same options as main constructor.
Expand Down Expand Up @@ -52,16 +52,6 @@ public function disableSilencerRestoration() : CallSilencerInterface;
*/
public function setInvokable(\Closure $invokableInst = null) : CallSilencerInterface;

/**
* Assign an alternate binding context/scope for main invokable closure. By default it is not re-bound
* and will have the context/scope of the object it was originally defined in.
*
* @param null|object $invokableBind Bind to apply to main invokable closure
*
* @return CallSilencerInterface
*/
public function setInvokableBind($invokableBind = null) : CallSilencerInterface;

/**
* Assigns a \Closure instance used to determine return value validity. It is passed the return value and the php
* error array (or null if non exists) as its only parameters.
Expand All @@ -72,17 +62,6 @@ public function setInvokableBind($invokableBind = null) : CallSilencerInterface;
*/
public function setValidator(\Closure $validatorInst = null) : CallSilencerInterface;

/**
* Assign an alternate binding context/scope for validation closure. By default it is bound
* to the silencer instance itself, allowing it to access the array of helper methods regarding
* return values and errors.
*
* @param null|object $validatorBind Bind to apply to result validation closure
*
* @return CallSilencerInterface
*/
public function setValidatorBind($validatorBind = null) : CallSilencerInterface;

/**
* Invoke the closure within a silenced environment.
*
Expand Down

0 comments on commit 71e01d1

Please sign in to comment.