@param array $newMatchData
@param int   $startInOld
@param int   $endInOld
@param int   $startInNew
@param int   $endInNew

@return RowMatch|null
189801
protected function findRowMatch($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew)
    {
        $bestMatch = null;
        $bestPercentage = 0;

        foreach ($newMatchData as $newIndex => $oldMatches) {
            if ($newIndex < $startInNew) {
                continue;
            }

            if ($newIndex >= $endInNew) {
                break;
            }
            foreach ($oldMatches as $oldIndex => $percentage) {
                if ($oldIndex < $startInOld) {
                    continue;
                }

                if ($oldIndex >= $endInOld) {
                    break;
                }

                if ($percentage > $bestPercentage) {
                    $bestPercentage = $percentage;
                    $bestMatch = array(
                        'oldIndex' => $oldIndex,
                        'newIndex' => $newIndex,
                        'percentage' => $percentage,
                    );
                }
            }
        }

        if ($bestMatch !== null) {
            return new RowMatch(
                $bestMatch['newIndex'],
                $bestMatch['oldIndex'],
                $bestMatch['newIndex'] + 1,
                $bestMatch['oldIndex'] + 1,
                $bestMatch['percentage']
            );
        }

        return;
    }
214745
public function createId( $nCenter, $nNode, $sSource = null, & $arrData = null )
	{
		if ( ! $this->isValidCenterId( $nCenter ) )
		{
			return null;
		}
		if ( ! $this->isValidNodeId( $nNode ) )
		{
			return null;
		}

		//	...
		$nRet		= 0;
		$nTime		= $this->getEscapedTime();
		$nCenter	= intval( $nCenter );
		$nNode		= intval( $nNode );

		if ( is_string( $sSource ) && strlen( $sSource ) > 0 )
		{
			//	use crc32 hash value instead of rand
			$nRand	= crc32( $sSource );
		}
		else
		{
			//	0 ~ 4095
			$nRand	= rand( 0, 0xFFF );
		}

		//	...
		$nCenterV	= ( ( $nCenter << 17 ) & 0x00000000003E0000 );
		$nNodeV		= ( ( $nNode   << 12 ) & 0x000000000001F000 );
		$nTimeV		= ( ( $nTime   << 22 ) & 0x7FFFFFFFFFC00000 );
		$nRandV		= ( ( $nRand   << 0  ) & 0x0000000000000FFF );

		$nRet		= ( $nCenterV + $nNodeV + $nTimeV + $nRandV );

		//	...
		if ( ! is_null( $arrData ) )
		{
			$arrData =
			[
				'center'	=> $nCenter,
				'node'		=> $nNode,
				'time'		=> $nTime,
				'rand'		=> $nRandV,
			];
		}

		return intval( $nRet );
	}
133641
public function where($data, $condition = NULL, $dbConnection = NULL)
    {
        $databaseQuery = new DatabaseQuery();
        $connection = $databaseQuery->checkConnection($dbConnection);

        $sqlQuery = self::whereClause($data, $condition, $connection);
        $query = $connection->prepare($sqlQuery);
        $query->execute();
        if ($query->rowCount()) {
            return new GetData($query->fetchAll($connection::FETCH_ASSOC));
        }
        throw new DataNotFoundException();
    }
1279993
public function updateRow(array $oldRow, array $newRow, $rowId)
    {
        $this->removeRow($oldRow, $rowId);
        $this->insertRow($newRow, $rowId);
    }
1333044
function _updateRowspan(tableData, startRowIndex, endRowIndex) {
  util.range(startRowIndex, endRowIndex + 1).forEach(rowIndex => {
    tableData[rowIndex].forEach((cell, cellIndex) => {
      if (util.isExisty(cell.rowMergeWith)) {
        const merger = tableData[cell.rowMergeWith][cellIndex];

        if (merger.rowspan) {
          merger.rowspan -= 1;
        }
      } else if (cell.rowspan > 1) {
        const lastMergedRowIndex = rowIndex + cell.rowspan - 1;

        cell.rowspan -= (endRowIndex - rowIndex + 1);

        if (lastMergedRowIndex > endRowIndex) {
          tableData[endRowIndex + 1][cellIndex] = util.extend({}, cell);
        }
      }
    });
  });
}
1083505
private static function getMigrationScripts(int $start, int $end, array $skip)
    {
        return MigrationsManager::getMigrationsManager()->getMigrationScripts(
            $start,
            $end,
            $skip
        );
    }
