Skip to content

Commit cffa826

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Cache] Fix dumping SplDoublyLinkedList iter mode [Console] fixed PHP7 Errors when not using Dispatcher
2 parents 1188b4d + 777fda3 commit cffa826

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,13 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
846846
}
847847

848848
if (null === $this->dispatcher) {
849-
return $command->run($input, $output);
849+
try {
850+
return $command->run($input, $output);
851+
} catch (\Exception $e) {
852+
throw $e;
853+
} catch (\Throwable $e) {
854+
throw new FatalThrowableError($e);
855+
}
850856
}
851857

852858
// bind before the console.command event, so the listeners have access to input options/arguments

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,24 @@ public function testRunDispatchesAllEventsWithException()
955955
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
956956
}
957957

958+
public function testRunWithError()
959+
{
960+
$this->setExpectedException('Exception', 'dymerr');
961+
962+
$application = new Application();
963+
$application->setAutoExit(false);
964+
$application->setCatchExceptions(false);
965+
966+
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
967+
$output->write('dym.');
968+
969+
throw new \Error('dymerr');
970+
});
971+
972+
$tester = new ApplicationTester($application);
973+
$tester->run(array('command' => 'dym'));
974+
}
975+
958976
/**
959977
* @expectedException \LogicException
960978
* @expectedExceptionMessage caught

src/Symfony/Component/VarDumper/Caster/SplCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, S
7171
$c->setIteratorMode(\SplDoublyLinkedList::IT_MODE_KEEP | $mode & ~\SplDoublyLinkedList::IT_MODE_DELETE);
7272

7373
$a += array(
74-
$prefix.'mode' => new ConstStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_KEEP) ? 'IT_MODE_KEEP' : 'IT_MODE_DELETE'), $mode),
74+
$prefix.'mode' => new ConstStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_DELETE) ? 'IT_MODE_DELETE' : 'IT_MODE_KEEP'), $mode),
7575
$prefix.'dllist' => iterator_to_array($c),
7676
);
7777
$c->setIteratorMode($mode);

src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,30 @@ public function testCastFileObject()
115115
EOTXT;
116116
$this->assertDumpMatchesFormat($dump, $var);
117117
}
118+
119+
/**
120+
* @dataProvider provideCastSplDoublyLinkedList
121+
*/
122+
public function testCastSplDoublyLinkedList($modeValue, $modeDump)
123+
{
124+
$var = new \SplDoublyLinkedList();
125+
$var->setIteratorMode($modeValue);
126+
$dump = <<<EOTXT
127+
SplDoublyLinkedList {
128+
%Amode: $modeDump
129+
dllist: []
130+
}
131+
EOTXT;
132+
$this->assertDumpMatchesFormat($dump, $var);
133+
}
134+
135+
public function provideCastSplDoublyLinkedList()
136+
{
137+
return array(
138+
array(\SplDoublyLinkedList::IT_MODE_FIFO, 'IT_MODE_FIFO | IT_MODE_KEEP'),
139+
array(\SplDoublyLinkedList::IT_MODE_LIFO, 'IT_MODE_LIFO | IT_MODE_KEEP'),
140+
array(\SplDoublyLinkedList::IT_MODE_FIFO | \SplDoublyLinkedList::IT_MODE_DELETE, 'IT_MODE_FIFO | IT_MODE_DELETE'),
141+
array(\SplDoublyLinkedList::IT_MODE_LIFO | \SplDoublyLinkedList::IT_MODE_DELETE, 'IT_MODE_LIFO | IT_MODE_DELETE'),
142+
);
143+
}
118144
}

0 commit comments

Comments
 (0)