Skip to content

Commit

Permalink
添加自我描述文档,安装和用法
Browse files Browse the repository at this point in the history
  • Loading branch information
wuding committed Feb 21, 2019
1 parent ab0ab32 commit 8e40e2b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,73 @@
# php-func

PHP 通用函数库及别名定义,按需加载



## Install

```sh
composer require wuding/php-func
```



## Usage

### func

func - 定义函数别名



#### 说明

```php
func ( mixed $function_config [, array $alias_classes = array() [ , mixed $... ]] ) : void
```

单独或批量定义函数别名,并预设参数默认值



#### 参数

**function_config**

要调用或声明的原始函数(名),也可以是批量配置

**alias_classes**

要定义的函数别名或依赖哪些类

**...**

函数的参数



#### 范例

bootstrap.php


```php
$Composer = require APP_PATH . '/../vendor/autoload.php';

$functions = [
'_isset' => ['', [], '', null],
'\Func\array_diff_kv' => ['', [], [], [], false],
'\Func\Arr::diff' => ['\Func\diff', [], [], [], false],
'str_match' => ['', '//', '', null, false],
'wtf' => [function ($text) { return $text; }, 'hi'],
];

func($functions, ['Variable', 'Arr', 'PCRE']);
func('\Func\Str\unicode_decode', '', [], [], [], false);
new \Func\Alias('test', function ($text) { return $text; }, 'test');

echo str_match('/^\d+元/', '3元', '1角', true);
echo unicode_decode('\u65b0\u6d6a\u5fae\u535a', 'json');
echo test('str');
```

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wuding/php-func",
"description": "PHP function polyfill",
"keywords": ["Function", "Polyfill"],
"keywords": ["Function", "Polyfill", "Shim"],
"license": "BSD-3-Clause",
"authors": [
{
Expand Down

0 comments on commit 8e40e2b

Please sign in to comment.