8000 [2.3] Static Code Analysis for Components · enumag/symfony@81f8181 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81f8181

Browse files
kalessilfabpot
authored andcommitted
[2.3] Static Code Analysis for Components
1 parent 707d359 commit 81f8181

File tree

18 files changed

+30
-37
lines changed

18 files changed

+30
-37
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function setServerParameter($key, $value)
136136
*/
137137
public function getServerParameter($key, $default = '')
138138
{
139-
return (isset($this->server[$key])) ? $this->server[$key] : $default;
139+
return isset($this->server[$key]) ? $this->server[$key] : $default;
140140
}
141141

142142
/**

src/Symfony/Component/Console/Helper/TableHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function setLayout($layout)
111111

112112
default:
113113
throw new \InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
114-
};
114+
}
115115

116116
return $this;
117117
}

src/Symfony/Component/Console/Output/ConsoleOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function_exists('php_uname') ? php_uname('s') : '',
131131
PHP_OS,
132132
);
133133

134-
return false !== stristr(implode(';', $checks), 'OS400');
134+
return false !== stripos(implode(';', $checks), 'OS400');
135135
}
136136

137137
/**

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,6 @@ public static function camelize($id)
536536
*/
537537
public static function underscore($id)
538538
{
539-
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.')));
539+
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), str_replace('_', '.', $id)));
540540
}
541541
}

src/Symfony/Component/DependencyInjection/Extension/Extension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ public function getConfiguration(array $config, ContainerBuilder $container)
9191
$container->addResource(new FileResource($r->getFileName()));
9292

9393
if (!method_exists($class, '__construct')) {
94-
$configuration = new $class();
95-
96-
return $configuration;
94+
return new $class();
9795
}
9896
}
9997
}

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ private function parseImports(SimpleXMLElement $xml, $file)
9191
return;
9292
}
9393

94+
$defaultDirectory = dirname($file);
9495
foreach ($imports as $import) {
95-
$this->setCurrentDir(dirname($file));
96+
$this->setCurrentDir($defaultDirectory);
9697
$this->import((string) $import['resource'], null, (bool) $import->getAttributeAsPhp('ignore-errors'), $file);
9798
}
9899
}

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ private function parseImports($content, $file)
9494
throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file));
9595
}
9696

97+
$defaultDirectory = dirname($file);
9798
foreach ($content['imports'] as $import) {
9899
if (!is_array($import)) {
99100
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
100101
}
101102

102-
$this->setCurrentDir(dirname($file));
103+
$this->setCurrentDir($defaultDirectory);
103104
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
104105
}
105106
}

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public function isAbsolutePath($file)
431431
return strspn($file, '/\\', 0, 1)
432432
|| (strlen($file) > 3 && ctype_alpha($file[0])
433433
&& substr($file, 1, 1) === ':'
434-
&& (strspn($file, '/\\', 2, 1))
434+
&& strspn($file, '/\\', 2, 1)
435435
)
436436
|| null !== parse_url($file, PHP_URL_SCHEME)
437437
;

src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function add(array $headers)
113113
*/
114114
public function get($key, $default = null, $first = true)
115115
{
116-
$key = strtr(strtolower($key), '_', '-');
116+
$key = str_replace('_', '-', strtolower($key));
117117

118118
if (!array_key_exists($key, $this->headers)) {
119119
if (null === $default) {
@@ -139,7 +139,7 @@ public function get($key, $default = null, $first = true)
139139
*/
140140
public function set($key, $values, $replace = true)
141141
{
142-
$key = strtr(strtolower($key), '_', '-');
142+
$key = str_replace('_', '-', strtolower($key));
143143

144144
$values = array_values((array) $values);
145145

@@ -163,7 +163,7 @@ public function set($key, $values, $replace = true)
163163
*/
164164
public function has($key)
165165
{
166-
return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers);
166+
return array_key_exists(str_replace('_', '-', strtolower($key)), $this->headers);
167167
}
168168

169169
/**
@@ -186,7 +186,7 @@ public function contains($key, $value)
186186
*/
187187
public function remove($key)
188188
{
189-
$key = strtr(strtolower($key), '_', '-');
189+
$key = str_replace('_', '-', strtolower($key));
190190

191191
unset($this->headers[$key]);
192192

src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function set($key, $values, $replace = true)
9999
{
100100
parent::set($key, $values, $replace);
101101

102-
$uniqueKey = strtr(strtolower($key), '_', '-');
102+
$uniqueKey = str_replace('_', '-', strtolower($key));
103103
$this->headerNames[$uniqueKey] = $key;
104104

105105
// ensure the cache-control header has sensible defaults
@@ -118,7 +118,7 @@ public function remove($key)
118118
{
119119
parent::remove($key);
120120

121-
$uniqueKey = strtr(strtolower($key), '_', '-');
121+
$uniqueKey = str_replace('_', '-', strtolower($key));
122122
unset($this->headerNames[$uniqueKey]);
123123

124124
if ('cache-control' === $uniqueKey) {

0 commit comments

Comments
 (0)
0