Skip to content

Commit

Permalink
minor #19617 Use try-finally where it possible (Koc)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.1 branch.

Discussion
----------

Use try-finally where it possible

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Just a minior refactoring for using PHP 5.5 feature.

Commits
-------

747ddf6 Use try-finally where it possible
  • Loading branch information
fabpot committed Aug 16, 2016
2 parents ac528c7 + 747ddf6 commit e34426e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
Expand Up @@ -45,21 +45,15 @@ public function process(ContainerBuilder $container)
$this->completeDefinition($id, $definition);
}
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
}

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;
} finally {
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();
}
}

Expand Down
18 changes: 5 additions & 13 deletions src/Symfony/Component/PropertyAccess/PropertyAccessor.php
Expand Up @@ -215,20 +215,12 @@ public function setValue(&$objectOrArray, $propertyPath, $value)
$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;
}
}

Expand Down
15 changes: 4 additions & 11 deletions src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php
Expand Up @@ -119,23 +119,16 @@ public function setIndentPad($pad)
*/
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);
}
}
}

Expand Down

0 comments on commit e34426e

Please sign in to comment.