Skip to content

Commit af6dcec

Browse files
committed
Singleton parameter is optional.
Signed-off-by: Joshua Parker <[email protected]>
1 parent ddd38d2 commit af6dcec

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Configuration/ApplicationBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ public function withProviders(array $providers = []): self
5353
* @param array $singletons
5454
* @return $this
5555
*/
56-
public function withSingletons(array $singletons): self
56+
public function withSingletons(array $singletons = []): self
5757
{
58+
if (empty($singletons)) {
59+
return $this;
60+
}
61+
5862
$this->registered(function ($app) use ($singletons) {
5963
foreach ($singletons as $key => $callable) {
6064
$app->singleton($key, $callable);

tests/Pipes/PipelineTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use Codefy\Framework\Configuration\ApplicationBuilder;
5+
use Codefy\Framework\Application;
66
use Codefy\Framework\Pipeline\Pipeline;
77
use Codefy\Framework\Pipeline\PipelineBuilder;
88
use Codefy\Framework\tests\Pipes\PipeFour;
@@ -11,10 +11,10 @@
1111
use Codefy\Framework\tests\Pipes\PipeTwo;
1212
use PHPUnit\Framework\Assert;
1313

14-
/** @var ApplicationBuilder $app */
14+
/** @var Application $app */
1515
$app = require_once __DIR__ . '/../vendor/bootstrap.php';
1616

17-
$pipeline = new Pipeline($app->return());
17+
$pipeline = new Pipeline($app);
1818

1919
it('has exception handled by onFailure method.', function () use ($pipeline) {
2020
$result = $pipeline

tests/vendor/bootstrap.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
use Qubus\Exception\Data\TypeException;
55

66
try {
7-
return Application::configure(['basePath' => dirname(path: __DIR__, levels: 2)]);
7+
return Application::configure(['basePath' => dirname(path: __DIR__, levels: 2)])
8+
->withProviders([
9+
// fill in custom providers
10+
])
11+
->withSingletons([
12+
// fill in custom singletons
13+
])
14+
->return();
815
} catch (TypeException $e) {
916
return $e->getMessage();
1017
}

0 commit comments

Comments
 (0)