From 8e40e2b5f47bf1e5a2ab072d4d38ed4be1604922 Mon Sep 17 00:00:00 2001 From: netjoin Date: Thu, 21 Feb 2019 08:57:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E6=88=91=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E6=96=87=E6=A1=A3=EF=BC=8C=E5=AE=89=E8=A3=85=E5=92=8C?= =?UTF-8?q?=E7=94=A8=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ composer.json | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 34f486c..4ea28e9 100644 --- a/README.md +++ b/README.md @@ -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'); +``` + diff --git a/composer.json b/composer.json index 20f4758..8ac8052 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "wuding/php-func", "description": "PHP function polyfill", - "keywords": ["Function", "Polyfill"], + "keywords": ["Function", "Polyfill", "Shim"], "license": "BSD-3-Clause", "authors": [ {