@param string $lockFile

@return int
323183
public function getLockLifetime($lockFile)
    {
        if (!file_exists($lockFile)) {
            return 0;
        }

        $pid = file_get_contents($lockFile);
        if (empty($pid)) {
            return 0;
        }

        if (!posix_kill(intval($pid), 0)) {
            return 0;
        }

        $stat = stat($lockFile);

        return (time() - $stat["mtime"]);
    }
1086723
private function readAutoReleaseMoment()
    {
        $lockFile = $this->getFileInfo()->openFile('r');
        $lockEndTimeAsString = $lockFile->getCurrentLine();
        $lockFile = null;
        $lockEndTime = new \DateTime($lockEndTimeAsString);

        return $lockEndTime;
    }
1040664
public static function getPidFromFile($pidFile, $check = false)
    {
        if ($pidFile && file_exists($pidFile)) {
            $pid = (int)file_get_contents($pidFile);

            // check
            if ($check && self::isRunning($pid)) {
                return $pid;
            }

            unlink($pidFile);
        }

        return 0;
    }
727553
public function create_lockfile($contents=null) {
		if(!$this->is_lockfile_present()) {
			$retval = $this->fsObj->create_file($this->get_lockfile());
			
			if(!is_null($contents)) {
				$this->fsObj->write($contents);
			}
		}
		else {
			throw new exception(__METHOD__ .": lockfile (". $this->lockFile .") already present");
		}
		
		return($retval);
	}
912275
public function find($id, ?int $lockMode = null, ?int $lockVersion = null)
    {
        $entity = $this->entityRepository->find($id, $lockMode, $lockVersion);
        if (null === $entity) {
            return null;
        }
        if ($entity instanceof EntityInterface) {
            $this->initialiseEntity($entity);

            return $entity;
        }
    }
1249117
protected function loadPackages(JsonFile $lockFile)
    {
        $lock = $lockFile->read();
        foreach ($this->managers as $name => $m) {
            $m->setConfig($lock[$name]);
        }
    }
1352195
protected function checkNumberOfAllowedFilters($cacheFile)
    {
        $pathInfo = pathinfo($cacheFile);
        $fileNameHash = preg_replace('%-.*$%', '', $pathInfo['filename']);
        // Grab all the similar files
        $cachedImages = glob($pathInfo['dirname'] . DS . $fileNameHash . '*');

        if (! is_array($cachedImages)) {
            $cachedImages = array();
        }

        // Loop through and remove the ones that are older than the time limit
        foreach ($cachedImages as $k => $image) {
            if (filemtime($image) < time() - $this->options['allowedFiltersTimeLimit']) {
                unset($cachedImages[$k]);
            }
        }

        // Check and see if we've reached the maximum allowed resizes within the current time limit.
        if (count($cachedImages) >= $this->options['numberOfAllowedFilters']) {
            throw new ErrorException('You cannot create anymore resizes/manipulations at this time.');
        }
    }
985299
public function size($remoteFile)
    {
        $size = @ftp_size($this->connection, $remoteFile);

        if ($size === -1) {
            throw new Exception('Unable to get file size');
        }

        return $size;
    }
1064528
public function lock($document, $lockMode, $lockVersion = null)
    {
        if (!is_object($document)) {
            throw new \InvalidArgumentException(gettype($document));
        }
        $this->unitOfWork->lock($document, $lockMode, $lockVersion);
    }
1244094
public static function obtainOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
    {
        $lock = $lockDirectory->createFile(self::OPTIMIZATION_LOCK_FILE);
        if (!$lock->lock(LOCK_EX, true)) {
            return false;
        }
        return $lock;
    }
