Skip to content

Commit

Permalink
Update Task.php
Browse files Browse the repository at this point in the history
  • Loading branch information
siad007 committed Dec 29, 2017
1 parent 16be52e commit e281322
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
30 changes: 21 additions & 9 deletions classes/phing/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,35 @@ public function maybeConfigure()
/**
* Perfrom this task
*
* @return void
*
* @throws BuildException
* @throws Error
*/
public function perform()
public function perform(): void
{
$reason = null;
try { // try executing task
$this->project->fireTaskStarted($this);
$this->maybeConfigure();
DispatchUtils::main($this);
$this->project->fireTaskFinished($this, $null = null);
} catch (Exception $exc) {
if ($exc instanceof BuildException) {
if ($this->getLocation() !== null) {
$exc->setLocation($this->getLocation());
}
} catch (\BuildException $ex) {
$loc = $ex->getLocation();
if ($loc === null || (string) $loc === '') {
$ex->setLocation($this->getLocation());
}
$this->project->fireTaskFinished($this, $exc);
throw $exc;
$reason = $ex;
throw $ex;
} catch (\Exception $ex) {
$reason = $ex;
$be = new \BuildException($ex);
$be->setLocation($this->getLocation());
throw $be;
} catch (\Error $ex) {
$reason = $ex;
throw $ex;
} finally {
$this->project->fireTaskFinished($this, $reason);
}
}
}
8 changes: 6 additions & 2 deletions test/classes/phing/tasks/TaskdefTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ public function testNoClassname()
}

/**
* @expectedException \PHPUnit\Framework\Error\Error
* @expectedException BuildException
*/
public function testClassNotFound()
{
try {
$this->expectBuildException("classNotFound", "classname specified doesn't exist");
$this->executeTarget("classNotFound");
$this->fail(
"Should throw ConfigurationException because: " .
"classname specified doesn't exist"
);
} catch (ConfigurationException $e) {
//ignored
}
Expand Down
2 changes: 1 addition & 1 deletion test/classes/phing/tasks/TypedefTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testNoClassname()
}

/**
* @expectedException \PHPUnit\Framework\Error\Error
* @expectedException BuildException
*/
public function testClassNotFound()
{
Expand Down

0 comments on commit e281322

Please sign in to comment.