Skip to content

Commit 23ad5f0

Browse files
committed
minor #17282 [2.3] Static Code Analysis for Components (kalessil)
This PR was squashed before being merged into the 2.3 branch (closes #17282). Discussion ---------- [2.3] Static Code Analysis for Components | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Static Code Analysis with Php Inspections (EA Extended): - several code constructs simplification - decoupling statements from foreach - extra colons/parenthesis removal (code style) - correct string functions usage (micro-optimization) - variable functions usage (php 5 compatible) Commits ------- 81f8181 [2.3] Static Code Analysis for Components
2 parents 6af5ffd + ae64649 commit 23ad5f0

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

Bundle/Bundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function registerCommands(Application $application)
181181
foreach ($finder as $file) {
182182
$ns = $prefix;
183183
if ($relativePath = $file->getRelativePath()) {
184-
$ns .= '\\'.strtr($relativePath, '/', '\\');
184+
$ns .= '\\'.str_replace('/', '\\', $relativePath);
185185
}
186186
$r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php'));
187187
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {

HttpCache/Store.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ class Store implements StoreInterface
3838
public function __construct($root)
3939
{
4040
$this->root = $root;
41-
if (!is_dir($this->root)) {
42-
if (false === @mkdir($this->root, 0777, true) && !is_dir($this->root)) {
43-
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
44-
}
41+
if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
42+
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
4543
}
4644
$this->keyCache = new \SplObjectStorage();
4745
$this->locks = array();
@@ -249,10 +247,8 @@ public function invalidate(Request $request)
249247
}
250248
}
251249

252-
if ($modified) {
253-
if (false === $this->save($key, serialize($entries))) {
254-
throw new \RuntimeException('Unable to store the metadata.');
255-
}
250+
if ($modified && false === $this->save($key, serialize($entries))) {
251+
throw new \RuntimeException('Unable to store the metadata.');
256252
}
257253
}
258254

@@ -273,7 +269,7 @@ private function requestsMatch($vary, $env1, $env2)
273269
}
274270

275271
foreach (preg_split('/[\s,]+/', $vary) as $header) {
276-
$key = strtr(strtolower($header), '_', '-');
272+
$key = str_replace('_', '-', strtolower($header));
277273
$v1 = isset($env1[$key]) ? $env1[$key] : null;
278274
$v2 = isset($env2[$key]) ? $env2[$key] : null;
279275
if ($v1 !== $v2) {

Profiler/PdoProfilerStorage.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,8 @@ protected function fetch($db, $query, array $args = array())
187187
$stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR);
188188
}
189189
$stmt->execute();
190-
$return = $stmt->fetchAll(\PDO::FETCH_ASSOC);
191190

192-
return $return;
191+
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
193192
}
194193

195194
protected function close($db)

UriSigner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function sign($uri)
5151

5252
$uri = $this->buildUrl($url, $params);
5353

54-
return $uri.(false === (strpos($uri, '?')) ? '?' : '&').'_hash='.$this->computeHash($uri);
54+
return $uri.(false === strpos($uri, '?') ? '?' : '&').'_hash='.$this->computeHash($uri);
5555
}
5656

5757
/**

0 commit comments

Comments
 (0)