traits/console.php
final protected function _convert($object)
	{
		// if this isn't an object then just return it
		if (!is_object($object)) {
			return $object;
		}
		//Mark this object as processed so we don't convert it twice and it
		//Also avoid recursion when objects refer to each other
		$this->_processed[] = $object;
		$object_as_array = array();
		// first add the class name
		$object_as_array['___class_name'] = get_class($object);
		// loop through object vars
		$object_vars = get_object_vars($object);
		foreach ($object_vars as $key => $value) {
			// same instance as parent object
			if ($value === $object || in_array($value, $this->_processed, true)) {
				$value = 'recursion - parent object [' . get_class($value) . ']';
			}
			$object_as_array[$key] = $this->_convert($value);
		}
		$reflection = new \ReflectionClass($object);
		// loop through the properties and add those
		foreach ($reflection->getProperties() as $property) {
			// if one of these properties was already added above then ignore it
			if (array_key_exists($property->getName(), $object_vars)) {
				continue;
			}
			$type = $this->_getPropertyKey($property);
			if ($this->_php_version >= 5.3) {
				$property->setAccessible(true);
			}
			try {
				$value = $property->getValue($object);
			} catch (\ReflectionException $e) {
				$value = 'only PHP 5.3 can access private/protected properties';
			}
			// same instance as parent object
			if ($value === $object || in_array($value, $this->_processed, true)) {
				$value = 'recursion - parent object [' . get_class($value) . ']';
			}
			$object_as_array[$type] = $this->_convert($value);
		}
		return $object_as_array;
	}
final protected function _convert($object)
	{
		// if this isn't an object then just return it
		if (!is_object($object)) {
			return $object;
		}
		//Mark this object as processed so we don't convert it twice and it
		//Also avoid recursion when objects refer to each other
		$this->_processed[] = $object;
		$object_as_array = array();
		// first add the class name
		$object_as_array['___class_name'] = get_class($object);
		// loop through object vars
		$object_vars = get_object_vars($object);
		foreach ($object_vars as $key => $value) {
			// same instance as parent object
			if ($value === $object || in_array($value, $this->_processed, true)) {
				$value = 'recursion - parent object [' . get_class($value) . ']';
			}
			$object_as_array[$key] = $this->_convert($value);
		}
		$reflection = new \ReflectionClass($object);
		// loop through the properties and add those
		foreach ($reflection->getProperties() as $property) {
			// if one of these properties was already added above then ignore it
			if (array_key_exists($property->getName(), $object_vars)) {
				continue;
			}
			$type = $this->_getPropertyKey($property);
			if ($this->_php_version >= 5.3) {
				$property->setAccessible(true);
			}
			try {
				$value = $property->getValue($object);
			} catch (\ReflectionException $e) {
				$value = 'only PHP 5.3 can access private/protected properties';
			}
			// same instance as parent object
			if ($value === $object || in_array($value, $this->_processed, true)) {
				$value = 'recursion - parent object [' . get_class($value) . ']';
			}
			$object_as_array[$type] = $this->_convert($value);
		}
		return $object_as_array;
	}
final protected function _convert ( $ object ) { // if this isn't an object then just return it if ( ! is_object ( $ object ) ) { return $ object ; } //Mark this object as processed so we don't convert it twice and it //Also avoid recursion when objects refer to each other $ this -> _processed [ ] = $ object ; $ object_as_array = array ( ) ; // first add the class name $ object_as_array [ '___class_name' ] = get_class ( $ object ) ; // loop through object vars $ object_vars = get_object_vars ( $ object ) ; foreach ( $ object_vars as $ key => $ value ) { // same instance as parent object if ( $ value === $ object || in_array ( $ value , $ this -> _processed , true ) ) { $ value = 'recursion - parent object [' . get_class ( $ value ) . ']' ; } $ object_as_array [ $ key ] = $ this -> _convert ( $ value ) ; } $ reflection = new \ ReflectionClass ( $ object ) ; // loop through the properties and add those foreach ( $ reflection -> getProperties ( ) as $ property ) { // if one of these properties was already added above then ignore it if ( array_key_exists ( $ property -> getName ( ) , $ object_vars ) ) { continue ; } $ type = $ this -> _getPropertyKey ( $ property ) ; if ( $ this -> _php_version >= 5.3 ) { $ property -> setAccessible ( true ) ; } try { $ value = $ property -> getValue ( $ object ) ; } catch ( \ ReflectionException $ e ) { $ value = 'only PHP 5.3 can access private/protected properties' ; } // same instance as parent object if ( $ value === $ object || in_array ( $ value , $ this -> _processed , true ) ) { $ value = 'recursion - parent object [' . get_class ( $ value ) . ']' ; } $ object_as_array [ $ type ] = $ this -> _convert ( $ value ) ; } return $ object_as_array ; }
converts an object to a better format for logging

@param Object
@return array
converts an object to a better format for logging