Completed
Push — master ( 1ef1a7...290b17 )
by Hiraku
02:04
created
src/Aspects/HttpGetRequest.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -60,6 +60,9 @@  discard block
 block discarded – undo
60 60
         }
61 61
     }
62 62
 
63
+    /**
64
+     * @param string $url
65
+     */
63 66
     public function importURL($url)
64 67
     {
65 68
         $struct = parse_url($url);
@@ -78,6 +81,11 @@  discard block
 block discarded – undo
78 81
     }
79 82
 
80 83
     // utility for __construct
84
+
85
+    /**
86
+     * @param string $key
87
+     * @param string $default
88
+     */
81 89
     private static function setOr(array $struct, $key, $default=null)
82 90
     {
83 91
         if (!empty($struct[$key])) {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function importURL($url)
64 64
     {
65 65
         $struct = parse_url($url);
66
-        if (! $struct) {
66
+        if (!$struct) {
67 67
             throw new \InvalidArgumentException("$url is not valid URL");
68 68
         }
69 69
 
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
         $this->username = self::setOr($struct, 'user', null);
75 75
         $this->password = self::setOr($struct, 'pass', null);
76 76
 
77
-        if (! empty($struct['query'])) {
77
+        if (!empty($struct['query'])) {
78 78
             parse_str($struct['query'], $this->query);
79 79
         }
80 80
     }
81 81
 
82 82
     // utility for __construct
83
-    private static function setOr(array $struct, $key, $default=null)
83
+    private static function setOr(array $struct, $key, $default = null)
84 84
     {
85 85
         if (!empty($struct[$key])) {
86 86
             return $struct[$key];
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             CURLOPT_USERAGENT => $this->genUA(),
101 101
         );
102 102
 
103
-        $curlOpts[CURLOPT_VERBOSE] = (bool) $this->verbose;
103
+        $curlOpts[CURLOPT_VERBOSE] = (bool)$this->verbose;
104 104
 
105 105
         if ($this->username && $this->password) {
106 106
             $curlOpts[CURLOPT_USERPWD] = "$this->username:$this->password";
Please login to merge, or discard this patch.
src/Factory.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
      * @param bool $auth
47 47
      * @return resource<curl>
48 48
      */
49
-    public static function getConnection($origin, $auth=false)
49
+    public static function getConnection($origin, $auth = false)
50 50
     {
51 51
         $instance = self::getInstance();
52 52
         if ($auth) {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * hirak/prestissimo
4
- * @author Hiraku NAKANO
5
- * @license MIT https://github.com/hirak/prestissimo
6
- */
3
+     * hirak/prestissimo
4
+     * @author Hiraku NAKANO
5
+     * @license MIT https://github.com/hirak/prestissimo
6
+     */
7 7
 namespace Hirak\Prestissimo;
8 8
 
9 9
 /**
Please login to merge, or discard this patch.
src/CurlRemoteFilesystem.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
      *
64 64
      * @return bool true
65 65
      */
66
-    public function copy($origin, $fileUrl, $fileName, $progress=true, $options=array())
66
+    public function copy($origin, $fileUrl, $fileName, $progress = true, $options = array())
67 67
     {
68 68
         $that = $this; // for PHP5.3
69 69
 
70
-        return $this->fetch($origin, $fileUrl, $progress, $options, function ($ch, $request) use ($that, $fileName) {
70
+        return $this->fetch($origin, $fileUrl, $progress, $options, function($ch, $request) use ($that, $fileName) {
71 71
             $fp = $that->createFile($fileName);
72 72
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
73 73
             curl_setopt($ch, CURLOPT_FILE, $fp);
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
      *
96 96
      * @return bool|string The content
97 97
      */
98
-    public function getContents($origin, $fileUrl, $progress=true, $options=array())
98
+    public function getContents($origin, $fileUrl, $progress = true, $options = array())
99 99
     {
100 100
         $that = $this; // for PHP5.3
101 101
 
102
-        return $this->fetch($origin, $fileUrl, $progress, $options, function ($ch, $request) use ($that) {
102
+        return $this->fetch($origin, $fileUrl, $progress, $options, function($ch, $request) use ($that) {
103 103
             // This order is important.
104 104
             curl_setopt($ch, CURLOPT_FILE, STDOUT);
105 105
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             if ($this->pluginConfig['insecure']) {
158 158
                 $opts[CURLOPT_VERIFYPEER] = false;
159 159
             }
160
-            if (! empty($pluginConfig['capath'])) {
160
+            if (!empty($pluginConfig['capath'])) {
161 161
                 $opts[CURLOPT_CAPATH] = $pluginConfig['capath'];
162 162
             }
163 163
 
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     /**
89 89
      * Get the content.
90 90
      *
91
-     * @param string $originUrl The origin URL
91
+     * @param string $origin The origin URL
92 92
      * @param string $fileUrl   The file URL
93 93
      * @param bool   $progress  Display the progression
94 94
      * @param array  $options   Additional context options
@@ -108,6 +108,11 @@  discard block
 block discarded – undo
108 108
         });
109 109
     }
110 110
 
111
+    /**
112
+     * @param string $fileUrl
113
+     * @param boolean $progress
114
+     * @param \Closure $exec
115
+     */
111 116
     protected function fetch($origin, $fileUrl, $progress, $options, $exec)
112 117
     {
113 118
         do {
@@ -222,11 +227,6 @@  discard block
 block discarded – undo
222 227
 
223 228
     /**
224 229
      * @internal
225
-     * @param  resource $ch
226
-     * @param  int $downBytesMax
227
-     * @param  int $downBytes
228
-     * @param  int $upBytesMax
229
-     * @param  int $upBytes
230 230
      */
231 231
     public function progress()
232 232
     {
Please login to merge, or discard this patch.
src/ParallelDownloader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
                 if ($pluginConfig['insecure']) {
105 105
                     $opts[CURLOPT_VERIFYPEER] = false;
106 106
                 }
107
-                if (! empty($pluginConfig['capath'])) {
107
+                if (!empty($pluginConfig['capath'])) {
108 108
                     $opts[CURLOPT_CAPATH] = $pluginConfig['capath'];
109 109
                 }
110 110
                 unset($opts[CURLOPT_ENCODING]);
Please login to merge, or discard this patch.
Switch Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -121,44 +121,44 @@
 block discarded – undo
121 121
             // wait for any event
122 122
             do {
123 123
                 switch (curl_multi_select($mh, 5)) {
124
-                case -1:
125
-                    usleep(10);
126
-                    do {
127
-                        $stat = curl_multi_exec($mh, $running);
128
-                    } while ($stat === CURLM_CALL_MULTI_PERFORM);
129
-                    continue 2;
130
-                case 0:
131
-                    continue 2;
132
-                default:
133
-                    do {
134
-                        $stat = curl_multi_exec($mh, $running);
135
-                    } while ($stat === CURLM_CALL_MULTI_PERFORM);
136
-
137
-                    do {
138
-                        if ($raised = curl_multi_info_read($mh, $remains)) {
139
-                            $ch = $raised['handle'];
140
-                            $errno = curl_errno($ch);
141
-                            $info = curl_getinfo($ch);
142
-                            curl_setopt($ch, CURLOPT_FILE, STDOUT);
143
-                            $index = (int)$ch;
144
-                            $outputFile = $chFpMap[$index];
145
-                            unset($chFpMap[$index]);
146
-                            if (CURLE_OK === $errno && 200 === $info['http_code']) {
147
-                                ++$this->successCnt;
148
-                            } else {
149
-                                ++$this->failureCnt;
150
-                                $outputFile->setFailure();
124
+                    case -1:
125
+                        usleep(10);
126
+                        do {
127
+                            $stat = curl_multi_exec($mh, $running);
128
+                        } while ($stat === CURLM_CALL_MULTI_PERFORM);
129
+                        continue 2;
130
+                    case 0:
131
+                        continue 2;
132
+                    default:
133
+                        do {
134
+                            $stat = curl_multi_exec($mh, $running);
135
+                        } while ($stat === CURLM_CALL_MULTI_PERFORM);
136
+
137
+                        do {
138
+                            if ($raised = curl_multi_info_read($mh, $remains)) {
139
+                                $ch = $raised['handle'];
140
+                                $errno = curl_errno($ch);
141
+                                $info = curl_getinfo($ch);
142
+                                curl_setopt($ch, CURLOPT_FILE, STDOUT);
143
+                                $index = (int)$ch;
144
+                                $outputFile = $chFpMap[$index];
145
+                                unset($chFpMap[$index]);
146
+                                if (CURLE_OK === $errno && 200 === $info['http_code']) {
147
+                                    ++$this->successCnt;
148
+                                } else {
149
+                                    ++$this->failureCnt;
150
+                                    $outputFile->setFailure();
151
+                                }
152
+                                unset($outputFile);
153
+                                $this->io->write($this->makeDownloadingText($info['url']));
154
+                                curl_multi_remove_handle($mh, $ch);
155
+                                $unused[] = $ch;
151 156
                             }
152
-                            unset($outputFile);
153
-                            $this->io->write($this->makeDownloadingText($info['url']));
154
-                            curl_multi_remove_handle($mh, $ch);
155
-                            $unused[] = $ch;
156
-                        }
157
-                    } while ($remains);
157
+                        } while ($remains);
158 158
 
159
-                    if ($packages) {
160
-                        break 2;
161
-                    }
159
+                        if ($packages) {
160
+                            break 2;
161
+                        }
162 162
                 }
163 163
             } while ($running);
164 164
         } while ($packages);
Please login to merge, or discard this patch.
src/Plugin.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         }
108 108
 
109 109
         $config = $this->config->get('prestissimo');
110
-        if (! is_array($config)) {
110
+        if (!is_array($config)) {
111 111
             $config = array();
112 112
         }
113 113
         $config += array(
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
             'privatePackages' => array(),
121 121
         );
122 122
 
123
-        if (! is_int($config['maxConnections']) || $config['maxConnections'] < 1) {
123
+        if (!is_int($config['maxConnections']) || $config['maxConnections'] < 1) {
124 124
             $config['maxConnections'] = 6;
125 125
         }
126
-        if (! is_int($config['minConnections']) || $config['minConnections'] > $config['maxConnections']) {
126
+        if (!is_int($config['minConnections']) || $config['minConnections'] > $config['maxConnections']) {
127 127
             $config['minConnections'] = 3;
128 128
         }
129
-        if (! is_bool($config['pipeline'])) {
129
+        if (!is_bool($config['pipeline'])) {
130 130
             $config['pipeline'] = (bool)$config['pipeline'];
131 131
         }
132
-        if (! is_bool($config['insecure'])) {
132
+        if (!is_bool($config['insecure'])) {
133 133
             $config['insecure'] = (bool)$config['insecure'];
134 134
         }
135
-        if (! is_string($config['capath'])) {
135
+        if (!is_string($config['capath'])) {
136 136
             $config['capath'] = '';
137 137
         }
138
-        if (! is_array($config['privatePackages'])) {
138
+        if (!is_array($config['privatePackages'])) {
139 139
             $config['privatePackages'] = (array)$config['privatePackages'];
140 140
         }
141 141
 
Please login to merge, or discard this patch.
src/OutputFile.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             fclose($this->fp);
50 50
         }
51 51
 
52
-        if (! $this->success) {
52
+        if (!$this->success) {
53 53
             unlink($this->fileName);
54 54
             foreach ($this->createdDirs as $dir) {
55 55
                 rmdir($dir);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         do {
75 75
             $dir = dirname($dir);
76 76
             $createdDirs[] = $dir;
77
-        } while (! file_exists($dir));
77
+        } while (!file_exists($dir));
78 78
         array_pop($createdDirs);
79 79
         $this->createdDirs = array_reverse($createdDirs);
80 80
 
Please login to merge, or discard this patch.