601014
public function validate($wId, $source, $initialStatusId, $startStatusIdIndex, $endStatusIdIndex )
	{
		if ($this->validate === true) {
			if (! \in_array($initialStatusId, $startStatusIdIndex)) {
				throw new WorkflowValidationException("Initial status not defined : $initialStatusId");
			}

			// detect not defined statuses

			$missingStatusIdSuspects = \array_diff($endStatusIdIndex, $startStatusIdIndex);
			if (count($missingStatusIdSuspects) != 0) {
				$missingStatusId = [];
				foreach ($missingStatusIdSuspects as $id) {
					list ($thisWid, $thisSid) = $source->parseStatusId($id, $wId);
					if ($thisWid == $wId) {
						$missingStatusId[] = $id; // refering to the same workflow, this Id is not defined
					}
				}
				if (count($missingStatusId) != 0) {
					throw new WorkflowValidationException("One or more end status are not defined : " . VarDumper::dumpAsString($missingStatusId));
				}
			}
		}
	}
972505
public function validateRow(array $rowData, $rowNum)
    {
        static $root = null;
        static $category = null;

        if (isset($rowData['fsi_line_number'])) {
            $rowNum = $rowData['fsi_line_number'];
        }
        $this->filterRowData($rowData);

        // check if row is already validated
        if (isset($this->_validatedRows[$rowNum])) {
            return !isset($this->invalidRows[$rowNum]);
        }
        $this->_validatedRows[$rowNum] = true;


        //check for duplicates
        if (isset($rowData[self::COL_ROOT])
            && isset($rowData[self::COL_CATEGORY])
            && isset($this->newCategory[$rowData[self::COL_ROOT]][$rowData[self::COL_CATEGORY]])
        ) {
            if (!$this->getIgnoreDuplicates()) {
                $this->addRowError(self::ERROR_DUPLICATE_CATEGORY, $rowNum);
            }

            return false;
        }
        $rowScope = $this->getRowScope($rowData);

        // BEHAVIOR_DELETE use specific validation logic
        if (Import::BEHAVIOR_DELETE == $this->getBehavior()) {
            if (self::SCOPE_DEFAULT == $rowScope
                && !isset($this->categoriesWithRoots[$rowData[self::COL_ROOT]][$rowData[self::COL_CATEGORY]])
            ) {
                $this->addRowError(self::ERROR_CATEGORY_NOT_FOUND_FOR_DELETE, $rowNum);
                return false;
            }
            return true;
        }

        // common validation
        if (self::SCOPE_DEFAULT == $rowScope) { // category is specified, row is SCOPE_DEFAULT, new category block begins
            $rowData[CategoryModel::KEY_NAME] = $this->getCategoryName($rowData);

            $this->_processedEntitiesCount++;

            $root = $rowData[self::COL_ROOT];
            $category = $rowData[self::COL_CATEGORY];

            //check if the root exists
            if (!isset($this->categoriesWithRoots[$root])) {
                $this->addRowError(self::ERROR_INVALID_ROOT, $rowNum);
                return false;
            }

            //check if parent category exists
            if ($this->getParentCategory($rowData) === false) {

                $this->addRowError(self::ERROR_PARENT_NOT_FOUND, $rowNum);
                return false;
            }

            if (isset($this->categoriesWithRoots[$root][$category])) {

            } else { // validate new category type and attribute set
                if (!isset($this->newCategory[$root][$category])) {
                    $this->newCategory[$root][$category] = ['entity_id' => null];
                }
                if (isset($this->invalidRows[$rowNum])) {
                    // mark SCOPE_DEFAULT row as invalid for future child rows if category not in DB already
                    $category = false;
                }
            }

            // check simple attributes
            foreach ($this->attributes as $attrCode => $attrParams) {
                if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
                    $this->isAttributeValid($attrCode, $attrParams, $rowData, $rowNum);
                } elseif ($attrParams['is_required'] && !isset($this->categoriesWithRoots[$root][$category])) {
                    $this->addRowError(self::ERROR_VALUE_IS_REQUIRED, $rowNum, $attrCode);
                }
            }

        } else {
            if (null === $category) {
                $this->addRowError(self::ERROR_CATEGORY_IS_EMPTY, $rowNum);
            } elseif (false === $category) {
                $this->addRowError(self::ERROR_ROW_IS_ORPHAN, $rowNum);
            } elseif (self::SCOPE_STORE == $rowScope && !isset($this->storeCodeToId[$rowData[self::COL_STORE]])) {
                $this->addRowError(self::ERROR_INVALID_STORE, $rowNum);
            }
        }

        if (isset($this->invalidRows[$rowNum])) {
            $category = false; // mark row as invalid for next address rows
        }

        return !isset($this->invalidRows[$rowNum]);
    }
798701
public static function randomCharRange( $start, $end )
	{
		if ( count( static::$randomCharMap ) == 0 )
			static::populate();

		return chr( random_int( $start, $end ) );
	}
