HuggableInterface in PHP and PSR-8

2.5k views Asked by At

On the PHP Framework Interop Group site (the maintainer of PSRs), there is a draft 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);
}

The draft is quite short but does not provide any examples of implementation. What is the purpose of implementing this interface?

2

There are 2 answers

0
ChristianM On BEST ANSWER

Having fun!

See merge date:

Crell on Apr 1, 2014 Merge in interface definitions.

It's a joke :) (April fools' day.)

0
dave1010 On

I started an implementation here: https://github.com/dave1010/php-fig-psr-8

It's not quite finished (contributors welcome!) but already useful if you need a PSR-8 implementation in your projects.