Added an PHP CS fixer config file and applied it to files.

We now use the same the same style as the symfony project, and it allows us to simply fix the style by executing php_cs_fixer fix in the project root.
This commit is contained in:
Jan Böhmer 2019-11-09 00:47:20 +01:00
parent 89258bc102
commit e557bdedd5
210 changed files with 2099 additions and 2742 deletions

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Helpers;
@ -26,7 +25,6 @@ use League\HTMLToMarkdown\HtmlConverter;
use s9e\TextFormatter\Bundles\Forum as TextFormatter;
use SebastianBergmann\CodeCoverage\Report\Text;
class BBCodeToMarkdownConverter
{
protected $html_to_markdown;
@ -39,10 +37,12 @@ class BBCodeToMarkdownConverter
/**
* Converts the given BBCode to markdown.
* BBCode tags that does not have a markdown aequivalent are outputed as HTML tags.
*
* @param $bbcode string The Markdown that should be converted.
*
* @return string The markdown version of the text.
*/
public function convert(string $bbcode) : string
public function convert(string $bbcode): string
{
//Convert BBCode to html
$xml = TextFormatter::parse($bbcode);
@ -51,4 +51,4 @@ class BBCodeToMarkdownConverter
//Now convert the HTML to markdown
return $this->html_to_markdown->convert($html);
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Helpers;
@ -25,7 +24,6 @@ namespace App\Helpers;
/**
* 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.
* @package App\Helpers
*/
class TreeViewNode
{
@ -39,11 +37,12 @@ class TreeViewNode
/**
* Creates a new TreeView node with the given parameters.
* @param string $text The text that is shown in the node. (e.g. the name of the node)
* @param string|null $href A link for the node. You have to activate "enableLinks" option in init of the treeview.
* Set this to null, if no href should be used.
* @param array|null $nodes An array containing other TreeViewNodes. They will be used as children nodes of the
* newly created nodes. Set to null, if it should not have children.
*
* @param string $text The text that is shown in the node. (e.g. the name of the node)
* @param string|null $href A link for the node. You have to activate "enableLinks" option in init of the treeview.
* Set this to null, if no href should be used.
* @param array|null $nodes An array containing other TreeViewNodes. They will be used as children nodes of the
* newly created nodes. Set to null, if it should not have children.
*/
public function __construct(string $text, ?string $href = null, ?array $nodes = null)
{
@ -56,6 +55,7 @@ class TreeViewNode
/**
* Returns the node text.
*
* @return string
*/
public function getText(): string
@ -64,18 +64,22 @@ class TreeViewNode
}
/**
* Sets the node text
* Sets the node text.
*
* @param string $text The new node text.
*
* @return TreeViewNode
*/
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
/**
* Returns the href link.
*
* @return string|null
*/
public function getHref(): ?string
@ -85,17 +89,21 @@ class TreeViewNode
/**
* Sets the href link.
*
* @param string|null $href The new href link.
*
* @return TreeViewNode
*/
public function setHref(?string $href): self
{
$this->href = $href;
return $this;
}
/**
* Returns the children nodes of this node.
*
* @return array|null
*/
public function getNodes(): ?array
@ -105,30 +113,34 @@ class TreeViewNode
/**
* Sets the children nodes.
*
* @param array|null $nodes The new children nodes
*
* @return TreeViewNode
*/
public function setNodes(?array $nodes): self
{
$this->nodes = $nodes;
return $this;
}
public function getState() : ?TreeViewNodeState
public function getState(): ?TreeViewNodeState
{
return $this->state;
}
public function setState(TreeViewNodeState $state) : self
public function setState(TreeViewNodeState $state): self
{
$this->state = $state;
return $this;
}
public function setDisabled(?bool $disabled) : self
public function setDisabled(?bool $disabled): self
{
//Lazy loading of state, so it does not need to get serialized and transfered, when it is empty.
if ($this->state == null) {
if (null == $this->state) {
$this->state = new TreeViewNodeState();
}
@ -137,10 +149,10 @@ class TreeViewNode
return $this;
}
public function setSelected(?bool $selected) : self
public function setSelected(?bool $selected): self
{
//Lazy loading of state, so it does not need to get serialized and transfered, when it is empty.
if ($this->state == null) {
if (null == $this->state) {
$this->state = new TreeViewNodeState();
}
@ -149,21 +161,20 @@ class TreeViewNode
return $this;
}
public function getTags() : ?array
public function getTags(): ?array
{
return $this->tags;
}
public function addTag(string $new_tag) : self
public function addTag(string $new_tag): self
{
//Lazy loading tags
if ($this->tags == null) {
$this->tags = array();
if (null == $this->tags) {
$this->tags = [];
}
$this->tags[] = $new_tag;
return $this;
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,24 +17,22 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Helpers;
class TreeViewNodeState
{
/** @var null|bool */
/** @var bool|null */
protected $checked = null;
/** @var null|bool */
/** @var bool|null */
protected $disabled = null;
/** @var null|bool */
/** @var bool|null */
protected $expanded = null;
/** @var null|bool */
/** @var bool|null */
protected $selected = null;
/**
@ -45,9 +43,6 @@ class TreeViewNodeState
return $this->disabled;
}
/**
* @param bool|null $disabled
*/
public function setDisabled(?bool $disabled): void
{
$this->disabled = $disabled;
@ -61,9 +56,6 @@ class TreeViewNodeState
return $this->expanded;
}
/**
* @param bool|null $expanded
*/
public function setExpanded(?bool $expanded): void
{
$this->expanded = $expanded;
@ -77,13 +69,8 @@ class TreeViewNodeState
return $this->selected;
}
/**
* @param bool|null $selected
*/
public function setSelected(?bool $selected): void
{
$this->selected = $selected;
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Helpers;
@ -28,8 +27,7 @@ use Doctrine\DBAL\Types\DateTimeType;
/**
* This DateTimeType all dates to UTC, so it can be later used with the timezones.
* Taken from here: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/working-with-datetime.html
* @package App\Helpers
* Taken from here: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/working-with-datetime.html.
*/
class UTCDateTimeType extends DateTimeType
{
@ -64,14 +62,10 @@ class UTCDateTimeType extends DateTimeType
self::$utc_timezone
);
if (! $converted) {
throw ConversionException::conversionFailedFormat(
$value,
$this->getName(),
$platform->getDateTimeFormatString()
);
if (!$converted) {
throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
}
return $converted;
}
}
}