original_string: protected function _moveUp($node, $number)
      {
          $config = $this->getConfig();
          list($parent, $left, $right) = [$config['parent'], $config['left'], $config['right']];
          list($nodeParent, $nodeLeft, $nodeRight) = array_values($node->extract([$parent, $left, $right]));
  
          $targetNode = null;
          if ($number !== true) {
              $targetNode = $this->_scope($this->_table->find())
                  ->select([$left, $right])
                  ->where(["$parent IS" => $nodeParent])
                  ->where(function ($exp) use ($config, $nodeLeft) {
                      /* @var \Cake\Database\Expression\QueryExpression $exp */
                      return $exp->lt($config['rightField'], $nodeLeft);
                  })
                  ->orderDesc($config['leftField'])
                  ->offset($number - 1)
                  ->limit(1)
                  ->first();
          }
          if (!$targetNode) {
              $targetNode = $this->_scope($this->_table->find())
                  ->select([$left, $right])
                  ->where(["$parent IS" => $nodeParent])
                  ->where(function ($exp) use ($config, $nodeLeft) {
                      /* @var \Cake\Database\Expression\QueryExpression $exp */
                      return $exp->lt($config['rightField'], $nodeLeft);
                  })
                  ->orderAsc($config['leftField'])
                  ->limit(1)
                  ->first();
  
              if (!$targetNode) {
                  return $node;
              }
          }
  
          list($targetLeft) = array_values($targetNode->extract([$left, $right]));
          $edge = $this->_getMax();
          $leftBoundary = $targetLeft;
          $rightBoundary = $nodeLeft - 1;
  
          $nodeToEdge = $edge - $nodeLeft + 1;
          $shift = $nodeRight - $nodeLeft + 1;
          $nodeToHole = $edge - $leftBoundary + 1;
          $this->_sync($nodeToEdge, '+', "BETWEEN {$nodeLeft} AND {$nodeRight}");
          $this->_sync($shift, '+', "BETWEEN {$leftBoundary} AND {$rightBoundary}");
          $this->_sync($nodeToHole, '-', "> {$edge}");
  
          $node->set($left, $targetLeft);
          $node->set($right, $targetLeft + ($nodeRight - $nodeLeft));
  
          $node->setDirty($left, false);
          $node->setDirty($right, false);
  
          return $node;
      }
code: protected function _moveUp($node, $number)
      {
          $config = $this->getConfig();
          list($parent, $left, $right) = [$config['parent'], $config['left'], $config['right']];
          list($nodeParent, $nodeLeft, $nodeRight) = array_values($node->extract([$parent, $left, $right]));
  
          $targetNode = null;
          if ($number !== true) {
              $targetNode = $this->_scope($this->_table->find())
                  ->select([$left, $right])
                  ->where(["$parent IS" => $nodeParent])
                  ->where(function ($exp) use ($config, $nodeLeft) {
                      /* @var \Cake\Database\Expression\QueryExpression $exp */
                      return $exp->lt($config['rightField'], $nodeLeft);
                  })
                  ->orderDesc($config['leftField'])
                  ->offset($number - 1)
                  ->limit(1)
                  ->first();
          }
          if (!$targetNode) {
              $targetNode = $this->_scope($this->_table->find())
                  ->select([$left, $right])
                  ->where(["$parent IS" => $nodeParent])
                  ->where(function ($exp) use ($config, $nodeLeft) {
                      /* @var \Cake\Database\Expression\QueryExpression $exp */
                      return $exp->lt($config['rightField'], $nodeLeft);
                  })
                  ->orderAsc($config['leftField'])
                  ->limit(1)
                  ->first();
  
              if (!$targetNode) {
                  return $node;
              }
          }
  
          list($targetLeft) = array_values($targetNode->extract([$left, $right]));
          $edge = $this->_getMax();
          $leftBoundary = $targetLeft;
          $rightBoundary = $nodeLeft - 1;
  
          $nodeToEdge = $edge - $nodeLeft + 1;
          $shift = $nodeRight - $nodeLeft + 1;
          $nodeToHole = $edge - $leftBoundary + 1;
          $this->_sync($nodeToEdge, '+', "BETWEEN {$nodeLeft} AND {$nodeRight}");
          $this->_sync($shift, '+', "BETWEEN {$leftBoundary} AND {$rightBoundary}");
          $this->_sync($nodeToHole, '-', "> {$edge}");
  
          $node->set($left, $targetLeft);
          $node->set($right, $targetLeft + ($nodeRight - $nodeLeft));
  
          $node->setDirty($left, false);
          $node->setDirty($right, false);
  
          return $node;
      }
