Changeset 1127
- Timestamp:
- 12/06/07 23:11:20 (7 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/auth/stubAuthResult.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/events/stubCallbackListener.php (modified) (7 diffs)
- trunk/src/main/php/net/stubbles/events/stubLazyEventListener.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/annotations/stubInjectAnnotation.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/ioc/annotations/stubNamedAnnotation.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/annotations/stubSingletonAnnotation.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/ioc/exceptions/stubBindingException.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/ioc/exceptions/stubInjectionException.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubBinder.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubBinding.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/stubBindingModule.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/stubBindingScope.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ioc/stubBindingScopeSingleton.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubBindingScopes.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubClassBinding.php (modified) (17 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubConstantBinding.php (modified) (7 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubDefaultInjectionProvider.php (modified) (6 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubInjector.php (modified) (11 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/broker/stubRequestBroker.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubAbstractStringFilter.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubFloatFilter.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/stubAbstractRequest.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/session/resourcemanager/stubSessionResource.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/session/resourcemanager/stubSessionResourceManager.php (modified) (14 diffs)
- trunk/src/main/php/net/stubbles/lang/exceptions/stubFileNotFoundException.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/lang/stubBaseObject.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/lang/stubEnum.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/lang/stubMode.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/php/serializer/stubPHPSerializerSPLSerializableMapping.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/php/serializer/stubUnknownObject.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/php/string/stubAbstractStringEncoder.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/php/string/stubHTMLSpecialCharsEncoder.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/rdbms/pdo/stubDatabasePDOConnection.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/rdbms/persistence/creator/stubDatabaseCreator.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/rdbms/persistence/eraser/stubDatabaseEraser.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/rdbms/persistence/finder/stubDatabaseFinder.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/rdbms/persistence/serializer/stubDatabaseSerializer.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/rdbms/persistence/stubSetterMethodHelper.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseTableDescription.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseTableJoin.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationArgumentState.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamValueState.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationTypeState.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/stubAnnotationStateParser.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/reflection/annotations/stubAnnotationFactory.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/stubReflectionClass.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/reflection/stubReflectionMethod.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/stubReflectionParameter.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/service/annotations/stubWebMethodAnnotation.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/service/jsonrpc/stubJsonRpcProcessor.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/service/soap/native/stubNativeSoapClient.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/service/soap/stubSoapClientConfiguration.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/cache/stubCache.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/datespan/stubDateSpanMonth.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/datespan/stubDateSpanYesterday.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/ext/stubXPClassLoader.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/log/stubLogDataFactory.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/log/stubLogger.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/net/http/stubHTTPResponse.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/net/http/stubHTTPURL.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/net/stubSocket.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/validators/stubAbstractCompositeValidator.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/validators/stubContainsValidator.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/validators/stubEqualValidator.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfClassLoader.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisConfig.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisIncludeTemplatePageElement.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisLoadExtensionPageElement.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/stubFrontController.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/variantmanager/stubVariantsMap.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/websites/variantmanager/stubVariantsPreInterceptor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/variantmanager/types/stubAbstractVariant.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/xml/stubXMLPostInterceptor.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/xml/rss/stubRSSFeedGenerator.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/xml/rss/stubRSSFeedItem.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLAttributeAnnotation.php (modified) (9 diffs)
- trunk/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLFragmentAnnotation.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLIgnoreAnnotation.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLMatcherAnnotation.php (modified) (6 diffs)
- trunk/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLMethodsAnnotation.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLPropertiesAnnotation.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLStrategyAnnotation.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/xml/serializer/annotations/stubXMLTagAnnotation.php (modified) (8 diffs)
- trunk/src/main/php/net/stubbles/xml/serializer/stubXMLSerializer.php (modified) (8 diffs)
- trunk/src/main/php/net/stubbles/xml/stubAbstractXMLStreamWriter.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/xml/stubDomXMLStreamWriter.php (modified) (17 diffs)
- trunk/src/main/php/net/stubbles/xml/stubLibXmlXMLStreamWriter.php (modified) (14 diffs)
- trunk/src/main/php/net/stubbles/xml/stubXMLException.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/xml/stubXMLStreamWriter.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/xml/stubXMLXIncludeStreamWrapper.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/xml/xsl/stubXSLCallback.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/xml/xsl/stubXSLMethodAnnotation.php (moved) (moved from trunk/src/main/php/net/stubbles/xml/xsl/XSLMethod.php) (1 diff)
- trunk/src/main/php/net/stubbles/xml/xsl/stubXSLProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/xml/xsl/util/stubXSLImageDimensions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/auth/stubAuthResult.php
r755 r1127 14 14 * @subpackage auth 15 15 */ 16 class stubAuthResult extends stubSerializableObject 16 class stubAuthResult extends stubSerializableObject 17 17 { 18 18 /** trunk/src/main/php/net/stubbles/events/stubCallbackListener.php
r1035 r1127 67 67 * @param string $method method of class to callback when listener is notified 68 68 * @param bool $autoRemove optional whether listener should be removed if it has handled one event or not 69 * @throws stubIllegalArgumentException 69 70 */ 70 71 public function __construct($instance, $method, $autoRemove = false) … … 101 102 $params = $this->refMethod->getParameters(); 102 103 103 if (count($params) == 0) {104 if (count($params) === 0) { 104 105 try { 105 106 $this->refMethod->invoke($this->instance); … … 115 116 foreach ($params as $param) { 116 117 // if argument of method takes an event 117 if (null != $param->getClass() && 'stubEvent' == $param->getClass()->getName()) {118 if (null != $param->getClass() && 'stubEvent' === $param->getClass()->getName()) { 118 119 // pass the event as argument 119 120 $args[] = $event; 120 121 continue; 121 // elseif argument of method takes the type of the context if context is not null122 } elseif (null != $param->getClass() && null != $event->getContext() && get_class($event->getContext()) == $param->getClass()->getName()) {122 } elseif (null != $param->getClass() && null !== $event->getContext() && get_class($event->getContext()) === $param->getClass()->getName()) { 123 // argument of method takes the type of the context if context is not null 123 124 // pass the context as argument 124 125 $args[] = $event->getContext(); 125 126 continue; 126 // if param is optional in general 127 } elseif ($param->isOptional() == true) { 128 // take the default value if available 129 if ($param->isDefaultValueAvailable() == true) { 127 } elseif ($param->isOptional() === true) { 128 // param is optional in general: take the default value if available 129 if ($param->isDefaultValueAvailable() === true) { 130 130 $args[] = $param->getDefaultValue(); 131 131 } else { … … 134 134 135 135 continue; 136 // if param allows null 137 } elseif ($param->allowsNull() == true) { 136 } elseif ($param->allowsNull() === true) { 138 137 $args[] = null; 139 138 continue; … … 218 217 private function createInstance() 219 218 { 220 if (is_object($this->instance) == true) {219 if (is_object($this->instance) === true) { 221 220 if (null == $this->refMethod) { 222 221 $refClass = new ReflectionClass($this->class); … … 252 251 private function loadMethod(ReflectionClass $refClass) 253 252 { 254 if ($refClass->hasMethod($this->method) == false) {253 if ($refClass->hasMethod($this->method) === false) { 255 254 throw new stubCallbackException('Could not execute ' . $this->class . '::' . $this->method . '(), method does not exist.'); 256 255 } … … 258 257 // we can not call non-public methods 259 258 $this->refMethod = $refClass->getMethod($this->method); 260 if ($this->refMethod->isPublic() == false) {259 if ($this->refMethod->isPublic() === false) { 261 260 throw new stubCallbackException('Could not execute ' . $this->class . '::' . $this->method . '(), method is not declared as public.'); 262 261 } 263 262 264 if ($this->refMethod->isStatic() == true) {263 if ($this->refMethod->isStatic() === true) { 265 264 $this->instance = null; 266 265 } trunk/src/main/php/net/stubbles/events/stubLazyEventListener.php
r1035 r1127 69 69 * 70 70 * @return stubEventListener 71 * @throws stubRuntimeException 71 72 */ 72 73 protected function createInstance() trunk/src/main/php/net/stubbles/ioc/annotations/stubInjectAnnotation.php
r844 r1127 1 1 <?php 2 2 /** 3 * Annotation to mark a method that is used for 4 * dependency injection 3 * Annotation to mark a method that is used for dependency injection 5 4 * 6 5 * @author Stephan Schmidt <schst@stubbles.net> 7 6 * @package stubbles 8 * @subpackage ioc_ injection7 * @subpackage ioc_annotations 9 8 */ 10 9 stubClassLoader::load('net.stubbles.reflection.annotations.stubAbstractAnnotation'); 11 12 10 /** 13 * Annotation to mark a method that is used for 14 * dependency injection 11 * Annotation to mark a method that is used for dependency injection 15 12 * 16 13 * @package stubbles 17 * @subpackage ioc_ injection14 * @subpackage ioc_annotations 18 15 */ 19 16 class stubInjectAnnotation extends stubAbstractAnnotation … … 51 48 * @return boolean 52 49 */ 53 public function isOptional() { 50 public function isOptional() 51 { 54 52 return $this->optional; 55 53 } trunk/src/main/php/net/stubbles/ioc/annotations/stubNamedAnnotation.php
r844 r1127 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection7 * @subpackage ioc_annotations 8 8 */ 9 10 9 stubClassLoader::load('net.stubbles.reflection.annotations.stubAbstractAnnotation'); 11 12 10 /** 13 11 * Annotation to name an injection 14 12 * 15 13 * @package stubbles 16 * @subpackage ioc_ injection14 * @subpackage ioc_annotations 17 15 */ 18 16 class stubNamedAnnotation extends stubAbstractAnnotation trunk/src/main/php/net/stubbles/ioc/annotations/stubSingletonAnnotation.php
r821 r1127 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection7 * @subpackage ioc_annotations 8 8 */ 9 9 … … 15 15 * 16 16 * @package stubbles 17 * @subpackage ioc_ injection17 * @subpackage ioc_annotations 18 18 */ 19 19 class stubSingletonAnnotation extends stubAbstractAnnotation trunk/src/main/php/net/stubbles/ioc/exceptions/stubBindingException.php
r852 r1127 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection7 * @subpackage ioc_exceptions 8 8 */ 9 9 … … 14 14 * 15 15 * @package stubbles 16 * @subpackage ioc_ injection16 * @subpackage ioc_exceptions 17 17 */ 18 18 class stubBindingException extends stubInjectionException 19 19 { 20 20 // intentionally empty 21 21 } 22 22 ?> trunk/src/main/php/net/stubbles/ioc/exceptions/stubInjectionException.php
r844 r1127 5 5 * @author Frank Kleine <mikey@stubbles.net> 6 6 * @package stubbles 7 * @subpackage ioc_ injection7 * @subpackage ioc_exceptions 8 8 */ 9 9 /** … … 11 11 * 12 12 * @package stubbles 13 * @subpackage ioc_ injection13 * @subpackage ioc_exceptions 14 14 */ 15 15 class stubInjectionException extends stubException 16 16 { 17 17 // intentionally empty 18 18 } 19 19 ?> trunk/src/main/php/net/stubbles/ioc/stubBinder.php
r1009 r1127 30 30 * @subpackage ioc 31 31 */ 32 class stubBinder extends stubBaseObject {33 32 class stubBinder extends stubBaseObject 33 { 34 34 /** 35 35 * Key for storing the binder in the registry … … 49 49 * @param stubInjector $injector 50 50 */ 51 public function __construct(stubInjector $injector = null) { 51 public function __construct(stubInjector $injector = null) 52 { 52 53 if ($injector === null) { 53 54 $this->injector = new stubInjector(); … … 63 64 * @return stubClassBinding 64 65 */ 65 public function bind($interface) { 66 public function bind($interface) 67 { 66 68 $binding = new stubClassBinding($this->injector, $interface); 67 69 $this->injector->addBinding($binding); … … 74 76 * @return stubConstantBinding 75 77 */ 76 public function bindConstant() { 78 public function bindConstant() 79 { 77 80 $binding = new stubConstantBinding($this->injector); 78 81 $this->injector->addBinding($binding); … … 85 88 * @return stubInjector 86 89 */ 87 public function getInjector() { 90 public function getInjector() 91 { 88 92 return $this->injector; 89 93 } trunk/src/main/php/net/stubbles/ioc/stubBinding.php
r1009 r1127 14 14 * @subpackage ioc 15 15 */ 16 interface stubBinding extends stubObject {17 16 interface stubBinding extends stubObject 17 { 18 18 /** 19 19 * Set the name of the injection trunk/src/main/php/net/stubbles/ioc/stubBindingModule.php
r1009 r1127 14 14 * @subpackage ioc 15 15 */ 16 interface stubBindingModule extends stubObject {17 16 interface stubBindingModule extends stubObject 17 { 18 18 /** 19 19 * Configure the binder trunk/src/main/php/net/stubbles/ioc/stubBindingScope.php
r1025 r1127 16 16 * @subpackage ioc 17 17 */ 18 interface stubBindingScope extends stubObject { 18 interface stubBindingScope extends stubObject 19 { 20 /** 21 * returns the instance from the scope 22 * 23 * @param stubReflectionClass $type type of the object 24 * @param stubReflectionClass $impl concrete implementation 25 * @param stubInjectionProvider $provider 26 * @return object 27 */ 19 28 public function getInstance(stubReflectionClass $type, stubReflectionClass $impl, stubInjectionProvider $provider); 20 29 } trunk/src/main/php/net/stubbles/ioc/stubBindingScopeSingleton.php
r1025 r1127 7 7 * @subpackage ioc 8 8 */ 9 10 9 stubClassLoader::load('net.stubbles.ioc.stubBindingScope', 11 10 'net.stubbles.reflection.stubReflectionClass' 12 11 ); 13 14 12 /** 15 13 * Scope for singletons … … 18 16 * @subpackage ioc 19 17 */ 20 class stubBindingScopeSingleton extends stubBaseObject implements stubBindingScope {21 18 class stubBindingScopeSingleton extends stubBaseObject implements stubBindingScope 19 { 22 20 /** 23 21 * Instances in this scope … … 30 28 * Create the instance, if it has not been created before 31 29 * 32 * @param stubReflectionClass $typetype of the object33 * @param stubReflectionClass $implconcrete implementation34 * @param stubInjectionProvider$provider35 * @return object30 * @param stubReflectionClass $type type of the object 31 * @param stubReflectionClass $impl concrete implementation 32 * @param stubInjectionProvider $provider 33 * @return object 36 34 */ 37 public function getInstance(stubReflectionClass $type, stubReflectionClass $impl, stubInjectionProvider $provider) { 35 public function getInstance(stubReflectionClass $type, stubReflectionClass $impl, stubInjectionProvider $provider) 36 { 38 37 $key = $impl->getName(); 39 38 if (!isset($this->instances[$key])) { 40 39 $this->instances[$key] = $provider->get($type); 41 40 } 41 42 42 return $this->instances[$key]; 43 43 } trunk/src/main/php/net/stubbles/ioc/stubBindingScopes.php
r1022 r1127 7 7 * @subpackage ioc 8 8 */ 9 10 9 stubClassLoader::load('net.stubbles.ioc.stubBindingScopeSingleton'); 11 12 10 /** 13 11 * All built-in scopes … … 16 14 * @subpackage ioc 17 15 */ 18 class stubBindingScopes extends stubBaseObject {19 16 class stubBindingScopes extends stubBaseObject 17 { 20 18 /** 21 19 * Scope for singleton objects … … 28 26 * Initialize all built-in scopes 29 27 */ 30 public static function __static() { 28 public static function __static() 29 { 31 30 self::$SINGLETON = new stubBindingScopeSingleton(); 32 31 } trunk/src/main/php/net/stubbles/ioc/stubClassBinding.php
r1025 r1127 17 17 * @subpackage ioc 18 18 */ 19 class stubClassBinding extends stubBaseObject implements stubBinding {20 19 class stubClassBinding extends stubBaseObject implements stubBinding 20 { 21 21 /** 22 22 * The injector used by this binding … … 25 25 */ 26 26 protected $injector = null; 27 28 27 /** 29 28 * The type for this binding … … 32 31 */ 33 32 protected $type = null; 34 35 33 /** 36 34 * The class that implements this binding … … 39 37 */ 40 38 protected $impl = null; 41 42 39 /** 43 40 * Annotated with a name … … 46 43 */ 47 44 protected $name = null; 48 49 45 /** 50 46 * Scope of the binding … … 53 49 */ 54 50 protected $scope = null; 55 56 51 /** 57 52 * Instance this type is bound to … … 60 55 */ 61 56 protected $instance = null; 62 63 57 /** 64 58 * The provider to use for this binding … … 69 63 70 64 /** 71 * Create a new binding 72 * 73 * @param stubInjector $injector 74 * @param string $type 75 */ 76 public function __construct($injector, $type) { 65 * constructor 66 * 67 * @param stubInjector $injector 68 * @param string $type 69 */ 70 public function __construct($injector, $type) 71 { 77 72 $this->injector = $injector; 78 73 $this->type = $type; … … 83 78 * Get the scope of the binding 84 79 * 85 * @return stubBindingScope 86 */ 87 public function getScope() { 80 * @return stubBindingScope 81 */ 82 public function getScope() 83 { 88 84 return $this->scope; 89 85 } … … 92 88 * Set the concrete implementation 93 89 * 94 * @param stubReflectionClass|string $impl 95 * @return stubBinding 96 */ 97 public function to($impl) { 90 * @param stubReflectionClass|string $impl 91 * @return stubBinding 92 */ 93 public function to($impl) 94 { 98 95 $this->impl = $impl; 99 96 return $this; … … 103 100 * Set the concrete instance 104 101 * 105 * @param object $impl 106 * @return stubBinding 107 */ 108 public function toInstance($instance) { 109 if (!$instance instanceof $this->type) { 102 * @param object $impl 103 * @return stubBinding 104 * @throws stubIllegalArgumentException 105 */ 106 public function toInstance($instance) 107 { 108 if (($instance instanceof $this->type) === false) { 110 109 throw new stubIllegalArgumentException("Instance of {$this->type} expectected, " . get_class($instance) . " given."); 111 110 } 111 112 112 $this->instance = $instance; 113 113 return $this; … … 121 121 * 'toInstance()' method. 122 122 * 123 * @param stubInjectionProvider 124 * @return stubBinding 125 */ 126 public function toProvider(stubInjectionProvider $provider) { 123 * @param stubInjectionProvider 124 * @return stubBinding 125 */ 126 public function toProvider(stubInjectionProvider $provider) 127 { 127 128 $this->provider = $provider; 128 129 return $this; … … 132 133 * Set the scope 133 134 * 134 * @param stubBindingScope $scope 135 * @return stubBinding 136 */ 137 public function in(stubBindingScope $scope) { 135 * @param stubBindingScope $scope 136 * @return stubBinding 137 */ 138 public function in(stubBindingScope $scope) 139 { 138 140 $this->scope = $scope; 139 141 return $this; … … 143 145 * Set the name of the injection 144 146 * 145 * @param string $name 146 * @return stubBinding 147 */ 148 public function named($name) { 147 * @param string $name 148 * @return stubBinding 149 */ 150 public function named($name) 151 { 149 152 $this->name = $name; 150 153 return $this; … … 158 161 * using the create() method. 159 162 * 160 * @return object 161 * @see create() 162 */ 163 public function getInstance() { 164 if ($this->instance != null) { 163 * @return object 164 * @see create() 165 */ 166 public function getInstance() 167 { 168 if (null !== $this->instance) { 165 169 return $this->instance; 166 170 } 167 171 168 if (is_string($this->impl) ) {172 if (is_string($this->impl) === true) { 169 173 $this->impl = new stubReflectionClass($this->impl); 170 174 } 171 175 172 if ( $this->scope === null) {176 if (null === $this->scope) { 173 177 if ($this->impl->hasAnnotation('Singleton')) { 174 178 $this->scope = stubBindingScopes::$SINGLETON; … … 176 180 } 177 181 178 if ( $this->provider === null) {182 if (null === $this->provider) { 179 183 $this->provider = new stubDefaultInjectionProvider($this->injector, $this->impl); 180 184 } 181 185 182 if ( $this->scope != null) {186 if (null !== $this->scope) { 183 187 return $this->scope->getInstance(new stubReflectionClass($this->type), $this->impl, $this->provider); 184 188 } 189 185 190 return $this->provider->get(new stubReflectionClass($this->type)); 186 191 } … … 188 193 /** 189 194 * Creates a unique key for this binding 190 */ 191 public function getKey() { 192 if ($this->name === null) { 195 * 196 * @return string 197 */ 198 public function getKey() 199 { 200 if (null === $this->name) { 193 201 return $this->type; 194 202 } 203 195 204 return $this->type . '#' . $this->name; 196 205 } trunk/src/main/php/net/stubbles/ioc/stubConstantBinding.php
r1009 r1127 14 14 * @subpackage ioc 15 15 */ 16 class stubConstantBinding extends stubBaseObject implements stubBinding {17 16 class stubConstantBinding extends stubBaseObject implements stubBinding 17 { 18 18 /** 19 19 * This string is used when generating the key … … 21 21 */ 22 22 const TYPE = '__CONSTANT__'; 23 24 23 /** 25 24 * The injector used by this binding 26 25 * 27 * @var stubInjector26 * @var stubInjector 28 27 */ 29 28 protected $injector = null; 30 31 29 /** 32 30 * Annotated with a name 33 31 * 34 * @var string32 * @var string 35 33 */ 36 34 protected $name = null; 37 38 35 /** 39 36 * Instance this type is bound to 40 37 * 41 * @var object38 * @var object 42 39 */ 43 40 protected $value = null; 44 41 45 42 /** 46 * Create a new binding43 * constructor 47 44 * 48 * @param stubInjector$injector45 * @param stubInjector $injector 49 46 */ 50 public function __construct($injector) { 47 public function __construct($injector) 48 { 51 49 $this->injector = $injector; 52 50 } … … 55 53 * Set the constant value 56 54 * 57 * @param mixed58 * @return stubBinding55 * @param mixed 56 * @return stubBinding 59 57 */ 60 public function to($value) { 58 public function to($value) 59 { 61 60 $this->value = $value; 62 61 return $this; … … 66 65 * Set the name of the injection 67 66 * 68 * @param string$name69 * @return stubBinding67 * @param string $name 68 * @return stubBinding 70 69 */ 71 public function named($name) { 70 public function named($name) 71 { 72 72 $this->name = $name; 73 73 return $this; … … 77 77 * Get the instance for this binding 78 78 * 79 * @return object79 * @return object 80 80 */ 81 public function getInstance() { 81 public function getInstance() 82 { 82 83 return $this->value; 83 84 } … … 85 86 /** 86 87 * Creates a unique key for this binding 88 * 89 * @return string 87 90 */ 88 public function getKey() { 91 public function getKey() 92 { 89 93 return self::TYPE . '#' . $this->name; 90 94 } … … 93 97 * Constant bindings have no scope 94 98 * 95 * @return stubBindingScope99 * @return stubBindingScope 96 100 */ 97 public function getScope() { 101 public function getScope() 102 { 98 103 return null; 99 104 }