767891
protected function checkBeginningOfDocBlock(File $phpCsFile, int $docBlockStartIndex, int $nextIndex): void
    {
        $tokens = $phpCsFile->getTokens();

        $diff = $tokens[$nextIndex]['line'] - $tokens[$docBlockStartIndex]['line'];
        if ($diff < 2) {
            return;
        }

        $fix = $phpCsFile->addFixableError('Expected no extra blank line before tags, got ' . ($diff - 1), $nextIndex, 'NoExtraNewlineBeforeTags');
        if ($fix) {
            return;
        }

        $phpCsFile->fixer->beginChangeset();

        for ($i = $docBlockStartIndex; $i < $nextIndex; $i++) {
            if ($tokens[$i]['line'] <= $tokens[$docBlockStartIndex]['line'] || $tokens[$i]['line'] >= $tokens[$nextIndex]['line']) {
                continue;
            }
            $phpCsFile->fixer->replaceToken($i, '');
        }

        $phpCsFile->fixer->endChangeset();
    }
282830
public static function loadLockPackages(array $lockData)
    {
        $loader = new ArrayLoader();
        $lockData = static::loadLockPackage($loader, $lockData);
        $lockData = static::loadLockPackage($loader, $lockData, true);
        $lockData = static::convertLockAlias($lockData);

        return $lockData;
    }
958235
public function getLineLength(PHP_CodeSniffer_File $phpcsFile, $currentLine) {
    $tokens = $phpcsFile->getTokens();

    $tokenCount = 0;
    $currentLineContent = '';

    $trim = (strlen($phpcsFile->eolChar) * -1);
    for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) {
      if ($tokens[$tokenCount]['line'] === $currentLine) {
        $currentLineContent .= $tokens[$tokenCount]['content'];
      }
    }

    return strlen($currentLineContent);
  }
943618
private double getFileAge(File file) {
        final Date d = new Date();
        final long modified = file.lastModified();
        final double time = (d.getTime() - modified) / 1000.0 / 60.0;
        LOGGER.debug("Lock file age is {} minutes", time);
        return time;
    }
1035136
protected function findDocBlockReturn(File $phpcsFile, int $docBlockStartIndex, int $docBlockEndIndex): ?int
    {
        $tokens = $phpcsFile->getTokens();

        for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
            if (!$this->isGivenKind(T_DOC_COMMENT_TAG, $tokens[$i])) {
                continue;
            }
            if ($tokens[$i]['content'] !== '@return') {
                continue;
            }

            return $i;
        }

        return null;
    }
687669
def _obtain_lock(self):
        """"""
        starttime = time.time()
        maxtime = starttime + float(self._max_block_time)
        while True:
            try:
                super(BlockingLockFile, self)._obtain_lock()
            except IOError:
                # synity check: if the directory leading to the lockfile is not
                # readable anymore, raise an exception
                curtime = time.time()
                if not osp.isdir(osp.dirname(self._lock_file_path())):
                    msg = "Directory containing the lockfile %r was not readable anymore after waiting %g seconds" % (
                        self._lock_file_path(), curtime - starttime)
                    raise IOError(msg)
                # END handle missing directory

                if curtime >= maxtime:
                    msg = "Waited %g seconds for lock at %r" % (maxtime - starttime, self._lock_file_path())
                    raise IOError(msg)
                # END abort if we wait too long
                time.sleep(self._check_interval)
            else:
                break
1195560
public static function main(string $projectRootDirectory = null): int
    {
        $return               = 0;
        $projectRootDirectory = $projectRootDirectory ?? Helper::getProjectRootDirectory();
        $files                = static::getFiles($projectRootDirectory);
        foreach ($files as $file) {
            $relativeFile = str_replace($projectRootDirectory, '', $file);
            $title        = "\n$relativeFile\n" . str_repeat('-', strlen($relativeFile)) . "\n";
            $errors       = [];
            $links        = static::getLinks($file);
            foreach ($links as $link) {
                static::checkLink($projectRootDirectory, $link, $file, $errors, $return);
            }
            if ([] !== $errors) {
                echo $title . implode('', $errors);
            }
        }

        return $return;
    }