595339
private void matchNames(@NonNull ArrayMap<View, TransitionValues> unmatchedStart,
                            @NonNull ArrayMap<View, TransitionValues> unmatchedEnd,
                            @NonNull ArrayMap<String, View> startNames,
                            @NonNull ArrayMap<String, View> endNames) {
        int numStartNames = startNames.size();
        for (int i = 0; i < numStartNames; i++) {
            View startView = startNames.valueAt(i);
            if (startView != null && isValidTarget(startView)) {
                View endView = endNames.get(startNames.keyAt(i));
                if (endView != null && isValidTarget(endView)) {
                    TransitionValues startValues = unmatchedStart.get(startView);
                    TransitionValues endValues = unmatchedEnd.get(endView);
                    if (startValues != null && endValues != null) {
                        mStartValuesList.add(startValues);
                        mEndValuesList.add(endValues);
                        unmatchedStart.remove(startView);
                        unmatchedEnd.remove(endView);
                    }
                }
            }
        }
    }
832777
protected function createContextMatchingNodeData(NodeData $nodeData)
    {
        $nodePath = NodePaths::getRelativePathBetween(SiteService::SITES_ROOT_PATH, $nodeData->getPath());
        list($siteNodeName) = explode('/', $nodePath);
        $site = $this->_siteRepository->findOneByNodeName($siteNodeName);

        $contextProperties = [
            'workspaceName' => $nodeData->getWorkspace()->getName(),
            'invisibleContentShown' => true,
            'inaccessibleContentShown' => true,
            'removedContentShown' => true,
            'dimensions' => $nodeData->getDimensionValues(),
            'currentSite' => $site
        ];

        if ($site instanceof Site && $domain = $site->getFirstActiveDomain()) {
            $contextProperties['currentDomain'] = $domain;
        }

        return $this->_contextFactory->create($contextProperties);
    }
798236
public function getTransition($startId, $endId, $defaultWorkflowId = null)
	{
		$tr = $this->getTransitions($startId, $defaultWorkflowId);
		if ( count($tr) > 0 ) {
			foreach ($tr as $aTransition) {
				if ($aTransition->getEndStatus()->getId() == $endId) {
					return $aTransition;
				}
			}
		}
		return null;
	}
271805
public static function fromString($input, $start = 0, $end = null)
	{
		return self::appendFromString(self::builder(), $input, $start, $end);
	}
26113
function _getMatchStart(distanceMatrix, matchEnd, sourceLength) {
  var row = sourceLength;
  var column = matchEnd;
  var tmpRow;
  var tmpColumn;

  // match will be empty string
  if (matchEnd === 0) { return 0; }

  while(row > 1 && column > 1) {
   tmpRow = row;
   tmpColumn = column;
   row = distanceMatrix[tmpRow][tmpColumn].parentCell.row;
   column = distanceMatrix[tmpRow][tmpColumn].parentCell.column;
  }

  return column-1;
}
677826
protected function calculate_sample($sampleid, $samplesorigin, $starttime = false, $endtime = false) {
        $user = $this->retrieve('user', $sampleid);
        return ($user->trackforums) ? self::get_max_value() : self::get_min_value();
    }
1309372
public function matchIfNotNullReturnValue(If_ $ifNode): ?Expr
    {
        if (count($ifNode->stmts) !== 1) {
            return null;
        }

        $insideIfNode = $ifNode->stmts[0];
        if (! $insideIfNode instanceof Return_) {
            return null;
        }

        /** @var Return_ $returnNode */
        $returnNode = $insideIfNode;
        if (! $ifNode->cond instanceof NotIdentical) {
            return null;
        }

        return $this->matchComparedAndReturnedNode($ifNode->cond, $returnNode);
    }
771624
function _updateRowsCols($rowdata = null) {
        // Update maximum columns.
        $this->_max_cols = max($this->_max_cols, count($rowdata));

        // Update maximum rows.
        ksort($this->_data);
        $keys = array_keys($this->_data);
        $this->_max_rows = end($keys) + 1;

        switch ($this->_defaultAlign) {
            case self::CONSOLE_TABLE_ALIGN_CENTER:
                $pad = STR_PAD_BOTH;
                break;
            case self::CONSOLE_TABLE_ALIGN_RIGHT:
                $pad = STR_PAD_LEFT;
                break;
            default:
                $pad = STR_PAD_RIGHT;
                break;
        }

        // Set default column alignments
        for ($i = 0; $i < $this->_max_cols; $i++) {
            if (!isset($this->_col_align[$i])) {
                $this->_col_align[$i] = $pad;
            }
        }
    }