Skip to content

Commit 6fff7b3

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Make PhpDocExtractor compatible with phpDocumentor v5 Reset question validator attempts only for actual stdin bumped Symfony version to 4.4.11 updated VERSION for 4.4.10 updated CHANGELOG for 4.4.10
2 parents e5354f4 + 52612b1 commit 6fff7b3

File tree

8 files changed

+147
-21
lines changed

8 files changed

+147
-21
lines changed

CHANGELOG-4.4.md

+22
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ in 4.4 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.4.0...v4.4.1
99

10+
* 4.4.10 (2020-06-12)
11+
12+
* bug #37227 [DependencyInjection][CheckTypeDeclarationsPass] Handle unresolved parameters pointing to environment variables (fancyweb)
13+
* bug #37103 [Form] switch the context when validating nested forms (xabbuh)
14+
* bug #37182 [HttpKernel] Fix regression where Store does not return response body correctly (mpdude)
15+
* bug #37193 [DependencyInjection][CheckTypeDeclarationsPass] Always resolve parameters (fancyweb)
16+
* bug #37191 [HttpClient] fix offset computation for data chunks (nicolas-grekas)
17+
* bug #37177 [Ldap] fix refreshUser() ignoring extra_fields (arkste)
18+
* bug #37181 [Mailer] Remove an internal annot (fabpot)
19+
* bug #36913 [FrameworkBundle] fix type annotation on ControllerTrait::addFlash() (ThomasLandauer)
20+
* bug #37162 [Mailer] added the reply-to addresses to the API SES transport request. (ribeiropaulor)
21+
* bug #37167 [Mime] use fromString when creating a new Address (fabpot)
22+
* bug #37169 [Cache] fix forward compatibility with Doctrine DBAL 3 (xabbuh)
23+
* bug #37159 [Mailer] Fixed generator bug when creating multiple transports using Transport::fromDsn (atailouloute)
24+
* bug #37048 [HttpClient] fix monitoring timeouts when other streams are active (nicolas-grekas)
25+
* bug #37085 [Form] properly cascade validation to child forms (xabbuh)
26+
* bug #37095 [PhpUnitBridge] Fix undefined index when output of "composer show" cannot be parsed (nicolas-grekas)
27+
* bug #37092 [PhpUnitBridge] fix undefined var on version 3.4 (nicolas-grekas)
28+
* bug #37065 [HttpClient] Throw JsonException instead of TransportException on empty response in Response::toArray() (jeroennoten)
29+
* bug #37077 [WebProfilerBundle] Move ajax clear event listener initialization on loadToolbar (Bruno BOUTAREL)
30+
* bug #37049 [Serializer] take into account the context when preserving empty array objects (xabbuh)
31+
1032
* 4.4.9 (2020-05-31)
1133

1234
* bug #37008 [Security] Fixed AbstractToken::hasUserChanged() (wouterj)

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",
123123
"symfony/phpunit-bridge": "^5.0.8",
124124
"symfony/security-acl": "~2.8|~3.0",
125-
"phpdocumentor/reflection-docblock": "^3.0|^4.0",
125+
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
126126
"twig/cssinliner-extra": "^2.12",
127127
"twig/inky-extra": "^2.12",
128128
"twig/markdown-extra": "^2.12"

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -507,14 +507,16 @@ private function getShell()
507507

