#!/usr/bin/php <?php require 'ext/Test.php'; require 'Rx.php'; $test_arrays = array('foobarbaz' => array('foo', 'bar', 'baz'), 'noelems' => array()); foreach ($test_arrays as $name => $value) { ok(RxUtil::is_seq_int_array($value), "test array {$name} is a seq_int_array"); } $test_nonarrays = array('nonseq' => array(1 => 'start-at-one', 'two', 'three'), 'nonint' => array('key' => 'value')); foreach ($test_nonarrays as $name => $value) { ok(!RxUtil::is_seq_int_array($value), "test array {$name} is not a seq_int_array"); }
function check($value) { if (!RxUtil::is_seq_int_array($value)) { return false; } foreach ($this->content_schemata as $i => $schema) { if (!array_key_exists($i, $value)) { return false; } if (!$schema->check($value[$i])) { return false; } } if (count($value) > count($this->content_schemata)) { if (!$this->tail_schema) { return false; } $tail = array_slice($value, count($this->content_schemata), count($value) - count($this->content_schemata)); if (!$this->tail_schema->check($tail)) { return false; } } return true; }