Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 86c8a8a

Browse filesBrowse files
Merge branch '7.2' into 7.3
* 7.2: fix: extract no type `@param` annotation with `PhpStanExtractor` [Validator] Fix docblock of `All` constraint constructor fix(console): fix progress bar messing output in section when there is an EOL
2 parents 36092eb + e7af9b8 commit 86c8a8a
Copy full SHA for 86c8a8a

File tree

6 files changed

+97
-3
lines changed
Filter options

6 files changed

+97
-3
lines changed

‎src/Symfony/Component/Console/Helper/ProgressBar.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressBar.php
+9
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,21 @@ private function overwrite(string $message): void
513513
if ($this->output instanceof ConsoleSectionOutput) {
514514
$messageLines = explode("\n", $this->previousMessage);
515515
$lineCount = \count($messageLines);
516+
517+
$lastLineWithoutDecoration = Helper::removeDecoration($this->output->getFormatter(), end($messageLines) ?? '');
518+
519+
// When the last previous line is empty (without formatting) it is already cleared by the section output, so we don't need to clear it again
520+
if ('' === $lastLineWithoutDecoration) {
521+
--$lineCount;
522+
}
523+
516524
foreach ($messageLines as $messageLine) {
517525
$messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine));
518526
if ($messageLineLength > $this->terminal->getWidth()) {
519527
$lineCount += floor($messageLineLength / $this->terminal->getWidth());
520528
}
521529
}
530+
522531
$this->output->clear($lineCount);
523532
} else {
524533
$lineCount = substr_count($this->previousMessage, "\n");

‎src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php
+75
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,81 @@ public function testOverwriteWithSectionOutput()
416416
);
417417
}
418418

419+
public function testOverwriteWithSectionOutputAndEol()
420+
{
421+
$sections = [];
422+
$stream = $this->getOutputStream(true);
423+
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
424+
425+
$bar = new ProgressBar($output, 50, 0);
426+
$bar->setFormat('[%bar%] %percent:3s%%' . PHP_EOL . '%message%' . PHP_EOL);
427+
$bar->setMessage('');
428+
$bar->start();
429+
$bar->display();
430+
$bar->setMessage('Doing something...');
431+
$bar->advance();
432+
$bar->setMessage('Doing something foo...');
433+
$bar->advance();
434+
435+
rewind($output->getStream());
436+
$this->assertEquals(escapeshellcmd(
437+
'[>---------------------------] 0%'.\PHP_EOL.\PHP_EOL.
438+
"\x1b[2A\x1b[0J".'[>---------------------------] 2%'.\PHP_EOL. 'Doing something...' . \PHP_EOL .
439+
"\x1b[2A\x1b[0J".'[=>--------------------------] 4%'.\PHP_EOL. 'Doing something foo...' . \PHP_EOL),
440+
escapeshellcmd(stream_get_contents($output->getStream()))
441+
);
442+
}
443+
444+
public function testOverwriteWithSectionOutputAndEolWithEmptyMessage()
445+
{
446+
$sections = [];
447+
$stream = $this->getOutputStream(true);
448+
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
449+
450+
$bar = new ProgressBar($output, 50, 0);
451+
$bar->setFormat('[%bar%] %percent:3s%%' . PHP_EOL . '%message%');
452+
$bar->setMessage('Start');
453+
$bar->start();
454+
$bar->display();
455+
$bar->setMessage('');
456+
$bar->advance();
457+
$bar->setMessage('Doing something...');
458+
$bar->advance();
459+
460+
rewind($output->getStream());
461+
$this->assertEquals(escapeshellcmd(
462+
'[>---------------------------] 0%'.\PHP_EOL.'Start'.\PHP_EOL.
463+
"\x1b[2A\x1b[0J".'[>---------------------------] 2%'.\PHP_EOL .
464+
"\x1b[1A\x1b[0J".'[=>--------------------------] 4%'.\PHP_EOL. 'Doing something...' . \PHP_EOL),
465+
escapeshellcmd(stream_get_contents($output->getStream()))
466+
);
467+
}
468+
469+
public function testOverwriteWithSectionOutputAndEolWithEmptyMessageComment()
470+
{
471+
$sections = [];
472+
$stream = $this->getOutputStream(true);
473+
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
474+
475+
$bar = new ProgressBar($output, 50, 0);
476+
$bar->setFormat('[%bar%] %percent:3s%%' . PHP_EOL . '<comment>%message%</comment>');
477+
$bar->setMessage('Start');
478+
$bar->start();
479+
$bar->display();
480+
$bar->setMessage('');
481+
$bar->advance();
482+
$bar->setMessage('Doing something...');
483+
$bar->advance();
484+
485+
rewind($output->getStream());
486+
$this->assertEquals(escapeshellcmd(
487+
'[>---------------------------] 0%'.\PHP_EOL."\x1b[33mStart\x1b[39m".\PHP_EOL.
488+
"\x1b[2A\x1b[0J".'[>---------------------------] 2%'.\PHP_EOL .
489+
"\x1b[1A\x1b[0J".'[=>--------------------------] 4%'.\PHP_EOL. "\x1b[33mDoing something...\x1b[39m" . \PHP_EOL),
490+
escapeshellcmd(stream_get_contents($output->getStream()))
491+
);
492+
}
493+
419494
public function testOverwriteWithAnsiSectionOutput()
420495
{
421496
// output has 43 visible characters plus 2 invisible ANSI characters

‎src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php
+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
1919
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
2020
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
21+
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
22+
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
2123
use PHPStan\PhpDocParser\Lexer\Lexer;
2224
use PHPStan\PhpDocParser\Parser\ConstExprParser;
2325
use PHPStan\PhpDocParser\Parser\PhpDocParser;
@@ -207,7 +209,7 @@ public function getType(string $class, string $property, array $context = []): ?
207209
$types = [];
208210

209211
foreach ($docNode->getTagsByName($tag) as $tagDocNode) {
210-
if ($tagDocNode->value instanceof InvalidTagValueNode) {
212+
if (!$tagDocNode->value instanceof ParamTagValueNode && !$tagDocNode->value instanceof ReturnTagValueNode && !$tagDocNode->value instanceof VarTagValueNode) {
211213
continue;
212214
}
213215

‎src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php
+1
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ public static function invalidTypesProvider(): iterable
697697
yield 'stat' => ['stat'];
698698
yield 'foo' => ['foo'];
699699
yield 'bar' => ['bar'];
700+
yield 'baz' => ['baz'];
700701
}
701702

702703
/**

‎src/Symfony/Component/PropertyInfo/Tests/Fixtures/InvalidDummy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Fixtures/InvalidDummy.php
+7
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,11 @@ public function getBar()
4747
{
4848
return 'bar';
4949
}
50+
51+
/**
52+
* @param $baz
53+
*/
54+
public function setBaz($baz)
55+
{
56+
}
5057
}

‎src/Symfony/Component/Validator/Constraints/All.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/All.php
+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class All extends Composite
2626
public array|Constraint $constraints = [];
2727

2828
/**
29-
* @param array<Constraint>|array<string,mixed>|null $constraints
30-
* @param string[]|null $groups
29+
* @param array<Constraint>|array<string,mixed>|Constraint|null $constraints
30+
* @param string[]|null $groups
3131
*/
3232
#[HasNamedArguments]
3333
public function __construct(mixed $constraints = null, ?array $groups = null, mixed $payload = null)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.