Skip to content

Commit

Permalink
PHPCS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Feb 17, 2018
1 parent 3c765e0 commit 8b8b951
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -44,4 +44,4 @@ before_script:

script:
- vendor/bin/phpunit
- if [ "$RUN_PHPCS" == "yes" ]; then vendor/bin/phpcs --config-set installed_paths vendor/joomla/coding-standards && vendor/bin/phpcs -p --report=full --extensions=php --standard=Joomla Storage/ Session.php Storage.php; fi;
- if [ "$RUN_PHPCS" == "yes" ]; then vendor/bin/phpcs --config-set installed_paths vendor/joomla/coding-standards && vendor/bin/phpcs -p --report=full --extensions=php --standard=ruleset.xml Storage/ Session.php Storage.php; fi;
2 changes: 1 addition & 1 deletion Storage.php
Expand Up @@ -139,7 +139,7 @@ public function close()
*/
public function read($id)
{
return;
return '';
}

/**
Expand Down
14 changes: 7 additions & 7 deletions Storage/Database.php
Expand Up @@ -70,8 +70,8 @@ public function read($id)
// Get the session data from the database table.
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName('data'))
->from($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));
->from($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));

$this->db->setQuery($query);

Expand Down Expand Up @@ -100,9 +100,9 @@ public function write($id, $data)
{
$query = $this->db->getQuery(true);
$query->update($this->db->quoteName('#__session'))
->set($this->db->quoteName('data') . ' = ' . $this->db->quote($data))
->set($this->db->quoteName('time') . ' = ' . $this->db->quote((int) time()))
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));
->set($this->db->quoteName('data') . ' = ' . $this->db->quote($data))
->set($this->db->quoteName('time') . ' = ' . $this->db->quote((int) time()))
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));

// Try to update the session data in the database table.
$this->db->setQuery($query);
Expand Down Expand Up @@ -139,7 +139,7 @@ public function destroy($id)
{
$query = $this->db->getQuery(true);
$query->delete($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));
->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));

// Remove a session from the database.
$this->db->setQuery($query);
Expand Down Expand Up @@ -171,7 +171,7 @@ public function gc($lifetime = 1440)
{
$query = $this->db->getQuery(true);
$query->delete($this->db->quoteName('#__session'))
->where($this->db->quoteName('time') . ' < ' . $this->db->quote((int) $past));
->where($this->db->quoteName('time') . ' < ' . $this->db->quote((int) $past));

// Remove expired sessions from the database.
$this->db->setQuery($query);
Expand Down
2 changes: 1 addition & 1 deletion Storage/Xcache.php
Expand Up @@ -54,7 +54,7 @@ public function read($id)
// Check if id exists
if (!xcache_isset($sess_id))
{
return;
return '';
}

return (string) xcache_get($sess_id);
Expand Down
23 changes: 23 additions & 0 deletions ruleset.xml
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<ruleset name="Joomla">

<arg name="report" value="full"/>
<arg name="tab-width" value="4"/>
<arg name="encoding" value="utf-8"/>
<arg value="sp"/>
<arg name="colors" />

<!-- Exclude folders not containing production code -->
<exclude-pattern>*/.github/*</exclude-pattern>
<exclude-pattern>*/.travis/*</exclude-pattern>

<!-- Exclude 3rd party libraries. -->
<exclude-pattern>*/vendor/*</exclude-pattern>

<rule ref="Joomla">
<!-- Variables inherited from the PHP SessionHandlerInterface definition are named in snake case -->
<exclude name="Joomla.NamingConventions.ValidVariableName"/>
<!-- Required due to legacy methods being named with a leading underscore, should be fixed in 2.0 -->
<exclude name="Joomla.NamingConventions.ValidFunctionName.MethodUnderscore"/>
</rule>
</ruleset>

0 comments on commit 8b8b951

Please sign in to comment.