Skip to content

Commit

Permalink
Improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Sep 24, 2021
1 parent 84c3850 commit 1118ca9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,14 @@ will return:
<a href="#fromjson">fromJson</a>
<a href="#get">get</a>
<a href="#getiterator">getIterator</a>
<a href="#grep">grep</a>
<a href="#groupby">groupBy</a>
<a href="#has">has</a>
<a href="#in">in</a>
<a href="#includes">includes</a>
<a href="#index">index</a>
<a href="#insertAfter">insertAfter</a>
<a href="#insertBefore">insertBefore</a>
<a href="#intersect">intersect</a>
<a href="#intersectassoc">intersectAssoc</a>
<a href="#intersectkeys">intersectKeys</a>
Expand Down Expand Up @@ -271,6 +274,7 @@ will return:

* [concat()](#concat) : Adds all elements with new keys
* [insertAfter()](#insertAfter) : Inserts the value after the given element
* [insertBefore()](#insertBefore) : Inserts the value before the given element
* [merge()](#merge) : Combines elements overwriting existing ones
* [pad()](#pad) : Fill up to the specified length with the given value
* [prepend()](#prepend) : Adds an element at the beginning
Expand Down Expand Up @@ -2702,7 +2706,7 @@ Returns the numerical index of the value.
public function pos( $value ) : ?int
```

* @param \Closure&#124;mixed $value Value to search for or function with (item, key) parameters return TRUE if value is found
* @param \Closure&#124;string|int $value Value to search for or function with (item, key) parameters return TRUE if value is found
* @return int&#124;null Position of the found value (zero based) or NULL if not found

**Examples:**
Expand Down
2 changes: 1 addition & 1 deletion src/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,7 @@ public function pop()
* Both examples will return "1" because the value "b" is at the second position
* and the returned index is zero based so the first item has the index "0".
*
* @param \Closure|mixed $value Value to search for or function with (item, key) parameters return TRUE if value is found
* @param \Closure|string|int $value Value to search for or function with (item, key) parameters return TRUE if value is found
* @return int|null Position of the found value (zero based) or NULL if not found
*/
public function pos( $value ) : ?int
Expand Down
7 changes: 7 additions & 0 deletions tests/MapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,13 @@ public function testPos()
$m = new Map( [4 => 'a', 8 => 'b'] );

$this->assertEquals( 1, $m->pos( 'b' ) );
}


public function testPosClosure()
{
$m = new Map( [4 => 'a', 8 => 'b'] );

$this->assertEquals( 1, $m->pos( function( $item, $key ) {
return $item === 'b';
} ) );
Expand Down

0 comments on commit 1118ca9

Please sign in to comment.