More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / consolidation / robo / scripts / composer / ScriptHandler.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Robo\composer\ScriptHandler.
6  */
7
8 namespace Robo\composer;
9
10 use Composer\Script\Event;
11 use Symfony\Component\Filesystem\Filesystem;
12
13 class ScriptHandler
14 {
15
16     /**
17      * Run prior to `composer installl` when a composer.lock is present.
18      * @param Event $event
19      */
20     public static function checkDependencies(Event $event)
21     {
22         if (version_compare(PHP_VERSION, '5.6.0') < 0) {
23             static::checkDependenciesFor55();
24         }
25     }
26
27     /**
28      * Check to see if the dependencies in composer.lock are compatible
29      * with php 5.5.
30      */
31     protected static function checkDependenciesFor55()
32     {
33         $fs = new Filesystem();
34         if (!$fs->exists('composer.lock')) {
35             return;
36         }
37
38         $composerLockContents = file_get_contents('composer.lock');
39         if (preg_match('#"php":.*(5\.6)#', $composerLockContents)) {
40             static::fixDependenciesFor55();
41         }
42     }
43
44     protected static function fixDependenciesFor55()
45     {
46         $fs = new Filesystem();
47         $status = 0;
48
49         $fs->remove('composer.lock');
50
51         // Composer has already read our composer.json file, so we will
52         // need to run in a new process to fix things up.
53         passthru('composer install --ansi', $status);
54
55         // Don't continue with the initial 'composer install' command
56         exit($status);
57     }
58 }