IDE友好的PHP代码

in PHP with 0 comment
<?php
/**
 * User: widdy
 * Date: 2018/5/17
 * Time: 18:29
 */

/**
 * 属性自动提示
 * @property int $years Total years of the current interval.
 * @property int $seconds Total seconds of the current interval.
 * @property-read int $dayzExcludeWeeks Total days remaining in the final week of the current instance (days % 7).
 * @property-read int $daysExcludeWeeks alias of dayzExcludeWeeks
 *
 * 静态方法自动提示
 * @method static string version()
 * @method static bool isDownForMaintenance()
 * @method static void registerConfiguredProviders()
 * @method static void registerDeferredProvider(string $provider, string $service = null)
 * @method static void boot()
 * @method static void booting(mixed $callback)
 * @method static void booted(mixed $callback)
 * @method static string getCachedServicesPath()
 *
 * 方法自动提示
 * @method bool hasEmergencyThatContains($message)
 */
class Foo
{
    public static function __callStatic($name, $arguments)
    {
        // TODO: Implement __callStatic() method.
    }
    public function __call($name, $arguments)
    {
        // TODO: Implement __call() method.
    }
    public function __get($name)
    {
        // TODO: Implement __get() method.
    }
}

有时候我们的类会有一些魔术方法来添加一些属性或者方法;此时IDE是分析不出来这些,也就没办法做自动提示。
我们可以将这些属性或方法添加到 注释,这样IDE就可以自动提示了。

Comments are closed.