508508
private function isTty(): bool
509509
{
510-
$inputStream = !$this->inputStream && \defined('STDIN') ? STDIN : $this->inputStream;
510+
if (!\defined('STDIN')) {
511+
return true;
512+
}
511513

512514
if (\function_exists('stream_isatty')) {
513-
return stream_isatty($inputStream);
515+
return stream_isatty(fopen('php://input', 'r'));
514516
}
515517

516518
if (\function_exists('posix_isatty')) {
517-
return posix_isatty($inputStream);
519+
return posix_isatty(fopen('php://input', 'r'));
518520
}
519521

520522
return true;

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

+28-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Console\Tests\Helper;
1313

14+
use Symfony\Component\Console\Application;
1415
use Symfony\Component\Console\Exception\InvalidArgumentException;
1516
use Symfony\Component\Console\Formatter\OutputFormatter;
1617
use Symfony\Component\Console\Helper\FormatterHelper;
@@ -21,6 +22,7 @@
2122
use Symfony\Component\Console\Question\ConfirmationQuestion;
2223
use Symfony\Component\Console\Question\Question;
2324
use Symfony\Component\Console\Terminal;
25+
use Symfony\Component\Console\Tester\ApplicationTester;
2426

2527
/**
2628
* @group tty
@@ -727,21 +729,36 @@ public function testAskThrowsExceptionOnMissingInputWithValidator()
727729
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), $question);
728730
}
729731

730-
public function testAskThrowsExceptionFromValidatorEarlyWhenTtyIsMissing()
732+
public function testQuestionValidatorRepeatsThePrompt()
731733
{
732-
$this->expectException('Exception');
733-
$this->expectExceptionMessage('Bar, not Foo');
734+
$tries = 0;
735+
$application = new Application();
736+
$application->setAutoExit(false);
737+
$application->register('question')
738+
->setCode(function ($input, $output) use (&$tries) {
739+
$question = new Question('This is a promptable question');
740+
$question->setValidator(function ($value) use (&$tries) {
741+
++$tries;
742+
if (!$value) {
743+
throw new \Exception();
744+
}
734745

735-
$output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock();
736-
$output->expects($this->once())->method('writeln');
746+
return $value;
747+
});
748+
749+
(new QuestionHelper())->ask($input, $output, $question);
737750

738-
(new QuestionHelper())->ask(
739-
$this->createStreamableInputInterfaceMock($this->getInputStream('Foo'), true),
740-
$output,
741-
(new Question('Q?'))->setHidden(true)->setValidator(function ($input) {
742-
throw new \Exception("Bar, not $input");
751+
return 0;
743752
})
744-
);
753+
;
754+
755+
$tester = new ApplicationTester($application);
756+
$tester->setInputs(['', 'not-empty']);
757+
758+
$statusCode = $tester->run(['command' => 'question'], ['interactive' => true]);
759+
760+
$this->assertSame(2, $tries);
761+
$this->assertSame($statusCode, 0);
745762
}
746763

747764
public function testEmptyChoices()

src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\PropertyInfo\Extractor;
1313

1414
use phpDocumentor\Reflection\DocBlock;
15+
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
1516
use phpDocumentor\Reflection\DocBlockFactory;
1617
use phpDocumentor\Reflection\DocBlockFactoryInterface;
1718
use phpDocumentor\Reflection\Types\Context;
@@ -88,10 +89,12 @@ public function getShortDescription(string $class, string $property, array $cont
8889
}
8990

9091
foreach ($docBlock->getTagsByName('var') as $var) {
91-
$varDescription = $var->getDescription()->render();
92+
if ($var && !$var instanceof InvalidTag) {
93+
$varDescription = $var->getDescription()->render();
9294

93-
if (!empty($varDescription)) {
94-
return $varDescription;
95+
if (!empty($varDescription)) {
96+
return $varDescription;
97+
}
9598
}
9699
}
97100

@@ -142,7 +145,7 @@ public function getTypes(string $class, string $property, array $context = []):
142145
$types = [];
143146
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */
144147
foreach ($docBlock->getTagsByName($tag) as $tag) {
145-
if ($tag && null !== $tag->getType()) {
148+
if ($tag && !$tag instanceof InvalidTag && null !== $tag->getType()) {
146149
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
147150
}
148151
}

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php

+33-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\PropertyInfo\Tests\Extractor;
1313

14+
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
15+
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
1416
use phpDocumentor\Reflection\Types\Collection;
1517
use PHPUnit\Framework\TestCase;
1618
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
@@ -46,6 +48,26 @@ public function testParamTagTypeIsOmitted()
4648
$this->assertNull($this->extractor->getTypes(OmittedParamTagTypeDocBlock::class, 'omittedType'));
4749
}
4850

51+
public function invalidTypesProvider()
52+
{
53+
return [
54+
'pub' => ['pub', null, null],
55+
'stat' => ['stat', null, null],
56+
'foo' => ['foo', $this->isPhpDocumentorV5() ? 'Foo.' : null, null],
57+
'bar' => ['bar', $this->isPhpDocumentorV5() ? 'Bar.' : null, null],
58+
];
59+
}
60+
61+
/**
62+
* @dataProvider invalidTypesProvider
63+
*/
64+
public function testInvalid($property, $shortDescription, $longDescription)
65+
{
66+
$this->assertNull($this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy', $property));
67+
$this->assertSame($shortDescription, $this->extractor->getShortDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy', $property));
68+
$this->assertSame($longDescription, $this->extractor->getLongDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy', $property));
69+
}
70+
4971
/**
5072
* @dataProvider typesWithNoPrefixesProvider
5173
*/
@@ -94,7 +116,7 @@ public function typesProvider()
94116
['donotexist', null, null, null],
95117
['staticGetter', null, null, null],
96118
['staticSetter', null, null, null],
97-
['emptyVar', null, null, null],
119+
['emptyVar', null, $this->isPhpDocumentorV5() ? 'This should not be removed.' : null, null],
98120
];
99121
}
100122

@@ -250,6 +272,16 @@ public function testDocBlockFallback($property, $types)
250272
{
251273
$this->assertEquals($types, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\DockBlockFallback', $property));
252274
}
275+
276+
protected function isPhpDocumentorV5()
277+
{
278+
if (class_exists(InvalidTag::class)) {
279+
return true;
280+
}
281+
282+
return (new \ReflectionMethod(StandardTagFactory::class, 'create'))
283+
->hasReturnType();
284+
}
253285
}
254286

255287
class EmptyDocBlock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
13+
14+
/**
15+
* @author Martin Rademacher <[email protected]>
16+
*/
17+
class InvalidDummy
18+
{
19+
/**
20+
* @var
21+
*/
22+
public $pub;
23+
24+
/**
25+
* @return
26+
*/
27+
public static function getStat()
28+
{
29+
return 'stat';
30+
}
31+
32+
/**
33+
* Foo.
34+
*
35+
* @param
36+
*/
37+
public function setFoo($foo)
38+
{
39+
}
40+
41+
/**
42+
* Bar.
43+
*
44+
* @return
45+
*/
46+
public function getBar()
47+
{
48+
return 'bar';
49+
}
50+
}

src/Symfony/Component/PropertyInfo/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"symfony/serializer": "^4.4|^5.0",
3131
"symfony/cache": "^4.4|^5.0",
3232
"symfony/dependency-injection": "^4.4|^5.0",
33-
"phpdocumentor/reflection-docblock": "^3.0|^4.0",
33+
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
3434
"doctrine/annotations": "~1.7"
3535
},
3636
"conflict": {

0 commit comments

Comments
 (0)