PHP和PSR-8中的HuggableInterface

rin*_*t.6 12 php interface

PHP Framework Interop Group站点(PSR的维护者)上,有一个草案PSR-8 Huggable Interface:

namespace Psr\Hug;

/**
 * Defines a huggable object.
 *
 * A huggable object expresses mutual affection with another huggable object.
 */
interface Huggable
{

    /**
     * Hugs this object.
     *
     * All hugs are mutual. An object that is hugged MUST in turn hug the other
     * object back by calling hug() on the first parameter. All objects MUST
     * implement a mechanism to prevent an infinite loop of hugging.
     *
     * @param Huggable $h
     *   The object that is hugging this object.
     */
    public function hug(Huggable $h);
}
Run Code Online (Sandbox Code Playgroud)

草案很短,但没有提供任何实施的例子.实现此接口的目的是什么?

Chr*_*anM 24

正玩得开心!

查看合并日期:

Crell于2014年4月1日合并接口定义.

这是个玩笑:)(愚人节.)


dav*_*010 6

我在这里开始实施:https : //github.com/dave1010/php-fig-psr-8

它尚未完成(欢迎贡献者!),但如果您的项目中需要PSR-8实施,它已经很有用。