Fixed code style.

This commit is contained in:
Jan Böhmer 2020-01-04 20:24:09 +01:00
parent 1aed1d1d26
commit 9a7223a301
142 changed files with 534 additions and 716 deletions

View file

@ -21,10 +21,8 @@
namespace App\Helpers\Trees;
use App\Entity\Base\StructuralDBElement;
use Doctrine\Common\Collections\Collection;
use RecursiveIterator;
class StructuralDBElementIterator extends \ArrayIterator implements \RecursiveIterator
{
@ -37,22 +35,24 @@ class StructuralDBElementIterator extends \ArrayIterator implements \RecursiveIt
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hasChildren()
{
/** @var StructuralDBElement $element */
$element = $this->current();
return !empty($element->getSubelements());
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function getChildren()
{
/** @var StructuralDBElement $element */
$element = $this->current();
return new StructuralDBElementIterator($element->getSubelements()->toArray());
return new self($element->getSubelements()->toArray());
}
}
}

View file

@ -21,11 +21,6 @@
namespace App\Helpers\Trees;
use App\Entity\Base\DBElement;
use App\Entity\Base\NamedDBElement;
use App\Entity\Base\StructuralDBElement;
use App\Helpers\Trees\TreeViewNodeState;
/**
* This class represents a node for the bootstrap treeview node.
* When you serialize an array of these objects to JSON, you can use the serialized data in data for the treeview.
@ -63,9 +58,10 @@ class TreeViewNode implements \JsonSerializable
/**
* Return the ID of the entity associated with this node.
* Null if this node is not connected with an entity.
*
* @return int|null
*/
public function getId() : ?int
public function getId(): ?int
{
return $this->id;
}
@ -73,12 +69,13 @@ class TreeViewNode implements \JsonSerializable
/**
* Sets the ID of the entity associated with this node.
* Null if this node is not connected with an entity.
* @param int|null $id
*
* @return $this
*/
public function setId(?int $id): self
{
$this->id = $id;
return $this;
}
@ -208,27 +205,27 @@ class TreeViewNode implements \JsonSerializable
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function jsonSerialize()
{
$ret = [
'text' => $this->text
'text' => $this->text,
];
if($this->href !== null) {
if (null !== $this->href) {
$ret['href'] = $this->href;
}
if($this->tags !== null) {
if (null !== $this->tags) {
$ret['tags'] = $this->tags;
}
if($this->nodes !== null) {
if (null !== $this->nodes) {
$ret['nodes'] = $this->nodes;
}
if($this->state !== null) {
if (null !== $this->state) {
$ret['state'] = $this->state;
}

View file

@ -21,11 +21,8 @@
namespace App\Helpers\Trees;
use App\Helpers\Trees\TreeViewNode;
class TreeViewNodeIterator extends \ArrayIterator implements \RecursiveIterator
{
/**
* @param $nodes TreeViewNode[]
*/
@ -35,22 +32,24 @@ class TreeViewNodeIterator extends \ArrayIterator implements \RecursiveIterator
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hasChildren()
{
/** @var TreeViewNode $element */
$element = $this->current();
return !empty($element->getNodes());
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function getChildren()
{
/** @var TreeViewNode $element */
$element = $this->current();
return new TreeViewNodeIterator($element->getNodes());
return new self($element->getNodes());
}
}
}

View file

@ -75,20 +75,20 @@ class TreeViewNodeState implements \JsonSerializable
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function jsonSerialize()
{
$ret = [];
if ($this->selected !== null) {
if (null !== $this->selected) {
$ret['selected'] = $this->selected;
}
if($this->disabled !== null) {
if (null !== $this->disabled) {
$ret['disabled'] = $this->disabled;
}
if($this->expanded !== null) {
if (null !== $this->expanded) {
$ret['expanded'] = $this->expanded;
}