Use try-finally where it possible

This commit is contained in:
Konstantin.Myakshin 2016-08-15 12:28:45 +03:00
parent 74b856166f
commit 747ddf6b0b
3 changed files with 17 additions and 38 deletions

View File

@ -45,21 +45,15 @@ class AutowirePass implements CompilerPassInterface
$this->completeDefinition($id, $definition);
}
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
} finally {
spl_autoload_unregister($throwingAutoloader);
spl_autoload_unregister($throwingAutoloader);
// Free memory and remove circular reference to container
$this->container = null;
$this->reflectionClasses = array();
$this->definedTypes = array();
$this->types = null;
$this->ambiguousServiceTypes = array();
if (isset($e)) {
throw $e;
// Free memory and remove circular reference to container
$this->container = null;
$this->reflectionClasses = array();
$this->definedTypes = array();
$this->types = null;
$this->ambiguousServiceTypes = array();
}
}

View File

@ -215,20 +215,12 @@ class PropertyAccessor implements PropertyAccessorInterface
$value = $zval[self::VALUE];
}
} catch (\TypeError $e) {
try {
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0);
} catch (InvalidArgumentException $e) {
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0);
} finally {
if (PHP_VERSION_ID < 70000 && false !== self::$previousErrorHandler) {
restore_error_handler();
self::$previousErrorHandler = false;
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
if (PHP_VERSION_ID < 70000 && false !== self::$previousErrorHandler) {
restore_error_handler();
self::$previousErrorHandler = false;
}
if (isset($e)) {
throw $e;
}
}

View File

@ -119,23 +119,16 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
*/
public function dump(Data $data, $output = null)
{
$exception = null;
if ($output) {
$prevOutput = $this->setOutput($output);
}
try {
$data->dump($this);
$this->dumpLine(-1);
} catch (\Exception $exception) {
// Re-thrown below
} catch (\Throwable $exception) {
// Re-thrown below
}
if ($output) {
$this->setOutput($prevOutput);
}
if (null !== $exception) {
throw $exception;
} finally {
if ($output) {
$this->setOutput($prevOutput);
}
}
}