Use PHPUnit's CS/WS.

This commit is contained in:
Jeff Welch 2013-02-15 18:34:08 -05:00
parent 6ad7d7ea8b
commit 04d19693aa
2 changed files with 25 additions and 13 deletions

View File

@ -59,7 +59,7 @@ class Context {
*
* @var array[] $arrays
*/
protected $arrays;
protected $arrays = array();
/**
* Previously seen objects.
@ -86,11 +86,15 @@ class Context {
{
if (is_array($value)) {
return $this->addArray($value);
} elseif (is_object($value)) {
}
else if (is_object($value)) {
return $this->addObject($value);
}
throw new ExporterException('Only arrays and objects are supported');
throw new ExporterException(
'Only arrays and objects are supported'
);
}
/**
@ -106,11 +110,15 @@ class Context {
{
if (is_array($value)) {
return $this->containsArray($value);
} elseif (is_object($value)) {
}
else if (is_object($value)) {
return $this->containsObject($value);
}
throw new Exception('Only arrays and objects are supported');
throw new Exception(
'Only arrays and objects are supported'
);
}
/**
@ -121,11 +129,12 @@ class Context {
*/
protected function addArray(array &$value)
{
if (($key = $this->containsArray($value)) !== false) {
if (($key = $this->containsArray($value)) !== FALSE) {
return $key;
}
$this->arrays[] = &$value;
return count($this->arrays) - 1;
}
@ -153,18 +162,21 @@ class Context {
*/
protected function containsArray(array &$value)
{
$keys = array_keys($this->arrays, $value, true);
$gen = '_PHP_Exporter_Key_'.hash('sha512', microtime(true));
$keys = array_keys($this->arrays, $value, TRUE);
$gen = '_PHP_Exporter_Key_'.hash('sha512', microtime(TRUE));
foreach ($keys as $key) {
$this->arrays[$key][$gen] = $gen;
if (isset($value[$gen]) && $value[$gen] === $gen) {
unset($this->arrays[$key][$gen]);
return $key;
}
unset($this->arrays[$key][$gen]);
}
return false;
return FALSE;
}
/**
@ -180,6 +192,6 @@ class Context {
return spl_object_hash($value);
}
return false;
return FALSE;
}
}

View File

@ -125,7 +125,7 @@ class Exporter
* @return string
* @see SebastianBergmann\PHP\Exporter\Exporter::export
*/
protected function recursiveExport(&$value, $indentation, $processed = null)
protected function recursiveExport(&$value, $indentation, $processed = NULL)
{
if ($value === NULL) {
return 'null';
@ -169,7 +169,7 @@ class Exporter
}
if (is_array($value)) {
if (($key = $processed->contains($value)) !== false) {
if (($key = $processed->contains($value)) !== FALSE) {
return 'Array &' . $key;
}
@ -221,7 +221,7 @@ class Exporter
return sprintf('%s Object &%s (%s)', $class, $hash, $values);
}
return var_export($value, true);
return var_export($value, TRUE);
}
/**