Add a failure about mismatching parameter names
@param string $fileName
@param int    $fileLine
@param stirng $calledFunction
@param int    $parameterNumber
@param string $expectedName
@param string $calledName
434759
protected function addParamNameMismatchFailure($fileName, $fileLine, $calledFunction, $parameterNumber, $expectedName, $calledName)
    {
        $data = 'Parameter names in function definition and docblock don\'t match when calling ' . $calledFunction . ' : parameter ' . $parameterNumber . ' (' . $calledName . ') should be called ' . $expectedName . ' according to docblock';
        $this->reportFailure($fileName, $fileLine, $data);
    }
1272007
public static function insertIntoFile($filename, $anchorString, $offset=0, $content)
    {
        if(!file_exists($filename)){
            throw new \Exception('Target File '.$filename.' does not exists');
        }
        $fileLines = file($filename);
        $resLines = [];
        $foundAnchor = false;
        foreach ($fileLines as $line) {
            if(self::contains($line, $anchorString)){
                $foundAnchor = true;
                // decrease the offset value until 0 to locate the target line
            } else {
                if($foundAnchor){
                    $offset = $offset - 1;
                }
            }
            if($offset == 0 && $foundAnchor ){
                if(is_array($content)){
                    $resLines = array_merge($resLines, $content);
                } else {
                    $resLines[] = $content;
                }
            }
            $resLines[] = $line;
        }
        $resLines = implode('',$resLines);
        file_put_contents($filename, $resLines);
    }
131702
public function theOperationInFile($filename)
    {
        $queryFile = sprintf('%s%s%s', self::$currentFeatureFile->getPath(), DIRECTORY_SEPARATOR, $filename);
        if (file_exists($queryFile)) {
            $file = new File($queryFile);
            $this->client->setGraphQL(file_get_contents($file->getPathname()));
        } else {
            throw new FileNotFoundException(null, 0, null, $queryFile);
        }
    }
655920
public function write(
        string $filename,
        string $data,
        int $mode = null,
        bool $ensureDirectory = false,
        bool $append = false
    ): bool {
        $mode = $mode ?? self::DEFAULT_FILE_MODE;

        try {
            if ($ensureDirectory) {
                $this->ensureDirectory(dirname($filename), $mode);
            }

            if ($this->exists($filename)) {
                //Forcing mode for existed file
                $this->setPermissions($filename, $mode);
            }

            $result = file_put_contents(
                $filename,
                $data,
                $append ? FILE_APPEND | LOCK_EX : LOCK_EX
            );

            if ($result !== false) {
                //Forcing mode after file creation
                $this->setPermissions($filename, $mode);
            }
        } catch (\Exception $e) {
            throw new WriteErrorException($e->getMessage(), $e->getCode(), $e);
        }

        return $result;
    }
513091
public function deleteDummyFile($fileName)
    {
        $absolutePathToFile = $this->getUploadFolderPath() . $fileName;
        $fileExists = file_exists($absolutePathToFile);

        if (!isset($this->dummyFiles[$fileName])) {
            throw new \InvalidArgumentException(
                'The file "' . $absolutePathToFile . '" which you are trying to delete ' .
                (!$fileExists ? 'does not exist and has never been ' : 'was not ') .
                'created by this instance of the testing framework.',
                1334439315
            );
        }

        if ($fileExists && !unlink($absolutePathToFile)) {
            throw new Exception('The file "' . $absolutePathToFile . '" could not be deleted.', 1334439327);
        }

        unset($this->dummyFiles[$fileName]);
    }
513467
protected function loadFile($filename)
    {
        if (!is_string($filename)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, gettype($filename)));
        }

        try {
            $content = file_get_contents($filename);
        } catch (\Exception $exception) {
            throw new RuntimeException(sprintf('Could not load file %s', $filename));
        }

        if ($content === false) {
            throw new RuntimeException(sprintf('Could not load file %s', $filename));
        }

        return $content;
    }
781984
public function assertFileNotEquals($expected, $canonicalize = false, $ignoreCase = false) {
        $this->callAssertMethod(__FUNCTION__, [
            'expected' => $expected,
            'additionalParams' => [
                $canonicalize,
                $ignoreCase,
            ],
        ]);
    }
1111735
public void processFile(String fileName, boolean failOnFileNotFound) throws Exception {

    boolean fileFound = false;
    InputStream f = null;
    try {
      String furl = null;

      File file = new File(fileName); // files in filesystem
      if (!file.exists()) {
        URL url = classLoadHelper.getResource(fileName);
        if (url != null) {
          try {
            furl = URLDecoder.decode(url.getPath(), "UTF-8");
          } catch (UnsupportedEncodingException e) {
            furl = url.getPath();
          }
          file = new File(furl);
          try {
            f = url.openStream();
          } catch (IOException ignor) {
            // Swallow the exception
          }
        }
      } else {
        try {
          f = new java.io.FileInputStream(file);
        } catch (FileNotFoundException e) {
          // ignore
        }
      }

      if (f == null) {
        fileFound = false;
      } else {
        fileFound = true;
      }
    } finally {
      try {
        if (f != null) {
          f.close();
        }
      } catch (IOException ioe) {
        logger.warn("Error closing jobs file " + fileName, ioe);
      }
    }

    if (!fileFound) {
      if (failOnFileNotFound) {
        throw new SchedulerException("File named '" + fileName + "' does not exist.");
      } else {
        logger.warn(
            "File named '"
                + fileName
                + "' does not exist. This is OK if you don't want to use an XML job config file.");
      }
    } else {
      processFile(fileName);
    }
  }
276432
public function setFileName($fileName = null) {
		if (empty($fileName)) {
			return false;
		}

		$this->_fileName = (string)$fileName;

		return true;
	}
559525
private function buildErrorMessage(array $errorValues, array &$errors, $funcName, $propertyName)
    {
        $message = \str_replace(':attribute', "'".$propertyName."'", $errors[$funcName]);

        foreach ($errorValues as $key => $value) {
            $message = \str_replace(":{$key}", $value, $message);
        }

        return $message;
    }
1071944
protected function assertFilenameValid($filename)
    {
        $result = new ValidationResult();
        $this->validate($result, $filename);
        if (!$result->isValid()) {
            throw new ValidationException($result);
        }
    }
1220378
protected function validateFileName($fileName = null)
    {
        if ($fileName === null) {
            $fileName = $this->fileName;
        }

        $fileName = trim($fileName);

        if (!strlen($fileName)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.file_name_required', [
                    'allowed' => implode(', ', $this->allowedExtensions),
                    'invalid' => pathinfo($fileName, PATHINFO_EXTENSION)
                ])
            ]);
        }

        if (!FileHelper::validateExtension($fileName, $this->allowedExtensions, false)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.invalid_file_extension', [
                    'allowed' => implode(', ', $this->allowedExtensions),
                    'invalid' => pathinfo($fileName, PATHINFO_EXTENSION)
                ])
            ]);
        }

        if (!FileHelper::validatePath($fileName, null)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.invalid_file', [
                    'name' => $fileName
                ])
            ]);
        }
    }
609023
public function _passThrough( $filePath, $startOffset = 0, $length = false, $fname = false )
    {
        if ( $fname )
            $fname .= "::_passThrough($filePath)";
        else
            $fname = "_passThrough($filePath)";

        $metaData = $this->_fetchMetadata( $filePath, $fname );
        // @todo Throw an exception
        if ( !$metaData )
            return false;

        // @todo Catch an exception
        $this->dfsbackend->passthrough( $filePath, $startOffset, $length );

        return true;
    }
445076
protected function reportFailure($fileName, $fileLine, $data)
    {
        switch ($this->_log) {
            case self::LOG_TO_FILE:
                file_put_contents(
                    $this->_logLocation,
                    $data . ' - in ' . $fileName . ' (line ' . $fileLine . ')',
                    FILE_APPEND
                );
                break;
            case self::LOG_TO_FIREPHP:
                require_once 'FirePHPCore/FirePHP.class.php';
                $firephp = FirePHP::getInstance(true);
                $firephp->warn($fileName . ' (line ' . $fileLine . ')', $data);
                break;
            case self::LOG_TO_PHPUNIT;
                $this->_failures[] = array(
                    'fileName' => $fileName,
                    'fileLine' => $fileLine,
                    'data' => $data
                );
                break;
        }
    }
515853
public void addFile(String filename, String filePath) {
        int pathIndex = filePathList.indexOf(filePath);
        if (pathIndex == -1) {
            fileNameList.add(filename);
            filePathList.add(filePath);
        }
    }
1289788
public function fileExists($fileName, $storageName = '')
    {
        //check whether file is set or not
        if ($fileName == '') {
            AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
            throw new Exception(Exception::MSG_NO_FILENAME);
        }

        //build URI
        $strURI = $this->strURIExist . $fileName;
        if ($storageName != '') {
            $strURI .= '?storage=' . $storageName;
        }
        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = json_decode(Utils::processCommand($signedURI, 'GET', '', ''));
        if (!$responseStream->FileExist->IsExist) {
            return FALSE;
        }
        return TRUE;
    }
185127
function writeFileFromFile($filename, $localFilename, $multicall = false)
    {
        if (!file_exists($localFilename)) {
            throw new InvalidArgumentException('localFilename = ' . print_r($localFilename, true));
        }

        $contents = file_get_contents($localFilename);
        return $this->writeFile($filename, $contents, $multicall);
    }