1616 * Components are objects implementing IComponent. They has parent component and own name.
1717 *
1818 * @property-read string $name
19- * @property-read IContainer|NULL $parent
19+ * @property-read IContainer|null $parent
2020 */
2121abstract class Component implements IComponent
2222{
@@ -34,8 +34,8 @@ abstract class Component implements IComponent
3434
3535 public function __construct ()
3636 {
37- list ($ parent , $ name ) = func_get_args () + [NULL , NULL ];
38- if ($ parent !== NULL ) {
37+ list ($ parent , $ name ) = func_get_args () + [null , null ];
38+ if ($ parent !== null ) {
3939 $ parent ->addComponent ($ this , $ name );
4040
4141 } elseif (is_string ($ name )) {
@@ -46,38 +46,38 @@ public function __construct()
4646
4747 /**
4848 * Lookup hierarchy for component specified by class or interface name.
49- * @param string|NULL
49+ * @param string|null
5050 * @param bool
51- * @return IComponent|NULL
51+ * @return IComponent|null
5252 */
53- public function lookup ($ type , $ throw = TRUE )
53+ public function lookup ($ type , $ throw = true )
5454 {
5555 if (!isset ($ this ->monitors [$ type ])) { // not monitored or not processed yet
5656 $ obj = $ this ->parent ;
5757 $ path = self ::NAME_SEPARATOR . $ this ->name ;
5858 $ depth = 1 ;
59- while ($ obj !== NULL ) {
59+ while ($ obj !== null ) {
6060 $ parent = $ obj ->getParent ();
61- if ($ type ? $ obj instanceof $ type : $ parent === NULL ) {
61+ if ($ type ? $ obj instanceof $ type : $ parent === null ) {
6262 break ;
6363 }
6464 $ path = self ::NAME_SEPARATOR . $ obj ->getName () . $ path ;
6565 $ depth ++;
6666 $ obj = $ parent ; // IComponent::getParent()
6767 if ($ obj === $ this ) {
68- $ obj = NULL ; // prevent cycling
68+ $ obj = null ; // prevent cycling
6969 }
7070 }
7171
7272 if ($ obj ) {
73- $ this ->monitors [$ type ] = [$ obj , $ depth , substr ($ path , 1 ), FALSE ];
73+ $ this ->monitors [$ type ] = [$ obj , $ depth , substr ($ path , 1 ), false ];
7474
7575 } else {
76- $ this ->monitors [$ type ] = [NULL , NULL , NULL , FALSE ]; // not found
76+ $ this ->monitors [$ type ] = [null , null , null , false ]; // not found
7777 }
7878 }
7979
80- if ($ throw && $ this ->monitors [$ type ][0 ] === NULL ) {
80+ if ($ throw && $ this ->monitors [$ type ][0 ] === null ) {
8181 throw new Nette \InvalidStateException ("Component ' $ this ->name ' is not attached to ' $ type'. " );
8282 }
8383
@@ -88,11 +88,11 @@ public function lookup($type, $throw = TRUE)
8888 /**
8989 * Lookup for component specified by class or interface name. Returns backtrace path.
9090 * A path is the concatenation of component names separated by self::NAME_SEPARATOR.
91- * @param string|NULL
91+ * @param string|null
9292 * @param bool
93- * @return string|NULL
93+ * @return string|null
9494 */
95- public function lookupPath ($ type = NULL , $ throw = TRUE )
95+ public function lookupPath ($ type = null , $ throw = true )
9696 {
9797 $ this ->lookup ($ type , $ throw );
9898 return $ this ->monitors [$ type ][2 ];
@@ -107,10 +107,10 @@ public function lookupPath($type = NULL, $throw = TRUE)
107107 public function monitor ($ type )
108108 {
109109 if (empty ($ this ->monitors [$ type ][3 ])) {
110- if ($ obj = $ this ->lookup ($ type , FALSE )) {
110+ if ($ obj = $ this ->lookup ($ type , false )) {
111111 $ this ->attached ($ obj );
112112 }
113- $ this ->monitors [$ type ][3 ] = TRUE ; // mark as monitored
113+ $ this ->monitors [$ type ][3 ] = true ; // mark as monitored
114114 }
115115 }
116116
@@ -152,7 +152,7 @@ protected function detached($obj)
152152
153153
154154 /**
155- * @return string|NULL
155+ * @return string|null
156156 */
157157 public function getName ()
158158 {
@@ -162,7 +162,7 @@ public function getName()
162162
163163 /**
164164 * Returns the container if any.
165- * @return IContainer|NULL
165+ * @return IContainer|null
166166 */
167167 public function getParent ()
168168 {
@@ -179,30 +179,30 @@ public function getParent()
179179 * @throws Nette\InvalidStateException
180180 * @internal
181181 */
182- public function setParent (IContainer $ parent = NULL , $ name = NULL )
182+ public function setParent (IContainer $ parent = null , $ name = null )
183183 {
184- if ($ parent === NULL && $ this ->parent === NULL && $ name !== NULL ) {
184+ if ($ parent === null && $ this ->parent === null && $ name !== null ) {
185185 $ this ->name = $ name ; // just rename
186186 return $ this ;
187187
188- } elseif ($ parent === $ this ->parent && $ name === NULL ) {
188+ } elseif ($ parent === $ this ->parent && $ name === null ) {
189189 return $ this ; // nothing to do
190190 }
191191
192192 // A component cannot be given a parent if it already has a parent.
193- if ($ this ->parent !== NULL && $ parent !== NULL ) {
193+ if ($ this ->parent !== null && $ parent !== null ) {
194194 throw new Nette \InvalidStateException ("Component ' $ this ->name ' already has a parent. " );
195195 }
196196
197197 // remove from parent?
198- if ($ parent === NULL ) {
198+ if ($ parent === null ) {
199199 $ this ->refreshMonitors (0 );
200- $ this ->parent = NULL ;
200+ $ this ->parent = null ;
201201
202202 } else { // add to parent
203203 $ this ->validateParent ($ parent );
204204 $ this ->parent = $ parent ;
205- if ($ name !== NULL ) {
205+ if ($ name !== null ) {
206206 $ this ->name = $ name ;
207207 }
208208
@@ -227,11 +227,11 @@ protected function validateParent(IContainer $parent)
227227 /**
228228 * Refreshes monitors.
229229 * @param int
230- * @param array|NULL (array = attaching, NULL = detaching)
230+ * @param array|null (array = attaching, null = detaching)
231231 * @param array
232232 * @return void
233233 */
234- private function refreshMonitors ($ depth , &$ missing = NULL , &$ listeners = [])
234+ private function refreshMonitors ($ depth , &$ missing = null , &$ listeners = [])
235235 {
236236 if ($ this instanceof IContainer) {
237237 foreach ($ this ->getComponents () as $ component ) {
@@ -241,11 +241,11 @@ private function refreshMonitors($depth, &$missing = NULL, &$listeners = [])
241241 }
242242 }
243243
244- if ($ missing === NULL ) { // detaching
244+ if ($ missing === null ) { // detaching
245245 foreach ($ this ->monitors as $ type => $ rec ) {
246246 if (isset ($ rec [1 ]) && $ rec [1 ] > $ depth ) {
247247 if ($ rec [3 ]) { // monitored
248- $ this ->monitors [$ type ] = [NULL , NULL , NULL , TRUE ];
248+ $ this ->monitors [$ type ] = [null , null , null , true ];
249249 $ listeners [] = [$ this , $ rec [0 ]];
250250 } else { // not monitored, just randomly cached
251251 unset($ this ->monitors [$ type ]);
@@ -262,25 +262,25 @@ private function refreshMonitors($depth, &$missing = NULL, &$listeners = [])
262262 unset($ this ->monitors [$ type ]);
263263
264264 } elseif (isset ($ missing [$ type ])) { // known from previous lookup
265- $ this ->monitors [$ type ] = [NULL , NULL , NULL , TRUE ];
265+ $ this ->monitors [$ type ] = [null , null , null , true ];
266266
267267 } else {
268- $ this ->monitors [$ type ] = NULL ; // forces re-lookup
269- if ($ obj = $ this ->lookup ($ type , FALSE )) {
268+ $ this ->monitors [$ type ] = null ; // forces re-lookup
269+ if ($ obj = $ this ->lookup ($ type , false )) {
270270 $ listeners [] = [$ this , $ obj ];
271271 } else {
272- $ missing [$ type ] = TRUE ;
272+ $ missing [$ type ] = true ;
273273 }
274- $ this ->monitors [$ type ][3 ] = TRUE ; // mark as monitored
274+ $ this ->monitors [$ type ][3 ] = true ; // mark as monitored
275275 }
276276 }
277277 }
278278
279279 if ($ depth === 0 ) { // call listeners
280- $ method = $ missing === NULL ? 'detached ' : 'attached ' ;
280+ $ method = $ missing === null ? 'detached ' : 'attached ' ;
281281 $ prev = [];
282282 foreach ($ listeners as $ item ) {
283- if (!in_array ($ item , $ prev , TRUE )) {
283+ if (!in_array ($ item , $ prev , true )) {
284284 $ item [0 ]->$ method ($ item [1 ]);
285285 $ prev [] = $ item ;
286286 }
@@ -297,17 +297,17 @@ private function refreshMonitors($depth, &$missing = NULL, &$listeners = [])
297297 */
298298 public function __clone ()
299299 {
300- if ($ this ->parent === NULL ) {
300+ if ($ this ->parent === null ) {
301301 return ;
302302
303303 } elseif ($ this ->parent instanceof Container) {
304304 $ this ->parent = $ this ->parent ->_isCloning ();
305- if ($ this ->parent === NULL ) { // not cloning
305+ if ($ this ->parent === null ) { // not cloning
306306 $ this ->refreshMonitors (0 );
307307 }
308308
309309 } else {
310- $ this ->parent = NULL ;
310+ $ this ->parent = null ;
311311 $ this ->refreshMonitors (0 );
312312 }
313313 }
0 commit comments