mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Added Macroable
for Hyperf\Utils\Arr
. (#4157)
Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
parent
8916691f53
commit
bcbcc49130
@ -1,5 +1,9 @@
|
||||
# v2.2.15 - TBD
|
||||
|
||||
## Added
|
||||
|
||||
- [#4157](https://github.com/hyperf/hyperf/pull/4157) Added `Macroable` for `Hyperf\Utils\Arr`.
|
||||
|
||||
# v2.2.14 - 2021-11-01
|
||||
|
||||
## Added
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Hyperf\Utils;
|
||||
|
||||
use ArrayAccess;
|
||||
use Hyperf\Macroable\Macroable;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,8 @@ use InvalidArgumentException;
|
||||
*/
|
||||
class Arr
|
||||
{
|
||||
use Macroable;
|
||||
|
||||
/**
|
||||
* Determine whether the given value is array accessible.
|
||||
* @param mixed $value
|
||||
|
@ -170,4 +170,14 @@ class ArrTest extends TestCase
|
||||
Arr::forget($data, [2]);
|
||||
$this->assertSame([1, 2], $data);
|
||||
}
|
||||
|
||||
public function testArrMacroable()
|
||||
{
|
||||
Arr::macro('foo', function () {
|
||||
return 'foo';
|
||||
});
|
||||
|
||||
$this->assertTrue(Arr::hasMacro('foo'));
|
||||
$this->assertFalse(Arr::hasMacro('bar'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user