Skip to content

Commit bf853d4

Browse files
committed
Merge branch '2.8' into 3.1
* 2.8: 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 Only count on arrays or countables to avoid warnings in PHP 7.2
2 parents d30f02f + 6f1ee11 commit bf853d4

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
@@ -746,7 +746,7 @@ public function getTerminalDimensions()
746746
* @param int $width The width
747747
* @param int $height The height
748748
*
749-
* @return Application The current application
749+
* @return $this
750750
*/
751751
public function setTerminalDimensions($width, $height)
752752
{

Command/Command.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function run(InputInterface $input, OutputInterface $output)
265265
*
266266
* @param callable $code A callable(InputInterface $input, OutputInterface $output)
267267
*
268-
* @return Command The current instance
268+
* @return $this
269269
*
270270
* @throws InvalidArgumentException
271271
*
@@ -325,7 +325,7 @@ public function mergeApplicationDefinition($mergeArgs = true)
325325
*
326326
* @param array|InputDefinition $definition An array of argument and option instances or a definition instance
327327
*
328-
* @return Command The current instance
328+
* @return $this
329329
*/
330330
public function setDefinition($definition)
331331
{
@@ -373,7 +373,7 @@ public function getNativeDefinition()
373373
* @param string $description A description text
374374
* @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
375375
*
376-
* @return Command The current instance
376+
* @return $this
377377
*/
378378
public function addArgument($name, $mode = null, $description = '', $default = null)
379379
{
@@ -391,7 +391,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n
391391
* @param string $description A description text
392392
* @param mixed $default The default value (must be null for InputOption::VALUE_NONE)
393393
*
394-
* @return Command The current instance
394+
* @return $this
395395
*/
396396
public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
397397
{
@@ -410,7 +410,7 @@ public function addOption($name, $shortcut = null, $mode = null, $description =
410410
*
411411
* @param string $name The command name
412412
*
413-
* @return Command The current instance
413+
* @return $this
414414
*
415415
* @throws InvalidArgumentException When the name is invalid
416416
*/
@@ -433,7 +433,7 @@ public function setName($name)
433433
*
434434
* @param string $title The process title
435435
*
436-
* @return Command The current instance
436+
* @return $this
437437
*/
438438
public function setProcessTitle($title)
439439
{
@@ -457,7 +457,7 @@ public function getName()
457457
*
458458
* @param string $description The description for the command
459459
*
460-
* @return Command The current instance
460+
* @return $this
461461
*/
462462
public function setDescription($description)
463463
{
@@ -481,7 +481,7 @@ public function getDescription()
481481
*
482482
* @param string $help The help for the command
483483
*
484-
* @return Command The current instance
484+
* @return $this
485485
*/
486486
public function setHelp($help)
487487
{
@@ -527,7 +527,7 @@ public function getProcessedHelp()
527527
*
528528
* @param string[] $aliases An array of aliases for the command
529529
*
530-
* @return Command The current instance
530+
* @return $this
531531
*
532532
* @throws InvalidArgumentException When an alias is invalid
533533
*/
@@ -579,7 +579,7 @@ public function getSynopsis($short = false)
579579
*
580580
* @param string $usage The usage, it'll be prefixed with the command name
581581
*
582-
* @return Command The current instance
582+
* @return $this
583583
*/
584584
public function addUsage($usage)
585585
{

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)