Check if a file should be included in coverage calculations.

@param string $file The filename

@return bool
552909
private function isCovered($file)
    {
        return in_array($file, $this->includedFiles)
            && !in_array($file, $this->excludedFiles)
            && isset($this->covered[$file]);
    }
992656
public function has($file)
    {
        if (($isArray = is_array($file)) || $file instanceof Traversable) {
            foreach ($file as $key => $f) {
                try {
                    if ( ! $this->has($f)) {
                        return false;
                    }
                }
                catch (InvalidArgumentException $e) {
                    throw new UnexpectedValueException(
                        sprintf(
                            "%s's value at key %s caused InvalidArgumentException",
                            $isArray ? 'Array' : 'FileBag',
                            $key
                        ),
                        null,
                        $e
                    );
                }
                catch (UnexpectedValueException $e) {
                    throw new UnexpectedValueException(
                        sprintf(
                            "%s's value at key %s caused UnexpectedValueException",
                            $isArray ? 'Array' : 'FileBag',
                            $key
                        ),
                        null,
                        $e
                    );
                }
            }
        }
        elseif ($file instanceof SplFileInfo
            || $file instanceof File
        ) {
            return $this->files->contains($file);
        }
        else {
            throw InvalidArgumentException::create(
                sprintf(
                    '%1$s/File|%1$s/File[]|%1$s/FileBag',
                    __NAMESPACE__
                ),
                $file
            );
        }

        return true;
    }
191142
protected function checkOneFile($file)
  {
    $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
    $_aclConfig = $this->_config->getAccessControlConfig();
    $directory = str_replace('\\','/', $resourceTypeInfo->getDirectory());
    $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($file->getFilename());

    if ($this->_config->forceAscii()) {
      $fileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($fileName);
    }
    $pathName = str_replace('\\','/', pathinfo($file->getPathname(), PATHINFO_DIRNAME) );
    $pathName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($pathName);

    // acl
    $aclMask = $_aclConfig->getComputedMask($this->_currentFolder->getResourceTypeName(), str_ireplace($directory,'',$pathName));
    $isAuthorized = (($aclMask & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW);
    if ( !$isAuthorized ){
      return false;
    }

    // if it is a folder fileName represents the dir
    if ( $file->isDir() && ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($fileName) || $resourceTypeInfo->checkIsHiddenPath($fileName) ) ){
      return false;
    }
    // folder name
    if ( !CKFinder_Connector_Utils_FileSystem::checkFolderPath($pathName) ){
      return false;
    }

    // is hidden
    if ( $resourceTypeInfo->checkIsHiddenPath($pathName) || $resourceTypeInfo->checkIsHiddenFile($fileName) ){
      return false;
    }

    // extension
    if ( !$resourceTypeInfo->checkExtension($fileName) || !CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) ){
      return false;
    }

    return true;
  }
351646
protected function checkFileReadable($file)
    {
        if (!file_exists($file)) {
            throw new \RuntimeException("File [$file] does not exist");
        }
        if (!is_file($file)) {
            throw new \RuntimeException("File [$file] is not a file");
        }
        if (!is_readable($file)) {
            throw new \RuntimeException("File [$file] is not readable");
        }
    }
424496
private function checkFile(string &$file): bool
    {
        $file = "{$this->directory}/{$file}";

        return file_exists($file) || (touch($file) && chmod($file, 0600));
    }
446391
public function containsFile(File $file)
    {
        if(!$file->exists()){
            return false;
        }
        $p1 = $this->filesDir->getAbsolutePath();
        $p2 = $file->getParentFolder()->getParentFolder()->getAbsolutePath();
        return $p1 == $p2;
    }
1076028
protected function _coverage($file, $coverage)
    {
        $result = [];
        $root = $this->parse($file);
        foreach ($root->lines['content'] as $num => $content) {
            $coverable = null;
            foreach ($content['nodes'] as $node) {
                if ($node->coverable && $node->lines['stop'] === $num) {
                    $coverable = $node;
                    break;
                }
            }
            if (!$coverable) {
                continue;
            }
            if (isset($coverage[$num])) {
                $result[$num] = $coverage[$num];
            } elseif (isset($coverable->lines['begin'])) {
                for ($i = $coverable->lines['begin']; $i <= $num; $i++) {
                    if (isset($coverage[$i])) {
                        $result[$num] = $coverage[$i];
                        break;
                    }
                }
                if (!isset($result[$num])) {
                    $result[$num] = 0;
                }
            } else {
                $result[$num] = 0;
            }
        }
        return $result;
    }
593804
public function rmFile($file)
    {

        if (!is_file($file)) {
            $this->errorMsg = "this is not a file";
            return false;
        }
        if (unlink($file)) {
            return true;
        } else {
            $this->errorMsg = "fail to remove the file!";
            return false;
        }
    }
266955
public function loadFile( $file ) {

		if ( empty( $this->files ) )
			$this->files = $this->readDirRecursive(
				$this->base_dir,
				'*' . $this->extension
			);

		if ( ! in_array( $file, $this->files ) )
			return FALSE;

		require_once $file;

		return TRUE;
	}
939382
private function checkNotAllowedTypes($file = '')
        {
            $notAllowedTypes = $this->getNotAllowedExt();

            if ('*' === $notAllowedTypes) {
                return true;
            }

            if(is_string($notAllowedTypes))
            {
                $notAllowedTypes = (array) $notAllowedTypes;
            }

            foreach($notAllowedTypes as $type){
                if(strstr($file, $type)){
                    return false;
                }else{
                    continue;
                }
            }

            return true;
        }
940203
private function shouldCopyFileInstead($file)
    {
        // Check if it should not be processed.
        if ($this->isExcludedFromVerbatim($file)) {
            return false;
        }

        foreach ($this->copyVerbatimPatterns as $pattern) {
            if (Str::is($pattern, $file)) {
                return true;
            }
        }

        return false;
    }
730779
protected function _fileGetContents($file)
    {
        if (!is_file($file)) {
            return false;
        }

        if ($this->_options['mode'] == 1) {
            $f = @fopen($file, 'r');
            @$data = fread($f, filesize($file));
            @fclose($f);
            return unserialize($data);
        } else {
            return include $file;
        }
    }
810472
public function isFile($file)
	{
		$file = Util::normalizePath($file);

		return (bool) $this->adapter->isFile($file);
	}
843180
private function isFile($file)
	{
		if(!!file_exists($file))
		{
			if(!!is_writable($file))
			{
				return TRUE;
			}
			else
			{
				$this->fileNotWritable($file);
			}
		}
		return FALSE;
	}
365506
private function shouldSkipFile(File $file): bool
    {
        if (Strings::contains($file->getFilename(), '/tests/')
            && ! Strings::contains($file->getFilename(), 'CodingStandard/tests/')
        ) {
            return true;
        }

        $classWrapper = $this->sniffClassWrapperFactory->createFromFirstClassInFile($file);
        if ($classWrapper === null) {
            return true;
        }

        return $classWrapper->implementsInterface() || $classWrapper->extends();
    }
337763
protected static function getData(string $file)
    {
        $file = __DIR__ . '/data/' . $file . '.php';
        if (\file_exists($file)) {
            /** @noinspection PhpIncludeInspection */
            return require $file;
        }

        return false;
    }
550846
public function hasLoaded(string $file) : bool
    {
        $file = $this->sanitizeFileName($file);
        return isset($this->loaded[$file]);
    }