@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @var array |
17 | 17 | */ |
18 | - protected static $namespace=[ __NAMESPACE__ ]; |
|
18 | + protected static $namespace = [__NAMESPACE__]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * 包含路径 |
22 | 22 | * |
23 | 23 | * @var array |
24 | 24 | */ |
25 | - protected static $includePath=[]; |
|
25 | + protected static $includePath = []; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * 将JAVA,路径分割转换为PHP分割符 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function realName(string $name):string |
34 | 34 | { |
35 | - return str_replace(['.','/'], '\\', $name); |
|
35 | + return str_replace(['.', '/'], '\\', $name); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | * @param string $name |
42 | 42 | * @return string|null |
43 | 43 | */ |
44 | - public static function realPath(string $name):?string |
|
44 | + public static function realPath(string $name): ?string |
|
45 | 45 | { |
46 | 46 | $absulotePath = static::toAbsolutePath($name); |
47 | - return file_exists($absulotePath)?$absulotePath:null; |
|
47 | + return file_exists($absulotePath) ? $absulotePath : null; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param string $filename |
65 | 65 | * @return string|null |
66 | 66 | */ |
67 | - public static function import(string $filename):?string |
|
67 | + public static function import(string $filename): ?string |
|
68 | 68 | { |
69 | 69 | if ($filename = static::realPath($filename)) { |
70 | 70 | @require_once $filename; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param string $className |
102 | 102 | * @return string|null |
103 | 103 | */ |
104 | - public static function getClassPath(string $className):?string |
|
104 | + public static function getClassPath(string $className): ?string |
|
105 | 105 | { |
106 | 106 | // 搜索路径 |
107 | 107 | foreach (static::$includePath as $includeNamespace => $includePaths) { |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | * @param string $className |
124 | 124 | * @return string|null |
125 | 125 | */ |
126 | - protected static function getClassPathByAlias(string $includePath, string $className):?string |
|
126 | + protected static function getClassPathByAlias(string $includePath, string $className): ?string |
|
127 | 127 | { |
128 | - $namepath=static::formatSeparator($className); |
|
129 | - $className=static::realName($className); |
|
128 | + $namepath = static::formatSeparator($className); |
|
129 | + $className = static::realName($className); |
|
130 | 130 | foreach (static::$namespace as $namespace) { |
131 | 131 | $path = $includePath.DIRECTORY_SEPARATOR.$namespace.DIRECTORY_SEPARATOR.$namepath.'.php'; |
132 | 132 | if ($path = static::realPath($path)) { |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | * @param string $className |
149 | 149 | * @return string|null |
150 | 150 | */ |
151 | - protected static function getClassPathByName(string $includeNamespace, string $includePath, string $className):?string |
|
151 | + protected static function getClassPathByName(string $includeNamespace, string $includePath, string $className): ?string |
|
152 | 152 | { |
153 | 153 | if (is_numeric($includeNamespace)) { |
154 | 154 | $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php'; |
155 | 155 | } else { |
156 | 156 | $nl = strlen($includeNamespace); |
157 | 157 | if (substr(static::realName($className), 0, $nl) === $includeNamespace) { |
158 | - $path=$includePath.DIRECTORY_SEPARATOR.static::formatSeparator(substr($className, $nl)).'.php'; |
|
158 | + $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator(substr($className, $nl)).'.php'; |
|
159 | 159 | } else { |
160 | - $path=$includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php'; |
|
160 | + $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php'; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | if ($path = static::realPath($path)) { |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | return nulll; |
167 | 167 | } |
168 | 168 | |
169 | - public static function addIncludePath(string $path, string $namespace=null) |
|
169 | + public static function addIncludePath(string $path, string $namespace = null) |
|
170 | 170 | { |
171 | 171 | if ($path = static::realPath($path)) { |
172 | 172 | $namespace = $namespace ?? 0; |
173 | 173 | if (array_key_exists($namespace, static::$includePath)) { |
174 | 174 | if (!\in_array($path, static::$includePath[$namespace])) { |
175 | - static::$includePath[$namespace][]=$path; |
|
175 | + static::$includePath[$namespace][] = $path; |
|
176 | 176 | } |
177 | 177 | } else { |
178 | - static::$includePath[$namespace][]=$path; |
|
178 | + static::$includePath[$namespace][] = $path; |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | public static function setNamespace(string $namespace) |
194 | 194 | { |
195 | 195 | if (!in_array($namespace, static::$namespace)) { |
196 | - static::$namespace[]=$namespace; |
|
196 | + static::$namespace[] = $namespace; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |