Skip to content

Commit 7112b53

Browse files
committed
minor #758 Fix CS (fabpot)
This PR was merged into the 1.12-dev branch. Discussion ---------- Fix CS Commits ------- 37eabb7 Fix CS
2 parents e472606 + 37eabb7 commit 7112b53

11 files changed

+47
-47
lines changed

src/Command/InstallRecipesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5050
$win = '\\' === \DIRECTORY_SEPARATOR;
5151
$force = $input->getOption('force');
5252

53-
if ($force && !@is_executable(strtok(exec($win ? 'where git' : 'command -v git'), PHP_EOL))) {
53+
if ($force && !@is_executable(strtok(exec($win ? 'where git' : 'command -v git'), \PHP_EOL))) {
5454
throw new RuntimeException('Cannot run "sync-recipes --force": git not found.');
5555
}
5656

src/Configurator/CopyFromRecipeConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private function removeFile(string $to)
147147
@unlink($to);
148148
$this->write(sprintf(' Removed <fg=green>"%s"</>', $this->path->relativize($to)));
149149

150-
if (0 === \count(glob(\dirname($to).'/*', GLOB_NOSORT))) {
150+
if (0 === \count(glob(\dirname($to).'/*', \GLOB_NOSORT))) {
151151
@rmdir(\dirname($to));
152152
}
153153
}

src/Configurator/DockerComposeConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function unconfigure(Recipe $recipe, $config, Lock $lock)
107107

108108
$name = $recipe->getName();
109109
// Remove recipe and add break line
110-
$contents = preg_replace(sprintf('{%s+###> %s ###.*?###< %s ###%s+}s', "\n", $name, $name, "\n"), PHP_EOL.PHP_EOL, file_get_contents($dockerComposeFile), -1, $count);
110+
$contents = preg_replace(sprintf('{%s+###> %s ###.*?###< %s ###%s+}s', "\n", $name, $name, "\n"), \PHP_EOL.\PHP_EOL, file_get_contents($dockerComposeFile), -1, $count);
111111
if (!$count) {
112112
return;
113113
}

src/Configurator/EnvConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private function configureEnvDist(Recipe $recipe, $vars, bool $update)
6969
$data = $this->markData($recipe, $data);
7070

7171
if (!$this->updateData($env, $data)) {
72-
file_put_contents($env, $data, FILE_APPEND);
72+
file_put_contents($env, $data, \FILE_APPEND);
7373
}
7474
}
7575
}

src/Configurator/GitignoreConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function configure(Recipe $recipe, $vars, Lock $lock, array $options = []
3636
$data = "\n".ltrim($this->markData($recipe, $data), "\r\n");
3737

3838
if (!$this->updateData($gitignore, $data)) {
39-
file_put_contents($gitignore, $data, FILE_APPEND);
39+
file_put_contents($gitignore, $data, \FILE_APPEND);
4040
}
4141
}
4242

src/Configurator/MakefileConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function configure(Recipe $recipe, $definitions, Lock $lock, array $optio
5050
}
5151

5252
if (!$this->updateData($makefile, $data)) {
53-
file_put_contents($makefile, $data, FILE_APPEND);
53+
file_put_contents($makefile, $data, \FILE_APPEND);
5454
}
5555
}
5656

src/CurlDownloader.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ class CurlDownloader
2525

2626
private static $options = [
2727
'http' => [
28-
'method' => CURLOPT_CUSTOMREQUEST,
29-
'content' => CURLOPT_POSTFIELDS,
28+
'method' => \CURLOPT_CUSTOMREQUEST,
29+
'content' => \CURLOPT_POSTFIELDS,
3030
],
3131
'ssl' => [
32-
'cafile' => CURLOPT_CAINFO,
33-
'capath' => CURLOPT_CAPATH,
32+
'cafile' => \CURLOPT_CAINFO,
33+
'capath' => \CURLOPT_CAPATH,
3434
],
3535
];
3636

@@ -46,15 +46,15 @@ class CurlDownloader
4646
public function __construct()
4747
{
4848
$this->multiHandle = $mh = curl_multi_init();
49-
curl_multi_setopt($mh, CURLMOPT_PIPELINING, /*CURLPIPE_MULTIPLEX*/ 2);
49+
curl_multi_setopt($mh, \CURLMOPT_PIPELINING, /*CURLPIPE_MULTIPLEX*/ 2);
5050
if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS')) {
51-
curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
51+
curl_multi_setopt($mh, \CURLMOPT_MAX_HOST_CONNECTIONS, 8);
5252
}
5353

5454
$this->shareHandle = $sh = curl_share_init();
55-
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
56-
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
57-
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
55+
curl_share_setopt($sh, \CURLSHOPT_SHARE, \CURL_LOCK_DATA_COOKIE);
56+
curl_share_setopt($sh, \CURLSHOPT_SHARE, \CURL_LOCK_DATA_DNS);
57+
curl_share_setopt($sh, \CURLSHOPT_SHARE, \CURL_LOCK_DATA_SSL_SESSION);
5858
}
5959

6060
public function get($origin, $url, $context, $file)
@@ -72,21 +72,21 @@ public function get($origin, $url, $context, $file)
7272
$headers = array_diff($params['options']['http']['header'], ['Connection: close']);
7373

7474
if (!isset($params['options']['http']['protocol_version'])) {
75-
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
75+
curl_setopt($ch, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_0);
7676
} else {
7777
$headers[] = 'Connection: keep-alive';
78-
if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & curl_version()['features'])) {
79-
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
78+
if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (\CURL_VERSION_HTTP2 & curl_version()['features'])) {
79+
curl_setopt($ch, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_2_0);
8080
}
8181
}
8282

83-
curl_setopt($ch, CURLOPT_URL, $url);
84-
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
85-
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
86-
curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
87-
curl_setopt($ch, CURLOPT_WRITEHEADER, $hd);
88-
curl_setopt($ch, CURLOPT_FILE, $fd);
89-
curl_setopt($ch, CURLOPT_SHARE, $this->shareHandle);
83+
curl_setopt($ch, \CURLOPT_URL, $url);
84+
curl_setopt($ch, \CURLOPT_HTTPHEADER, $headers);
85+
curl_setopt($ch, \CURLOPT_FOLLOWLOCATION, true);
86+
curl_setopt($ch, \CURLOPT_DNS_USE_GLOBAL_CACHE, false);
87+
curl_setopt($ch, \CURLOPT_WRITEHEADER, $hd);
88+
curl_setopt($ch, \CURLOPT_FILE, $fd);
89+
curl_setopt($ch, \CURLOPT_SHARE, $this->shareHandle);
9090

