Permalink
Browse files

Merge pull request #1049 from elkuku/underscore-2

Rename protected members in JUri
  • Loading branch information...
2 parents 6adaeab + 877d33b commit 536e4debf430e3242784cd3c1f1def225abc96ff @eddieajau eddieajau committed Mar 27, 2012
Showing with 76 additions and 78 deletions.
  1. +76 −78 libraries/joomla/environment/uri.php
@@ -24,63 +24,63 @@ class JURI
{
/**
* @var string Original URI
- * @since 11.1
+ * @since 12.1
*/
- protected $_uri = null;
+ protected $uri = null;
/**
* @var string Protocol
- * @since 11.1
+ * @since 12.1
*/
- protected $_scheme = null;
+ protected $scheme = null;
/**
* @var string Host
- * @since 11.1
+ * @since 12.1
*/
- protected $_host = null;
+ protected $host = null;
/**
* @var integer Port
- * @since 11.1
+ * @since 12.1
*/
- protected $_port = null;
+ protected $port = null;
/**
* @var string Username
- * @since 11.1
+ * @since 12.1
*/
- protected $_user = null;
+ protected $user = null;
/**
* @var string Password
- * @since 11.1
+ * @since 12.1
*/
- protected $_pass = null;
+ protected $pass = null;
/**
* @var string Path
- * @since 11.1
+ * @since 12.1
*/
- protected $_path = null;
+ protected $path = null;
/**
* @var string Query
- * @since 11.1
+ * @since 12.1
*/
- protected $_query = null;
+ protected $query = null;
/**
* @var string Anchor
- * @since 11.1
+ * @since 12.1
*/
- protected $_fragment = null;
+ protected $fragment = null;
/**
* @var array Query variable hash
- * @since 11.1
+ * @since 12.1
*/
- protected $_vars = array();
+ protected $vars = array();
/**
* @var array An array of JURI instances.
@@ -331,41 +331,38 @@ public static function reset()
*/
public function parse($uri)
{
- // Initialise variables
- $retval = false;
-
// Set the original URI to fall back on
- $this->_uri = $uri;
+ $this->uri = $uri;
- // Parse the URI and populate the object fields. If URI is parsed properly,
+ // Parse the URI and populate the object fields. If URI is parsed properly,
// set method return value to true.
- if ($_parts = JString::parse_url($uri))
- {
- $retval = true;
- }
+ $parts = JString::parse_url($uri);
+
+ $retval = ($parts) ? true : false;
// We need to replace & with & for parse_str to work right...
- if (isset($_parts['query']) && strpos($_parts['query'], '&'))
+ if (isset($parts['query']) && strpos($parts['query'], '&'))
{
- $_parts['query'] = str_replace('&', '&', $_parts['query']);
+ $parts['query'] = str_replace('&', '&', $parts['query']);
}
- $this->_scheme = isset($_parts['scheme']) ? $_parts['scheme'] : null;
- $this->_user = isset($_parts['user']) ? $_parts['user'] : null;
- $this->_pass = isset($_parts['pass']) ? $_parts['pass'] : null;
- $this->_host = isset($_parts['host']) ? $_parts['host'] : null;
- $this->_port = isset($_parts['port']) ? $_parts['port'] : null;
- $this->_path = isset($_parts['path']) ? $_parts['path'] : null;
- $this->_query = isset($_parts['query']) ? $_parts['query'] : null;
- $this->_fragment = isset($_parts['fragment']) ? $_parts['fragment'] : null;
+ $this->scheme = isset($parts['scheme']) ? $parts['scheme'] : null;
+ $this->user = isset($parts['user']) ? $parts['user'] : null;
+ $this->pass = isset($parts['pass']) ? $parts['pass'] : null;
+ $this->host = isset($parts['host']) ? $parts['host'] : null;
+ $this->port = isset($parts['port']) ? $parts['port'] : null;
+ $this->path = isset($parts['path']) ? $parts['path'] : null;
+ $this->query = isset($parts['query']) ? $parts['query'] : null;
+ $this->fragment = isset($parts['fragment']) ? $parts['fragment'] : null;
// Parse the query
- if (isset($_parts['query']))
+ if (isset($parts['query']))
{
- parse_str($_parts['query'], $this->_vars);
+ parse_str($parts['query'], $this->vars);
}
+
return $retval;
}
@@ -384,14 +381,14 @@ public function toString(array $parts = array('scheme', 'user', 'pass', 'host',
$query = $this->getQuery();
$uri = '';
- $uri .= in_array('scheme', $parts) ? (!empty($this->_scheme) ? $this->_scheme . '://' : '') : '';
- $uri .= in_array('user', $parts) ? $this->_user : '';
- $uri .= in_array('pass', $parts) ? (!empty($this->_pass) ? ':' : '') . $this->_pass . (!empty($this->_user) ? '@' : '') : '';
- $uri .= in_array('host', $parts) ? $this->_host : '';
- $uri .= in_array('port', $parts) ? (!empty($this->_port) ? ':' : '') . $this->_port : '';
- $uri .= in_array('path', $parts) ? $this->_path : '';
+ $uri .= in_array('scheme', $parts) ? (!empty($this->scheme) ? $this->scheme . '://' : '') : '';
+ $uri .= in_array('user', $parts) ? $this->user : '';
+ $uri .= in_array('pass', $parts) ? (!empty($this->pass) ? ':' : '') . $this->pass . (!empty($this->user) ? '@' : '') : '';
+ $uri .= in_array('host', $parts) ? $this->host : '';
+ $uri .= in_array('port', $parts) ? (!empty($this->port) ? ':' : '') . $this->port : '';
+ $uri .= in_array('path', $parts) ? $this->path : '';
$uri .= in_array('query', $parts) ? (!empty($query) ? '?' . $query : '') : '';
- $uri .= in_array('fragment', $parts) ? (!empty($this->_fragment) ? '#' . $this->_fragment : '') : '';
+ $uri .= in_array('fragment', $parts) ? (!empty($this->fragment) ? '#' . $this->fragment : '') : '';
return $uri;
}
@@ -409,11 +406,12 @@ public function toString(array $parts = array('scheme', 'user', 'pass', 'host',
*/
public function setVar($name, $value)
{
- $tmp = @$this->_vars[$name];
- $this->_vars[$name] = $value;
+ $tmp = isset($this->vars[$name]) ? $this->vars[$name] : null;
+
+ $this->vars[$name] = $value;
// Empty the query
- $this->_query = null;
+ $this->query = null;
return $tmp;
}
@@ -429,7 +427,7 @@ public function setVar($name, $value)
*/
public function hasVar($name)
{
- return array_key_exists($name, $this->_vars);
+ return array_key_exists($name, $this->vars);
}
/**
@@ -444,9 +442,9 @@ public function hasVar($name)
*/
public function getVar($name, $default = null)
{
- if (array_key_exists($name, $this->_vars))
+ if (array_key_exists($name, $this->vars))
{
- return $this->_vars[$name];
+ return $this->vars[$name];
}
return $default;
}
@@ -462,12 +460,12 @@ public function getVar($name, $default = null)
*/
public function delVar($name)
{
- if (array_key_exists($name, $this->_vars))
+ if (array_key_exists($name, $this->vars))
{
- unset($this->_vars[$name]);
+ unset($this->vars[$name]);
// Empty the query
- $this->_query = null;
+ $this->query = null;
}
}
@@ -485,19 +483,19 @@ public function setQuery($query)
{
if (is_array($query))
{
- $this->_vars = $query;
+ $this->vars = $query;
}
else
{
if (strpos($query, '&') !== false)
{
$query = str_replace('&', '&', $query);
}
- parse_str($query, $this->_vars);
+ parse_str($query, $this->vars);
}
// Empty the query
- $this->_query = null;
+ $this->query = null;
}
/**
@@ -513,16 +511,16 @@ public function getQuery($toArray = false)
{
if ($toArray)
{
- return $this->_vars;
+ return $this->vars;
}
// If the query is empty build it first
- if (is_null($this->_query))
+ if (is_null($this->query))
{
- $this->_query = self::buildQuery($this->_vars);
+ $this->query = self::buildQuery($this->vars);
}
- return $this->_query;
+ return $this->query;
}
/**
@@ -555,7 +553,7 @@ public static function buildQuery(array $params)
*/
public function getScheme()
{
- return $this->_scheme;
+ return $this->scheme;
}
/**
@@ -570,7 +568,7 @@ public function getScheme()
*/
public function setScheme($scheme)
{
- $this->_scheme = $scheme;
+ $this->scheme = $scheme;
}
/**
@@ -583,7 +581,7 @@ public function setScheme($scheme)
*/
public function getUser()
{
- return $this->_user;
+ return $this->user;
}
/**
@@ -597,7 +595,7 @@ public function getUser()
*/
public function setUser($user)
{
- $this->_user = $user;
+ $this->user = $user;
}
/**
@@ -610,7 +608,7 @@ public function setUser($user)
*/
public function getPass()
{
- return $this->_pass;
+ return $this->pass;
}
/**
@@ -624,7 +622,7 @@ public function getPass()
*/
public function setPass($pass)
{
- $this->_pass = $pass;
+ $this->pass = $pass;
}
/**
@@ -637,7 +635,7 @@ public function setPass($pass)
*/
public function getHost()
{
- return $this->_host;
+ return $this->host;
}
/**
@@ -651,7 +649,7 @@ public function getHost()
*/
public function setHost($host)
{
- $this->_host = $host;
+ $this->host = $host;
}
/**
@@ -664,7 +662,7 @@ public function setHost($host)
*/
public function getPort()
{
- return (isset($this->_port)) ? $this->_port : null;
+ return (isset($this->port)) ? $this->port : null;
}
/**
@@ -678,7 +676,7 @@ public function getPort()
*/
public function setPort($port)
{
- $this->_port = $port;
+ $this->port = $port;
}
/**
@@ -690,7 +688,7 @@ public function setPort($port)
*/
public function getPath()
{
- return $this->_path;
+ return $this->path;
}
/**
@@ -704,7 +702,7 @@ public function getPath()
*/
public function setPath($path)
{
- $this->_path = $this->_cleanPath($path);
+ $this->path = $this->_cleanPath($path);
}
/**
@@ -717,7 +715,7 @@ public function setPath($path)
*/
public function getFragment()
{
- return $this->_fragment;
+ return $this->fragment;
}
/**
@@ -732,7 +730,7 @@ public function getFragment()
*/
public function setFragment($anchor)
{
- $this->_fragment = $anchor;
+ $this->fragment = $anchor;
}
/**

0 comments on commit 536e4de

Please sign in to comment.