Browse Source

Add +30 days warnings for the dev phars

Jordi Boggiano 13 years ago
parent
commit
d57ad21346
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/Composer/Compiler.php

+ 11 - 1
src/Composer/Compiler.php

@@ -168,7 +168,7 @@ class Compiler
 
     private function getStub()
     {
-        return <<<'EOF'
+        $stub = <<<'EOF'
 #!/usr/bin/env php
 <?php
 /*
@@ -183,6 +183,16 @@ class Compiler
 
 Phar::mapPhar('composer.phar');
 
+EOF;
+
+        // add warning once the phar is older than 30 days
+        if (preg_match('{^[a-f0-9]+$}', $this->version)) {
+            $stub .= 'if (time() > '.(time()+30*86400).') {'.
+                "\n    echo 'This dev build of composer is outdated, please run \"'.\$argv[0].' self-update\" to get the latest.'.PHP_EOL;".
+                "\n}\n";
+        }
+
+        return $stub .= <<<'EOF'
 require 'phar://composer.phar/bin/composer';
 
 __HALT_COMPILER();