Validate file has the include regex if this regex is set.

@param string $path The file path.

@return bool True if it pass this validation.
359352
private function validateIncludeRegex(string $path): bool
    {
        $includeRegex = $this->config->getIncludeRegex();
        return $includeRegex === null || Validator::regex($includeRegex)->validate($path) === true;
    }
262745
protected function checkIfPathToFileCheckPrefix(string $path): bool
    {
        if (file_exists($path) === true) {
            return substr($path, 0, 7) === 'file://';
        }

        return true;
    }
724327
protected static function isValidPath(string $path): bool
    {
        // http://tools.ietf.org/html/rfc3986#section-3
        // The scheme and path components are required, though the path may be
        // empty (no characters)
        if ($path === '') {
            return true;
        }

        // http://tools.ietf.org/html/rfc3986#section-3.3
        // path          = path-abempty    ; begins with "/" or is empty
        //               / path-absolute   ; begins with "/" but not "//"
        //               / path-noscheme   ; begins with a non-colon segment
        //               / path-rootless   ; begins with a segment
        //               / path-empty      ; zero characters
        //
        // path-abempty  = *( "/" segment )
        // path-absolute = "/" [ segment-nz *( "/" segment ) ]
        // path-noscheme = segment-nz-nc *( "/" segment )
        // path-rootless = segment-nz *( "/" segment )
        // path-empty    = 0<pchar>
        // segment       = *pchar
        // segment-nz    = 1*pchar
        // segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
        //               ; non-zero-length segment without any colon ":"
        // pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
        $pattern = sprintf(
            '/\A(?:(?:[%s%s:@]|(?:%s))*\/?)*\z/',
            static::UNRESERVED_SET,
            static::SUB_DELIMS_SET,
            static::PCT_ENCODED_SET
        );

        return !!preg_match($pattern, $path);
    }
804731
protected static function validatePath($path)
    {
        // Validate path by default logic
        $path = parent::validatePath($path);

        // Collection of existing folders for error message
        $existingFolders = array();

        // Check now if any of the target directories exists
        foreach (self::getFolders() as $folder) {
            if (file_exists($path . $folder)) {
                $existingFolders[] =  $folder . '/';
            }
        }

        // Any folder found? => Exception
        if (count($existingFolders) > 0) {
            throw new Exception(
                'The target directory contains the following files/folders already: ' .
                implode(' & ', $existingFolders) . '.' . PHP_EOL . 'Remove those files/folders first and try again.' .
                PHP_EOL
            );
        }

        return $path;
    }
746300
public function checkFilter($path)
    {
        //No filters? Include all paths.
        if (empty($this->filters)) {
            return true;
        }

        //Match either with or without braces.
        $cleanPath = str_replace(array('{', '}'), array('', ''), $path);
        foreach ($this->filters as $filter) {
            if (stripos($path, $filter) !== false || stripos($cleanPath, $filter) !== false) {
                return true;
            }
        }
        return false;
    }
793260
public function isValidPath($path)
    {
        $isValidPath = false;

        $pathValue = $this->getValueByPath($path);
        if (!is_null($pathValue)) {
            $isValidPath = true;
        }

        return $isValidPath;
    }
598750
private function validateRoute($path)
    {
        $complementType = self::getType('strtoupper');

        $thePath = App::$complementType();

        if ($thePath == $path || strpos($path, $thePath) === false) {
            $type = self::getType('ucfirst', false);
            $msg = 'The ' . $type . " path: '$path' isn't a valid route.";
            self::$errors[] = ['message' => $msg];

            return false;
        }

        return true;
    }
473599
public function isFile($path)
    {
        $node = $this->at($path);
        return null !== $node && 'file' === $node->type;
    }
350054
public function validate( string $path ) {

		$command = PB_XMLLINT_COMMAND . ' --noout --schema ' . escapeshellcmd( $this->getSchemaPath() ) . ' ' . escapeshellcmd( $path ) . ' 2>&1';

		// Execute command
		$this->errors = [];
		$output = [];
		$return_var = 0;
		exec( $command, $output, $return_var );

		if ( isset( $output[0] ) && str_ends_with( $output[0], ' validates' ) ) {
			return true;
		} else {
			$this->errors = $output;
			return false;
		}
	}
471543
private function checkPathPatterns($path)
    {
        foreach ($this->pathPatterns as $pattern) {
            if (preg_match('/^' . $pattern . '$/D', $path)) {
                return true;
            }
        }

        return false;
    }
369184
protected function checkPath($path)
    {
        foreach ($this->chroots as $chroot) {
            if (StringHelper::contains($path, $chroot)) {
                return true;
            }
        }
        return false;
    }
159417
private function includeFile($path)
    {
        $shopgate_config = null;

        // try including the file
        if (file_exists($path)) {
            ob_start();
            /** @noinspection PhpIncludeInspection */
            include($path);
            ob_end_clean();
        } else {
            return false;
        }

        // check $shopgate_config
        if (!isset($shopgate_config) || !is_array($shopgate_config)) {
            return false;
        } else {
            return $shopgate_config;
        }
    }
155122
public function checkPath($path = null)
  {
    if($path === null)
    {
      $path = $this->path;
    }

    if(strlen($path) == 0)
    {
      return TRUE;
    }

    $pattern = "/^" . $this->regex["path"] . "$/";
    $status = @preg_match($pattern, $path);

    if($status === FALSE)
    {
      throw new Exception("URI path validation failed");
    }

    return ($status == 1);
  }
1032123
protected function isLocalPath(string $path): bool
    {
        if (Str::startsWith($path, ['https://', 'http://', '//'])) {
            return false;
        }

        return \filter_var($path, FILTER_VALIDATE_URL) === false;
    }
1059827
protected function is_valid_file($path) {
        global $CFG;

        $realpath = realpath($path);

        // Additional theme directory.
        $addthemedirectory = core_component::get_plugin_types()['theme'];
        $addrealroot = realpath($addthemedirectory);

        // Original theme directory.
        $themedirectory = $CFG->dirroot . "/theme";
        $realroot = realpath($themedirectory);

        // File should end in .scss and must be in sites theme directory, else ignore it.
        $pathvalid = $realpath !== false;
        $pathvalid = $pathvalid && (substr($path, -5) === '.scss');
        $pathvalid = $pathvalid && (strpos($realpath, $realroot) === 0 || strpos($realpath, $addrealroot) === 0);
        return $pathvalid;
    }
732190
public function checkPath($path)
    {
        $path = realpath($path);

        return ($path !== false && is_dir($path)) ? $path : false;
    }
554635
public function fileExists($path)
    {
        $filePath = $this->getFullPath($path);

        return file_exists($filePath) ? true : false;
    }