Update the VERSION file in a component directory.

@param string $version The new version. (do not prefix with `v`).
@param array $component The component data as an array.
@return bool
359970
private function updateComponentVersionFile($version, array $component)
    {
        $path = $this->rootPath() .'/'. $component['path'] .'/VERSION';
        $result = file_put_contents($path, $version);

        if (!$result) {
            throw new \RuntimeException('File write failed');
        }

        return true;
    }
448068
protected function _getVersion($component)
    {
        if (!isset(self::$_versions[$component]))
        {
            try
            {
                if ($component === 'koowa') {
                    $version = Koowa::VERSION;
                }
                else $version = $this->getObject('com://admin/' . $component.'.version')->getVersion();
            }
            catch (Exception $e) {
                $version = null;
            }

            self::$_versions[$component] = $version;
        }

        return self::$_versions[$component];
    }
249065
public function upgrade( $version ) {

		if ( $version < 1 ) {
			// Upgrade from version 0 (prior to Pressbooks\Taxonomy class) to version 1 (simplified chapter types)
			$this->upgradeChapterTypes();
			flush_rewrite_rules( false );
		}
		if ( $version < 2 ) {
			$this->insertTerms(); // Re-trigger
		}
		if ( $version < 3 ) {
			$this->upgradeLicenses();
		}
		if ( $version < 4 ) {
			$this->differentiatePublicDomain();
		}
	}
606914
public function setVersion($version) {
        if (in_array($version, self::$_VERSIONS)) {
            $this->_version = $version;
        } else {
            Mage::throwException('Unsupported Varnish version: '.$version);
        }
    }
444196
public static function isVersion($version){
        $currentVersion = Craft::$app->getVersion();
        $version = explode('.', $version);
        $currentVersion = explode('.', $currentVersion);
        $isVersion = true;
        foreach($version as $key => $value){
            if ((int)$currentVersion[$key] < $version[$key]){ 
                $isVersion = false;
            }
        }
        return $isVersion;
    }
200984
public function setVersion($version)
    {
        if (null !== $version) {
            Assert::string($version, 'The application version must be a string. Got: %s');
            Assert::notEmpty($version, 'The application version must not be empty.');
        }

        $this->version = $version;

        return $this;
    }
498408
public static function toComponents(Version $version)
    {
        return array(
            Parser::MAJOR => $version->getMajor(),
            Parser::MINOR => $version->getMinor(),
            Parser::PATCH => $version->getPatch(),
            Parser::PRE_RELEASE => $version->getPreRelease(),
            Parser::BUILD => $version->getBuild()
        );
    }
201783
public function migrate($version = null)
    {
        $migrations     = $this->getMigrations();
        $versions       = $this->getVersions();
        $currentVersion = $this->getCurrentVersion();

        if (!count($migrations)) {
            throw new \RuntimeException('No migrations found.');
        }

        if ($version === null) {
            $version = max(array_merge($versions, array_keys(iterator_to_array($migrations))));
        } else {
            if ($version != 0 && empty($migrations[$version])) {
                throw new \RuntimeException('Version is not valid.');
            }
        }

        // Prepare SQL logs
        if (is_file($this->getLogFile())) {
            File::delete($this->getLogFile());
        }

        Folder::create(dirname($this->getLogFile()));

        $queryLogStream = new Stream($this->getLogFile(), Stream::MODE_WRITE_ONLY_FROM_END);
        $logListener = function (Event $event) use ($queryLogStream) {
            $queryLogStream->write($event['query'] . ";\n\n");
        };
        Ioc::getDispatcher()->listen('onMigrationAfterQuery', $logListener);

        $direction = ($version > $currentVersion) ? AbstractMigration::UP : AbstractMigration::DOWN;

        $migrations = iterator_to_array($migrations);

        $count = 0;

        try {
            if ($direction === AbstractMigration::DOWN) {
                krsort($migrations);

                foreach ($migrations as $migration) {
                    if ($migration['version'] <= $version) {
                        break;
                    }

                    if (in_array($migration['version'], $versions)) {
                        $this->executeMigration($migration, AbstractMigration::DOWN);
                    }

                    $count++;
                }
            }

            ksort($migrations);

            foreach ($migrations as $migration) {
                if ($migration['version'] > $version) {
                    break;
                }

                if (!in_array($migration['version'], $versions, true)) {
                    $this->executeMigration($migration, AbstractMigration::UP);
                }

                $count++;
            }
        } catch (\PDOException $e) {
            $queryLogStream->write("-- ERROR: {$e->getMessage()}\n" . $this->db->getQuery());

            throw $e;
        }

        Ioc::getDispatcher()->removeListener($logListener);

        if (!$count) {
            $this->out('No change.');
        }
    }
