phpstorm 利用@property @method 友好提示變量指向


/**

 * A simple API extension for DateInterval.
 * The implemenation provides helpers to handle weeks but only days are saved.
 * Weeks are calculated based on the total days of the current instance.
 *
 * @property int $years Total years of the current interval.
 * @property int $months Total months of the current interval.
 * @property int $weeks Total weeks of the current interval calculated from the days.
 * @property int $dayz Total days of the current interval (weeks * 7 + days).
 * @property int $hours Total hours of the current interval.
 * @property int $minutes Total minutes of the current interval.
 * @property int $seconds Total seconds of the current interval.
 *
 * @property-read integer $dayzExcludeWeeks Total days remaining in the final week of the current instance (days % 7).
 * @property-read integer $daysExcludeWeeks alias of dayzExcludeWeeks
 *
 * @method static CarbonInterval years($years = 1) Create instance specifying a number of years.
 * @method static CarbonInterval year($years = 1) Alias for years()
 * @method static CarbonInterval months($months = 1) Create instance specifying a number of months.
 * @method static CarbonInterval month($months = 1) Alias for months()
 * @method static CarbonInterval weeks($weeks = 1) Create instance specifying a number of weeks.
 * @method static CarbonInterval week($weeks = 1) Alias for weeks()
 * @method static CarbonInterval days($days = 1) Create instance specifying a number of days.
 * @method static CarbonInterval dayz($days = 1) Alias for days()
 * @method static CarbonInterval day($days = 1) Alias for days()
 * @method static CarbonInterval hours($hours = 1) Create instance specifying a number of hours.
 * @method static CarbonInterval hour($hours = 1) Alias for hours()
 * @method static CarbonInterval minutes($minutes = 1) Create instance specifying a number of minutes.
 * @method static CarbonInterval minute($minutes = 1) Alias for minutes()
 
 */
 class CarbonInterval extends DateInterval
{
 
//結合這個方法,就能個非常友好 靜態方法的提示
public static function __callStatic($name, $args)
{
    $arg = count($args) === 0 ? 1 : $args[0];
 
    switch ($name) {
        case 'years':
        case 'year':
            return new static($arg);
 
        case 'months':
        case 'month':
            return new static(null, $arg);
 
        case 'weeks':
        case 'week':
            return new static(null, null, $arg);
 
        case 'days':
        case 'dayz':
        case 'day':
            return new static(null, null, null, $arg);
 
        case 'hours':
        case 'hour':
            return new static(null, null, null, null, $arg);
 
        case 'minutes':
        case 'minute':
            return new static(null, null, null, null, null, $arg);
 
        case 'seconds':
        case 'second':
            return new static(null, null, null, null, null, null, $arg);
    }
}
 
 
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM