8000 CS Fixes by chalasr · Pull Request #22844 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

CS Fixes #22844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2017
Merged

CS Fixes #22844

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function ($key, $value, $isHit) {
}

/**
* This adapter to take advantage of how PHP stores arrays in its latest versions.
* This adapter takes advantage of how PHP stores arrays in its latest versions.
*
* @param string $file The PHP file were values are cached
* @param CacheItemPoolInterface $fallbackPool Fallback when opcache is disabled
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Simple/PhpArrayCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct($file, CacheInterface $fallbackPool)
}

/**
* This adapter to take advantage of how PHP stores arrays in its latest versions.
* This adapter takes advantage of how PHP stores arrays in its latest versions.
*
* @param string $file The PHP file were values are cached
*
Expand Down
22 changes: 6 additions & 16 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,10 @@ public function doRun(InputInterface $input, OutputInterface $output)
}

try {
$e = $this->runningCommand = null;
$this->runningCommand = null;
// the command name MUST be the first element of the input
$command = $this->find($name);
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
if (null !== $e) {
if (null !== $this->dispatcher) {
$event = new ConsoleErrorEvent($input, $output, $e);
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
Expand Down Expand Up @@ -813,24 +810,17 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
} else {
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
if (null !== $e) {
$event = new ConsoleErrorEvent($input, $output, $e, $command);
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
$e = $event->getError();

if (0 === $exitCode = $event->getExitCode()) {
$e = null;
if (0 !== $exitCode = $event->getExitCode()) {
throw $e;
}
}

$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);

if (null !== $e) {
throw $e;
} finally {
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
}

return $event->getExitCode();
Expand Down
4 changes: 0 additions & 4 deletions src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ public function handleException($exception, array $error = null)
if ($this->loggedErrors & $type) {
try {
$this->loggers[$type][0]->log($this->loggers[$type][1], $message, array('exception' => $exception));
} catch (\Exception $handlerException) {
} catch (\Throwable $handlerException) {
}
}
Expand All @@ -558,7 +557,6 @@ public function handleException($exception, array $error = null)
}
try {
call_user_func($this->exceptionHandler, $exception);
} catch (\Exception $handlerException) {
} catch (\Throwable $handlerException) {
}
if (isset($handlerException)) {
Expand Down Expand Up @@ -598,8 +596,6 @@ public static function handleFatalError(array $error = null)
while (self::$stackedErrorLevels) {
static::unstackErrors();
}
} catch (\Exception $exception) {
// Handled below
} catch (\Throwable $exception) {
// Handled below
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function updateDefinition(ContainerBuilder $container, $id, Definition $

$returnType = $m->getReturnType();
if (null !== $returnType && !$returnType->isBuiltin()) {
$returnType = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : $returnType->__toString();
$returnType = $returnType->getName();
if (null !== $class) {
$declaringClass = $m->getDeclaringClass()->getName();
if ('self' === strtolower($returnType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa
return;
}
if (!is_string($type)) {
$name = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();
$name = $type->getName();

if ($type->isBuiltin()) {
return $noBuiltin ? null : $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,12 @@ public function createArgumentMetadata($controller)
}

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

return $arguments;
}

/**
* Returns whether an argument is variadic.
*
* @param \ReflectionParameter $parameter
*
* @return bool
*/
private function isVariadic(\ReflectionParameter $parameter)
{
return $parameter->isVariadic();
}

/**
* Determines whether an argument has a default value.
*
* @param \ReflectionParameter $parameter
*
* @return bool
*/
private function hasDefaultValue(\ReflectionParameter $parameter)
{
return $parameter->isDefaultValueAvailable();
}

/**
* Returns a default value if available.
*
* @param \ReflectionParameter $parameter
*
* @return mixed|null
*/
private function getDefaultValue(\ReflectionParameter $parameter)
{
return $this->hasDefaultValue($parameter) ? $parameter->getDefaultValue() : null;
}

/**
* Returns an associated type to the given parameter if available.
*
Expand All @@ -88,7 +52,7 @@ private function getType(\ReflectionParameter $parameter)
if (!$type = $parameter->getType()) {
return;
}
$typeName = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReflectionType::__toString() is deprecated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right - and there are more of it in the code base, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, all fixed. addressed your other comments also

$typeName = $type->getName();
if ('array' === $typeName && !$type->isBuiltin()) {
// Special case for HHVM with variadics
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private function extractFromAccessor($class, $property)
*/
private function extractFromReflectionType(\ReflectionType $reflectionType)
{
$phpTypeOrClass = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : $reflectionType->__toString();
$phpTypeOrClass = $reflectionType->getName();
$nullable = $reflectionType->allowsNull();

if (Type::BUILTIN_TYPE_ARRAY === $phpTypeOrClass) {
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNes
$prefix = Caster::PREFIX_VIRTUAL;

$a += array(
$prefix.'name' => $c instanceof \ReflectionNamedType ? $c->getName() : $c->__toString(),
$prefix.'name' => $c->getName(),
$prefix.'allowsNull' => $c->allowsNull(),
$prefix.'isBuiltin' => $c->isBuiltin(),
);
Expand Down Expand Up @@ -174,7 +174,7 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra

if (isset($a[$prefix.'returnType'])) {
$v = $a[$prefix.'returnType'];
$v = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
$v = $v->getName();
$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 : '', ''));
}
if (isset($a[$prefix.'class'])) {
Expand Down Expand Up @@ -242,7 +242,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
));

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

if (isset($a[$prefix.'typeHint'])) {
Expand Down
26 changes: 9 additions & 17 deletions src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public function parse($value, $flags = 0)
$this->refs = array();

$mbEncoding = null;
$e = null;
$data = null;

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

try {
$data = $this->doParse($value, $flags);
} catch (\Exception $e) {
} catch (\Throwable $e) {
}

if (null !== $mbEncoding) {
mb_internal_encoding($mbEncoding);
}

$this->lines = array();
$this->currentLine = '';
$this->refs = array();
$this->skippedLineNumbers = array();
$this->locallySkippedLineNumbers = array();

if (null !== $e) {
throw $e;
} finally {
if (null !== $mbEncoding) {
mb_internal_encoding($mbEncoding);
}
$this->lines = array();
$this->currentLine = '';
$this->refs = array();
$this->skippedLineNumbers = array();
$this->locallySkippedLineNumbers = array();
}

return $data;
Expand Down
0