Skip to content

Commit 0f7d89c

Browse files
phananlstrojny
authored andcommitted
feat: Add a noop() function (#195)
1 parent 7aadb25 commit 0f7d89c

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"src/Functional/Memoize.php",
7878
"src/Functional/Minimum.php",
7979
"src/Functional/None.php",
80+
"src/Functional/Noop.php",
8081
"src/Functional/Not.php",
8182
"src/Functional/OmitKeys.php",
8283
"src/Functional/PartialAny.php",

docs/functional-php.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
- [id()](#id)
6868
- [tap()](#tap)
6969
- [repeat()](#repeat)
70+
- [noop()](#noop)
7071

7172
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
7273

@@ -1063,7 +1064,6 @@ $one = const_function(1);
10631064
$one(); // -> 1
10641065
```
10651066

1066-
10671067
## id()
10681068
Proxy function that does nothing except returning its first argument.
10691069

@@ -1097,4 +1097,10 @@ use function Functional\repeat;
10971097
repeat(function () {
10981098
echo 'foo';
10991099
})(3); // 'foofoofoo'
1100-
```
1100+
```
1101+
1102+
## noop()
1103+
1104+
A no-operation function, i.e. a function that does nothing.
1105+
1106+
``void Functional\noop()``

src/Functional/Functional.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ final class Functional
272272
*/
273273
const none = '\Functional\none';
274274

275+
/**
276+
* @see \Functional\noop
277+
*/
278+
const noop = '\Functional\noop';
279+
275280
/**
276281
* @see \Functional\not
277282
*/

src/Functional/Noop.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Copyright (C) 2011-2017 by Lars Strojny <lstrojny@php.net>
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
namespace Functional;
24+
25+
/**
26+
* A no-operation function.
27+
*/
28+
function noop()
29+
{
30+
}

0 commit comments

Comments
 (0)