Skip to content

Commit e34426e

Browse files
committed
minor #19617 Use try-finally where it possible (Koc)
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
2 parents ac528c7 + 747ddf6 commit e34426e

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,15 @@ public function process(ContainerBuilder $container)
4545
$this->completeDefinition($id, $definition);
4646
}
4747
}
48-
} catch (\Exception $e) {
49-
} catch (\Throwable $e) {
50-
}
51-
52-
spl_autoload_unregister($throwingAutoloader);
53-
54-
// Free memory and remove circular reference to container
55-
$this->container = null;
56-
$this->reflectionClasses = array();
57-
$this->definedTypes = array();
58-
$this->types = null;
59-
$this->ambiguousServiceTypes = array();
60-
61-
if (isset($e)) {
62-
throw $e;
48+
} finally {
49+
spl_autoload_unregister($throwingAutoloader);
50+
51+
// Free memory and remove circular reference to container
52+
$this->container = null;
53+
$this->reflectionClasses = array();
54+
$this->definedTypes = array();
55+
$this->types = null;
56+
$this->ambiguousServiceTypes = array();
6357
}
6458
}
6559

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,20 +215,12 @@ public function setValue(&$objectOrArray, $propertyPath, $value)
215215
$value = $zval[self::VALUE];
216216
}
217217
} catch (\TypeError $e) {
218-
try {
219-
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0);
220-
} catch (InvalidArgumentException $e) {
218+
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0);
219+
} finally {
220+
if (PHP_VERSION_ID < 70000 && false !== self::$previousErrorHandler) {
221+
restore_error_handler();
222+
self::$previousErrorHandler = false;
221223
}
222-
} catch (\Exception $e) {
223-
} catch (\Throwable $e) {
224-
}
225-
226-
if (PHP_VERSION_ID < 70000 && false !== self::$previousErrorHandler) {
227-
restore_error_handler();
228-
self::$previousErrorHandler = false;
229-
}
230-
if (isset($e)) {
231-
throw $e;
232224
}
233225
}
234226

src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,16 @@ public function setIndentPad($pad)
119119
*/
120120
public function dump(Data $data, $output = null)
121121
{
122-
$exception = null;
123122
if ($output) {
124123
$prevOutput = $this->setOutput($output);
125124
}
126125
try {
127126
$data->dump($this);
128127
$this->dumpLine(-1);
129-
} catch (\Exception $exception) {
130-
// Re-thrown below
131-
} catch (\Throwable $exception) {
132-
// Re-thrown below
133-
}
134-
if ($output) {
135-
$this->setOutput($prevOutput);
136-
}
137-
if (null !== $exception) {
138-
throw $exception;
128+
} finally {
129+
if ($output) {
130+
$this->setOutput($prevOutput);
131+
}
139132
}
140133
}
141134

0 commit comments

Comments
 (0)