/** * @dataProvider getGreater */ public function testIsGreaterThan($left, $right) { $this->assertTrue(Comparator::isGreaterThan(Builder::create()->importString($left), Builder::create()->importString($right))); }
check('The "apc.enable_cli" setting is off.', 'Notice: The "apc.enable_cli" is on and may cause problems with Phars.', function () { return false == ini_get('apc.enable_cli'); }, false); } echo "{$n}Everything seems good!{$n}{$n}"; echo "Download{$n}"; echo "--------{$n}{$n}"; // Retrieve manifest echo " - Downloading manifest...{$n}"; $manifest = file_get_contents('http://box-project.github.io/box2/manifest.json'); echo " - Reading manifest...{$n}"; $manifest = json_decode($manifest); $current = null; foreach ($manifest as $item) { $item->version = Parser::toVersion($item->version); if ($current && Comparator::isGreaterThan($item->version, $current->version)) { $current = $item; } } if (!$item) { echo " x No application download was found.{$n}"; } echo " - Downloading Box v", Dumper::toString($item->version), "...{$n}"; file_put_contents($item->name, file_get_contents($item->url)); echo " - Checking file checksum...{$n}"; if ($item->sha1 !== sha1_file($item->name)) { unlink($item->name); echo " x The download was corrupted.{$n}"; } echo " - Checking if valid Phar...{$n}"; try {
/** * Validates the data, processes it, and returns a new instance of Manifest. * * @param array $decoded The decoded JSON data. * @param Json $json The Json instance used to decode the data. * * @return Manifest The new instance. */ private static function create($decoded, Json $json) { $json->validate($json->decodeFile(PHAR_UPDATE_MANIFEST_SCHEMA), $decoded); $updates = array(); foreach ($decoded as $update) { $updates[] = new Update($update->name, $update->sha1, $update->url, Parser::toVersion($update->version), isset($update->publicKey) ? $update->publicKey : null); } usort($updates, function (Update $a, Update $b) { return Comparator::isGreaterThan($a->getVersion(), $b->getVersion()); }); return new static($updates); }