/**
  * traverse a list held in an object
  *
  * @param  object $list
  *         the list to walk
  * @param  string $listName
  *         what is the name of $list in the calling code?
  * @param  callable $callable
  *         what are we calling
  * @return void
  */
 public static function using($list, $listName, callable $callable)
 {
     // robustness!
     if (!IsListyObject::check($list)) {
         throw new InvalidArgumentException($listName . ' cannot be traversed as a list');
     }
     foreach ($list as $key => $data) {
         $name = $listName . '->' . quote_property($key);
         $callable($data, $key, $name);
     }
 }
/**
 * can $list be safely (and sensibly) used in a foreach() loop?
 *
 * @param  object $list
 *         the value to inspect
 * @return bool
 *         TRUE if $list can be used in a foreach() loop
 *         FALSE otherwise
 */
function is_listy_object($list)
{
    return IsListyObject::check($list);
}
 /**
  * @covers ::check
  * @dataProvider provideNonLists
  *
  * @param mixed $list
  *        the non-list that we're going to use
  */
 public function test_anything_else_returns_false($list)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     IsListyObject::check($list, '$list');
     // ----------------------------------------------------------------
     // test the results
 }