diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
index fe36436c71..4e8b817f77 100644
--- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
+++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
@@ -84,7 +84,7 @@ class TwigExtractor implements ExtractorInterface
$this->twig->parse($this->twig->tokenize($template));
foreach ($visitor->getMessages() as $message) {
- $catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ? $message[1] : $this->defaultDomain);
+ $catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
}
$visitor->disable();
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
index d4c8738844..a55bbb9895 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
@@ -305,7 +305,7 @@ EOF
$synthetic = $definition->isSynthetic() ? 'yes' : 'no';
$output->writeln(sprintf('Synthetic %s', $synthetic));
- $file = $definition->getFile() ? $definition->getFile() : '-';
+ $file = $definition->getFile() ?: '-';
$output->writeln(sprintf('Required File %s', $file));
} elseif ($definition instanceof Alias) {
$alias = $definition;
diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php
index 7d66799c08..34ad20e459 100644
--- a/src/Symfony/Component/Config/Util/XmlUtils.php
+++ b/src/Symfony/Component/Config/Util/XmlUtils.php
@@ -191,17 +191,17 @@ class XmlUtils
return;
case ctype_digit($value):
$raw = $value;
- $cast = intval($value);
+ $cast = (int) $value;
- return '0' == $value[0] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
+ return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
case 'true' === $lowercaseValue:
return true;
case 'false' === $lowercaseValue:
return false;
case is_numeric($value):
- return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
+ return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;
case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value):
- return floatval($value);
+ return (float) $value;
default:
return $value;
}
diff --git a/src/Symfony/Component/Console/Helper/ProgressHelper.php b/src/Symfony/Component/Console/Helper/ProgressHelper.php
index e927fe3b10..7d80107909 100644
--- a/src/Symfony/Component/Console/Helper/ProgressHelper.php
+++ b/src/Symfony/Component/Console/Helper/ProgressHelper.php
@@ -235,11 +235,11 @@ class ProgressHelper extends Helper
$redraw = true;
}
- $prevPeriod = intval($this->current / $this->redrawFreq);
+ $prevPeriod = (int) ($this->current / $this->redrawFreq);
$this->current += $step;
- $currPeriod = intval($this->current / $this->redrawFreq);
+ $currPeriod = (int) ($this->current / $this->redrawFreq);
if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
$this->display();
}
@@ -269,11 +269,11 @@ class ProgressHelper extends Helper
$redraw = true;
}
- $prevPeriod = intval($this->current / $this->redrawFreq);
+ $prevPeriod = (int) ($this->current / $this->redrawFreq);
$this->current = $current;
- $currPeriod = intval($this->current / $this->redrawFreq);
+ $currPeriod = (int) ($this->current / $this->redrawFreq);
if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
$this->display();
}
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
index e152b9af2f..c12a60d2b9 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
@@ -1341,13 +1341,13 @@ EOF;
if ('' === $name) {
$name .= $firstChars[$i%$firstCharsLength];
- $i = intval($i/$firstCharsLength);
+ $i = (int) ($i/$firstCharsLength);
}
while ($i > 0) {
--$i;
$name .= $nonFirstChars[$i%$nonFirstCharsLength];
- $i = intval($i/$nonFirstCharsLength);
+ $i = (int) ($i/$nonFirstCharsLength);
}
++$this->variableCount;
diff --git a/src/Symfony/Component/DomCrawler/Link.php b/src/Symfony/Component/DomCrawler/Link.php
index 863a6383d6..86ed2bedcd 100644
--- a/src/Symfony/Component/DomCrawler/Link.php
+++ b/src/Symfony/Component/DomCrawler/Link.php
@@ -154,7 +154,7 @@ class Link
}
if ('.' === substr($path, -1)) {
- $path = $path.'/';
+ $path .= '/';
}
$output = array();
diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php
index 4f8caecb38..940cb5b999 100644
--- a/src/Symfony/Component/Finder/Finder.php
+++ b/src/Symfony/Component/Finder/Finder.php
@@ -436,9 +436,9 @@ class Finder implements \IteratorAggregate, \Countable
public function ignoreDotFiles($ignoreDotFiles)
{
if ($ignoreDotFiles) {
- $this->ignore = $this->ignore | static::IGNORE_DOT_FILES;
+ $this->ignore |= static::IGNORE_DOT_FILES;
} else {
- $this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES;
+ $this->ignore &= ~static::IGNORE_DOT_FILES;
}
return $this;
@@ -458,9 +458,9 @@ class Finder implements \IteratorAggregate, \Countable
public function ignoreVCS($ignoreVCS)
{
if ($ignoreVCS) {
- $this->ignore = $this->ignore | static::IGNORE_VCS_FILES;
+ $this->ignore |= static::IGNORE_VCS_FILES;
} else {
- $this->ignore = $this->ignore & ~static::IGNORE_VCS_FILES;
+ $this->ignore &= ~static::IGNORE_VCS_FILES;
}
return $this;
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
index 5520119fdf..418661aebe 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
@@ -131,7 +131,7 @@ class ChoiceType extends AbstractType
// Add "[]" to the name in case a select tag with multiple options is
// displayed. Otherwise only one of the selected options is sent in the
// POST request.
- $view->vars['full_name'] = $view->vars['full_name'].'[]';
+ $view->vars['full_name'] .= '[]';
}
}
diff --git a/src/Symfony/Component/Form/Util/ServerParams.php b/src/Symfony/Component/Form/Util/ServerParams.php
index 3b1f835182..9b9c02d393 100644
--- a/src/Symfony/Component/Form/Util/ServerParams.php
+++ b/src/Symfony/Component/Form/Util/ServerParams.php
@@ -35,7 +35,7 @@ class ServerParams
} elseif (0 === strpos($max, '0')) {
$max = intval($max, 8);
} else {
- $max = intval($max);
+ $max = (int) $max;
}
switch (substr($iniMax, -1)) {
diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php
index 98b1176063..24d03437d4 100644
--- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php
+++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php
@@ -270,7 +270,7 @@ class UploadedFile extends File
} elseif (0 === strpos($max, '0')) {
$max = intval($max, 8);
} else {
- $max = intval($max);
+ $max = (int) $max;
}
switch (substr($iniMax, -1)) {
diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php
index 8a66e94567..f6c319c9ed 100644
--- a/src/Symfony/Component/HttpFoundation/Request.php
+++ b/src/Symfony/Component/HttpFoundation/Request.php
@@ -975,7 +975,7 @@ class Request
}
if (false !== $pos) {
- return intval(substr($host, $pos + 1));
+ return (int) substr($host, $pos + 1);
}
return 'https' === $this->getScheme() ? 443 : 80;
diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php
index fa80ccc2af..3db864db8a 100644
--- a/src/Symfony/Component/HttpFoundation/Response.php
+++ b/src/Symfony/Component/HttpFoundation/Response.php
@@ -1195,7 +1195,7 @@ class Response
protected function ensureIEOverSSLCompatibility(Request $request)
{
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
- if (intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) {
+ if ((int) preg_replace("/(MSIE )(.*?);/", "$2", $match[0]) < 9) {
$this->headers->remove('Cache-Control');
}
}
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php
index 9e1a310cb9..a3738b6de0 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php
@@ -86,7 +86,7 @@ class MemoryDataCollector extends DataCollector
} elseif (0 === strpos($max, '0')) {
$max = intval($max, 8);
} else {
- $max = intval($max);
+ $max = (int) $max;
}
switch (substr($memoryLimit, -1)) {
diff --git a/src/Symfony/Component/OptionsResolver/Options.php b/src/Symfony/Component/OptionsResolver/Options.php
index a341ecc94d..e6da18c764 100644
--- a/src/Symfony/Component/OptionsResolver/Options.php
+++ b/src/Symfony/Component/OptionsResolver/Options.php
@@ -92,8 +92,7 @@ class Options implements \ArrayAccess, \Iterator, \Countable
// Setting is equivalent to overloading while discarding the previous
// option value
- unset($this->options[$option]);
- unset($this->lazy[$option]);
+ unset($this->options[$option], $this->lazy[$option]);
$this->overload($option, $value);
}
@@ -270,9 +269,7 @@ class Options implements \ArrayAccess, \Iterator, \Countable
throw new OptionDefinitionException('Options cannot be removed anymore once options have been read.');
}
- unset($this->options[$option]);
- unset($this->lazy[$option]);
- unset($this->normalizers[$option]);
+ unset($this->options[$option], $this->lazy[$option], $this->normalizers[$option]);
}
/**
@@ -470,10 +467,8 @@ class Options implements \ArrayAccess, \Iterator, \Countable
foreach ($this->lazy[$option] as $closure) {
$this->options[$option] = $closure($this, $this->options[$option]);
}
- unset($this->lock[$option]);
-
// The option now isn't lazy anymore
- unset($this->lazy[$option]);
+ unset($this->lock[$option], $this->lazy[$option]);
}
/**
@@ -509,9 +504,7 @@ class Options implements \ArrayAccess, \Iterator, \Countable
$this->lock[$option] = true;
$this->options[$option] = $normalizer($this, array_key_exists($option, $this->options) ? $this->options[$option] : null);
- unset($this->lock[$option]);
-
// The option is now normalized
- unset($this->normalizers[$option]);
+ unset($this->lock[$option], $this->normalizers[$option]);
}
}
diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php
index f1b8afffb5..a710bf75e7 100644
--- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php
+++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php
@@ -242,7 +242,7 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf
if (null === $propertyChanges['parentAcl'][1]) {
$sets[] = 'parent_object_identity_id = NULL';
} else {
- $sets[] = 'parent_object_identity_id = '.intval($propertyChanges['parentAcl'][1]->getId());
+ $sets[] = 'parent_object_identity_id = '.(int) $propertyChanges['parentAcl'][1]->getId();
}
$this->regenerateAncestorRelations($acl);
@@ -453,7 +453,7 @@ QUERY;
$query,
$this->options['entry_table_name'],
$classId,
- null === $objectIdentityId ? 'NULL' : intval($objectIdentityId),
+ null === $objectIdentityId ? 'NULL' : (int) $objectIdentityId,
null === $field ? 'NULL' : $this->connection->quote($field),
$aceOrder,
$securityIdentityId,
@@ -571,7 +571,7 @@ QUERY;
$classId,
null === $oid ?
$this->connection->getDatabasePlatform()->getIsNullExpression('object_identity_id')
- : 'object_identity_id = '.intval($oid),
+ : 'object_identity_id = '.(int) $oid,
null === $field ?
$this->connection->getDatabasePlatform()->getIsNullExpression('field_name')
: 'field_name = '.$this->connection->quote($field),
@@ -812,7 +812,7 @@ QUERY;
$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
$aceIdProperty->setAccessible(true);
- $aceIdProperty->setValue($ace, intval($aceId));
+ $aceIdProperty->setValue($ace, (int) $aceId);
} else {
$currentIds[$ace->getId()] = true;
}
@@ -888,7 +888,7 @@ QUERY;
$aceIdProperty = new \ReflectionProperty($ace, 'id');
$aceIdProperty->setAccessible(true);
- $aceIdProperty->setValue($ace, intval($aceId));
+ $aceIdProperty->setValue($ace, (int) $aceId);
}
}
}
diff --git a/src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php b/src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php
index 71a6313ae4..5a7aa1abee 100644
--- a/src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php
+++ b/src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php
@@ -50,7 +50,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac
$authenticateHeader = sprintf('Digest realm="%s", qop="auth", nonce="%s"', $this->realmName, $nonceValueBase64);
if ($authException instanceof NonceExpiredException) {
- $authenticateHeader = $authenticateHeader.', stale="true"';
+ $authenticateHeader .= ', stale="true"';
}
if (null !== $this->logger) {
diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php
index 4f246960f3..40e4f743af 100644
--- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php
+++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php
@@ -81,7 +81,7 @@ class IsbnValidator extends ConstraintValidator
return false;
}
- $checkSum += $digit * intval(10 - $i);
+ $checkSum += $digit * (10 - $i);
}
return 0 === $checkSum % 11;
diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php
index ab7c72e405..6564ad4422 100644
--- a/src/Symfony/Component/Yaml/Inline.php
+++ b/src/Symfony/Component/Yaml/Inline.php
@@ -125,7 +125,7 @@ class Inline
if (false !== $locale) {
setlocale(LC_NUMERIC, 'C');
}
- $repr = is_string($value) ? "'$value'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : strval($value));
+ $repr = is_string($value) ? "'$value'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', (string) $value) : (string) $value);
if (false !== $locale) {
setlocale(LC_NUMERIC, $locale);
@@ -157,8 +157,9 @@ class Inline
{
// array
$keys = array_keys($value);
- if ((1 == count($keys) && '0' == $keys[0])
- || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
+ $keysCount = count($keys);
+ if ((1 === $keysCount && '0' == $keys[0])
+ || ($keysCount > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) === $keysCount * ($keysCount - 1) / 2)
) {
$output = array();
foreach ($value as $val) {
@@ -431,7 +432,7 @@ class Inline
case 0 === strpos($scalar, '!str'):
return (string) substr($scalar, 5);
case 0 === strpos($scalar, '! '):
- return intval(self::parseScalar(substr($scalar, 2)));
+ return (int) self::parseScalar(substr($scalar, 2));
case 0 === strpos($scalar, '!!php/object:'):
if (self::$objectSupport) {
return unserialize(substr($scalar, 13));
@@ -444,23 +445,23 @@ class Inline
return;
case ctype_digit($scalar):
$raw = $scalar;
- $cast = intval($scalar);
+ $cast = (int) $scalar;
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
$raw = $scalar;
- $cast = intval($scalar);
+ $cast = (int) $scalar;
- return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
+ return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
case is_numeric($scalar):
- return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
+ return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
case '.inf' === $scalarLower:
case '.nan' === $scalarLower:
return -log(0);
case '-.inf' === $scalarLower:
return log(0);
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
- return floatval(str_replace(',', '', $scalar));
+ return (float) str_replace(',', '', $scalar);
case preg_match(self::getTimestampRegex(), $scalar):
return strtotime($scalar);
}
diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php
index 6b2cc72aed..f815931507 100644
--- a/src/Symfony/Component/Yaml/Parser.php
+++ b/src/Symfony/Component/Yaml/Parser.php
@@ -423,7 +423,7 @@ class Parser
if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) {
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
- return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
+ return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
}
try {