@param int $bugId
@param int $length
@param int $from
@param int $to

@throws Exception
@throws CacheException
194516
public function handle(int $bugId, int $length, int $from, int $to)
    {
        $bug = $this->entityManager->find(Bug::class, $bugId);

        if (!$bug || !$bug instanceof Bug) {
            return;
        }

        if (!$this->workflowRegistry instanceof Registry) {
            throw new Exception('Can not handle reduce path message: No workflows were defined');
        }

        $model = $bug->getTask()->getModel();
        $workflow = WorkflowHelper::get($this->workflowRegistry, $model);

        $graph = $this->graphBuilder->build($workflow);
        $path = Path::unserialize($bug->getPath());

        if ($bug->getLength() >= $length) {
            // The reproduce path has not been reduced.
            $newPath = PathBuilder::createWithShortestPath($graph, $path, $from, $to);
            // Make sure new path shorter than old path.
            if ($newPath->countPlaces() < $path->countPlaces()) {
                try {
                    $subject = $this->subjectManager->createSubject($model);
                    PathRunner::run($newPath, $workflow, $subject);
                } catch (Throwable $newThrowable) {
                    if ($newThrowable->getMessage() === $bug->getBugMessage()) {
                        $this->dispatch($bug->getId(), $newPath);
                    }
                }
            }
        }

        $this->postHandle($bugId);
    }
475814
public static function SubsequenceWithLength( $iter, $startingLoc, $length )
	{
		if ( $startingLoc instanceof XPath2Item )
		{
			$startingLoc = $startingLoc->getTypedValue();
		}

		$startingLoc = round( $startingLoc );

		if ( $length instanceof XPath2Item )
		{
			$length = $length->getTypedValue();
		}

		$length = round( $length );

		if ( $startingLoc == INF || $startingLoc == -INF || is_nan( $startingLoc ) || is_nan( $length ) )
		{
			return EmptyIterator::$Shared;
		}
		return new NodeIterator( function() use( $iter, $startingLoc, $length ) { return ExtFuncs::SubsequenceIterator( $iter->CloneInstance(), $startingLoc, $length ); } );
	}
1058983
protected static function _setCache($from, $subject, $value) {
		$cache = &static::_getCache($from, $subject);
		$cache = $value;
	}
102224
public function copy_message($uids, $to_mbox, $from_mbox='')
    {
        if (!strlen($from_mbox)) {
            $from_mbox = $this->folder;
        }

        list($uids, $all_mode) = $this->parse_uids($uids);

        // exit if no message uids are specified
        if (empty($uids)) {
            return false;
        }

        if (!$this->check_connection()) {
            return false;
        }

        // copy messages
        $copied = $this->conn->copy($uids, $from_mbox, $to_mbox);

        if ($copied) {
            $this->clear_messagecount($to_mbox);
        }

        return $copied;
    }
673189
public function sync(MountManager $mountManager, string $from, string $to, array $config = []): void
    {
        if (!$mountManager->has($from)) {
            throw new Exception\RuntimeException("Path \"$from\" does not exist.");
        }

        $metadata = $mountManager->getMetadata($from);
        $fileExists = $mountManager->has($to);
        if ($metadata && 'file' == $metadata['type']) {
            $sourceIsNewer = false;
            if ($fileExists) {
                $toMetadata = $mountManager->getMetadata($to);
                $sourceIsNewer = $toMetadata && $metadata['timestamp'] > $toMetadata['timestamp'];
            }

            if (!$fileExists || $sourceIsNewer) {
                $this->putFile($mountManager, $from, $to, $config);
            }
        } else {
            $this->syncDirectory($mountManager, $from, $to, $config);
        }

    }
586502
public function copy($messages, $from, $to)
    {
        // Clear last COPYUID data
        unset($this->data['COPYUID']);

        if (!$this->select($from)) {
            return false;
        }

        // Clear internal status cache
        unset($this->data['STATUS:'.$to]);

        $result = $this->execute('UID COPY', array(
            $this->compressMessageSet($messages), $this->escape($to)),
            self::COMMAND_NORESPONSE);

        return $result == self::ERROR_OK;
    }
