Skip to content

Commit 5be7ed8

Browse files
committed
[Console] Add getters for Application::$autoExit and $catchExceptions
1 parent 94eb384 commit 5be7ed8

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,16 @@ public function getHelp()
254254
return $this->getLongVersion();
255255
}
256256

257+
/**
258+
* Gets whether to catch exceptions or not during commands execution.
259+
*
260+
* @return bool Whether to catch exceptions or not during commands execution
261+
*/
262+
public function areExceptionsCatched()
263+
{
264+
return $this->catchExceptions;
265+
}
266+
257267
/**
258268
* Sets whether to catch exceptions or not during commands execution.
259269
*
@@ -266,6 +276,16 @@ public function setCatchExceptions($boolean)
266276
$this->catchExceptions = (bool) $boolean;
267277
}
268278

279+
/**
280+
* Gets whether to automatically exit after a command execution or not.
281+
*
282+
* @return bool Whether to automatically exit after a command execution or not
283+
*/
284+
public function isAutoExitEnabled()
285+
{
286+
return $this->autoExit;
287+
}
288+
269289
/**
270290
* Sets whether to automatically exit after a command execution or not.
271291
*

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ public function testSetCatchExceptions()
477477
$tester = new ApplicationTester($application);
478478

479479
$application->setCatchExceptions(true);
480+
$this->assertTrue($application->areExceptionsCatched());
480481
$tester->run(array('command' => 'foo'), array('decorated' => false));
481482
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag');
482483

@@ -490,6 +491,15 @@ public function testSetCatchExceptions()
490491
}
491492
}
492493

494+
public function testAutoExitSetting()
495+
{
496+
$application = new Application();
497+
$this->assertTrue($application->isAutoExitEnabled());
498+
499+
$application->setAutoExit(false);
500+
$this->assertFalse($application->isAutoExitEnabled());
501+
}
502+
493503
/**
494504
* @group legacy
495505
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy