| Conditions | 25 |
| Paths | 520 |
| Total Lines | 54 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 20 | * |
||
| 21 | */ |
||
| 22 | public function _updateScope(Smarty_Internal_Template $tpl, $varName, $tagScope = 0) |
||
| 23 | { |
||
| 24 | if ($tagScope) { |
||
| 25 | $this->_updateVarStack($tpl, $varName); |
||
| 26 | $tagScope = $tagScope & ~Smarty::SCOPE_LOCAL; |
||
| 27 | if (!$tpl->scope && !$tagScope) return; |
||
| 28 | } |
||
| 29 | $mergedScope = $tagScope | $tpl->scope; |
||
| 30 | if ($mergedScope) { |
||
| 31 | if ($mergedScope & Smarty::SCOPE_GLOBAL && $varName) { |
||
|
|
|||
| 32 | Smarty::$global_tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ]; |
||
| 33 | } |
||
| 34 | // update scopes |
||
| 35 | foreach ($this->_getAffectedScopes($tpl, $mergedScope) as $ptr) { |
||
| 36 | $this->_updateVariableInOtherScope($ptr->tpl_vars, $tpl, $varName); |
||
| 37 | if($tagScope && $ptr->_isTplObj() && isset($tpl->_cache[ 'varStack' ])) { |
||
| 38 | $this->_updateVarStack($ptr, $varName); } |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Get array of objects which needs to be updated by given scope value |
||
| 45 | * |
||
| 46 | * @param Smarty_Internal_Template $tpl |
||
| 47 | * @param int $mergedScope merged tag and template scope to which bubble up variable value |
||
| 48 | * |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | public function _getAffectedScopes(Smarty_Internal_Template $tpl, $mergedScope) |
||
| 52 | { |
||
| 53 | $_stack = array(); |
||
| 54 | $ptr = $tpl->parent; |
||
| 55 | if ($mergedScope && isset($ptr) && $ptr->_isTplObj()) { |
||
| 56 | $_stack[] = $ptr; |
||
| 57 | $mergedScope = $mergedScope & ~Smarty::SCOPE_PARENT; |
||
| 58 | if (!$mergedScope) { |
||
| 59 | // only parent was set, we are done |
||
| 60 | return $_stack; |
||
| 61 | } |
||
| 62 | $ptr = $ptr->parent; |
||
| 63 | } |
||
| 64 | while (isset($ptr) && $ptr->_isTplObj()) { |
||
| 65 | $_stack[] = $ptr; |
||
| 66 | $ptr = $ptr->parent; |
||
| 67 | } |
||
| 68 | if ($mergedScope & Smarty::SCOPE_SMARTY) { |
||
| 69 | if (isset($tpl->smarty)) { |
||
| 70 | $_stack[] = $tpl->smarty; |
||
| 71 | } |
||
| 72 | } elseif ($mergedScope & Smarty::SCOPE_ROOT) { |
||
| 73 | while (isset($ptr)) { |
||
| 74 | if (!$ptr->_isTplObj()) { |
||
| 116 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: