@param string|null $fileArgument

@return string|null The file path to edit, null if the input was null, or the value of the referenced variable

@throws \InvalidArgumentException If the variable is not found in the current context
331472
private function extractFilePath($fileArgument)
    {
        // If the file argument was a variable, get it from the context
        if ($fileArgument !== null &&
            \strlen($fileArgument) > 0 &&
            $fileArgument[0] === '$') {
            $fileArgument = $this->context->get(\preg_replace('/^\$/', '', $fileArgument));
        }

        return $fileArgument;
    }
929579
public static function notNull($argValue, $argName = '')
    {
        $valid = ($argValue !== null);
        if (!$valid) {
            $message = implode(' ', array_filter(['Argument', $argName, 'must not be null']));
            throw new \InvalidArgumentException($message);
        }
        return $valid;
    }
1301485
public function handleOpen(string $fileName): void
	{
		if (strpos($fileName, '..' . DIRECTORY_SEPARATOR) !== false) {
			throw new InvalidArgumentException;
		}
		$file = $this->getFileInfo($fileName);
		if ($file->isDir) {
			$path = $this->getPath();
			$path[] = $fileName;
			$this->setPath($path);
		} else {
			$this->viewFile($file);
		}

		$this->redrawControl('fileManagerContainer');
	}
1166272
public function setFile($file) {
        if (!file_exists($file) || !is_readable($file)) {
            throw new InvalidArgumentException("The file '{$file}' cannot be opened.");
        }
        $this->file = $file;
        return $this;
    }
439328
public function get_original($file, $args = NULL) {
    $this->file = $file;

    if (!$this->setFilename()) {
      return $this->image_element_empty();
    }

    $this->setupArguments($args);

    return $this->image_element_original();
  }
309154
public function load($configurationFile = null)
    {
        $this->hosts = array();
        $this->configuration = array();

        if (isset($configurationFile)) {
            $this->configurationFile = $configurationFile;
        }

        if (file_exists($this->configurationFile) === false) {
            throw new InvalidArgumentException(sprintf('The configuration file "%s" is not valid.', $this->configurationFile));
        }

        $json = file_get_contents($this->configurationFile);

        $this->validateSyntax($json);

        $json = $this->importExtendedConfiguration($json);
        if ($this->validateSchema($json)) {
            $this->configuration = json_decode($json, true);
        }

        $this->processEventSubscribers();
    }
678861
public function getFilePathHeader() {
        if($this->filePathHeader === null){
            throw new InvalidArgumentException(sprintf("The filePathContent must be setter."));
        }
        $path = $this->filePathHeader;
        if($this->container){
            $path = $this->container->get("kernel")->locateResource($path);
        }
        if(!$this->chainModel->getExporterManager()->getFs()->exists($path)){
            throw new InvalidArgumentException(sprintf("The filePathHeader '%s' does not exist.",$path));
        }
        return $path;
    }
1184355
static function  rebasedFilename($file,$from,$to) {
		if (!Strings::startsWith($file, $from)) {
			throw new \InvalidArgumentException("File $file is not in directory $from");
		}
		$secondPart=Strings::substring($file, Strings::length($from));
		if ($secondPart[0]=="/") $secondPart=substr($secondPart,1);
		$newPath=$to."/".$secondPart;
		return $newPath;
	}
902630
public function getArgument($key)
    {
        if ($this->hasArgument($key)) {
            return $this->arguments[$key];
        }

        throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName()));
    }
1211887
private function validate($content, $file)
    {
        if (null === $content) {
            return $content;
        }

        if (!is_array($content)) {
            throw new \InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
        }

        foreach (array_keys($content) as $namespace) {
            if (in_array($namespace, ['imports', 'parameters'])) {
                continue;
            }
        }

        return $content;
    }
1181825
private function setClientFilename($clientFilename)
    {
        if (preg_match('`[/\\]+`', $clientFilename) > 0) {
            throw new \InvalidArgumentException('Filename contain invalid character "\" or "/" in his name.');
        }

        $this->clientFilename = (empty($clientFilename) ? null : (string) $clientFilename);

        return $this;
    }
874681
public function getFileDirPrefix($filename)
    {
        if (empty($filename)) {
            throw new InvalidArgumentException('Invalid filename argument');
        }

        $path = array();
        $parts = explode('.', $filename);

        for ($i = 0; $i < min(strlen($parts[0]), $this->prefixSize); $i++) {
            $path[] = $filename[$i];
        }

        $path = $this->getPath($path);

        return $path;
    }
621770
public function removeArgument(IArgument $arg): IRequest
    {
        if ($arg instanceof IMergeableArgument) {
            if (!isset($this->mergeableArguments[$arg->getKey()])) {
                throw new \InvalidArgumentException("This argument doesn't exists");
            }
            $this->mergeableArguments[$arg->getKey()]->removeArgument($arg);

            if ($this->mergeableArguments[$arg->getKey()]->isEmpty()) {
                unset($this->mergeableArguments[$arg->getKey()]);
            }
        } elseif ($arg instanceof IStackableArgument) {
            if (!isset($this->stackableArguments[$arg->getKey()])) {
                throw new \InvalidArgumentException("This argument doesn't exists");
            }
            $this->stackableArguments[$arg->getKey()]->removeArgument($arg);

            if ($this->stackableArguments[$arg->getKey()]->isEmpty()) {
                unset($this->stackableArguments[$arg->getKey()]);
            }
        } else {
            unset($this->arguments[$arg->getKey()]);
        }

        return $this;
    }
739578
public function rename($name)
    {
        $this->guardDeletedFile();

        // If there is any slash character in new name, Selectel
        // will create new virtual directory and copy file to
        // this new one. Such behaviour may be unexpected.

        if (count(explode('/', $name)) > 1) {
            throw new InvalidArgumentException('File name can not contain "/" character.');
        }

        $destination = $this->directory().'/'.$name;

        $response = $this->api->request('PUT', $this->absolutePath($destination), [
            'headers' => [
                'X-Copy-From' => $this->absolutePath(),
                'Content-Length' => 0,
            ],
        ]);

        if ($response->getStatusCode() !== 201) {
            throw new ApiRequestFailedException(
                'Unable to rename file from "'.$this->name().'" to "'.$name.'" (path: "'.$this->directory().'").',
                $response->getStatusCode()
            );
        }

        // Since Selectel Storage does not provide such method as "rename",
        // we need to delete original file after copying. Also, "deleted"
        // flag needs to be reverted because file was actually renamed.

        $this->delete();
        $this->deleted = false;

        return $this->data['name'] = $destination;
    }
27007
private function parseFile($file)
    {
        $data = sscanf($file, '@%[^:]:%[^?]');

        if (empty($data[0])) {
            throw new \InvalidArgumentException(sprintf('File "%s" has invalid syntax', $file));
        }

        return $data;
    }
1112248
public static function fromFile($file, array $option = array())
    {
        if (!file_exists($file)) {
            throw new \InvalidArgumentException('File not found: ' . $file);
        }

        return new self(new FileIterator($file), $option);
    }
884013
public function filePath($path)
    {
        $file = $this->realPath($path);
        if (!is_file($file)) {
            throw new \InvalidArgumentException(sprintf('The path is not a file: %s', $file));
        }

        return $path;
    }