Skip to content

Commit

Permalink
Merge pull request #6991 from cakephp/cleanup
Browse files Browse the repository at this point in the history
Fix a few things that scrutinizer complains about.
  • Loading branch information
ADmad committed Jul 10, 2015
2 parents 14a2bad + 9233b3e commit bd66f5d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Auth/DefaultPasswordHasher.php
Expand Up @@ -44,7 +44,7 @@ class DefaultPasswordHasher extends AbstractPasswordHasher
* Generates password hash.
*
* @param string $password Plain text password to hash.
* @return string Password hash
* @return bool|string Password hash or false on failure
* @link http://book.cakephp.org/3.0/en/core-libraries/components/authentication.html#hashing-passwords
*/
public function hash($password)
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/CacheEngine.php
Expand Up @@ -218,7 +218,7 @@ public function groups()
* Generates a safe key for use with cache engine storage engines.
*
* @param string $key the key passed over
* @return mixed string $key or false
* @return bool|string string key or false
*/
public function key($key)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Cache/Engine/NullEngine.php
Expand Up @@ -67,7 +67,7 @@ public function read($key)
*/
public function readMany($keys)
{
return false;
return [];
}

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ public function delete($key)
*/
public function deleteMany($keys)
{
return false;
return [];
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -183,7 +183,7 @@ protected function _setExtension($request, $response)
$extensions = Router::extensions();
foreach ($accepts as $types) {
$ext = array_intersect($extensions, $types);
if ($ext) {
if (!empty($ext)) {
$this->ext = current($ext);
break;
}
Expand Down Expand Up @@ -647,8 +647,9 @@ public function responseType()
* Maps a content type alias back to its mime-type(s)
*
* @param string|array $alias String alias to convert back into a content type. Or an array of aliases to map.
* @return string|null Null on an undefined alias. String value of the mapped alias type. If an
* alias maps to more than one content type, the first one will be returned.
* @return string|null|array Null on an undefined alias. String value of the mapped alias type. If an
* alias maps to more than one content type, the first one will be returned. If an array is provided
* for $alias, an array of mapped types will be returned.
*/
public function mapAlias($alias)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Configure/Engine/IniConfig.php
Expand Up @@ -148,7 +148,7 @@ protected function _parseNestedValues($values)
* @param string $key The identifier to write to. If the key has a . it will be treated
* as a plugin prefix.
* @param array $data The data to convert to ini file.
* @return int Bytes saved.
* @return bool Success.
*/
public function dump($key, array $data)
{
Expand All @@ -172,7 +172,7 @@ public function dump($key, array $data)
$contents = trim(implode("\n", $result));

$filename = $this->_getFilePath($key);
return file_put_contents($filename, $contents);
return file_put_contents($filename, $contents) > 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Configure/Engine/JsonConfig.php
Expand Up @@ -88,11 +88,11 @@ public function read($key)
* @param string $key The identifier to write to. If the key has a . it will
* be treated as a plugin prefix.
* @param array $data Data to dump.
* @return int Bytes saved.
* @return bool Success
*/
public function dump($key, array $data)
{
$filename = $this->_getFilePath($key);
return file_put_contents($filename, json_encode($data));
return file_put_contents($filename, json_encode($data)) > 0;
}
}
7 changes: 4 additions & 3 deletions src/Core/Configure/Engine/PhpConfig.php
Expand Up @@ -25,7 +25,6 @@
* Files compatible with PhpConfig should return an array that
* contains all of the configuration data contained in the file.
*
* @deprecated 3.0.0 Setting a `$config` variable is deprecated. Use `return` instead.
*/
class PhpConfig implements ConfigEngineInterface
{
Expand Down Expand Up @@ -58,6 +57,8 @@ public function __construct($path = null)
* Files with `.` in the name will be treated as values in plugins. Instead of
* reading from the initialized path, plugin keys will be located using Plugin::path().
*
* Setting a `$config` variable is deprecated. Use `return` instead.
*
* @param string $key The identifier to read from. If the key has a . it will be treated
* as a plugin prefix.
* @return array Parsed configuration values.
Expand Down Expand Up @@ -87,13 +88,13 @@ public function read($key)
* @param string $key The identifier to write to. If the key has a . it will be treated
* as a plugin prefix.
* @param array $data Data to dump.
* @return int Bytes saved.
* @return bool Success
*/
public function dump($key, array $data)
{
$contents = '<?php' . "\n" . 'return ' . var_export($data, true) . ';';

$filename = $this->_getFilePath($key);
return file_put_contents($filename, $contents);
return file_put_contents($filename, $contents) > 0;
}
}
2 changes: 1 addition & 1 deletion src/Database/Connection.php
Expand Up @@ -237,7 +237,7 @@ public function prepare($sql)
*/
public function execute($query, array $params = [], array $types = [])
{
if ($params) {
if (!empty($params)) {
$statement = $this->prepare($query);
$statement->bind($params, $types);
$statement->execute();
Expand Down
2 changes: 1 addition & 1 deletion src/Database/IdentifierQuoter.php
Expand Up @@ -109,7 +109,7 @@ protected function _quoteParts($query)
}

$result = $this->_basicQuoter($contents);
if ($result) {
if (!empty($result)) {
$query->{$part}($result, true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Network/Http/Auth/Digest.php
Expand Up @@ -75,7 +75,7 @@ public function authentication(Request $request, array $credentials)
*
* @param \Cake\Network\Http\Request $request The request object.
* @param array $credentials Authentication credentials.
* @return Array modified credentials.
* @return array modified credentials.
*/
protected function _getServerInfo(Request $request, $credentials)
{
Expand All @@ -86,7 +86,7 @@ protected function _getServerInfo(Request $request, $credentials)
);

if (!$response->header('WWW-Authenticate')) {
return false;
return [];
}
preg_match_all(
'@(\w+)=(?:(?:")([^"]+)"|([^\s,$]+))@',
Expand Down

0 comments on commit bd66f5d

Please sign in to comment.