-
-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into skip-closure-support
# Conflicts: # src/Support/HigherOrderMessage.php
- Loading branch information
Showing
6 changed files
with
116 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Support; | ||
|
||
use Pest\Expectation; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class HigherOrderCallables | ||
{ | ||
/** | ||
* @var object | ||
*/ | ||
private $target; | ||
|
||
public function __construct(object $target) | ||
{ | ||
$this->target = $target; | ||
} | ||
|
||
/** | ||
* @template TValue | ||
* | ||
* Create a new expectation. Callable values will be executed prior to returning the new expectation. | ||
* | ||
* @param callable|TValue $value | ||
* | ||
* @return Expectation<TValue> | ||
*/ | ||
public function expect($value) | ||
{ | ||
return new Expectation(is_callable($value) ? Reflection::bindCallable($value) : $value); | ||
} | ||
|
||
/** | ||
* @template TValue | ||
* | ||
* Create a new expectation. Callable values will be executed prior to returning the new expectation. | ||
* | ||
* @param callable|TValue $value | ||
* | ||
* @return Expectation<TValue> | ||
*/ | ||
public function and($value) | ||
{ | ||
return $this->expect($value); | ||
} | ||
|
||
/** | ||
* @template TValue | ||
* | ||
* @param callable(): TValue $callable | ||
* | ||
* @return TValue|object | ||
*/ | ||
public function tap(callable $callable) | ||
{ | ||
Reflection::bindCallable($callable); | ||
|
||
return $this->target; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters