Update custom values between delimiter with real values

@param $file
4409
protected function userDefinedVars($file)
    {
        $start = $this->delimiter[0];
        $end = $this->delimiter[1];

        if ($this->customData !== null) {
            $customVars = explode(';', $this->customData);
            foreach ($customVars as $rawVar) {
                $arrayVar = explode('=', $rawVar);
                File::put($file, str_replace($start . $arrayVar[0] . $end, $arrayVar[1], File::get($file)));
            }
        }
    }
97897
protected function addUploadedFile($file)
    {
        $this->clear();

        $this->uploaded_file = $this->getFileManager()->make($file);

        // Get the original values
        $filename = $this->uploaded_file->getClientOriginalName();
        $content_type = $this->uploaded_file->getMimeType();

        // Set model values
        $this->instanceWrite('file_name', $filename);
        $this->instanceWrite('file_size', $this->uploaded_file->getSize());
        $this->instanceWrite('content_type', $content_type);
        $this->instanceWrite('updated_at', date('Y-m-d H:i:s'));
        $this->instanceWrite('queued_file', null);

        // Queue all styles for writing
        $this->setQueue('write', $this->styles);
    }
371225
public function change_perm_by_real($file, $file_new, $type='file'){
    if ( !empty($file) &&
      !empty($file_new) &&
      file_exists($file_new) &&
      ($id_opt = $this->real_to_perm($file, $type)) &&
      !$this->real_to_perm($file_new, $type)
    ){
      $is_file = $type === 'file';
      $code = $is_file ? bbn\str::file_ext(basename($file_new), 1)[0] : basename($file_new).'/';
      if ( ($id_parent = $this->create_perm_by_real(dirname($file_new).'/', 'dir'))
      ){
        $this->options->set_prop($id_opt, ['code' => $code]);
        $this->options->move($id_opt, $id_parent);
        return true;
      }
    }
    return false;
  }
710732
public static function extension($file, $separator = self::SEPARATOR_BOTH){
        return self::validate($file, $separator) ? substr($file, strrpos($file, '.') + 1) : false;
    }
1231378
public function copyTo($file)
    {
        if (null === $this->file) {
            throw LogicException::create(
                'The update file has not been downloaded.'
            );
        }

        $mode = 0755;

        if (file_exists($file)) {
            $mode = fileperms($file) & 511;
        }

        if (false === @copy($this->file, $file)) {
            throw FileException::lastError();
        }

        if (false === @chmod($file, $mode)) {
            throw FileException::lastError();
        }

        $key = $file . '.pubkey';

        if (file_exists($this->file . '.pubkey')) {
            if (false === @copy($this->file . '.pubkey', $key)) {
                throw FileException::lastError();
            }
        } elseif (file_exists($key)) {
            if (false === @unlink($key)) {
                throw FileException::lastError();
            }
        }
    }
402189
public function addResource(string $file): void
    {
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        $this->processData(json_decode($contents, true));
    }
895626
public function set_file($file) {
        if (!file_exists($file) || (!is_readable($file))) {
            throw new progressive_parser_exception('invalid_file_to_parse');
        }
        $this->file = $file;
        $this->contents = null;
    }
87223
public function addTrace($file)
    {
        // If the file does not contain the trace, add it.
        if (strpos(File::get($file), $this->realPath) === false && $this->debug == true) {
            File::prepend($file, $this->realPath);
            File::append($file, '</span>');
        }
    }
206791
protected function setFileSize($file)
    {
        $this->fileSize = ! is_null($this->elfinderFilePath) ? $this->getFileSize() : (is_string($file) ? $this->size($file) : $file->getClientSize());
    }
1117392
public function import($file)
    {
        $rules = $this->yaml->load($file);

        foreach ($rules as $rule) {
            list($key, $value) = each($rule);
            switch ($key) {
                case 'root':
                    $this->setRoot($value);
                    break;
                case 'match':
                    $this->addMatchRule($value);
                    break;
            }
        }
    }