code_tokens: protected function _moveUp ( $ node , $ number ) { $ config = $ this -> getConfig ( ) ; list ( $ parent , $ left , $ right ) = [ $ config [ 'parent' ] , $ config [ 'left' ] , $ config [ 'right' ] ] ; list ( $ nodeParent , $ nodeLeft , $ nodeRight ) = array_values ( $ node -> extract ( [ $ parent , $ left , $ right ] ) ) ; $ targetNode = null ; if ( $ number !== true ) { $ targetNode = $ this -> _scope ( $ this -> _table -> find ( ) ) -> select ( [ $ left , $ right ] ) -> where ( [ "$parent IS" => $ nodeParent ] ) -> where ( function ( $ exp ) use ( $ config , $ nodeLeft ) { /* @var \Cake\Database\Expression\QueryExpression $exp */ return $ exp -> lt ( $ config [ 'rightField' ] , $ nodeLeft ) ; } ) -> orderDesc ( $ config [ 'leftField' ] ) -> offset ( $ number - 1 ) -> limit ( 1 ) -> first ( ) ; } if ( ! $ targetNode ) { $ targetNode = $ this -> _scope ( $ this -> _table -> find ( ) ) -> select ( [ $ left , $ right ] ) -> where ( [ "$parent IS" => $ nodeParent ] ) -> where ( function ( $ exp ) use ( $ config , $ nodeLeft ) { /* @var \Cake\Database\Expression\QueryExpression $exp */ return $ exp -> lt ( $ config [ 'rightField' ] , $ nodeLeft ) ; } ) -> orderAsc ( $ config [ 'leftField' ] ) -> limit ( 1 ) -> first ( ) ; if ( ! $ targetNode ) { return $ node ; } } list ( $ targetLeft ) = array_values ( $ targetNode -> extract ( [ $ left , $ right ] ) ) ; $ edge = $ this -> _getMax ( ) ; $ leftBoundary = $ targetLeft ; $ rightBoundary = $ nodeLeft - 1 ; $ nodeToEdge = $ edge - $ nodeLeft + 1 ; $ shift = $ nodeRight - $ nodeLeft + 1 ; $ nodeToHole = $ edge - $ leftBoundary + 1 ; $ this -> _sync ( $ nodeToEdge , '+' , "BETWEEN {$nodeLeft} AND {$nodeRight}" ) ; $ this -> _sync ( $ shift , '+' , "BETWEEN {$leftBoundary} AND {$rightBoundary}" ) ; $ this -> _sync ( $ nodeToHole , '-' , "> {$edge}" ) ; $ node -> set ( $ left , $ targetLeft ) ; $ node -> set ( $ right , $ targetLeft + ( $ nodeRight - $ nodeLeft ) ) ; $ node -> setDirty ( $ left , false ) ; $ node -> setDirty ( $ right , false ) ; return $ node ; }
docstring: Helper function used with the actual code for moveUp
  
  @param \Cake\Datasource\EntityInterface $node The node to move
  @param int|bool $number How many places to move the node, or true to move to first position
  @throws \Cake\Datasource\Exception\RecordNotFoundException When node was not found
  @return \Cake\Datasource\EntityInterface|bool $node The node after being moved or false on failure
docstring_tokens: Helper function used with the actual code for moveUp