Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from koriym/internal-types
Add internal type binding test
- Loading branch information
Showing
6 changed files
with
65 additions
and
12 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
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,16 @@ | ||
<?php | ||
namespace Ray\Di; | ||
|
||
class FakeInternalTypeModule extends AbstractModule | ||
{ | ||
protected function configure() | ||
{ | ||
$this->bind('')->annotatedWith('type-bool')->toInstance(false); | ||
$this->bind('')->annotatedWith('type-int')->toInstance(1); | ||
$this->bind('')->annotatedWith('type-string')->toInstance('1'); | ||
$this->bind('')->annotatedWith('type-array')->toInstance([1]); | ||
$this->bind('')->annotatedWith('type-callable')->toInstance(function(){}); | ||
$this->bind('')->annotatedWith('type-object')->toInstance(new \stdClass); | ||
$this->bind('')->annotatedWith('type-resource')->toInstance(fopen("foo", "w")); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
namespace Ray\Di; | ||
|
||
use Ray\Di\Di\Named; | ||
|
||
class FakeInternalTypes | ||
{ | ||
public $bool; | ||
public $int; | ||
public $string; | ||
public $array; | ||
public $callable; | ||
|
||
/** | ||
* @Named("bool=type-bool,int=type-int,string=type-string,array=type-array,callable=type-callable") | ||
*/ | ||
public function __construct( | ||
bool $bool, | ||
int $int, | ||
string $string, | ||
array $array, | ||
callable $callable | ||
) { | ||
$this->bool = $bool; | ||
$this->int = $int; | ||
$this->string = $string; | ||
$this->array = $array; | ||
$this->callable = $callable; | ||
} | ||
|
||
public function stringId(string $id) | ||
{ | ||
unset($id); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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