9191
foreach (self::$options as $type => $options) {
9292
foreach ($options as $name => $curlopt) {
@@ -106,7 +106,7 @@ public function get($origin, $url, $context, $file)
106106
];
107107

108108
curl_multi_add_handle($this->multiHandle, $ch);
109-
$params['notification'](STREAM_NOTIFY_RESOLVE, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0, false);
109+
$params['notification'](\STREAM_NOTIFY_RESOLVE, \STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0, false);
110110
$active = true;
111111

112112
try {
@@ -128,7 +128,7 @@ public function get($origin, $url, $context, $file)
128128
if ('' !== curl_error($h)) {
129129
throw new TransportException(curl_error($h));
130130
}
131-
if ($job['file'] && CURLE_OK === curl_errno($h) && !isset($this->exceptions[$i])) {
131+
if ($job['file'] && \CURLE_OK === curl_errno($h) && !isset($this->exceptions[$i])) {
132132
fclose($job['fd']);
133133
rename($job['file'].'~', $job['file']);
134134
}
@@ -158,8 +158,8 @@ public function get($origin, $url, $context, $file)
158158
}
159159
}
160160

161-
if ('' !== curl_error($ch) || CURLE_OK !== curl_errno($ch)) {
162-
$this->exceptions[(int) $ch] = new TransportException(curl_error($ch), curl_getinfo($ch, CURLINFO_HTTP_CODE) ?: 0);
161+
if ('' !== curl_error($ch) || \CURLE_OK !== curl_errno($ch)) {
162+
$this->exceptions[(int) $ch] = new TransportException(curl_error($ch), curl_getinfo($ch, \CURLINFO_HTTP_CODE) ?: 0);
163163
}
164164
if (isset($this->exceptions[(int) $ch])) {
165165
throw $this->exceptions[(int) $ch];
@@ -193,24 +193,24 @@ private function onProgress($ch, callable $notify, array $progress, array $previ
193193
}
194194

195195
if (!$previousProgress['http_code'] && $progress['http_code'] && $progress['http_code'] < 200 || 400 <= $progress['http_code']) {
196-
$code = 403 === $progress['http_code'] ? STREAM_NOTIFY_AUTH_RESULT : STREAM_NOTIFY_FAILURE;
197-
$notify($code, STREAM_NOTIFY_SEVERITY_ERR, curl_error($ch), $progress['http_code'], 0, 0, false);
196+
$code = 403 === $progress['http_code'] ? \STREAM_NOTIFY_AUTH_RESULT : \STREAM_NOTIFY_FAILURE;
197+
$notify($code, \STREAM_NOTIFY_SEVERITY_ERR, curl_error($ch), $progress['http_code'], 0, 0, false);
198198
}
199199

200200
if ($previousProgress['download_content_length'] < $progress['download_content_length']) {
201-
$notify(STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, (int) $progress['download_content_length'], false);
201+
$notify(\STREAM_NOTIFY_FILE_SIZE_IS, \STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, (int) $progress['download_content_length'], false);
202202
}
203203

204204
if ($previousProgress['size_download'] < $progress['size_download']) {
205-
$notify(STREAM_NOTIFY_PROGRESS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, (int) $progress['size_download'], (int) $progress['download_content_length'], false);
205+
$notify(\STREAM_NOTIFY_PROGRESS, \STREAM_NOTIFY_SEVERITY_INFO, '', 0, (int) $progress['size_download'], (int) $progress['download_content_length'], false);
206206
}
207207
}
208208

209209
private function finishProgress($ch, callable $notify, array $progress)
210210
{
211211
if ($progress['download_content_length'] < 0) {
212-
$notify(STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, (int) $progress['size_download'], false);
213-
$notify(STREAM_NOTIFY_PROGRESS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, (int) $progress['size_download'], (int) $progress['size_download'], false);
212+
$notify(\STREAM_NOTIFY_FILE_SIZE_IS, \STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, (int) $progress['size_download'], false);
213+
$notify(\STREAM_NOTIFY_PROGRESS, \STREAM_NOTIFY_SEVERITY_INFO, '', 0, (int) $progress['size_download'], (int) $progress['size_download'], false);
214214
}
215215
}
216216
}

src/Flex.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public function lockPlatform()
313313
}
314314

315315
$this->lock->set('php', [
316-
'version' => $this->config->get('platform')['php'] ?? (PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION),
316+
'version' => $this->config->get('platform')['php'] ?? (\PHP_MAJOR_VERSION.'.'.\PHP_MINOR_VERSION),
317317
]);
318318
}
319319

@@ -708,7 +708,7 @@ public function populateFilesCacheDir(InstallerEvent $event)
708708
$fileUrl = current($package->getDistUrls());
709709
}
710710

