-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.1.0 更改getYear()、getMonth()、getDay()的返回类型,非兼容性更新;新增吉神宜趋、凶神宜忌;新增每日宜忌…
…、时辰宜忌;新增支持方法扩展;修复农历日获取时辰列表遇闰月报错的问题。
- Loading branch information
Showing
35 changed files
with
915 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace com\tyme; | ||
|
||
use BadMethodCallException; | ||
use Closure; | ||
|
||
/** | ||
* 扩展Trait | ||
* @author 6tail | ||
* @package com\tyme | ||
*/ | ||
trait ExtendTrait | ||
{ | ||
/** | ||
* @var array 扩展方法列表 | ||
*/ | ||
protected static array $methods = []; | ||
|
||
/** | ||
* 扩展方法 | ||
* @param string $methodName 方法名 | ||
* @param Closure $function 方法体 | ||
* @return void | ||
*/ | ||
public static function extend(string $methodName, Closure $function): void | ||
{ | ||
static::$methods[$methodName] = $function; | ||
} | ||
|
||
/** | ||
* 方法调用 | ||
* @param $method string 方法名 | ||
* @param $parameters mixed 参数 | ||
* @return mixed | ||
* @throws BadMethodCallException | ||
*/ | ||
public function __call(string $method, mixed $parameters) | ||
{ | ||
if (!isset(static::$methods[$method])) { | ||
throw new BadMethodCallException(sprintf('Method %s not exist in %s', $method, static::class)); | ||
} | ||
$function = static::$methods[$method]; | ||
$function = $function->bindTo($this, static::class); | ||
return $function(...$parameters); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.