diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 1370f1c838..22c889ecd7 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -136,7 +136,7 @@ abstract class Client */ public function getServerParameter($key, $default = '') { - return (isset($this->server[$key])) ? $this->server[$key] : $default; + return isset($this->server[$key]) ? $this->server[$key] : $default; } /** diff --git a/src/Symfony/Component/Console/Helper/TableHelper.php b/src/Symfony/Component/Console/Helper/TableHelper.php index 00814ecdd9..16aede1248 100644 --- a/src/Symfony/Component/Console/Helper/TableHelper.php +++ b/src/Symfony/Component/Console/Helper/TableHelper.php @@ -111,7 +111,7 @@ class TableHelper extends Helper default: throw new \InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout)); - }; + } return $this; } diff --git a/src/Symfony/Component/Console/Output/ConsoleOutput.php b/src/Symfony/Component/Console/Output/ConsoleOutput.php index 8e1f360141..f666c793e2 100644 --- a/src/Symfony/Component/Console/Output/ConsoleOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleOutput.php @@ -131,7 +131,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface PHP_OS, ); - return false !== stristr(implode(';', $checks), 'OS400'); + return false !== stripos(implode(';', $checks), 'OS400'); } /** diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index fb0e31911b..75de9c4fde 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -536,6 +536,6 @@ class Container implements IntrospectableContainerInterface */ public static function underscore($id) { - return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.'))); + return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), str_replace('_', '.', $id))); } } diff --git a/src/Symfony/Component/DependencyInjection/Extension/Extension.php b/src/Symfony/Component/DependencyInjection/Extension/Extension.php index f8e058bafd..20ea1002cb 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/Extension.php +++ b/src/Symfony/Component/DependencyInjection/Extension/Extension.php @@ -91,9 +91,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn $container->addResource(new FileResource($r->getFileName())); if (!method_exists($class, '__construct')) { - $configuration = new $class(); - - return $configuration; + return new $class(); } } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 95470ce7f7..b268cb9904 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -91,8 +91,9 @@ class XmlFileLoader extends FileLoader return; } + $defaultDirectory = dirname($file); foreach ($imports as $import) { - $this->setCurrentDir(dirname($file)); + $this->setCurrentDir($defaultDirectory); $this->import((string) $import['resource'], null, (bool) $import->getAttributeAsPhp('ignore-errors'), $file); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 440b46fa80..91adf2b78d 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -94,12 +94,13 @@ class YamlFileLoader extends FileLoader throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file)); } + $defaultDirectory = dirname($file); foreach ($content['imports'] as $import) { if (!is_array($import)) { throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file)); } - $this->setCurrentDir(dirname($file)); + $this->setCurrentDir($defaultDirectory); $this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file); } } diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 3ff72d28fb..4fe9f3485e 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -431,7 +431,7 @@ class Filesystem return strspn($file, '/\\', 0, 1) || (strlen($file) > 3 && ctype_alpha($file[0]) && substr($file, 1, 1) === ':' - && (strspn($file, '/\\', 2, 1)) + && strspn($file, '/\\', 2, 1) ) || null !== parse_url($file, PHP_URL_SCHEME) ; diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index bcf143099e..761be9673f 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -113,7 +113,7 @@ class HeaderBag implements \IteratorAggregate, \Countable */ public function get($key, $default = null, $first = true) { - $key = strtr(strtolower($key), '_', '-'); + $key = str_replace('_', '-', strtolower($key)); if (!array_key_exists($key, $this->headers)) { if (null === $default) { @@ -139,7 +139,7 @@ class HeaderBag implements \IteratorAggregate, \Countable */ public function set($key, $values, $replace = true) { - $key = strtr(strtolower($key), '_', '-'); + $key = str_replace('_', '-', strtolower($key)); $values = array_values((array) $values); @@ -163,7 +163,7 @@ class HeaderBag implements \IteratorAggregate, \Countable */ public function has($key) { - return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers); + return array_key_exists(str_replace('_', '-', strtolower($key)), $this->headers); } /** @@ -186,7 +186,7 @@ class HeaderBag implements \IteratorAggregate, \Countable */ public function remove($key) { - $key = strtr(strtolower($key), '_', '-'); + $key = str_replace('_', '-', strtolower($key)); unset($this->headers[$key]); diff --git a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index a0a3f63080..37635c2e63 100644 --- a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -99,7 +99,7 @@ class ResponseHeaderBag extends HeaderBag { parent::set($key, $values, $replace); - $uniqueKey = strtr(strtolower($key), '_', '-'); + $uniqueKey = str_replace('_', '-', strtolower($key)); $this->headerNames[$uniqueKey] = $key; // ensure the cache-control header has sensible defaults @@ -118,7 +118,7 @@ class ResponseHeaderBag extends HeaderBag { parent::remove($key); - $uniqueKey = strtr(strtolower($key), '_', '-'); + $uniqueKey = str_replace('_', '-', strtolower($key)); unset($this->headerNames[$uniqueKey]); if ('cache-control' === $uniqueKey) { diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index 8437af995a..9082b3e304 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -181,7 +181,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface foreach ($finder as $file) { $ns = $prefix; if ($relativePath = $file->getRelativePath()) { - $ns .= '\\'.strtr($relativePath, '/', '\\'); + $ns .= '\\'.str_replace('/', '\\', $relativePath); } $r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php')); if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index 41cfa86f53..c37cc459ea 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -38,10 +38,8 @@ class Store implements StoreInterface public function __construct($root) { $this->root = $root; - if (!is_dir($this->root)) { - if (false === @mkdir($this->root, 0777, true) && !is_dir($this->root)) { - throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); - } + if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) { + throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); } $this->keyCache = new \SplObjectStorage(); $this->locks = array(); @@ -249,10 +247,8 @@ class Store implements StoreInterface } } - if ($modified) { - if (false === $this->save($key, serialize($entries))) { - throw new \RuntimeException('Unable to store the metadata.'); - } + if ($modified && false === $this->save($key, serialize($entries))) { + throw new \RuntimeException('Unable to store the metadata.'); } } @@ -273,7 +269,7 @@ class Store implements StoreInterface } foreach (preg_split('/[\s,]+/', $vary) as $header) { - $key = strtr(strtolower($header), '_', '-'); + $key = str_replace('_', '-', strtolower($header)); $v1 = isset($env1[$key]) ? $env1[$key] : null; $v2 = isset($env2[$key]) ? $env2[$key] : null; if ($v1 !== $v2) { diff --git a/src/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php index a545e6b44b..da50cedb15 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php @@ -187,9 +187,8 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface $stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); } $stmt->execute(); - $return = $stmt->fetchAll(\PDO::FETCH_ASSOC); - return $return; + return $stmt->fetchAll(\PDO::FETCH_ASSOC); } protected function close($db) diff --git a/src/Symfony/Component/HttpKernel/UriSigner.php b/src/Symfony/Component/HttpKernel/UriSigner.php index 5a96ef2228..b56da28d3e 100644 --- a/src/Symfony/Component/HttpKernel/UriSigner.php +++ b/src/Symfony/Component/HttpKernel/UriSigner.php @@ -51,7 +51,7 @@ class UriSigner $uri = $this->buildUrl($url, $params); - return $uri.(false === (strpos($uri, '?')) ? '?' : '&').'_hash='.$this->computeHash($uri); + return $uri.(false === strpos($uri, '?') ? '?' : '&').'_hash='.$this->computeHash($uri); } /** diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 5270df26f3..3b9b49490d 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -442,11 +442,11 @@ class PropertyAccessor implements PropertyAccessorInterface } foreach ($itemToRemove as $item) { - call_user_func(array($object, $access[self::ACCESS_REMOVER]), $item); + $object->{$access[self::ACCESS_REMOVER]}($item); } foreach ($itemsToAdd as $item) { - call_user_func(array($object, $access[self::ACCESS_ADDER]), $item); + $object->{$access[self::ACCESS_ADDER]}($item); } } elseif (!$access[self::ACCESS_HAS_PROPERTY] && property_exists($object, $property)) { // Needed to support \stdClass instances. We need to explicitly diff --git a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php index 5e1159f733..4e5766756f 100644 --- a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php @@ -172,10 +172,8 @@ class DigestData throw new BadCredentialsException(sprintf('Missing mandatory digest value; received header "%s" (%s)', $this->header, implode(', ', $keys))); } - if ('auth' === $this->elements['qop']) { - if (!isset($this->elements['nc']) || !isset($this->elements['cnonce'])) { - throw new BadCredentialsException(sprintf('Missing mandatory digest value; received header "%s"', $this->header)); - } + if ('auth' === $this->elements['qop'] && !isset($this->elements['nc'], $this->elements['cnonce'])) { + throw new BadCredentialsException(sprintf('Missing mandatory digest value; received header "%s"', $this->header)); } if ($expectedRealm !== $this->elements['realm']) { diff --git a/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php b/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php index 4b42a92ee9..ba63a4c530 100644 --- a/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php @@ -30,8 +30,8 @@ class IcuResFileDumper implements DumperInterface } // save a file for each domain + $file = $messages->getLocale().'.'.$this->getExtension(); foreach ($messages->getDomains() as $domain) { - $file = $messages->getLocale().'.'.$this->getExtension(); $path = $options['path'].'/'.$domain.'/'; if (!is_dir($path) && !@mkdir($path) && !is_dir($path)) { diff --git a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php index 1ebb68a49d..6275d1c547 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php @@ -190,7 +190,7 @@ class XmlFileLoader extends FileLoader */ private function loadClassMetadataFromXml(ClassMetadata $metadata, $classDescription) { - foreach ($classDescription->{'group-sequence-provider'} as $_) { + if (count($classDescription->{'group-sequence-provider'}) > 0) { $metadata->setGroupSequenceProvider(true); }