add psalm and travis check

This commit is contained in:
Dominik Liebler
2019-08-31 14:31:01 +02:00
parent 88bd6ab7f1
commit 5fb2980b45
17 changed files with 1215 additions and 45 deletions

View File

@@ -5,7 +5,10 @@ namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Tests;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\HttpInMemoryCacheHandler;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowDatabaseHandler;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\UriInterface;
class ChainTest extends TestCase
{
@@ -24,11 +27,11 @@ class ChainTest extends TestCase
public function testCanRequestKeyInFastStorage()
{
$uri = $this->createMock('Psr\Http\Message\UriInterface');
$uri = $this->createMock(UriInterface::class);
$uri->method('getPath')->willReturn('/foo/bar');
$uri->method('getQuery')->willReturn('index=1');
$request = $this->createMock('Psr\Http\Message\RequestInterface');
$request = $this->createMock(RequestInterface::class);
$request->method('getMethod')
->willReturn('GET');
$request->method('getUri')->willReturn($uri);
@@ -38,11 +41,11 @@ class ChainTest extends TestCase
public function testCanRequestKeyInSlowStorage()
{
$uri = $this->createMock('Psr\Http\Message\UriInterface');
$uri = $this->createMock(UriInterface::class);
$uri->method('getPath')->willReturn('/foo/baz');
$uri->method('getQuery')->willReturn('');
$request = $this->createMock('Psr\Http\Message\RequestInterface');
$request = $this->createMock(RequestInterface::class);
$request->method('getMethod')
->willReturn('GET');
$request->method('getUri')->willReturn($uri);

View File

@@ -2,25 +2,27 @@
namespace DesignPatterns\Behavioral\Observer;
use SplSubject;
class UserObserver implements \SplObserver
{
/**
* @var User[]
* @var SplSubject[]
*/
private $changedUsers = [];
/**
* It is called by the Subject, usually by SplSubject::notify()
*
* @param \SplSubject $subject
* @param SplSubject $subject
*/
public function update(\SplSubject $subject)
public function update(SplSubject $subject)
{
$this->changedUsers[] = clone $subject;
}
/**
* @return User[]
* @return SplSubject[]
*/
public function getChangedUsers(): array
{

View File

@@ -10,7 +10,7 @@ class AndSpecification implements Specification
private $specifications;
/**
* @param Specification[] ...$specifications
* @param Specification[] $specifications
*/
public function __construct(Specification ...$specifications)
{

View File

@@ -10,14 +10,14 @@ class OrSpecification implements Specification
private $specifications;
/**
* @param Specification[] ...$specifications
* @param Specification[] $specifications
*/
public function __construct(Specification ...$specifications)
{
$this->specifications = $specifications;
}
/**
/*
* if at least one specification is true, return true, else return false
*/
public function isSatisfiedBy(Item $item): bool