240043
protected function updateFile($filename)
    {
        $current = Context::getParam('current-version');
        $next = Context::getParam('new-version');

        $content = file_get_contents($filename);
        if (false === strpos($content, $current)) {
            throw new Exception('The version class ' . $filename . " does not contain the current version $current");
        }
        if (isset($this->options['pattern'])) {
            $current = str_replace('%version%', $current, $this->options['pattern']);
            $next = str_replace('%version%', $next, $this->options['pattern']);
        }
        $content = str_replace($current, $next, $content);
        if (false === strpos($content, $next)) {
            throw new Exception('The version class ' . $filename . " could not be updated with version $next");
        }
        file_put_contents($filename, $content);
    }
635063
public function update($version = '') : bool
    {
        $this->setPathToUpdate(base_path(), $this->config['exclude_folders']);

        if ($this->hasCorrectPermissionForUpdate()) {
            if (empty($version)) {
                $version = $this->getVersionAvailable();
            }
            $sourcePath = $this->config['download_path'].DIRECTORY_SEPARATOR.$this->prepend.$version.$this->append;

            // Move all directories first
            collect((new Finder())->in($sourcePath)->exclude($this->config['exclude_folders'])->directories()->sort(function ($a, $b) {
                return strlen($b->getRealpath()) - strlen($a->getRealpath());
            }))->each(function ($directory) { /** @var \SplFileInfo $directory */
                if (count(array_intersect(File::directories(
                        $directory->getRealPath()), $this->config['exclude_folders'])) == 0) {
                    File::copyDirectory(
                        $directory->getRealPath(),
                        base_path($directory->getRelativePath()).'/'.$directory->getBasename()
                    );
                }
                File::deleteDirectory($directory->getRealPath());
            });

            // Now move all the files left in the main directory
            collect(File::allFiles($sourcePath, true))->each(function ($file) { /* @var \SplFileInfo $file */
                File::copy($file->getRealPath(), base_path($file->getFilename()));
            });

            File::deleteDirectory($sourcePath);
            $this->deleteVersionFile();
            event(new UpdateSucceeded($version));

            return true;
        }

        event(new UpdateFailed($this));

        return false;
    }
781546
private function addToComponentManifest($version, array $component)
    {
        $manifest = $this->getManifest($this->manifest());
        $index = $this->getManifestComponentModuleIndex($manifest, $component['id']);

        array_unshift($manifest['modules'][$index]['versions'], 'v'. $version);

        $content = json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) ."\n";
        $result = file_put_contents($this->manifest(), $content);
        $this->setManifest($manifest);

        if (!$result) {
            throw new \RuntimeException('File write failed');
        }
    }
446195
public function setHTTPVersion($version = self::HTTP_1)
	{
		if ($version == self::HTTP_0 || $version == self::HTTP_1) {
			$this->httpVersion = $version;
		} else {
			throw new RuntimeException('Invalid HTTP version setted.');
		}
		
		return $this;
	}
686115
public function saveLastProcessedVersion($version)
    {
        $this->lastProcessedVersion = $version;
        $this->myCreateColumn       = null;
        $this->deleteFromSQL(['serverurl' => constant('FLEXIBEE_URL')]);
        if (is_null($this->insertToSQL(['serverurl' => constant('FLEXIBEE_URL'),
                    'changeid' => $version]))) {
            $this->addStatusMessage(_("Last Processed Change ID Saving Failed"),
                'error');
        } else {
            if ($this->debug === true) {
                $this->addStatusMessage(sprintf(_('Last Processed Change ID #%s Saved'),
                        $version));
            }
        }
    }
1275826
protected static function isFileVersionMatch(string $version): bool
    {
        try {
            $fileVersion = null;
            if (class_exists(self::CONNECTOR_CLASS)) {
                $ref = new \ReflectionClass(self::CONNECTOR_CLASS);
                if (preg_match(FW::VERSION_WITHOUT_BUG_FIX, $ref->getDocComment(), $result)) {
                    $fileVersion = Arr::first($result);
                }
            }

            return version_compare($fileVersion, $version, '>=');
        } catch (\Exception $e) {
            return false;
        }
    }
443446
public function setVersion ($version)
    {
        $version = strtolower(strval($version));
        if (! self::isValid($version)) {
            $version = self::DEFAULT_UNRESOLVED_VERSION;
        }
        
        $this->numbers = self::parse($version);
        $this->version = $version;
        return $this;
    }
220165
public function setVersion($version)
    {
        $this->version
            = preg_match('/^' . self::REGEX_VECTOR . '$/ux', $version)
            ? $version
            : '';

        $this->content = null;
        return $this;
    }
765878
public function setCurrentVersion($version)
    {
        $version = min($this->getMaxVersion(), $version);
        $version = max($version, 0);
        $this->_getVersion()->version = $version;
        $this->_getVersion()->saveEntity();
    }