Skip to content

Commit ff62bb2

Browse files
allowingovertrue
authored andcommitted
不应该在类的定义文件中定义常量 (overtrue#128)
* 删除定义在类文件中的常量 由于类是自动加载的,那么在自动加载之前常量存在,因为这个文件还未被php引擎读取 * 新建定义常量的文件 这个文件由 composer 加载 * 增加自动加载常量的文件声明 * 修正:不应该是autoload-dev * 修正代码风格
1 parent f09615a commit ff62bb2

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"autoload": {
1818
"psr-4": {
1919
"Overtrue\\Pinyin\\": "src/"
20-
}
20+
},
21+
"files": "src/const.php"
2122
},
2223
"autoload-dev": {
2324
"psr-4": {

src/Pinyin.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@
2323
* @link http://overtrue.me
2424
*/
2525

26-
define('PINYIN_DEFAULT', 4096);
27-
define('PINYIN_TONE', 2);
28-
define('PINYIN_NO_TONE', 4);
29-
define('PINYIN_ASCII_TONE', 8);
30-
define('PINYIN_NAME', 16);
31-
define('PINYIN_KEEP_NUMBER', 32);
32-
define('PINYIN_KEEP_ENGLISH', 64);
33-
define('PINYIN_UMLAUT_V', 128);
34-
define('PINYIN_KEEP_PUNCTUATION', 256);
35-
3626
/**
3727
* Class Pinyin.
3828
*

src/const.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
define('PINYIN_DEFAULT', 4096);
4+
define('PINYIN_TONE', 2);
5+
define('PINYIN_NO_TONE', 4);
6+
define('PINYIN_ASCII_TONE', 8);
7+
define('PINYIN_NAME', 16);
8+
define('PINYIN_KEEP_NUMBER', 32);
9+
define('PINYIN_KEEP_ENGLISH', 64);
10+
define('PINYIN_UMLAUT_V', 128);
11+
define('PINYIN_KEEP_PUNCTUATION', 256);

0 commit comments

Comments
 (0)