Skip to content

Commit c85e512

Browse files
committed
Merge pull request #97 from kalessil/master
Static Code Analysis with Php Inspections (EA Extended)
2 parents 49b5ee6 + b484e80 commit c85e512

File tree

63 files changed

+336
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+336
-351
lines changed

lib/addon/sfPager.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function getPreviousPage()
380380
*/
381381
public function setPage($page)
382382
{
383-
$this->page = intval($page);
383+
$this->page = (int) $page;
384384

385385
if ($this->page <= 0)
386386
{

lib/cache/sfFileCache.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function has($key)
8383
*/
8484
public function set($key, $data, $lifetime = null)
8585
{
86-
if ($this->getOption('automatic_cleaning_factor') > 0 && rand(1, $this->getOption('automatic_cleaning_factor')) == 1)
86+
if ($this->getOption('automatic_cleaning_factor') > 0 && mt_rand(1, $this->getOption('automatic_cleaning_factor')) == 1)
8787
{
8888
$this->clean(sfCache::OLD);
8989
}
@@ -235,12 +235,12 @@ protected function read($path, $type = self::READ_DATA)
235235
}
236236

237237
@flock($fp, LOCK_SH);
238-
$data[self::READ_TIMEOUT] = intval(@stream_get_contents($fp, 12, 0));
238+
$data[self::READ_TIMEOUT] = (int) @stream_get_contents($fp, 12, 0);
239239
if ($type != self::READ_TIMEOUT && time() < $data[self::READ_TIMEOUT])
240240
{
241241
if ($type & self::READ_LAST_MODIFIED)
242242
{
243-
$data[self::READ_LAST_MODIFIED] = intval(@stream_get_contents($fp, 12, 12));
243+
$data[self::READ_LAST_MODIFIED] = (int) @stream_get_contents($fp, 12, 12);
244244
}
245245
if ($type & self::READ_DATA)
246246
{

lib/cache/sfMemcacheCache.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the symfony package.
55
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6-
*
6+
*
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
@@ -60,7 +60,7 @@ public function initialize($options = array())
6060
foreach ($this->getOption('servers') as $server)
6161
{
6262
$port = isset($server['port']) ? $server['port'] : 11211;
63-
if (!$this->memcache->addServer($server['host'], $port, isset($server['persistent']) ? $server['persistent'] : true))
63+
if (!$this->memcache->addserver($server['host'], $port, isset($server['persistent']) ? $server['persistent'] : true))
6464
{
6565
throw new sfInitializationException(sprintf('Unable to connect to the memcache server (%s:%s).', $server['host'], $port));
6666
}

lib/cache/sfSQLiteCache.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function has($key)
9494
*/
9595
public function set($key, $data, $lifetime = null)
9696
{
97-
if ($this->getOption('automatic_cleaning_factor') > 0 && rand(1, $this->getOption('automatic_cleaning_factor')) == 1)
97+
if ($this->getOption('automatic_cleaning_factor') > 0 && mt_rand(1, $this->getOption('automatic_cleaning_factor')) == 1)
9898
{
9999
$this->clean(sfCache::OLD);
100100
}
@@ -167,7 +167,7 @@ public function getTimeout($key)
167167

168168
$rs = $this->dbh->query(sprintf("SELECT timeout FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time()));
169169

170-
return $rs->numRows() ? intval($rs->fetchSingle()) : 0;
170+
return $rs->numRows() ? (int) $rs->fetchSingle() : 0;
171171
}
172172

173173
/**
@@ -184,7 +184,7 @@ public function getLastModified($key)
184184

185185
$rs = $this->dbh->query(sprintf("SELECT last_modified FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time()));
186186

187-
return $rs->numRows() ? intval($rs->fetchSingle()) : 0;
187+
return $rs->numRows() ? (int) $rs->fetchSingle() : 0;
188188
}
189189

190190
/**

lib/config/sfAutoloadConfigHandler.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static public function getConfiguration(array $configFiles)
160160
foreach ($configFiles as $i => $configFile)
161161
{
162162
$configFilePath = str_replace(DIRECTORY_SEPARATOR, '/', $configFile);
163-
$path = str_replace(DIRECTORY_SEPARATOR, '/', realpath(join('/', array_slice(explode('/', $configFilePath), 0, -2))));
163+
$path = str_replace(DIRECTORY_SEPARATOR, '/', realpath(implode('/', array_slice(explode('/', $configFilePath), 0, -2))));
164164
if (in_array($path, $pluginPaths))
165165
{
166166
$pluginConfigFiles[] = $configFile;

lib/config/sfPluginConfiguration.class.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/*
44
* This file is part of the symfony package.
55
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6-
*
6+
*
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
1010

1111
/**
1212
* sfPluginConfiguration represents a configuration for a symfony plugin.
13-
*
13+
*
1414
* @package symfony
1515
* @subpackage config
1616
* @author Kris Wallsmith <kris.wallsmith@symfony-project.com>
@@ -26,7 +26,7 @@ abstract class sfPluginConfiguration
2626

2727
/**
2828
* Constructor.
29-
*
29+
*
3030
* @param sfProjectConfiguration $configuration The project configuration
3131
* @param string $rootDir The plugin root directory
3232
* @param string $name The plugin name
@@ -50,7 +50,7 @@ public function __construct(sfProjectConfiguration $configuration, $rootDir = nu
5050

5151
/**
5252
* Sets up the plugin.
53-
*
53+
*
5454
* This method can be used when creating a base plugin configuration class for other plugins to extend.
5555
*/
5656
public function setup()
@@ -59,7 +59,7 @@ public function setup()
5959

6060
/**
6161
* Configures the plugin.
62-
*
62+
*
6363
* This method is called before the plugin's classes have been added to sfAutoload.
6464
*/
6565
public function configure()
@@ -68,9 +68,9 @@ public function configure()
6868

6969
/**
7070
* Initializes the plugin.
71-
*
71+
*
7272
* This method is called after the plugin's classes have been added to sfAutoload.
73-
*
73+
*
7474
* @return boolean|null If false sfApplicationConfiguration will look for a config.php (maintains BC with symfony < 1.2)
7575
*/
7676
public function initialize()
@@ -79,7 +79,7 @@ public function initialize()
7979

8080
/**
8181
* Returns the plugin root directory.
82-
*
82+
*
8383
* @return string
8484
*/
8585
public function getRootDir()
@@ -89,7 +89,7 @@ public function getRootDir()
8989

9090
/**
9191
* Returns the plugin name.
92-
*
92+
*
9393
* @return string
9494
*/
9595
public function getName()
@@ -99,11 +99,11 @@ public function getName()
9999

100100
/**
101101
* Initializes autoloading for the plugin.
102-
*
102+
*
103103
* This method is called when a plugin is initialized in a project
104104
* configuration. Otherwise, autoload is handled in
105105
* {@link sfApplicationConfiguration} using {@link sfAutoload}.
106-
*
106+
*
107107
* @see sfSimpleAutoload
108108
*/
109109
public function initializeAutoload()
@@ -126,10 +126,10 @@ public function initializeAutoload()
126126

127127
/**
128128
* Filters sfAutoload configuration values.
129-
*
130-
* @param sfEvent $event
131-
* @param array $config
132-
*
129+
*
130+
* @param sfEvent $event
131+
* @param array $config
132+
*
133133
* @return array
134134
*/
135135
public function filterAutoloadConfig(sfEvent $event, array $config)
@@ -169,10 +169,10 @@ public function connectTests()
169169

170170
/**
171171
* Listens for the "task.test.filter_test_files" event and adds tests from the current plugin.
172-
*
172+
*
173173
* @param sfEvent $event
174174
* @param array $files
175-
*
175+
*
176176
* @return array An array of files with the appropriate tests from the current plugin merged in
177177
*/
178178
public function filterTestFiles(sfEvent $event, $files)
@@ -211,18 +211,18 @@ public function filterTestFiles(sfEvent $event, $files)
211211

212212
/**
213213
* Guesses the plugin root directory.
214-
*
214+
*
215215
* @return string
216216
*/
217217
protected function guessRootDir()
218218
{
219219
$r = new ReflectionClass(get_class($this));
220-
return realpath(dirname($r->getFilename()).'/..');
220+
return realpath(dirname($r->getFileName()).'/..');
221221
}
222222

223223
/**
224224
* Guesses the plugin name.
225-
*
225+
*
226226
* @return string
227227
*/
228228
protected function guessName()

lib/config/sfRootConfigHandler.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function execute($configFiles)
3535
$config = static::getConfiguration($configFiles);
3636

3737
// determine if we're loading the system config_handlers.yml or a module config_handlers.yml
38-
$moduleLevel = ($this->getParameterHolder()->get('module_level') === true) ? true : false;
38+
$moduleLevel = ($this->getParameterHolder()->get('module_level') === true);
3939

4040
if ($moduleLevel)
4141
{

lib/config/sfRoutingConfigHandler.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function parse($configFiles)
9595
else
9696
{
9797
$routes[$name] = array(isset($params['class']) ? $params['class'] : 'sfRoute', array(
98-
$params['url'] ? $params['url'] : '/',
98+
$params['url'] ?: '/',
9999
isset($params['params']) ? $params['params'] : (isset($params['param']) ? $params['param'] : array()),
100100
isset($params['requirements']) ? $params['requirements'] : array(),
101101
isset($params['options']) ? $params['options'] : array(),

lib/debug/sfWebDebug.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public function asHtml()
207207
$titles[] = sprintf('<li%s><a title="%s" href="%s"%s>%s</a></li>',
208208
$panel->getStatus() ? ' class="sfWebDebug'.ucfirst($this->getPriority($panel->getStatus())).'"' : '',
209209
$panel->getPanelTitle(),
210-
$panel->getTitleUrl() ? $panel->getTitleUrl() : '#',
210+
$panel->getTitleUrl() ?: '#',
211211
$panel->getTitleUrl() ? '' : ' onclick="sfWebDebugShowDetailsFor(\''.$id.'\'); return false;"',
212212
$title
213213
);

0 commit comments

Comments
 (0)