Skip to content

Commit

Permalink
Strict compare
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Jun 25, 2017
1 parent a28cf64 commit 1a781fc
Show file tree
Hide file tree
Showing 55 changed files with 109 additions and 109 deletions.
2 changes: 1 addition & 1 deletion src/Application/AbstractWebApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function redirect($url, $code = 303)
$prefix = $uri->toString(['scheme', 'user', 'pass', 'host', 'port']);

// We just need the prefix since we have a path relative to the root.
if ($url[0] == '/')
if ($url[0] === '/')
{
$url = $prefix . $url;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Authentication/Test/Mock/MockMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class MockMethod extends AbstractMethod
*/
public function authenticate(Credential $credential)
{
if ($credential->username == 'flower')
if ($credential->username === 'flower')
{
if ($credential->password == '1234')
if ($credential->password === '1234')
{
$this->status = Authentication::SUCCESS;

Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Storage/RedisStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected function connect()
return $this;
}

if (($this->defaultHost == 'localhost' || filter_var($this->defaultHost, FILTER_VALIDATE_IP)))
if (($this->defaultHost === 'localhost' || filter_var($this->defaultHost, FILTER_VALIDATE_IP)))
{
$this->driver->connect('tcp://' . $this->defaultHost . ':' . $this->defaultPort, $this->defaultPort);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Compare/Compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function setOperator($operator)
*/
public function quote($string, $quote = "''")
{
if (!$quote && $quote != '0')
if (!$quote && (string) $quote !== '0')
{
return $string;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/RootCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function prepareExecute()
throw new \Exception('RootCommand::$app should have Console Application');
}

if (!$this->getOption('ansi') || strtolower($this->getOption('ansi')) == 'off')
if (!$this->getOption('ansi') || strtolower($this->getOption('ansi')) === 'off')
{
$this->console->set('ansi', false);

Expand Down
2 changes: 1 addition & 1 deletion src/Data/Test/DataSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public function testFilter()
{
$keys[] = $key;

return $data->flower == 'sakura';
return $data->flower === 'sakura';
});

$this->assertEquals(['sakura'], $new->flower);
Expand Down
2 changes: 1 addition & 1 deletion src/DataMapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ This will generate where conditions like below:

``` sql
WHERE `id` >= '5'
AND `name` != 'bar'
AND `name` !== 'bar'
AND `published` < '1'
AND `catid` NOT IN (1,2,3,4,5)
```
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Command/AbstractWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function updateOne($table, $data, $key, $updateNulls = false)
}

// Only process scalars that are not internal fields.
if (is_array($v) || is_object($v) || $k[0] == '_')
if (is_array($v) || is_object($v) || $k[0] === '_')
{
continue;
}
Expand Down
16 changes: 8 additions & 8 deletions src/Database/Driver/AbstractDatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public function replacePrefix($sql, $prefix = '#__')

$l = $k - 1;

while ($l >= 0 && $sql{$l} == '\\')
while ($l >= 0 && $sql{$l} === '\\')
{
$l--;
$escaped = !$escaped;
Expand Down Expand Up @@ -620,11 +620,11 @@ public static function splitSql($sql)
{
$current = substr($sql, $i, 1);

if (($current == '"' || $current == '\''))
if (($current === '"' || $current === '\''))
{
$n = 2;

while (substr($sql, $i - $n + 1, 1) == '\\' && $n < $i)
while (substr($sql, $i - $n + 1, 1) === '\\' && $n < $i)
{
$n++;
}
Expand All @@ -647,7 +647,7 @@ public static function splitSql($sql)
}
}

if (($current == ';' && !$open) || $i == $end - 1)
if (($current === ';' && !$open) || $i == $end - 1)
{
$queries[] = substr($sql, $start, ($i - $start + 1));
$start = $i + 1;
Expand Down Expand Up @@ -699,12 +699,12 @@ public function setQuery($query)
*/
public function loadAll($key = null, $class = '\\stdClass')
{
if (strtolower($class) == 'array')
if (strtolower($class) === 'array')
{
return $this->getReader()->loadArrayList($key);
}

if (strtolower($class) == 'assoc')
if (strtolower($class) === 'assoc')
{
return $this->getReader()->loadAssocList($key);
}
Expand All @@ -721,12 +721,12 @@ public function loadAll($key = null, $class = '\\stdClass')
*/
public function loadOne($class = '\\stdClass')
{
if (strtolower($class) == 'array')
if (strtolower($class) === 'array')
{
return $this->getReader()->loadArray();
}

if (strtolower($class) == 'assoc')
if (strtolower($class) === 'assoc')
{
return $this->getReader()->loadAssoc();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Driver/Pdo/PdoDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function __construct(\PDO $connection = null, $options = [])
$options = array_merge($defaultOptions, $options);

// We shouldn't use pdo directly.
if ($this->name == 'pdo')
if ($this->name === 'pdo')
{
$this->name = $options['driver'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Query/QueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function registerQueryTables(QueryInterface $query)
{
foreach ($this->tables as $alias => $table)
{
if ($table['join'] == 'FROM')
if ($table['join'] === 'FROM')
{
$query->from($query->quoteName($table['name']) . ' AS ' . $query->quoteName($alias));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Test/AbstractDatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static function setUpBeforeClass()
$db->select($dbname);

// MySQL Strict Mode
if (static::$driver == 'mysql' && !empty(static::$dsn['strict_mode']))
if (static::$driver === 'mysql' && !empty(static::$dsn['strict_mode']))
{
$db->setQuery("SET sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_ALL_TABLES'")->execute();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Environment/Browser/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,6 @@ public function isRobot($refresh = false)
*/
public function isSSLConnection()
{
return (!empty($this->server['HTTPS']) && strtolower($this->server['HTTPS']) != 'off');
return (!empty($this->server['HTTPS']) && strtolower($this->server['HTTPS']) !== 'off');
}
}
4 changes: 2 additions & 2 deletions src/Environment/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function getOS()
*/
public function isWin()
{
return $this->getOS() == 'WIN';
return $this->getOS() === 'WIN';
}

/**
Expand Down Expand Up @@ -126,7 +126,7 @@ public function isUnix()
*/
public function isLinux()
{
return $this->getOS() == 'LIN';
return $this->getOS() === 'LIN';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Environment/Test/PlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ protected function setUp()
// Detect the native operating system type.
$this->os = strtoupper(substr(PHP_OS, 0, 3));

$this->isWin = $this->os == 'WIN';
$this->isWin = $this->os === 'WIN';

$this->isMac = $this->os == 'MAC';
$this->isMac = $this->os === 'MAC';

$this->isUnix = in_array($this->os, ['CYG', 'DAR', 'FRE', 'LIN', 'NET', 'OPE', 'MAC']);

$this->isLinux = $this->os == 'LIN';
$this->isLinux = $this->os === 'LIN';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Event/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Then we trigger the event we created:
$dispatcher->triggerEvent($event);

// ContentListener::onBeforeContentSave will set title into $content object.
$content->title == 'My content';
$content->title === 'My content';
```

If a method name in listener equals to event name, Dispatcher will run this method and inject Event into this method.
Expand Down
4 changes: 2 additions & 2 deletions src/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function folders($path, $recursive = false, $toArray = false)

// If set to recursive, every returned folder name will include a dot (.),
// so we can't using isDot() to detect folder.
return $iterator->isDir() && ($iterator->getBasename() != '..');
return $iterator->isDir() && ($iterator->getBasename() !== '..');
}
else
{
Expand Down Expand Up @@ -193,7 +193,7 @@ public static function items($path, $recursive = false, $toArray = false)

// If set to recursive, every returned folder name will include a dot (.),
// so we can't using isDot() to detect folder.
return ($iterator->getBasename() != '..');
return ($iterator->getBasename() !== '..');
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/Filesystem/Path/PathLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,20 @@ protected function removeDots($path)
foreach ($path as $key => $row)
{
// Remove dot files
if ($row == '.')
if ($row === '.')
{
unset($path[$key]);
}

// Remove dots and go parent dir
if ($row == '..' && !$isBeginning)
if ($row === '..' && !$isBeginning)
{
unset($path[$key]);
unset($path[$key - 1]);
}

// Do not get parent if dots in the beginning
if ($row != '..' && $isBeginning)
if ($row !== '..' && $isBeginning)
{
$isBeginning = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Filesystem/Test/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function testFind()
// Callable condition
$condition = function ($current, $key, $iterator)
{
return pathinfo($current->getBasename(), PATHINFO_EXTENSION) == 'html';
return pathinfo($current->getBasename(), PATHINFO_EXTENSION) === 'html';
};

$files = Filesystem::find(static::$dest, $condition, true, true);
Expand All @@ -289,7 +289,7 @@ public function testFindByCallback()
{
$condition = function ($current, $key, $iterator)
{
return pathinfo($current->getBasename(), PATHINFO_EXTENSION) == 'html';
return pathinfo($current->getBasename(), PATHINFO_EXTENSION) === 'html';
};

$files = Filesystem::find(static::$dest, $condition, true, true);
Expand Down
16 changes: 8 additions & 8 deletions src/Filter/HtmlCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static function isBadAttribute($attrSubSet)
$attrSubSet[1] = strtolower($attrSubSet[1]);

return (
((strpos($attrSubSet[1], 'expression') !== false) && ($attrSubSet[0]) == 'style')
((strpos($attrSubSet[1], 'expression') !== false) && ($attrSubSet[0]) === 'style')
|| (strpos($attrSubSet[1], 'javascript:') !== false)
|| (strpos($attrSubSet[1], 'behaviour:') !== false)
|| (strpos($attrSubSet[1], 'vbscript:') !== false)
Expand Down Expand Up @@ -253,7 +253,7 @@ protected function cleanTags($source)
$currentSpace = strpos($tagLeft, ' ');

// Are we an open tag or a close tag?
if (substr($currentTag, 0, 1) == '/')
if (substr($currentTag, 0, 1) === '/')
{
// Close Tag
$isCloseTag = true;
Expand Down Expand Up @@ -309,7 +309,7 @@ protected function cleanTags($source)
}

// Do we have an attribute to process? [check for equal sign]
if ($fromSpace != '/' && (($nextEqual && $nextSpace && $nextSpace < $nextEqual) || !$nextEqual))
if ($fromSpace !== '/' && (($nextEqual && $nextSpace && $nextSpace < $nextEqual) || !$nextEqual))
{
if (!$nextEqual)
{
Expand Down Expand Up @@ -343,14 +343,14 @@ protected function cleanTags($source)
else
// No more equal signs so add any extra text in the tag into the attribute array [eg. checked]
{
if ($fromSpace != '/')
if ($fromSpace !== '/')
{
$attr = substr($fromSpace, 0, $nextSpace);
}
}

// Last Attribute Pair
if (!$attr && $fromSpace != '/')
if (!$attr && $fromSpace !== '/')
{
$attr = $fromSpace;
}
Expand Down Expand Up @@ -404,7 +404,7 @@ protected function cleanTags($source)
}

// Append any code after the end of tags and return
if ($postTag != '<')
if ($postTag !== '<')
{
$preTag .= $postTag;
}
Expand Down Expand Up @@ -447,7 +447,7 @@ protected function cleanAttributes($attrSet)
// AND blacklisted attributes
if ((!preg_match('/[a-z]*$/i', $attrSubSet[0]))
|| (($this->xssAuto) && ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist))
|| (substr($attrSubSet[0], 0, 2) == 'on'))))
|| (substr($attrSubSet[0], 0, 2) === 'on'))))
{
continue;
}
Expand Down Expand Up @@ -558,7 +558,7 @@ protected function escapeAttributeValues($source)
// Figure out if we have a single or double quote and look for the matching closing quote
// Closing quote should be "/>, ">, "<space>, or " at the end of the string
$quote = substr($matches[0][0], -1);
$pregMatch = ($quote == '"') ? '#(\"\s*/\s*>|\"\s*>|\"\s+|\"$)#' : "#(\'\s*/\s*>|\'\s*>|\'\s+|\'$)#";
$pregMatch = ($quote === '"') ? '#(\"\s*/\s*>|\"\s*>|\"\s+|\"$)#' : "#(\'\s*/\s*>|\'\s*>|\'\s+|\'$)#";

// Get the portion after attribute value
if (preg_match($pregMatch, substr($remainder, $nextBefore), $matches, PREG_OFFSET_CAPTURE))
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/OutputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function objectHTMLSafe(&$mixed, $quote_style = ENT_QUOTES, $exclu
{
foreach (get_object_vars($mixed) as $k => $v)
{
if (is_array($v) || is_object($v) || $v == null || substr($k, 1, 1) == '_')
if (is_array($v) || is_object($v) || $v == null || substr($k, 1, 1) === '_')
{
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Field/AbstractField.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,11 @@ protected function handleXml(\SimpleXMLElement $xml)

$name = $parent->getName();

if ($name == 'fieldset')
if ($name === 'fieldset')
{
$this->fieldset = $this->fieldset ? : (string) $parent['name'];
}
elseif ($name == 'group')
elseif ($name === 'group')
{
array_unshift($group, (string) $parent['name']);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Field/ListField.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function handleOptions($xml, $options = [])
{
foreach ($xml->children() as $name => $option)
{
if ($option->getName() == 'optgroup')
if ($option->getName() === 'optgroup')
{
foreach ($option->children() as $opt)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Form/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static function setByPath(&$data, $paths, $value, $separator = '/', $type
*/
$createStore = function($type)
{
if (strtolower($type) == 'array')
if (strtolower($type) === 'array')
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Helper/ServerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function getAllHeaders()

foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
if (substr($name, 0, 5) === 'HTTP_')
{
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
Expand Down
Loading

0 comments on commit 1a781fc

Please sign in to comment.