phpstorm写php代码提示,phpstorm中编写了类如何进行友好代码提示

在一个类文件头部,写入下面代码:/**

* 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);

}

}

}

那么我们在phpstorm声明类的时候后,就会 进行代码提醒

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值