Skip to content
Permalink
Browse files

Fix scrutinizer warnings in several packages.

Scrutinizer found a few undefined variable issues and ambiguous boolean
casting issues which I've fixed here.
  • Loading branch information...
markstory committed Oct 2, 2015
1 parent d7a4896 commit 673a5175f18d808075fafd6216a4c36199e02d44
@@ -15,5 +15,6 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$versionFile = file(CORE_PATH . 'VERSION.txt');
$config['Cake.version'] = trim(array_pop($versionFile));
return $config;
return [
'Cake.version' => trim(array_pop($versionFile))
];
@@ -45,7 +45,7 @@ public static function build($passwordHasher)
}
$className = App::className($class, 'Auth', 'PasswordHasher');
if (!$className) {
if ($className === false) {
throw new RuntimeException(sprintf('Password hasher class "%s" was not found.', $class));
}
@@ -265,7 +265,7 @@ public function key($key)
protected function _key($key)
{
$key = $this->key($key);
if (!$key) {
if ($key === false) {
throw new InvalidArgumentException('An empty value is not valid as a cache key');
}
@@ -29,7 +29,7 @@ class BufferedIterator extends Collection implements Countable, Serializable
/**
* The in-memory cache containing results from previous iterators
*
* @var callable
* @var \SplDoublyLinkedList
*/
protected $_buffer;
@@ -57,7 +57,7 @@ public function __construct($items, callable $condition)
{
$this->_condition = $condition;
parent::__construct($items);
$this->_innnerIterator = $this->getInnerIterator();
$this->_innerIterator = $this->getInnerIterator();
}
/**
@@ -162,7 +162,7 @@ public function quiet($message, $newlines = 1)
* @param int $level The message's output level, see above.
* @return int|bool Returns the number of bytes returned from writing to stdout.
*/
public function out($message = null, $newlines = 1, $level = ConsoleIo::NORMAL)
public function out($message = '', $newlines = 1, $level = ConsoleIo::NORMAL)
{
if ($level <= $this->_level) {
$this->_lastWritten = $this->_out->write($message, $newlines);
@@ -212,7 +212,7 @@ public function overwrite($message, $newlines = 1, $size = null)
* @param int $newlines Number of newlines to append
* @return void
*/
public function err($message = null, $newlines = 1)
public function err($message = '', $newlines = 1)
{
$this->_err->write($message, $newlines);
}
@@ -363,7 +363,7 @@ protected function _encrypt($value, $encrypt)
if (is_array($value)) {
$value = $this->_implode($value);
}
if (!$encrypt) {
if ($encrypt === false) {
return $value;
}
$this->_checkCipher($encrypt);
@@ -448,7 +448,7 @@ public function requestedWith($type = null)
list($contentType) = explode(';', $request->header('CONTENT_TYPE'));
}
$response = $this->response;
if (!$type) {
if ($type === null) {
return $response->mapType($contentType);
}
if (is_string($type)) {
@@ -579,7 +579,7 @@ public function renderAs(Controller $controller, $type, array $options = [])
if (!in_array($helper, $controller->helpers) && empty($controller->helpers[$helper])) {
$helperClass = App::className($helper, 'View/Helper', 'Helper');
if ($helperClass) {
if ($helperClass !== false) {
$controller->helpers[] = $helper;
}
}
@@ -300,10 +300,10 @@ protected function _validatePost(Controller $controller)
$locked = explode('|', $locked);
$unlocked = explode('|', $unlocked);
$lockedFields = [];
$fields = Hash::flatten($check);
$fieldList = array_keys($fields);
$multi = [];
$multi = $lockedFields = [];
$isUnlocked = false;
foreach ($fieldList as $i => $key) {
if (preg_match('/(\.\d+){1,10}$/', $key)) {
@@ -208,7 +208,7 @@ public static function config($name, ConfigEngineInterface $engine)
*/
public static function configured($name = null)
{
if ($name) {
if ($name !== null) {
return isset(static::$_engines[$name]);
}
return array_keys(static::$_engines);
@@ -344,7 +344,7 @@ protected static function _getEngine($config)
public static function version()
{
if (!isset(static::$_values['Cake']['version'])) {
require CORE_PATH . 'config/config.php';
$config = require CORE_PATH . 'config/config.php';
static::write($config);
}
return static::$_values['Cake']['version'];
@@ -27,7 +27,7 @@ trait FileConfigTrait
*
* @var string
*/
protected $_path = null;
protected $_path = '';
/**
* Get file path
@@ -350,7 +350,7 @@ public static function routes($plugin = null)
*/
public static function loaded($plugin = null)
{
if ($plugin) {
if ($plugin !== null) {
return isset(static::$_plugins[$plugin]);
}
$return = array_keys(static::$_plugins);
@@ -190,13 +190,13 @@ public static function parseDsn($dsn)
throw new InvalidArgumentException('Only strings can be passed to parseDsn');
}
$scheme = '';
if (preg_match("/^([\w\\\]+)/", $dsn, $matches)) {
$scheme = $matches[1];
$dsn = preg_replace("/^([\w\\\]+)/", 'file', $dsn);
}
$parsed = parse_url($dsn);
if ($parsed === false) {
return $dsn;
}
@@ -1694,7 +1694,7 @@ protected function _decorateStatement($statement)
* Helper function used to build conditions by composing QueryExpression objects.
*
* @param string $part Name of the query part to append the new part to
* @param string|array|ExpressionInterface|callback $append Expression or builder function to append.
* @param string|null|array|ExpressionInterface|callback $append Expression or builder function to append.
* @param string $conjunction type of conjunction to be used to operate part
* @param array $types associative array of type names used to bind values to query
* @return void

0 comments on commit 673a517

Please sign in to comment.
You can’t perform that action at this time.