-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ivan Vegner
committed
Aug 2, 2017
1 parent
177e532
commit 073e6fa
Showing
6 changed files
with
84 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<?php | ||
|
||
namespace SD\DependencyInjection; | ||
|
||
interface DeclarerInterface { | ||
|
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,7 @@ | ||
<?php | ||
namespace SD\DependencyInjection; | ||
|
||
interface ProviderInterface { | ||
public function getName(): string; | ||
public function provide(); | ||
} |
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,32 @@ | ||
<?php | ||
namespace tests; | ||
|
||
use SD\DependencyInjection\AutoDeclareTrait; | ||
use SD\DependencyInjection\ContainerAwareTrait; | ||
use SD\DependencyInjection\DeclarerInterface; | ||
use SD\DependencyInjection\ProviderInterface; | ||
|
||
class LegacyProvider implements DeclarerInterface, ProviderInterface { | ||
use AutoDeclareTrait { | ||
declareDependencies as autoDeclareDependencies; | ||
} | ||
use ContainerAwareTrait; | ||
|
||
private $name; | ||
|
||
public function declareDependencies() { | ||
return array_merge($this->autoDeclareDependencies(), ['name']); | ||
} | ||
|
||
public function setName(string $name) { | ||
$this->name = $name; | ||
} | ||
|
||
public function getName(): string { | ||
return 'helloWorld'; | ||
} | ||
|
||
public function provide() { | ||
return new LegacyService($this->name, $this->container); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
namespace tests; | ||
|
||
use SD\DependencyInjection\Container; | ||
|
||
class LegacyService { | ||
private $container; | ||
private $name; | ||
|
||
public function __construct(string $name, Container $container) { | ||
$this->name = $name; | ||
$this->container = $container; | ||
} | ||
|
||
public function getName(): string { | ||
return $this->name; | ||
} | ||
|
||
public function getContainer() { | ||
return $this->container; | ||
} | ||
} |