/** * get the list of possible types that could match an array * * @param array $item * the item to examine * @return string[] * a list of matching types */ private static function fromArray($item) { // our return type $retval = array_merge(array_slice(GetArrayTypes::from($item), 0, -1), ['Traversable' => 'Traversable', 'array' => 'array']); // all done return $retval; }
/** * get a full list of strict types than an array can satisfy * * @param array $item * the item to examine * @return string[] * the array's list of types */ function get_array_types($item) { return GetArrayTypes::from($item); }
/** * @covers ::from * @dataProvider provideNonArraysToTest */ public function testRejectsNonArrays($data, $expectedTypes) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change $actualTypes = GetArrayTypes::from($data); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedTypes, $actualTypes); }