873875
public void execute() {
        Iterator<?> elementIter = XMLUtil.selectNodes(document, "/BugCollection/BugInstance").iterator();
        Iterator<BugInstance> bugInstanceIter = bugCollection.iterator();

        Set<String> bugTypeSet = new HashSet<>();
        Set<String> bugCategorySet = new HashSet<>();
        Set<String> bugCodeSet = new HashSet<>();

        // Add short and long descriptions to BugInstance elements.
        // We rely on the Document and the BugCollection storing
        // the bug instances in the same order.
        while (elementIter.hasNext() && bugInstanceIter.hasNext()) {
            Element element = (Element) elementIter.next();
            BugInstance bugInstance = bugInstanceIter.next();

            String bugType = bugInstance.getType();
            bugTypeSet.add(bugType);

            BugPattern bugPattern = bugInstance.getBugPattern();

            bugCategorySet.add(bugPattern.getCategory());
            bugCodeSet.add(bugPattern.getAbbrev());

            element.addElement("ShortMessage").addText(bugPattern.getShortDescription());
            element.addElement("LongMessage").addText(bugInstance.getMessage());

            // Add pre-formatted display strings in "Message"
            // elements for all bug annotations.
            Iterator<?> annElementIter = element.elements().iterator();
            Iterator<BugAnnotation> annIter = bugInstance.annotationIterator();
            while (annElementIter.hasNext() && annIter.hasNext()) {
                Element annElement = (Element) annElementIter.next();
                BugAnnotation ann = annIter.next();
                annElement.addElement("Message").addText(ann.toString());
            }
        }

        // Add BugPattern elements for each referenced bug types.
        addBugCategories(bugCategorySet);
        addBugPatterns(bugTypeSet);
        addBugCodes(bugCodeSet);
    }
166628
public function ipInRange($ip, $from, $to)
    {
        $ip = $this->getIpNumberFromAddress($ip);
        $from = $this->getIpNumberFromAddress($from);
        $to = $this->getIpNumberFromAddress($to);

        return (!$ip || !$from || !$to) ? false : ($ip <= $to && $from <= $ip);
    }
757066
public function draw(int $from = 5): void
	{
		$dots = 0;

		$fromLength = strlen($from);

		$totalLength = $fromLength + 5;

		do
		{
			do
			{
				$numbers = str_pad($from, $fromLength, '0', STR_PAD_LEFT);

				$this->output->write("\r" . str_pad($numbers . ' ' . str_repeat('.', $dots) . ' ', $totalLength, ' '));

				$this->sleep();
			}
			while($dots++ < 3);

			$dots = 0;
		}
		while($from-- > 1);

		$this->output->write("\r" . str_repeat(' ', $totalLength) . "\r");
	}
167468
private function copyFromTo($from, $to)
    {
        $directory = dirname($to);
        if (!is_dir($directory)) {
            mkdir($directory, 0777, true);
        }

        copy($from, $to);
    }
963879
public static function BcRange(string $num, string $from, string $to, int $scale = 0): bool
    {
        if (!preg_match('/^[0-9]+(\.[0-9]+)?$/', $num)) {
            return false;
        }

        if (bccomp($num, $from, $scale) !== -1) {
            if (bccomp($num, $to, $scale) !== 1) {
                return true;
            }
        }

        return false;
    }