355170
protected function parseFile($file)
    {
        $this->file    = $file;
        // When running as a PHAR, copy the SQLite database
        // to a temporary file. Required as the SQLite3 driver
        // does not support streams (and it can"t, see #55154).
        if (!strncasecmp(__FILE__, 'phar://', 7)) {
            $this->file = tempnam(
                sys_get_temp_dir(),
                'Wordlists'
            );
            copy($file, $this->file);
        }

        $this->db   = new \PDO('sqlite:' . $this->file);
        $metadata   = $this->db->query(
            'SELECT type, value '.
            'FROM metadata '.
            'ORDER BY type ASC, id ASC'
        );
        foreach ($metadata as $row) {
            if (!array_key_exists($row['type'], $this->metadata)) {
                continue;
            }
            if (is_array($this->metadata[$row['type']])) {
                $this->metadata[$row['type']][] = $row['value'];
            } else {
                $this->metadata[$row['type']] = $row['value'];
            }
        }

        // Try to create a collator for the given locale.
        $this->collator = new \Collator(
            str_replace('-', '_', $this->metadata['locale'])
        );
        // -127 = U_USING_DEFAULT_WARNING
        // -128 = U_USING_FALLBACK_WARNING.
        //    0 = U_ZERO_ERROR (no error).
        if (!in_array(intl_get_error_code(), array(-127, -128, 0))) {
            throw new \Erebot\InvalidValueException(
                "Invalid locale (".$this->metadata['locale']."): ".
                intl_get_error_message()
            );
        }
        // Ignore differences in case, accents and punctuation.
        $this->collator->setStrength(\Collator::PRIMARY);

        $this->countQuery = $this->db->prepare(
            'SELECT COUNT(1) '.
            'FROM words'
        );

        $this->getQuery = $this->db->prepare(
            'SELECT value '.
            'FROM words '.
            'ORDER BY sortkey ASC '.
            'LIMIT 1 OFFSET :offset'
        );

        $this->existsQuery = $this->db->prepare(
            'SELECT value '.
            'FROM words '.
            'WHERE sortkey = :key '.
            'LIMIT 1'
        );
    }
221291
private function setContaoFile($file)
    {
        if (is_array($file)) {
            return serialize(array_map([__CLASS__, 'setContaoFile'], $file));
        }

        if ($file instanceof FilesModel) {
            return $file->uuid;
        }
        if (Validator::isStringUuid($file)) {
            return StringUtil::uuidToBin($file);
        }
        return $file;
    }
885322
protected function loadFile($file)
    {
        $requiredFiles = $this->getRequiredFiles($file);
        $this->values[$file] = true;

        foreach ($requiredFiles as $fileToRequire) {
            $overrideConfig = require $fileToRequire['path'];
            $this->config->addConfig([$file => $overrideConfig], $fileToRequire['environment']);
        }
    }
1260920
public function inc($file)
    {
        $b = $this;
        if (file_exists($this->getBlockPath() . '/' . $file)) {
            include $this->getBlockPath() . '/' . $file;
        }
    }
865878
public function setFile($file = null)
    {
        if (is_null($file)) {
            $this->file = ['name' => date('Ymd-His'), 'part' => 1];
        } else {
            if (!array_key_exists("name", $file) && !array_key_exists("part", $file)) {
                $this->file = $file['1'];
            } else {
                $this->file = $file;
            }
        }
        return $this;
    }
639194
private function db_update( $file ){
        require $file;
        if( isset($table) ){
            // Test required members
            $config = wp_parse_args($table, [
                'name' => str_replace('.php', '', basename($file)),
                'version' => false,
                'engine' => Engine::INNODB,
                'columns' => false,
                'primary_key' => [],
                'indexes' => [],
                'unique' => [],
                'fulltext' => [],
            ]);
            $table_name = $config['name'];
            if( $config['name'] && $config['version'] && $config['indexes'] ){
                if( $this->need_update($table_name, $config['version']) ){
                    // Add prefix
                    $config['name'] = $this->db->prefix.$config['name'];
                    // Need update. Let's make query!
                    $query = $this->make_query($config);
                    if( !function_exists('dbDelta') ){
                        require_once ABSPATH . "wp-admin/includes/upgrade.php";
                    }
                    // Do dbDelta
                    $result = dbDelta($query);
                    // Return message
                    if( isset( $result[$config['name']] ) ){
                        $message = sprintf('<code>%s</code> created.', $config['name']);
                    }else{
                        $message = sprintf('<code>%s</code> updated.', $config['name']);
                    }
                    if( !empty($this->db->last_error) ){
                        $message .= sprintf(' <small>(Error: %s)</small>', $this->db->last_error);
                    }
                    // Check table existence
                    if( $this->table_exists($config['name']) ){
                        update_option($this->option_key, array_merge($this->option, [
                            $table_name => $config['version'],
                        ]));
                    }else{
                        $message = sprintf('Failed to create or update <code>%s</code>', $config['name']);
                    }
                    return $message;
                }
            }else{
                throw new \Exception(sprintf('Config file %s is wrong.', $file));
            }
        }else{
            throw new \Exception(sprintf('Config file %s must be PHP Array format.', $file));
        }
        return '';
    }
577066
protected function _setCurrentFile($file)
    {
        $this->_currentFile = $file .((!is_link($file) && is_dir($file) && substr($file, -1) != DS) ? DS : '');
        return $this;
    }