Changeset 1371
- Timestamp:
- 02/25/08 23:27:22 (3 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ioc/ioc.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/stubAbstractIOCPreInterceptor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/stubBinder.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/stubBinding.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/stubBindingModule.php (deleted)
- trunk/src/main/php/net/stubbles/ioc/stubClassBinding.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/stubConstantBinding.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubInjector.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/IOCTestSuite.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubAbstractIOCPreInterceptorTestCase.php (added)
- trunk/src/test/php/net/stubbles/ioc/stubBinderTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorBasicTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorConstantTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorImplementedByTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorNamedTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorProviderTestCase.php (added)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorSingletonTestCase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ioc/ioc.php
r1222 r1371 7 7 * @subpackage ioc 8 8 */ 9 // @codeCoverageIgnoreStart 9 10 stubClassLoader::load('net::stubbles::ioc::stubBinder'); 11 // @codeCoverageIgnoreEnd 10 12 ?> trunk/src/main/php/net/stubbles/ioc/stubAbstractIOCPreInterceptor.php
r1301 r1371 29 29 { 30 30 $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 31 if ( $binder === null) {31 if (null === $binder) { 32 32 $binder = new stubBinder(); 33 33 stubRegistry::set(stubBinder::REGISTRY_KEY, $binder); 34 34 } 35 35 36 $this->configure($binder); 36 37 } 37 38 38 39 /** 39 * Configure the binder40 * configure the binder 40 41 * 41 42 * @param stubBinder $binder trunk/src/main/php/net/stubbles/ioc/stubBinder.php
r1301 r1371 78 78 public function bindConstant() 79 79 { 80 $binding = new stubConstantBinding( $this->injector);80 $binding = new stubConstantBinding(); 81 81 $this->injector->addBinding($binding); 82 82 return $binding; trunk/src/main/php/net/stubbles/ioc/stubBinding.php
r1370 r1371 37 37 */ 38 38 public function getKey(); 39 40 /**41 * get the scope for this binding42 *43 * @return stubBindingScope44 */45 public function getScope();46 39 } 47 40 ?> trunk/src/main/php/net/stubbles/ioc/stubClassBinding.php
r1370 r1371 190 190 return $this->type . '#' . $this->name; 191 191 } 192 193 /**194 * get the scope of the binding195 *196 * @return stubBindingScope197 */198 public function getScope()199 {200 return $this->scope;201 }202 203 192 } 204 193 ?> trunk/src/main/php/net/stubbles/ioc/stubConstantBinding.php
r1370 r1371 21 21 * This string is used when generating the key for a constant binding. 22 22 */ 23 const TYPE = '__CONSTANT__'; 24 /** 25 * injector used by this binding 26 * 27 * @var stubInjector 28 */ 29 protected $injector = null; 23 const TYPE = '__CONSTANT__'; 30 24 /** 31 25 * annotated with a name … … 33 27 * @var string 34 28 */ 35 protected $name = null;29 protected $name = null; 36 30 /** 37 31 * provider that holds the binded value … … 43 37 /** 44 38 * constructor 45 *46 * @param stubInjector $injector47 39 */ 48 public function __construct( $injector)40 public function __construct() 49 41 { 50 $this->injector = $injector;51 42 $this->valueProvider = new stubValueInjectionProvider(); 52 43 } … … 95 86 return self::TYPE . '#' . $this->name; 96 87 } 97 98 /**99 * constant bindings have no scope100 *101 * @return stubBindingScope102 */103 public function getScope()104 {105 return null;106 }107 88 } 108 89 ?> trunk/src/main/php/net/stubbles/ioc/stubInjector.php
r1370 r1371 153 153 154 154 foreach ($class->getMethods() as $method) { 155 if (strncmp($method->getName(), '__', 2) === 0) { 156 continue; 157 } 158 159 if ($method->isPublic() === false) { 160 continue; 161 } 162 163 if ($method->hasAnnotation('Inject') === false) { 155 if (strncmp($method->getName(), '__', 2) === 0 || $method->isPublic() === false || $method->hasAnnotation('Inject') === false) { 164 156 continue; 165 157 } trunk/src/test/php/net/stubbles/ioc/IOCTestSuite.php
r1235 r1371 29 29 $suite->addTestFile($dir . '/annotations/stubNamedAnnotationTestCase.php'); 30 30 $suite->addTestFile($dir . '/annotations/stubSingletonAnnotationTestCase.php'); 31 $suite->addTestFile($dir . '/stubAbstractIOCPreInterceptorTestCase.php'); 31 32 $suite->addTestFile($dir . '/stubBinderTestCase.php'); 32 33 $suite->addTestFile($dir . '/stubInjectorBasicTestCase.php'); … … 34 35 $suite->addTestFile($dir . '/stubInjectorImplementedByTestCase.php'); 35 36 $suite->addTestFile($dir . '/stubInjectorNamedTestCase.php'); 37 $suite->addTestFile($dir . '/stubInjectorProviderTestCase.php'); 36 38 $suite->addTestFile($dir . '/stubInjectorSingletonTestCase.php'); 37 39 $suite->addTestFile($dir . '/stubIOCPreInterceptorTestCase.php'); trunk/src/test/php/net/stubbles/ioc/stubBinderTestCase.php
r1235 r1371 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection_test7 * @subpackage ioc_test 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ioc::stubBinder'); … … 13 13 * 14 14 * @package stubbles 15 * @subpackage ioc_ injection_test15 * @subpackage ioc_test 16 16 */ 17 17 class stubBinderTestCase extends PHPUnit_Framework_TestCase trunk/src/test/php/net/stubbles/ioc/stubInjectorBasicTestCase.php
r1235 r1371 489 489 $this->assertType('stubInjectorTestCase_Goodyear', $obj->getGoodyearBySetter()); 490 490 } 491 492 /** 493 * given injector should be used instead of creating a new one 494 * 495 * @test 496 */ 497 public function injectedInjectorIsUsed() 498 { 499 $injector = new stubInjector(); 500 $binder = new stubBinder($injector); 501 $this->assertSame($injector, $binder->getInjector()); 502 } 503 504 /** 505 * requesting a missing binding throws a binding exception 506 * 507 * @test 508 * @expectedException stubBindingException 509 */ 510 public function missingBindingThrowsBindingException() 511 { 512 $injector = new stubInjector(); 513 $injector->getInstance('stubInjectorTestCase_Vehicle'); 514 } 515 516 /** 517 * requesting a missing binding throws a binding exception 518 * 519 * @test 520 * @expectedException stubBindingException 521 */ 522 public function missingBindingOnInjectionHandlingThrowsBindingException() 523 { 524 $injector = new stubInjector(); 525 $class = new stubInjectorTestCase_Bike(); 526 $injector->handleInjections($class); 527 } 491 528 } 492 529 ?> trunk/src/test/php/net/stubbles/ioc/stubInjectorConstantTestCase.php
r1235 r1371 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection_test7 * @subpackage ioc_test 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ioc::stubBinder'); … … 29 29 * 30 30 * @package stubbles 31 * @subpackage ioc_ injection_test31 * @subpackage ioc_test 32 32 */ 33 33 class stubInjectorConstantTestCase extends PHPUnit_Framework_TestCase trunk/src/test/php/net/stubbles/ioc/stubInjectorImplementedByTestCase.php
r1235 r1371 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection_test7 * @subpackage ioc_test 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ioc::stubBinder'); … … 34 34 * 35 35 * @package stubbles 36 * @subpackage ioc_ injection_test36 * @subpackage ioc_test 37 37 */ 38 38 class stubInjectorImplementedByTestCase extends PHPUnit_Framework_TestCase trunk/src/test/php/net/stubbles/ioc/stubInjectorNamedTestCase.php
r1235 r1371 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection_test7 * @subpackage ioc_test 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ioc::stubBinder'); … … 56 56 * 57 57 * @package stubbles 58 * @subpackage ioc_ injection_test58 * @subpackage ioc_test 59 59 */ 60 60 class stubInjectorNamedTestCase extends PHPUnit_Framework_TestCase trunk/src/test/php/net/stubbles/ioc/stubInjectorSingletonTestCase.php
r1235 r1371 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection_test7 * @subpackage ioc_test 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ioc::stubBinder'); … … 77 77 * 78 78 * @package stubbles 79 * @subpackage ioc_ injection_test79 * @subpackage ioc_test 80 80 */ 81 81 class stubInjectorSingletonTestCase extends PHPUnit_Framework_TestCase