1016155
public function copy($from, $to)
    {
        $from = ltrim($from, "/");
        $to   = ltrim($to, "/");

        if (!$this->exists($from)) {
            $path = $this->bucket . "/" . $from;
            throw new ExceptionStorage("Object {$path} Not found", static::E_NOT_IS_DIR);
        }

        if ($this->exists($to)) {
            $path = $this->bucket . "/" . $to;
            throw new ExceptionStorage("Object {$path} exists");
        }

        // Copia Object
        $this->clientS3->copyObject(array(
            'Bucket'     => $this->bucket,
            'Key'        => $to,
            'CopySource' => $this->bucket . '/' . rawurlencode($from),
            'ACL'        => static::ACL_PUBLIC_READ,
            'MetadataDirective' => 'COPY',
        ));

        $pathFrom = trim($from, '/') . '/';

        $iterator = $this->clientS3->getIterator('ListObjects', array(
            'Bucket' => $this->bucket,
            'Prefix' => $pathFrom,
        ));

        foreach ($iterator as $object)
        {
            $pattern = preg_quote($pathFrom, "/");
            $Key = preg_replace("/^{$pattern}/", "", $object['Key']);

            if (!empty($Key))
            {
                $pattern = preg_quote($pathFrom, "/");
                $Key = preg_replace("/^{$pattern}/", "", $object['Key']);

                $origem  = $this->bucket . '/' . $object['Key'];
                $destino = trim($to, "/") . "/" . $Key;

                // Copia Object
                $this->clientS3->copyObject(array(
                    'Bucket'     => $this->bucket,
                    'Key'        => $destino,
                    'CopySource' => $origem,
                    'ACL'        => static::ACL_PUBLIC_READ,
                    'MetadataDirective' => 'COPY'
                ));
            }
        }

        return true;
    }
58720
protected function executeAction($from = null, $to = null)
    {
        $context = $this->getRequest()->getParam('id', 'gems');
        $from    = $this->getRequest()->getParam('from', $from);
        $to      = $this->getRequest()->getParam('to', $to);

        $batch = $this->loader->getTaskRunnerBatch('upgrade' . $context);
        $batch->minimalStepDurationMs = 3000; // 3 seconds max before sending feedback

        if (!$batch->isLoaded()) {
            $this->_upgrades->setBatch($batch);
            $this->_upgrades->execute($context, $to, $from);
        }

        $title = sprintf($this->_('Upgrading %s'), $context);
        $this->_helper->BatchRunner($batch, $title, $this->accesslog);

        $this->html->br();
        $this->compatibilityReportAction();
    }
32225
public function setBounds($from, $length = null, $stopOutOfBounds = false) {
        $this->from = $from;
        $this->length = $length;
        $this->outOfBounds = (bool) $stopOutOfBounds;
        return $this;
    }
1016451
public function slice($from, $length)
    {
        $result = clone $this;
        $result->response->docs = array_slice($this->response->docs, $from, $length);
        return $result;
    }
471367
public function migrateExpiredJobs($from, $to, $attempt = true)
    {
        $this->redis->watch($from);

        $jobs = $this->redis->zRangeByScore($from, '-inf', $this->currentTime());

        if (!empty($jobs)) {
            $this->transaction(function () use ($from, $to, $jobs, $attempt) {

                $this->redis->zRemRangeByRank($from, 0, count($jobs) - 1);

                for ($i = 0; $i < count($jobs); $i += 100) {

                    $values = array_slice($jobs, $i, 100);

                    $this->redis->rPush($to, ...$values);
                }
            });
        }

        $this->redis->unwatch();
    }
404259
public function dispatch(int $bugId, Path $newPath = null): int
    {
        $callback = function () use ($bugId, $newPath) {
            $bug = $this->entityManager->find(Bug::class, $bugId, LockMode::PESSIMISTIC_WRITE);

            if (!$bug || !$bug instanceof Bug) {
                return 0;
            }

            if ($newPath) {
                $bug->setPath(Path::serialize($newPath));
                $bug->setLength($newPath->countPlaces());
                $path = $newPath;
            } else {
                $path = Path::unserialize($bug->getPath());
            }

            $messagesCount = 0;
            if ($path->countPlaces() > 2) {
                $pairs = Randomizer::randomPairs($path->countPlaces(), floor(sqrt($path->countPlaces())));
                foreach ($pairs as $pair) {
                    $message = new ReducePathMessage($bug->getId(), static::getName(), $path->countPlaces(), $pair[0], $pair[1]);
                    $this->messageBus->dispatch($message);
                    ++$messagesCount;
                }
            }

            $bug->setMessagesCount($bug->getMessagesCount() + $messagesCount);

            return $messagesCount;
        };

        $messagesCount = $this->entityManager->transactional($callback);

        return true === $messagesCount ? 0 : $messagesCount;
    }