Autocompleting PhpSpec's SUS in PhpStorm

TL;DR: adding @mixin annotation to your specifications you will give you SUS auto-completion.

I think one of the problems of PhpSpec adaptation is lack of IDE's support, and while community is doing heck of a job asking for official support on Jetbrains Issue tracker we still can make our life easier with a little trick.

To quickly explain how @mixin annotation in PhpStorm works I'll quote Jetbrains blog:

PhpStorm will interpret @mixin annotation the same way as actual “use trait”

And this essentially will give us full auto-completion and hinting of methods that we may want to use.

Let's consider following example of String Calculator:

class StringCalculator  
    public function sum($number)
        return (int) $number;

And in order to get auto-completion of the SUS your spec needs to look like:

namespace spec;

use PhpSpec\ObjectBehavior;  
use StringCalculator;

 * @mixin StringCalculator
class StringCalculatorSpec extends ObjectBehavior  
    function it_returns_bare_number()

And that's it. Hope it will enrich your PhpSpec and PhpStorm experience.

I've also included video that demonstrates usage: