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

Skip to content

Commit 174ee82

Browse files
committed
Merge branch '5.4' into patch-2
2 parents 65bb39c + 77b8c94 commit 174ee82

File tree

18 files changed

+179
-138
lines changed

18 files changed

+179
-138
lines changed

.github/sync-translations.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
require __DIR__.'/../vendor/autoload.php';
1414

15-
function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $domain)
15+
function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $domain, ?\DOMElement $header = null)
1616
{
1717
$dom = new \DOMDocument('1.0', 'utf-8');
1818
$dom->formatOutput = true;
@@ -27,6 +27,10 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
2727
$xliffFile->setAttribute('datatype', 'plaintext');
2828
$xliffFile->setAttribute('original', 'file.ext');
2929

30+
if (null !== $header) {
31+
mergeDom($dom, $xliffFile, $header);
32+
}
33+
3034
$xliffBody = $xliffFile->appendChild($dom->createElement('body'));
3135
foreach ($messages->all($domain) as $source => $target) {
3236
$translation = $dom->createElement('trans-unit');
@@ -62,6 +66,24 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
6266
return preg_replace('/^ +/m', '$0$0', $dom->saveXML());
6367
}
6468

69+
function mergeDom(\DOMDocument $dom, \DOMNode $tree, \DOMNode $input)
70+
{
71+
$new = $dom->createElement($input->tagName);
72+
foreach ($input->attributes as $key => $value) {
73+
$new->setAttribute($key, $value);
74+
}
75+
$tree->appendChild($new);
76+
foreach ($input->childNodes as $child) {
77+
if ($child instanceof \DOMText) {
78+
$new->appendChild($dom->createTextNode(str_replace(' ', ' ', $child->textContent)));
79+
} elseif ($child instanceof \DOMNode) {
80+
mergeDom($dom, $new, $child);
81+
} else {
82+
// We just need to update our script to handle this node types
83+
throw new \LogicException('Unsupported node type: '.get_class($child));
84+
}
85+
}
86+
}
6587

6688
foreach (['Security/Core' => 'security', 'Form' => 'validators', 'Validator' => 'validators'] as $component => $domain) {
6789
$dir = __DIR__.'/../src/Symfony/Component/'.$component.'/Resources/translations';
@@ -95,6 +117,13 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
95117
$localeCatalogue->setMetadata($source, $metadata, $domain);
96118
}
97119

98-
file_put_contents($file, dumpXliff1('en', $localeCatalogue, $domain));
120+
$inputDom = new \DOMDocument();
121+
$inputDom->loadXML(file_get_contents($file->getRealPath()));
122+
$header = null;
123+
if (1 === $inputDom->getElementsByTagName('header')->count()) {
124+
$header = $inputDom->getElementsByTagName('header')->item(0);
125+
}
126+
127+
file_put_contents($file, dumpXliff1('en', $localeCatalogue, $domain, $header));
99128
}
100129
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"friendsofphp/proxy-manager-lts": "^1.0.2",
3838
"doctrine/event-manager": "~1.0",
3939
"doctrine/persistence": "^2|^3",
40-
"twig/twig": "^2.13|^3.0.4",
40+
"twig/twig": "^2.13|~3.8.0",
4141
"psr/cache": "^1.0|^2.0",
4242
"psr/container": "^1.1.1",
4343
"psr/event-dispatcher": "^1.0",

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,27 +403,55 @@ private static function hasColorSupport()
403403
return false;
404404
}
405405

406-
if ('Hyper' === getenv('TERM_PROGRAM')) {
406+
if (!self::isTty()) {
407+
return false;
408+
}
409+
410+
if ('\\' === \DIRECTORY_SEPARATOR && \function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(\STDOUT)) {
407411
return true;
408412
}
409413

410-
if (\DIRECTORY_SEPARATOR === '\\') {
411-
return (\function_exists('sapi_windows_vt100_support')
412-
&& sapi_windows_vt100_support(\STDOUT))
413-
|| false !== getenv('ANSICON')
414-
|| 'ON' === getenv('ConEmuANSI')
415-
|| 'xterm' === getenv('TERM');
414+
if ('Hyper' === getenv('TERM_PROGRAM')
415+
|| false !== getenv('COLORTERM')
416+
|| false !== getenv('ANSICON')
417+
|| 'ON' === getenv('ConEmuANSI')
418+
) {
419+
return true;
416420
}
417421

422+
if ('dumb' === $term = (string) getenv('TERM')) {
423+
return false;
424+
}
425+
426+
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
427+
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
428+
}
429+
430+
/**
431+
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
432+
*
433+
* Reference: Composer\Util\Platform::isTty
434+
* https://github.com/composer/composer
435+
*/
436+
private static function isTty(): bool
437+
{
438+
// Detect msysgit/mingw and assume this is a tty because detection
439+
// does not work correctly, see https://github.com/composer/composer/issues/9690
440+
if (\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
441+
return true;
442+
}
443+
444+
// Modern cross-platform function, includes the fstat fallback so if it is present we trust it
418445
if (\function_exists('stream_isatty')) {
419446
return @stream_isatty(\STDOUT);
420447
}
421448

422-
if (\function_exists('posix_isatty')) {
423-
return @posix_isatty(\STDOUT);
449+
// Only trusting this if it is positive, otherwise prefer fstat fallback.
450+
if (\function_exists('posix_isatty') && @posix_isatty(\STDOUT)) {
451+
return true;
424452
}
425453

426-
$stat = fstat(\STDOUT);
454+
$stat = @fstat(\STDOUT);
427455

428456
// Check if formatted mode is S_IFCHR
429457
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=7.2.5",
2020
"symfony/polyfill-php80": "^1.16",
2121
"symfony/translation-contracts": "^1.1|^2|^3",
22-
"twig/twig": "^2.13|^3.0.4"
22+
"twig/twig": "^2.13|~3.8.0"
2323
},
2424
"require-dev": {
2525
"doctrine/annotations": "^1.12|^2",

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"symfony/property-info": "^4.4|^5.0|^6.0",
6767
"symfony/web-link": "^4.4|^5.0|^6.0",
6868
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
69-
"twig/twig": "^2.10|^3.0"
69+
"twig/twig": "^2.10|~3.8.0"
7070
},
7171
"conflict": {
7272
"doctrine/annotations": "<1.13.1",

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"symfony/twig-bridge": "^4.4|^5.0|^6.0",
5252
"symfony/validator": "^4.4|^5.0|^6.0",
5353
"symfony/yaml": "^4.4|^5.0|^6.0",
54-
"twig/twig": "^2.13|^3.0.4"
54+
"twig/twig": "^2.13|~3.8.0"
5555
},
5656
"conflict": {
5757
"symfony/browser-kit": "<4.4",

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/http-kernel": "^5.0|^6.0",
2525
"symfony/polyfill-ctype": "~1.8",
2626
"symfony/polyfill-php80": "^1.16",
27-
"twig/twig": "^2.13|^3.0.4"
27+
"twig/twig": "^2.13|~3.8.0"
2828
},
2929
"require-dev": {
3030
"symfony/asset": "^4.4|^5.0|^6.0",

src/Symfony/Bundle/WebProfilerBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/polyfill-php80": "^1.16",
2424
"symfony/routing": "^4.4|^5.0|^6.0",
2525
"symfony/twig-bundle": "^4.4|^5.0|^6.0",
26-
"twig/twig": "^2.13|^3.0.4"
26+
"twig/twig": "^2.13|~3.8.0"
2727
},
2828
"require-dev": {
2929
"symfony/browser-kit": "^4.4|^5.0|^6.0",

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -503,19 +503,7 @@ private function isInteractiveInput($inputStream): bool
503503
return self::$stdinIsInteractive;
504504
}
505505

506-
if (\function_exists('stream_isatty')) {
507-
return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
508-
}
509-
510-
if (\function_exists('posix_isatty')) {
511-
return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
512-
}
513-
514-
if (!\function_exists('shell_exec')) {
515-
return self::$stdinIsInteractive = true;
516-
}
517-
518-
return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
506+
return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
519507
}
520508

521509
/**

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,13 @@ protected function hasColorSupport()
9595
return false;
9696
}
9797

98-
if (!$this->isTty()) {
98+
// Detect msysgit/mingw and assume this is a tty because detection
99+
// does not work correctly, see https://github.com/composer/composer/issues/9690
100+
if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
99101
return false;
100102
}
101103

102-
if (\DIRECTORY_SEPARATOR === '\\'
103-
&& \function_exists('sapi_windows_vt100_support')
104-
&& @sapi_windows_vt100_support($this->stream)
105-
) {
104+
if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($this->stream)) {
106105
return true;
107106
}
108107

@@ -114,43 +113,11 @@ protected function hasColorSupport()
114113
return true;
115114
}
116115

117-
$term = (string) getenv('TERM');
118-
119-
if ('dumb' === $term) {
116+
if ('dumb' === $term = (string) getenv('TERM')) {
120117
return false;
121118
}
122119

123120
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
124-
return 1 === @preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
125-
}
126-
127-
/**
128-
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
129-
*
130-
* Reference: Composer\Util\Platform::isTty
131-
* https://github.com/composer/composer
132-
*/
133-
private function isTty(): bool
134-
{
135-
// Detect msysgit/mingw and assume this is a tty because detection
136-
// does not work correctly, see https://github.com/composer/composer/issues/9690
137-
if (\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
138-
return true;
139-
}
140-
141-
// Modern cross-platform function, includes the fstat fallback so if it is present we trust it
142-
if (\function_exists('stream_isatty')) {
143-
return stream_isatty($this->stream);
144-
}
145-
146-
// Only trusting this if it is positive, otherwise prefer fstat fallback.
147-
if (\function_exists('posix_isatty') && posix_isatty($this->stream)) {
148-
return true;
149-
}
150-
151-
$stat = @fstat($this->stream);
152-
153-
// Check if formatted mode is S_IFCHR
154-
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
121+
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
155122
}
156123
}

0 commit comments

Comments
 (0)