<?php
namespace tomlib\object;

function try_get_property($object, $name, $default = null) {
		if(property_exists($object, $name))
				return $object->$name;
		else
				return $default;
}

function to_indexed_array($object, $properties, $reference = false) {
		if($reference) {
				foreach($properties as $property) {
						$result[] =& try_get_property($object, $property);
				}
		} else {
				foreach($properties as $property) {
						$result[] = try_get_property($object, $property);
				}
		}

		return $result;
}

<?php
namespace tomlib\object;

function try_get_property($object, $name, $default = null) {
		if(property_exists($object, $name))
				return $object->$name;
		else
				return $default;
}

function to_indexed_array($object, $properties, $reference = false) {
		if($reference) {
				foreach($properties as $property) {
						$result[$property] =& try_get_property($object, $property);
				}
		} else {
				foreach($properties as $property) {
						$result[$property] = try_get_property($object, $property);
				}
		}

		return $result;
}

Add index assignments to to_indexed_array
Add index assignments to to_indexed_array

Beforehand, to_indexed_array wouldn't return an indexed array, instead it would just push the values into the array.