8000 minor #22844 CS Fixes (chalasr) · symfony/symfony@063da35 · GitHub
[go: up one dir, main page]

Skip to content

Commit 063da35

Browse files
minor #22844 CS Fixes (chalasr)
This PR was merged into the 4.0-dev branch. Discussion ---------- CS Fixes | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 21114f8 CS Fixes
2 parents 3892a95 + 21114f8 commit 063da35

File tree

10 files changed

+25
-83
lines changed

10 files changed

+25
-83
lines changed

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function ($key, $value, $isHit) {
5353
}
5454

5555
/**
56-
* This adapter to take advantage of how PHP stores arrays in its latest versions.
56+
* This adapter takes advantage of how PHP stores arrays in its latest versions.
5757
*
5858
* @param string $file The PHP file were values are cached
5959
* @param CacheItemPoolInterface $fallbackPool Fallback when opcache is disabled

src/Symfony/Component/Cache/Simple/PhpArrayCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct($file, CacheInterface $fallbackPool)
3737
}
3838

3939
/**
40-
* This adapter to take advantage of how PHP stores arrays in its latest versions.
40+
* This adapter takes advantage of how PHP stores arrays in its latest versions.
4141
*
4242
* @param string $file The PHP file were values are cached
4343
*

src/Symfony/Component/Console/Application.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,10 @@ public function doRun(InputInterface $input, OutputInterface $output)
194194
}
195195

196196
try {
197-
$e = $this->runningCommand = null;
197+
$this->runningCommand = null;
198198
// the command name MUST be the first element of the input
199199
$command = $this->find($name);
200-
} catch (\Exception $e) {
201200
} catch (\Throwable $e) {
202-
}
203-
if (null !== $e) {
204201
if (null !== $this->dispatcher) {
205202
$event = new ConsoleErrorEvent($input, $output, $e);
206203
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
@@ -813,24 +810,17 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
813810
} else {
814811
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
815812
}
816-
} catch (\Exception $e) {
817813
} catch (\Throwable $e) {
818-
}
819-
if (null !== $e) {
820814
$event = new ConsoleErrorEvent($input, $output, $e, $command);
821815
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
822816
$e = $event->getError();
823817

824-
if (0 === $exitCode = $event->getExitCode()) {
825-
$e = null;
818+
if (0 !== $exitCode = $event->getExitCode()) {
819+
throw $e;
826820
}
827-
}
828-
829-
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
830-
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
831-
832-
if (null !== $e) {
833-
throw $e;
821+
} finally {
822+
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
823+
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
834824
}
835825

836826
return $event->getExitCode();

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ public function handleException($exception, array $error = null)
541541
if ($this->loggedErrors & $type) {
542542
try {
543543
$this->loggers[$type][0]->log($this->loggers[$type][1], $message, array('exception' => $exception));
544-
} catch (\Exception $handlerException) {
545544
} catch (\Throwable $handlerException) {
546545
}
547546
}
@@ -558,7 +557,6 @@ public function handleException($exception, array $error = null)
558557
}
559558
try {
560559
call_user_func($this->exceptionHandler, $exception);
561-
} catch (\Exception $handlerException) {
562560
} catch (\Throwable $handlerException) {
563561
}
564562
if (isset($handlerException)) {
@@ -598,8 +596,6 @@ public static function handleFatalError(array $error = null)
598596
while (self::$stackedErrorLevels) {
599597
static::unstackErrors();
600598
}
601-
} catch (\Exception $exception) {
602-
// Handled below
603599
} catch (\Throwable $exception) {
604600
// Handled below
605601
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function updateDefinition(ContainerBuilder $container, $id, Definition $
8989

9090
$returnType = $m->getReturnType();
9191
if (null !== $returnType && !$returnType->isBuiltin()) {
92-
$returnType = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : $returnType->__toString();
92+
$returnType = $returnType->getName();
9393
if (null !== $class) {
9494
$declaringClass = $m->getDeclaringClass()->getName();
9595
if ('self' === strtolower($returnType)) {

src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa
7676
return;
7777
}
7878
if (!is_string($type)) {
79-
$name = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();
79+
$name = $type->getName();
8080

8181
if ($type->isBuiltin()) {
8282
return $noBuiltin ? null : $name;

src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,48 +34,12 @@ public function createArgumentMetadata($controller)
3434
}
3535

3636
foreach ($reflection->getParameters() as $param) {
37-
$arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param), $param->allowsNull());
37+
$arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $param->isVariadic(), $param->isDefaultValueAvailable(), $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null, $param->allowsNull());
3838
}
3939

4040
return $arguments;
4141
}
4242

43-
/**
44-
* Returns whether an argument is variadic.
45-
*
46-
* @param \ReflectionParameter $parameter
47-
*
48-
* @return bool
49-
*/
50-
private function isVariadic(\ReflectionParameter $parameter)
51-
{
52-
return $parameter->isVariadic();
53-
}
54-
55-
/**
56-
* Determines whether an argument has a default value.
57-
*
58-
* @param \ReflectionParameter $parameter
59-
*
60-
* @return bool
61-
*/
62-
private function hasDefaultValue(\ReflectionParameter $parameter)
63-
{
64-
return $parameter->isDefaultValueAvailable();
65-
}
66-
67-
/**
68-
* Returns a default value if available.
69-
*
70-
* @param \ReflectionParameter $parameter
71-
*
72-
* @return mixed|null
73-
*/
74-
private function getDefaultValue(\ReflectionParameter $parameter)
75-
{
76-
return $this->hasDefaultValue($parameter) ? $parameter->getDefaultValue() : null;
77-
}
78-
7943
/**
8044
* Returns an associated type to the given parameter if available.
8145
*
@@ -88,7 +52,7 @@ private function getType(\ReflectionParameter $parameter)
8852
if (!$type = $parameter->getType()) {
8953
return;
9054
}
91-
$typeName = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();
55+
$typeName = $type->getName();
9256
if ('array' === $typeName && !$type->isBuiltin()) {
9357
// Special case for HHVM with variadics
9458
return;

src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private function extractFromAccessor($class, $property)
195195
*/
196196
private function extractFromReflectionType(\ReflectionType $reflectionType)
197197
{
198-
$phpTypeOrClass = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : $reflectionType->__toString();
198+
$phpTypeOrClass = $reflectionType->getName();
199199
$nullable = $reflectionType->allowsNull();
200200

201201
if (Type::BUILTIN_TYPE_ARRAY === $phpTypeOrClass) {

src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNes
8787
$prefix = Caster::PREFIX_VIRTUAL;
8888

8989
$a += array(
90-
$prefix.'name' => $c instanceof \ReflectionNamedType ? $c->getName() : $c->__toString(),
90+
$prefix.'name' => $c->getName(),
9191
$prefix.'allowsNull' => $c->allowsNull(),
9292
$prefix.'isBuiltin' => $c->isBuiltin(),
9393
);
@@ -174,7 +174,7 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra
174174

175175
if (isset($a[$prefix.'returnType'])) {
176176
$v = $a[$prefix.'returnType'];
177-
$v = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
177+
$v = $v->getName();
178178
$a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType']->allowsNull() ? '?'.$v : $v, array(class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', ''));
179179
}
180180
if (isset($a[$prefix.'class'])) {
@@ -242,7 +242,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
242242
));
243243

