isInstalledAsPhar() 공개 정적인 메소드

public static isInstalledAsPhar ( )
예제 #1
0
파일: Runner.php 프로젝트: thekabal/tki
 /**
  * @param ConfigInterface $config
  * @param bool            $isDryRun
  *
  * @return CacheManagerInterface
  */
 private function createCacheManager(ConfigInterface $config, $isDryRun)
 {
     if ($config->usingCache() && (ToolInfo::isInstalledAsPhar() || ToolInfo::isInstalledByComposer())) {
         return new FileCacheManager(new FileHandler($config->getCacheFile()), new Signature(PHP_VERSION, ToolInfo::getVersion(), $config->usingLinter(), $config->getRules()), $isDryRun);
     }
     return new NullCacheManager();
 }
 private function isCacheAvailable()
 {
     static $result;
     if (null === $result) {
         $result = $this->isEnabled && (ToolInfo::isInstalledAsPhar() || ToolInfo::isInstalledByComposer());
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!ToolInfo::isInstalledAsPhar()) {
         $output->writeln('<error>Self-update is available only for PHAR version.</error>');
         return 1;
     }
     $remoteTag = $this->getLatestTag();
     if (null === $remoteTag) {
         $output->writeln('<error>Unable to determine newest version.</error>');
         return 0;
     }
     $currentVersion = 'v' . $this->getApplication()->getVersion();
     if ($currentVersion === $remoteTag) {
         $output->writeln('<info>php-cs-fixer is already up to date.</info>');
         return 0;
     }
     $remoteVersionParsed = $this->parseVersion($remoteTag);
     $currentVersionParsed = $this->parseVersion($currentVersion);
     if ($remoteVersionParsed[0] > $currentVersionParsed[0] && true !== $input->getOption('force')) {
         $output->writeln(sprintf('<info>A new major version of php-cs-fixer is available</info> (<comment>%s</comment>)', $remoteTag));
         $output->writeln(sprintf('<info>Before upgrading please read</info> https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/%s/UPGRADE.md', $remoteTag));
         $output->writeln('<info>If you are ready to upgrade run this command with</info> <comment>-f</comment>');
         $output->writeln('<info>Checking for new minor/patch version...</info>');
         // test if there is a new minor version available
         $remoteTag = $this->getLatestNotMajorUpdateTag($currentVersion);
         if ($currentVersion === $remoteTag) {
             $output->writeln('<info>no minor update for php-cs-fixer.</info>');
             return 0;
         }
     }
     $remoteFilename = sprintf('https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/%s/php-cs-fixer.phar', $remoteTag);
     $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-tmp.phar';
     try {
         $copyResult = @copy($remoteFilename, $tempFilename);
         if (false === $copyResult) {
             $output->writeln(sprintf('<error>Unable to download new version %s from the server.</error>', $remoteTag));
             return 1;
         }
         chmod($tempFilename, 0777 & ~umask());
         // test the phar validity
         $phar = new \Phar($tempFilename);
         // free the variable to unlock the file
         unset($phar);
         rename($tempFilename, $localFilename);
         $output->writeln(sprintf('<info>php-cs-fixer updated</info> (<comment>%s</comment>)', $remoteTag));
     } catch (\Exception $e) {
         if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
             throw $e;
         }
         unlink($tempFilename);
         $output->writeln(sprintf('<error>The download of %s is corrupt (%s).</error>', $remoteTag, $e->getMessage()));
         $output->writeln('<error>Please re-run the self-update command to try again.</error>');
         return 1;
     }
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!ToolInfo::isInstalledAsPhar()) {
         $output->writeln('<error>Self-update is available only for PHAR version.</error>');
         return 1;
     }
     $remoteTag = $this->getRemoteTag();
     if (null === $remoteTag) {
         $output->writeln('<error>Unable to determine newest version.</error>');
         return;
     }
     if ('v' . $this->getApplication()->getVersion() === $remoteTag) {
         $output->writeln('<info>php-cs-fixer is already up to date.</info>');
         return;
     }
     $remoteFilename = $this->buildVersionFileUrl($remoteTag);
     $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-tmp.phar';
     try {
         $copyResult = @copy($remoteFilename, $tempFilename);
         if (false === $copyResult) {
             $output->writeln('<error>Unable to download new versions from the server.</error>');
             return 1;
         }
         chmod($tempFilename, 0777 & ~umask());
         // test the phar validity
         $phar = new \Phar($tempFilename);
         // free the variable to unlock the file
         unset($phar);
         rename($tempFilename, $localFilename);
         $output->writeln(sprintf('<info>php-cs-fixer updated</info> (<comment>%s</comment>)', $remoteTag));
     } catch (\Exception $e) {
         if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
             throw $e;
         }
         unlink($tempFilename);
         $output->writeln(sprintf('<error>The download is corrupt (%s).</error>', $e->getMessage()));
         $output->writeln('<error>Please re-run the self-update command to try again.</error>');
         return 1;
     }
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!ToolInfo::isInstalledAsPhar()) {
         $output->writeln('<error>Self-update is available only for PHAR version.</error>');
         return 1;
     }
     if (false !== ($remoteVersion = @file_get_contents('http://get.sensiolabs.org/php-cs-fixer.version'))) {
         if ($this->getApplication()->getVersion() === $remoteVersion) {
             $output->writeln('<info>php-cs-fixer is already up to date.</info>');
             return;
         }
     }
     $remoteFilename = 'http://get.sensiolabs.org/php-cs-fixer.phar';
     $localFilename = $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-tmp.phar';
     if (false === @file_get_contents($remoteFilename)) {
         $output->writeln('<error>Unable to download new versions from the server.</error>');
         return 1;
     }
     try {
         copy($remoteFilename, $tempFilename);
         chmod($tempFilename, 0777 & ~umask());
         // test the phar validity
         $phar = new \Phar($tempFilename);
         // free the variable to unlock the file
         unset($phar);
         rename($tempFilename, $localFilename);
         $output->writeln('<info>php-cs-fixer updated.</info>');
     } catch (\Exception $e) {
         if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
             throw $e;
         }
         unlink($tempFilename);
         $output->writeln(sprintf('<error>The download is corrupt (%s).</error>', $e->getMessage()));
         $output->writeln('<error>Please re-run the self-update command to try again.</error>');
         return 1;
     }
 }
예제 #6
0
 /**
  * @return CacheManagerInterface
  */
 public function getCacheManager()
 {
     if (null === $this->cacheManager) {
         if ($this->getUsingCache() && (ToolInfo::isInstalledAsPhar() || ToolInfo::isInstalledByComposer())) {
             $this->cacheManager = new FileCacheManager(new FileHandler($this->getCacheFile()), new Signature(PHP_VERSION, ToolInfo::getVersion(), $this->getRules()), $this->isDryRun());
         } else {
             $this->cacheManager = new NullCacheManager();
         }
     }
     return $this->cacheManager;
 }
예제 #7
0
 public function testIsInstallAsPhar()
 {
     $this->assertFalse(ToolInfo::isInstalledAsPhar());
 }