711-
if (!preg_match('/^https?:/', $fileUrl) || !$originUrl = parse_url($fileUrl, PHP_URL_HOST)) {
711+
if (!preg_match('/^https?:/', $fileUrl) || !$originUrl = parse_url($fileUrl, \PHP_URL_HOST)) {
712712
continue;
713713
}
714714

@@ -1011,10 +1011,10 @@ public static function getSubscribedEvents(): array
10111011

10121012
if (version_compare('2.0.0', PluginInterface::PLUGIN_API_VERSION, '>')) {
10131013
$events += [
1014-
InstallerEvents::PRE_DEPENDENCIES_SOLVING => [['populateProvidersCacheDir', PHP_INT_MAX]],
1015-
InstallerEvents::POST_DEPENDENCIES_SOLVING => [['populateFilesCacheDir', PHP_INT_MAX], ['lockPlatform']],
1016-
PackageEvents::PRE_PACKAGE_INSTALL => [['populateFilesCacheDir', ~PHP_INT_MAX]],
1017-
PackageEvents::PRE_PACKAGE_UPDATE => [['populateFilesCacheDir', ~PHP_INT_MAX]],
1014+
InstallerEvents::PRE_DEPENDENCIES_SOLVING => [['populateProvidersCacheDir', \PHP_INT_MAX]],
1015+
InstallerEvents::POST_DEPENDENCIES_SOLVING => [['populateFilesCacheDir', \PHP_INT_MAX], ['lockPlatform']],
1016+
PackageEvents::PRE_PACKAGE_INSTALL => [['populateFilesCacheDir', ~\PHP_INT_MAX]],
1017+
PackageEvents::PRE_PACKAGE_UPDATE => [['populateFilesCacheDir', ~\PHP_INT_MAX]],
10181018
PluginEvents::PRE_FILE_DOWNLOAD => 'onFileDownload',
10191019
];
10201020
} else {

src/ParallelDownloader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function download(array &$nextArgs, callable $nextCallback, bool $quiet =
7575

7676
$note = '';
7777
if ($this->io->isDecorated()) {
78-
$note = '\\' === \DIRECTORY_SEPARATOR ? '' : (false !== stripos(PHP_OS, 'darwin') ? '🎵' : '🎶');
78+
$note = '\\' === \DIRECTORY_SEPARATOR ? '' : (false !== stripos(\PHP_OS, 'darwin') ? '🎵' : '🎶');
7979
$note .= $this->downloader ? ('\\' !== \DIRECTORY_SEPARATOR ? ' 💨' : '') : '';
8080
}
8181

@@ -158,7 +158,7 @@ public function getContents($originUrl, $fileUrl, $progress = true, $options = [
158158
*/
159159
public function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax, $nativeDownload = true)
160160
{
161-
if (!$nativeDownload && STREAM_NOTIFY_SEVERITY_ERR === $severity) {
161+
if (!$nativeDownload && \STREAM_NOTIFY_SEVERITY_ERR === $severity) {
162162
throw new TransportException($message, $messageCode);
163163
}
164164

@@ -168,12 +168,12 @@ public function callbackGet($notificationCode, $severity, $message, $messageCode
168168
return;
169169
}
170170

171-
if (STREAM_NOTIFY_FILE_SIZE_IS === $notificationCode) {
171+
if (\STREAM_NOTIFY_FILE_SIZE_IS === $notificationCode) {
172172
++$state->bytesMaxCount;
173173
$state->bytesMax += $bytesMax;
174174
}
175175

176-
if (!$bytesMax || STREAM_NOTIFY_PROGRESS !== $notificationCode) {
176+
if (!$bytesMax || \STREAM_NOTIFY_PROGRESS !== $notificationCode) {
177177
if ($state->nextArgs && !$nativeDownload) {
178178
$this->getNext();
179179
}

src/ScriptExecutor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private function expandPhpScript(string $cmd): string
118118
$arguments = $phpFinder->findArguments();
119119

120120
if ($env = (string) (getenv('COMPOSER_ORIGINAL_INIS'))) {
121-
$paths = explode(PATH_SEPARATOR, $env);
121+
$paths = explode(\PATH_SEPARATOR, $env);
122122
$ini = array_shift($paths);
123123
} else {
124124
$ini = php_ini_loaded_file();

0 commit comments

Comments
 (0)