PHP code example of ciaranmcnulty / phpspec-typehintedmethods

1. Go to this page and download the library: Download ciaranmcnulty/phpspec-typehintedmethods library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ciaranmcnulty / phpspec-typehintedmethods example snippets


function it_does_foo()
{
    $this->foo(new \ArrayObject());
}

public function foo(\ArrayObject $arrayObject)
{
    // TODO: write logic here
}

function it_does_something_with_a_token(TokenInterface $token)
{
    $token->getId()->willReturn(1234);

    $this->foo($token)->shouldReturn(1234);
}

function it_does_something_with_a_token(ArrayToken $token)
{
    $token->getId()->willReturn(1234);

    $this->foo($token)->shouldReturn(1234);
}