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

Skip to content

Commit 77b5fc4

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: undefined offset fix (#19406) [EventDispatcher] Removed unused variable
2 parents 3a78921 + 382ad65 commit 77b5fc4

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public static function getStyleDefinition($name)
108108
self::$styles = self::initStyles();
109109
}
110110

111-
if (!self::$styles[$name]) {
112-
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
111+
if (isset(self::$styles[$name])) {
112+
return self::$styles[$name];
113113
}
114114

115-
return self::$styles[$name];
115+
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
116116
}
117117

118118
/**
@@ -124,13 +124,7 @@ public static function getStyleDefinition($name)
124124
*/
125125
public function setStyle($name)
126126
{
127-
if ($name instanceof TableStyle) {
128-
$this->style = $name;
129-
} elseif (isset(self::$styles[$name])) {
130-
$this->style = self::$styles[$name];
131-
} else {
132-
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
133-
}
127+
$this->style = $this->resolveStyle($name);
134128

135129
return $this;
136130
}
@@ -660,4 +654,17 @@ private static function initStyles()
660654
'symfony-style-guide' => $styleGuide,
661655
);
662656
}
657+
658+
private function resolveStyle($name)
659+
{
660+
if ($name instanceof TableStyle) {
661+
return $name;
662+
}
663+
664+
if (isset(self::$styles[$name])) {
665+
return self::$styles[$name];
666+
}
667+
668+
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
669+
}
663670
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,25 @@ public function testColumnStyle()
631631
$this->assertEquals($expected, $this->getOutputContent($output));
632632
}
633633

634+
/**
635+
* @expectedException Symfony\Component\Console\Exception\InvalidArgumentException
636+
* @expectedExceptionMessage Style "absent" is not defined.
637+
*/
638+
public function testIsNotDefinedStyleException()
639+
{
640+
$table = new Table($this->getOutputStream());
641+
$table->setStyle('absent');
642+
}
643+
644+
/**
645+
* @expectedException Symfony\Component\Console\Exception\InvalidArgumentException
646+
* @expectedExceptionMessage Style "absent" is not defined.
647+
*/
648+
public function testGetStyleDefinition()
649+
{
650+
Table::getStyleDefinition('absent');
651+
}
652+
634653
protected function getOutputStream()
635654
{
636655
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false);

src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testDispatch()
142142
public function testLegacyDispatch()
143143
{
144144
$event = new Event();
145-
$return = $this->dispatcher->dispatch(self::preFoo, $event);
145+
$this->dispatcher->dispatch(self::preFoo, $event);
146146
$this->assertEquals('pre.foo', $event->getName());
147147
}
148148

0 commit comments

Comments
 (0)