Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d57ad21

Browse files
committed
Add +30 days warnings for the dev phars
1 parent ca55836 commit d57ad21

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Composer/Compiler.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function stripWhitespace($source)
168168

169169
private function getStub()
170170
{
171-
return <<<'EOF'
171+
$stub = <<<'EOF'
172172
#!/usr/bin/env php
173173
<?php
174174
/*
@@ -183,6 +183,16 @@ private function getStub()
183183
184184
Phar::mapPhar('composer.phar');
185185

186+
EOF;
187+
188+
// add warning once the phar is older than 30 days
189+
if (preg_match('{^[a-f0-9]+$}', $this->version)) {
190+
$stub .= 'if (time() > '.(time()+30*86400).') {'.
191+
"\n echo 'This dev build of composer is outdated, please run \"'.\$argv[0].' self-update\" to get the latest.'.PHP_EOL;".
192+
"\n}\n";
193+
}
194+
195+
return $stub .= <<<'EOF'
186196
require 'phar://composer.phar/bin/composer';
187197
188198
__HALT_COMPILER();

0 commit comments

Comments
 (0)