update deps & install rector

This commit is contained in:
Dominik Liebler
2019-12-14 12:50:05 +01:00
parent 04acce6759
commit 579a5ac946
87 changed files with 2432 additions and 786 deletions

View File

@@ -11,15 +11,13 @@ class Form implements Renderable
/**
* @var Renderable[]
*/
private $elements;
private array $elements;
/**
* runs through all elements and calls render() on them, then returns the complete representation
* of the form.
*
* from the outside, one will not see this and the form will act like a single object instance
*
* @return string
*/
public function render(): string
{
@@ -34,9 +32,6 @@ class Form implements Renderable
return $formCode;
}
/**
* @param Renderable $element
*/
public function addElement(Renderable $element)
{
$this->elements[] = $element;

View File

@@ -2,19 +2,21 @@
namespace DesignPatterns\Structural\Composite\Tests;
use DesignPatterns\Structural\Composite;
use DesignPatterns\Structural\Composite\Form;
use DesignPatterns\Structural\Composite\TextElement;
use DesignPatterns\Structural\Composite\InputElement;
use PHPUnit\Framework\TestCase;
class CompositeTest extends TestCase
{
public function testRender()
{
$form = new Composite\Form();
$form->addElement(new Composite\TextElement('Email:'));
$form->addElement(new Composite\InputElement());
$embed = new Composite\Form();
$embed->addElement(new Composite\TextElement('Password:'));
$embed->addElement(new Composite\InputElement());
$form = new Form();
$form->addElement(new TextElement('Email:'));
$form->addElement(new InputElement());
$embed = new Form();
$embed->addElement(new TextElement('Password:'));
$embed->addElement(new InputElement());
$form->addElement($embed);
// This is just an example, in a real world scenario it is important to remember that web browsers do not

View File

@@ -4,10 +4,7 @@ namespace DesignPatterns\Structural\Composite;
class TextElement implements Renderable
{
/**
* @var string
*/
private $text;
private string $text;
public function __construct(string $text)
{