244244
if ($v = $c->getType()) {
245-
$a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
245+
$a[$prefix.'typeHint'] = $v->getName();
246246
}
247247

248248
if (isset($a[$prefix.'typeHint'])) {

src/Symfony/Component/Yaml/Parser.php

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public function parse($value, $flags = 0)
9393
$this->refs = array();
9494

9595
$mbEncoding = null;
96-
$e = null;
9796
$data = null;
9897

9998
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
@@ -103,22 +102,15 @@ public function parse($value, $flags = 0)
103102

104103
try {
105104
$data = $this->doParse($value, $flags);
106-
} catch (\Exception $e) {
107-
} catch (\Throwable $e) {
108-
}
109-
110-
if (null !== $mbEncoding) {
111-
mb_internal_encoding($mbEncoding);
112-
}
113-
114-
$this->lines = array();
115-
$this->currentLine = '';
116-
$this->refs = array();
117-
$this->skippedLineNumbers = array();
118-
$this->locallySkippedLineNumbers = array();
119-
120-
if (null !== $e) {
121-
throw $e;
105+
} finally {
106+
if (null !== $mbEncoding) {
107+
mb_internal_encoding($mbEncoding);
108+
}
109+
$this->lines = array();
110+
$this->currentLine = '';
111+
$this->refs = array();
112+
$this->skippedLineNumbers = array();
113+
$this->locallySkippedLineNumbers = array();
122114
}
123115

124116
return $data;

0 commit comments

Comments
 (0)
0