Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'cs/remove-underscores' of https://github.com/arse/zf2 i…
Browse files Browse the repository at this point in the history
…nto feature/protected-underscores

Conflicts:
	library/Zend/Console/Getopt.php
  • Loading branch information
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 199 deletions.
88 changes: 44 additions & 44 deletions src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,37 @@ class Decoder
*
* @var string
*/
protected $_source;
protected $source;

/**
* Caches the source length
*
* @var int
*/
protected $_sourceLength;
protected $sourceLength;

/**
* The offset within the souce being decoded
*
* @var int
*
*/
protected $_offset;
protected $offset;

/**
* The current token being considered in the parser cycle
*
* @var int
*/
protected $_token;
protected $token;

/**
* Flag indicating how objects should be decoded
*
* @var int
* @access protected
*/
protected $_decodeType;
protected $decodeType;

/**
* Constructor
Expand All @@ -85,15 +85,15 @@ class Decoder
protected function __construct($source, $decodeType)
{
// Set defaults
$this->_source = self::decodeUnicodeString($source);
$this->_sourceLength = strlen($this->_source);
$this->_token = self::EOF;
$this->_offset = 0;
$this->source = self::decodeUnicodeString($source);
$this->sourceLength = strlen($this->source);
$this->token = self::EOF;
$this->offset = 0;

switch ($decodeType) {
case Json::TYPE_ARRAY:
case Json::TYPE_OBJECT:
$this->_decodeType = $decodeType;
$this->decodeType = $decodeType;
break;
default:
throw new InvalidArgumentException("Unknown decode type '{$decodeType}', please use one of the constants Json::TYPE_*");
Expand Down Expand Up @@ -141,7 +141,7 @@ public static function decode($source, $objectDecodeType = Json::TYPE_OBJECT)
*/
protected function _decodeValue()
{
switch ($this->_token) {
switch ($this->token) {
case self::DATUM:
$result = $this->_tokenValue;
$this->_getNextToken();
Expand All @@ -168,7 +168,7 @@ protected function _decodeValue()
* name that should wrap the data contained within the encoded source.
*
* Decodes to either an array or StdClass object, based on the value of
* {@link $_decodeType}. If invalid $_decodeType present, returns as an
* {@link $decodeType}. If invalid $decodeType present, returns as an
* array.
*
* @return array|StdClass
Expand All @@ -181,32 +181,32 @@ protected function _decodeObject()

while ($tok && $tok != self::RBRACE) {
if ($tok != self::DATUM || ! is_string($this->_tokenValue)) {
throw new RuntimeException('Missing key in object encoding: ' . $this->_source);
throw new RuntimeException('Missing key in object encoding: ' . $this->source);
}

$key = $this->_tokenValue;
$tok = $this->_getNextToken();

if ($tok != self::COLON) {
throw new RuntimeException('Missing ":" in object encoding: ' . $this->_source);
throw new RuntimeException('Missing ":" in object encoding: ' . $this->source);
}

$tok = $this->_getNextToken();
$members[$key] = $this->_decodeValue();
$tok = $this->_token;
$tok = $this->token;

if ($tok == self::RBRACE) {
break;
}

if ($tok != self::COMMA) {
throw new RuntimeException('Missing "," in object encoding: ' . $this->_source);
throw new RuntimeException('Missing "," in object encoding: ' . $this->source);
}

$tok = $this->_getNextToken();
}

switch ($this->_decodeType) {
switch ($this->decodeType) {
case Json::TYPE_OBJECT:
// Create new StdClass and populate with $members
$result = new \stdClass();
Expand Down Expand Up @@ -243,14 +243,14 @@ protected function _decodeArray()
while ($tok && $tok != self::RBRACKET) {
$result[$index++] = $this->_decodeValue();

$tok = $this->_token;
$tok = $this->token;

if ($tok == self::RBRACKET || !$tok) {
break;
}

if ($tok != self::COMMA) {
throw new RuntimeException('Missing "," in array encoding: ' . $this->_source);
throw new RuntimeException('Missing "," in array encoding: ' . $this->source);
}

$tok = $this->_getNextToken();
Expand All @@ -268,13 +268,13 @@ protected function _eatWhitespace()
{
if (preg_match(
'/([\t\b\f\n\r ])*/s',
$this->_source,
$this->source,
$matches,
PREG_OFFSET_CAPTURE,
$this->_offset)
&& $matches[0][1] == $this->_offset)
$this->offset)
&& $matches[0][1] == $this->offset)
{
$this->_offset += strlen($matches[0][0]);
$this->offset += strlen($matches[0][0]);
}
}

Expand All @@ -287,37 +287,37 @@ protected function _eatWhitespace()
*/
protected function _getNextToken()
{
$this->_token = self::EOF;
$this->token = self::EOF;
$this->_tokenValue = null;
$this->_eatWhitespace();

if ($this->_offset >= $this->_sourceLength) {
if ($this->offset >= $this->sourceLength) {
return(self::EOF);
}

$str = $this->_source;
$str_length = $this->_sourceLength;
$i = $this->_offset;
$str = $this->source;
$str_length = $this->sourceLength;
$i = $this->offset;
$start = $i;

switch ($str{$i}) {
case '{':
$this->_token = self::LBRACE;
$this->token = self::LBRACE;
break;
case '}':
$this->_token = self::RBRACE;
$this->token = self::RBRACE;
break;
case '[':
$this->_token = self::LBRACKET;
$this->token = self::LBRACKET;
break;
case ']':
$this->_token = self::RBRACKET;
$this->token = self::RBRACKET;
break;
case ',':
$this->_token = self::COMMA;
$this->token = self::COMMA;
break;
case ':':
$this->_token = self::COLON;
$this->token = self::COLON;
break;
case '"':
$result = '';
Expand Down Expand Up @@ -373,36 +373,36 @@ protected function _getNextToken()
}
} while ($i < $str_length);

$this->_token = self::DATUM;
$this->token = self::DATUM;
//$this->_tokenValue = substr($str, $start + 1, $i - $start - 1);
$this->_tokenValue = $result;
break;
case 't':
if (($i+ 3) < $str_length && substr($str, $start, 4) == "true") {
$this->_token = self::DATUM;
$this->token = self::DATUM;
}
$this->_tokenValue = true;
$i += 3;
break;
case 'f':
if (($i+ 4) < $str_length && substr($str, $start, 5) == "false") {
$this->_token = self::DATUM;
$this->token = self::DATUM;
}
$this->_tokenValue = false;
$i += 4;
break;
case 'n':
if (($i+ 3) < $str_length && substr($str, $start, 4) == "null") {
$this->_token = self::DATUM;
$this->token = self::DATUM;
}
$this->_tokenValue = NULL;
$i += 3;
break;
}

if ($this->_token != self::EOF) {
$this->_offset = $i + 1; // Consume the last token character
return($this->_token);
if ($this->token != self::EOF) {
$this->offset = $i + 1; // Consume the last token character
return($this->token);
}

$chr = $str{$i};
Expand All @@ -424,14 +424,14 @@ protected function _getNextToken()
throw new RuntimeException("Illegal number format: {$datum}");
}

$this->_token = self::DATUM;
$this->_offset = $start + strlen($datum);
$this->token = self::DATUM;
$this->offset = $start + strlen($datum);
}
} else {
throw new RuntimeException('Illegal Token');
}

return $this->_token;
return $this->token;
}

/**
Expand Down
20 changes: 10 additions & 10 deletions src/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ class Encoder
*
* @var boolean
*/
protected $_cycleCheck;
protected $cycleCheck;

/**
* Additional options used during encoding
*
* @var array
*/
protected $_options = array();
protected $options = array();

/**
* Array of visited objects; used to prevent cycling.
*
* @var array
*/
protected $_visited = array();
protected $visited = array();

/**
* Constructor
Expand All @@ -51,8 +51,8 @@ class Encoder
*/
protected function __construct($cycleCheck = false, $options = array())
{
$this->_cycleCheck = $cycleCheck;
$this->_options = $options;
$this->cycleCheck = $cycleCheck;
$this->options = $options;
}

/**
Expand Down Expand Up @@ -107,11 +107,11 @@ protected function _encodeValue(&$value)
*/
protected function _encodeObject(&$value)
{
if ($this->_cycleCheck) {
if ($this->cycleCheck) {
if ($this->_wasVisited($value)) {

if (isset($this->_options['silenceCyclicalExceptions'])
&& $this->_options['silenceCyclicalExceptions']===true) {
if (isset($this->options['silenceCyclicalExceptions'])
&& $this->options['silenceCyclicalExceptions']===true) {

return '"* RECURSION (' . str_replace('\\', '\\\\', get_class($value)) . ') *"';

Expand All @@ -123,7 +123,7 @@ protected function _encodeObject(&$value)
}
}

$this->_visited[] = $value;
$this->visited[] = $value;
}

$props = '';
Expand Down Expand Up @@ -162,7 +162,7 @@ protected function _encodeObject(&$value)
*/
protected function _wasVisited(&$value)
{
if (in_array($value, $this->_visited, true)) {
if (in_array($value, $this->visited, true)) {
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Expr
*
* @var string
*/
protected $_expression;
protected $expression;

/**
* Constructor
Expand All @@ -53,7 +53,7 @@ class Expr
*/
public function __construct($expression)
{
$this->_expression = (string) $expression;
$this->expression = (string) $expression;
}

/**
Expand All @@ -63,6 +63,6 @@ public function __construct($expression)
*/
public function __toString()
{
return $this->_expression;
return $this->expression;
}
}
Loading

0 comments on commit 96f4abb

Please sign in to comment.