Skip to content

Commit 83bbbbb

Browse files
committed
updated php-cli dokuwiki#4384
1 parent 91c051b commit 83bbbbb

File tree

6 files changed

+55
-23
lines changed

6 files changed

+55
-23
lines changed

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/composer/InstalledVersions.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class InstalledVersions
3232
*/
3333
private static $installed;
3434

35+
/**
36+
* @var bool
37+
*/
38+
private static $installedIsLocalDir;
39+
3540
/**
3641
* @var bool|null
3742
*/
@@ -309,6 +314,12 @@ public static function reload($data)
309314
{
310315
self::$installed = $data;
311316
self::$installedByVendor = array();
317+
318+
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
319+
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
320+
// so we have to assume it does not, and that may result in duplicate data being returned when listing
321+
// all installed packages for example
322+
self::$installedIsLocalDir = false;
312323
}
313324

314325
/**
@@ -325,19 +336,24 @@ private static function getInstalled()
325336
$copiedLocalDir = false;
326337

327338
if (self::$canGetVendors) {
339+
$selfDir = strtr(__DIR__, '\\', '/');
328340
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
341+
$vendorDir = strtr($vendorDir, '\\', '/');
329342
if (isset(self::$installedByVendor[$vendorDir])) {
330343
$installed[] = self::$installedByVendor[$vendorDir];
331344
} elseif (is_file($vendorDir.'/composer/installed.php')) {
332345
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
333346
$required = require $vendorDir.'/composer/installed.php';
334347
self::$installedByVendor[$vendorDir] = $required;
335348
$installed[] = $required;
336-
if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
349+
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
337350
self::$installed = $required;
338-
$copiedLocalDir = true;
351+
self::$installedIsLocalDir = true;
339352
}
340353
}
354+
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
355+
$copiedLocalDir = true;
356+
}
341357
}
342358
}
343359

vendor/composer/installed.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -709,17 +709,17 @@
709709
},
710710
{
711711
"name": "splitbrain/php-cli",
712-
"version": "1.3.3",
713-
"version_normalized": "1.3.3.0",
712+
"version": "1.3.4",
713+
"version_normalized": "1.3.4.0",
714714
"source": {
715715
"type": "git",
716716
"url": "https://github.com/splitbrain/php-cli.git",
717-
"reference": "8189c68cbde3fd8c3e0fc26295b776b143b6e481"
717+
"reference": "4e669f38f660b0e9f76ed14dda7f12bff390f94f"
718718
},
719719
"dist": {
720720
"type": "zip",
721-
"url": "https://api.github.com/repos/splitbrain/php-cli/zipball/8189c68cbde3fd8c3e0fc26295b776b143b6e481",
722-
"reference": "8189c68cbde3fd8c3e0fc26295b776b143b6e481",
721+
"url": "https://api.github.com/repos/splitbrain/php-cli/zipball/4e669f38f660b0e9f76ed14dda7f12bff390f94f",
722+
"reference": "4e669f38f660b0e9f76ed14dda7f12bff390f94f",
723723
"shasum": ""
724724
},
725725
"require": {
@@ -731,7 +731,7 @@
731731
"suggest": {
732732
"psr/log": "Allows you to make the CLI available as PSR-3 logger"
733733
},
734-
"time": "2024-12-18T08:16:26+00:00",
734+
"time": "2025-03-15T09:02:01+00:00",
735735
"type": "library",
736736
"installation-source": "dist",
737737
"autoload": {
@@ -761,7 +761,7 @@
761761
],
762762
"support": {
763763
"issues": "https://github.com/splitbrain/php-cli/issues",
764-
"source": "https://github.com/splitbrain/php-cli/tree/1.3.3"
764+
"source": "https://github.com/splitbrain/php-cli/tree/1.3.4"
765765
},
766766
"install-path": "../splitbrain/php-cli"
767767
},

vendor/composer/installed.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'dokuwiki/dokuwiki',
44
'pretty_version' => 'dev-master',
55
'version' => 'dev-master',
6-
'reference' => 'c408a2af01195b7a0821b224bb0e83b4c623ae0f',
6+
'reference' => '91c051b578b6f689d63885c95ea2d73e0e46f39a',
77
'type' => 'project',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -22,7 +22,7 @@
2222
'dokuwiki/dokuwiki' => array(
2323
'pretty_version' => 'dev-master',
2424
'version' => 'dev-master',
25-
'reference' => 'c408a2af01195b7a0821b224bb0e83b4c623ae0f',
25+
'reference' => '91c051b578b6f689d63885c95ea2d73e0e46f39a',
2626
'type' => 'project',
2727
'install_path' => __DIR__ . '/../../',
2828
'aliases' => array(),
@@ -122,9 +122,9 @@
122122
'dev_requirement' => false,
123123
),
124124
'splitbrain/php-cli' => array(
125-
'pretty_version' => '1.3.3',
126-
'version' => '1.3.3.0',
127-
'reference' => '8189c68cbde3fd8c3e0fc26295b776b143b6e481',
125+
'pretty_version' => '1.3.4',
126+
'version' => '1.3.4.0',
127+
'reference' => '4e669f38f660b0e9f76ed14dda7f12bff390f94f',
128128
'type' => 'library',
129129
'install_path' => __DIR__ . '/../splitbrain/php-cli',
130130
'aliases' => array(),

vendor/splitbrain/php-cli/src/Colors.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class Colors
3131
const C_LIGHTGRAY = 'lightgray';
3232
const C_WHITE = 'white';
3333

34+
// Regex pattern to match color codes
35+
const C_CODE_REGEX = "/(\33\[[0-9;]+m)/";
36+
3437
/** @var array known color names */
3538
protected $colors = array(
3639
self::C_RESET => "\33[0m",

vendor/splitbrain/php-cli/src/TableFormatter.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ protected function substr($string, $start = 0, $length = null)
293293
protected function wordwrap($str, $width = 75, $break = "\n", $cut = false)
294294
{
295295
$lines = explode($break, $str);
296+
$color_reset = $this->colors->getColorCode(Colors::C_RESET);
296297
foreach ($lines as &$line) {
297298
$line = rtrim($line);
298299
if ($this->strlen($line) <= $width) {
@@ -301,18 +302,30 @@ protected function wordwrap($str, $width = 75, $break = "\n", $cut = false)
301302
$words = explode(' ', $line);
302303
$line = '';
303304
$actual = '';
305+
$color = '';
304306
foreach ($words as $word) {
307+
if (preg_match_all(Colors::C_CODE_REGEX, $word, $color_codes) ) {
308+
# Word contains color codes
309+
foreach ($color_codes[0] as $code) {
310+
if ($code == $color_reset) {
311+
$color = '';
312+
} else {
313+
# Remember color so we can reapply it after a line break
314+
$color = $code;
315+
}
316+
}
317+
}
305318
if ($this->strlen($actual . $word) <= $width) {
306319
$actual .= $word . ' ';
307320
} else {
308321
if ($actual != '') {
309322
$line .= rtrim($actual) . $break;
310323
}
311-
$actual = $word;
324+
$actual = $color . $word;
312325
if ($cut) {
313326
while ($this->strlen($actual) > $width) {
314327
$line .= $this->substr($actual, 0, $width) . $break;
315-
$actual = $this->substr($actual, $width);
328+
$actual = $color . $this->substr($actual, $width);
316329
}
317330
}
318331
$actual .= ' ';
@@ -322,4 +335,4 @@ protected function wordwrap($str, $width = 75, $break = "\n", $cut = false)
322335
}
323336
return implode($break, $lines);
324337
}
325-
}
338+
}

0 commit comments

Comments
 (0)