Skip to content

Commit 8ff0494

Browse files
committed
Merge branch '3.2'
* 3.2: [FrameworkBundle] Ignore AnnotationException exceptions in the AnnotationsCacheWarmer fixed @return when returning this or static override property constraints in child class removed unneeded comment [Console] improved code coverage of Command class [FrameworkBundle] Make TemplateController working without the Templating component [FrameworkBundle] Allow multiple transactions with the same name Only count on arrays or countables to avoid warnings in PHP 7.2
2 parents 7b57f3c + dd95075 commit 8ff0494

File tree

11 files changed

+72
-37
lines changed

11 files changed

+72
-37
lines changed

Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ public function getTerminalDimensions()
751751
* @param int $width The width
752752
* @param int $height The height
753753
*
754-
* @return Application The current application
754+
* @return $this
755755
*
756756
* @deprecated since version 3.2, to be removed in 4.0. Set the COLUMNS and LINES env vars instead.
757757
*/

Command/Command.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public function run(InputInterface $input, OutputInterface $output)
266266
*
267267
* @param callable $code A callable(InputInterface $input, OutputInterface $output)
268268
*
269-
* @return Command The current instance
269+
* @return $this
270270
*
271271
* @throws InvalidArgumentException
272272
*
@@ -326,7 +326,7 @@ public function mergeApplicationDefinition($mergeArgs = true)
326326
*
327327
* @param array|InputDefinition $definition An array of argument and option instances or a definition instance
328328
*
329-
* @return Command The current instance
329+
* @return $this
330330
*/
331331
public function setDefinition($definition)
332332
{
@@ -374,7 +374,7 @@ public function getNativeDefinition()
374374
* @param string $description A description text
375375
* @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
376376
*
377-
* @return Command The current instance
377+
* @return $this
378378
*/
379379
public function addArgument($name, $mode = null, $description = '', $default = null)
380380
{
@@ -392,7 +392,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n
392392
* @param string $description A description text
393393
* @param mixed $default The default value (must be null for InputOption::VALUE_NONE)
394394
*
395-
* @return Command The current instance
395+
* @return $this
396396
*/
397397
public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
398398
{
@@ -411,7 +411,7 @@ public function addOption($name, $shortcut = null, $mode = null, $description =
411411
*
412412
* @param string $name The command name
413413
*
414-
* @return Command The current instance
414+
* @return $this
415415
*
416416
* @throws InvalidArgumentException When the name is invalid
417417
*/
@@ -434,7 +434,7 @@ public function setName($name)
434434
*
435435
* @param string $title The process title
436436
*
437-
* @return Command The current instance
437+
* @return $this
438438
*/
439439
public function setProcessTitle($title)
440440
{
@@ -478,7 +478,7 @@ public function isHidden()
478478
*
479479
* @param string $description The description for the command
480480
*
481-
* @return Command The current instance
481+
* @return $this
482482
*/
483483
public function setDescription($description)
484484
{
@@ -502,7 +502,7 @@ public function getDescription()
502502
*
503503
* @param string $help The help for the command
504504
*
505-
* @return Command The current instance
505+
* @return $this
506506
*/
507507
public function setHelp($help)
508508
{
@@ -548,7 +548,7 @@ public function getProcessedHelp()
548548
*
549549
* @param string[] $aliases An array of aliases for the command
550550
*
551-
* @return Command The current instance
551+
* @return $this
552552
*
553553
* @throws InvalidArgumentException When an alias is invalid
554554
*/
@@ -600,7 +600,7 @@ public function getSynopsis($short = false)
600600
*
601601
* @param string $usage The usage, it'll be prefixed with the command name
602602
*
603-
* @return Command The current instance
603+
* @return $this
604604
*/
605605
public function addUsage($usage)
606606
{

Formatter/OutputFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function getStyleStack()
208208
*
209209
* @param string $string
210210
*
211-
* @return OutputFormatterStyle|bool false if string is not format string
211+
* @return OutputFormatterStyle|false false if string is not format string
212212
*/
213213
private function createStyleFromString($string)
214214
{

Formatter/OutputFormatterStyleStack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getCurrent()
104104
/**
105105
* @param OutputFormatterStyleInterface $emptyStyle
106106
*
107-
* @return OutputFormatterStyleStack
107+
* @return $this
108108
*/
109109
public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
110110
{

Helper/DescriptorHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function describe(OutputInterface $output, $object, array $options = arra
7878
* @param string $format
7979
* @param DescriptorInterface $descriptor
8080
*
81-
* @return DescriptorHelper
81+
* @return $this
8282
*/
8383
public function register($format, DescriptorInterface $descriptor)
8484
{

Helper/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function setHelperSet(HelperSet $helperSet = null)
3535
/**
3636
* Gets the helper set associated with this helper.
3737
*
38-
* @return HelperSet A HelperSet instance
38+
* @return HelperSet|null
3939
*/
4040
public function getHelperSet()
4141
{

Helper/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static function setStyleDefinition($name, TableStyle $style)
107107
*
108108
* @param string $name The style name
109109
*
110-
* @return TableStyle A TableStyle instance
110+
* @return TableStyle
111111
*/
112112
public static function getStyleDefinition($name)
113113
{
@@ -127,7 +127,7 @@ public static function getStyleDefinition($name)
127127
*
128128
* @param TableStyle|string $name The style name or a TableStyle instance
129129
*
130-
* @return Table
130+
* @return $this
131131
*/
132132
public function setStyle($name)
133133
{

Helper/TableStyle.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TableStyle
3737
*
3838
* @param string $paddingChar
3939
*
40-
* @return TableStyle
40+
* @return $this
4141
*/
4242
public function setPaddingChar($paddingChar)
4343
{
@@ -65,7 +65,7 @@ public function getPaddingChar()
6565
*
6666
* @param string $horizontalBorderChar
6767
*
68-
* @return TableStyle
68+
* @return $this
6969
*/
7070
public function setHorizontalBorderChar($horizontalBorderChar)
7171
{
@@ -89,7 +89,7 @@ public function getHorizontalBorderChar()
8989
*
9090
* @param string $verticalBorderChar
9191
*
92-
* @return TableStyle
92+
* @return $this
9393
*/
9494
public function setVerticalBorderChar($verticalBorderChar)
9595
{
@@ -113,7 +113,7 @@ public function getVerticalBorderChar()
113113
*
114114
* @param string $crossingChar
115115
*
116-
* @return TableStyle
116+
* @return $this
117117
*/
118118
public function setCrossingChar($crossingChar)
119119
{
@@ -137,7 +137,7 @@ public function getCrossingChar()
137137
*
138138
* @param string $cellHeaderFormat
139139
*
140-
* @return TableStyle
140+
* @return $this
141141
*/
142142
public function setCellHeaderFormat($cellHeaderFormat)
143143
{
@@ -161,7 +161,7 @@ public function getCellHeaderFormat()
161161
*
162162
* @param string $cellRowFormat
163163
*
164-
* @return TableStyle
164+
* @return $this
165165
*/
166166
public function setCellRowFormat($cellRowFormat)
167167
{
@@ -185,7 +185,7 @@ public function getCellRowFormat()
185185
*
186186
* @param string $cellRowContentFormat
187187
*
188-
* @return TableStyle
188+
* @return $this
189189
*/
190190
public function setCellRowContentFormat($cellRowContentFormat)
191191
{
@@ -209,7 +209,7 @@ public function getCellRowContentFormat()
209209
*
210210
* @param string $borderFormat
211211
*
212-
* @return TableStyle
212+
* @return $this
213213
*/
214214
public function setBorderFormat($borderFormat)
215215
{
@@ -233,7 +233,7 @@ public function getBorderFormat()
233233
*
234234
* @param int $padType STR_PAD_*
235235
*
236-
* @return TableStyle
236+
* @return $this
237237
*/
238238
public function setPadType($padType)
239239
{

Question/ChoiceQuestion.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getChoices()
5858
*
5959
* @param bool $multiselect
6060
*
61-
* @return ChoiceQuestion The current instance
61+
* @return $this
6262
*/
6363
public function setMultiselect($multiselect)
6464
{
@@ -93,7 +93,7 @@ public function getPrompt()
9393
*
9494
* @param string $prompt
9595
*
96-
* @return ChoiceQuestion The current instance
96+
* @return $this
9797
*/
9898
public function setPrompt($prompt)
9999
{
@@ -109,7 +109,7 @@ public function setPrompt($prompt)
109109
*
110110
* @param string $errorMessage
111111
*
112-
* @return ChoiceQuestion The current instance
112+
* @return $this
113113
*/
114114
public function setErrorMessage($errorMessage)
115115
{

Question/Question.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function isHidden()
7777
*
7878
* @param bool $hidden
7979
*
80-
* @return Question The current instance
80+
* @return $this
8181
*
8282
* @throws LogicException In case the autocompleter is also used
8383
*/
@@ -107,7 +107,7 @@ public function isHiddenFallback()
107107
*
108108
* @param bool $fallback
109109
*
110-
* @return Question The current instance
110+
* @return $this
111111
*/
112112
public function setHiddenFallback($fallback)
113113
{
@@ -131,7 +131,7 @@ public function getAutocompleterValues()
131131
*
132132
* @param null|array|\Traversable $values
133133
*
134-
* @return Question The current instance
134+
* @return $this
135135
*
136136
* @throws InvalidArgumentException
137137
* @throws LogicException
@@ -162,7 +162,7 @@ public function setAutocompleterValues($values)
162162
*
163163
* @param null|callable $validator
164164
*
165-
* @return Question The current instance
165+
* @return $this
166166
*/
167167
public function setValidator(callable $validator = null)
168168
{
@@ -188,7 +188,7 @@ public function getValidator()
188188
*
189189
* @param null|int $attempts
190190
*
191-
* @return Question The current instance
191+
* @return $this
192192
*
193193
* @throws InvalidArgumentException In case the number of attempts is invalid.
194194
*/
@@ -222,7 +222,7 @@ public function getMaxAttempts()
222222
*
223223
* @param callable $normalizer
224224
*
225-
* @return Question The current instance
225+
* @return $this
226226
*/
227227
public function setNormalizer(callable $normalizer)
228228
{

Tests/Command/CommandTest.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ public function testSetApplication()
5454
$command = new \TestCommand();
5555
$command->setApplication($application);
5656
$this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application');
57+
$this->assertEquals($application->getHelperSet(), $command->getHelperSet());
58+
}
59+
60+
public function testSetApplicationNull()
61+
{
62+
$command = new \TestCommand();
63+
$command->setApplication(null);
64+
$this->assertNull($command->getHelperSet());
5765
}
5866

5967
public function testSetGetDefinition()
@@ -156,6 +164,13 @@ public function testGetSetAliases()
156164
$this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases');
157165
}
158166

167+
public function testSetAliasesNull()
168+
{
169+
$command = new \TestCommand();
170+
$this->setExpectedException('InvalidArgumentException');
171+
$command->setAliases(null);
172+
}
173+
159174
public function testGetSynopsis()
160175
{
161176
$command = new \TestCommand();
@@ -164,6 +179,15 @@ public function testGetSynopsis()
164179
$this->assertEquals('namespace:name [--foo] [--] [<bar>]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
165180
}
166181

182+
public function testAddGetUsages()
183+
{
184+
$command = new \TestCommand();
185+
$command->addUsage('foo1');
186+
$command->addUsage('foo2');
187+
$this->assertContains('namespace:name foo1', $command->getUsages());
188+
$this->assertContains('namespace:name foo2', $command->getUsages());
189+
}
190+
167191
public function testGetHelper()
168192
{
169193
$application = new Application();
@@ -275,8 +299,8 @@ public function testRunReturnsIntegerExitCode()
275299

276300
$command = $this->getMockBuilder('TestCommand')->setMethods(array('execute'))->getMock();
277301
$command->expects($this->once())
278-
->method('execute')
279-
->will($this->returnValue('2.3'));
302+
->method('execute')
303+
->will($this->returnValue('2.3'));
280304
$exitCode = $command->run(new StringInput(''), new NullOutput());
281305
$this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)');
282306
}
@@ -297,6 +321,17 @@ public function testRunReturnsAlwaysInteger()
297321
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
298322
}
299323

324+
public function testRunWithProcessTitle()
325+
{
326+
$command = new \TestCommand();
327+
$command->setApplication(new Application());
328+
$command->setProcessTitle('foo');
329+
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
330+
if (function_exists('cli_set_process_title')) {
331+
$this->assertEquals('foo', cli_get_process_title());
332+
}
333+
}
334+
300335
public function testSetCode()
301336
{
302337
$command = new \TestCommand();

0 commit comments

Comments
 (0)