Applied code style rules to src/

This commit is contained in:
Jan Böhmer 2020-01-05 15:46:58 +01:00
parent 700c049d26
commit f861de791f
186 changed files with 1462 additions and 1059 deletions

View file

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
/**
* Part-DB Version 0.4+ "nextgen"
* Copyright (C) 2016 - 2019 Jan Böhmer

View file

@ -66,6 +66,12 @@ abstract class DBElement
*/
protected $id;
public function __clone()
{
//Set ID to null, so that an new entry is created
$this->id = null;
}
/**
* Get the ID. The ID can be zero, or even negative (for virtual elements). If an element is virtual, can be
* checked with isVirtualElement().
@ -86,10 +92,4 @@ abstract class DBElement
* @return string The ID as a string;
*/
abstract public function getIDString(): string;
public function __clone()
{
//Set ID to null, so that an new entry is created
$this->id = null;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -45,6 +45,17 @@ abstract class NamedDBElement extends DBElement
*/
protected $name = '';
/******************************************************************************
*
* Helpers
*
******************************************************************************/
public function __toString()
{
return $this->getName();
}
/********************************************************************************
*
* Getters
@ -80,15 +91,4 @@ abstract class NamedDBElement extends DBElement
return $this;
}
/******************************************************************************
*
* Helpers
*
******************************************************************************/
public function __toString()
{
return $this->getName();
}
}

View file

@ -113,11 +113,11 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
*/
public function isChildOf(self $another_element): bool
{
$class_name = \get_class($this);
$class_name = static::class;
//Check if both elements compared, are from the same type
// (we have to check inheritance, or we get exceptions when using doctrine entities (they have a proxy type):
if (!is_a($another_element, $class_name) && !is_a($this, \get_class($another_element))) {
if (! is_a($another_element, $class_name) && ! is_a($this, \get_class($another_element))) {
throw new \InvalidArgumentException('isChildOf() only works for objects of the same type!');
}
@ -201,7 +201,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
*/
public function getFullPath(string $delimiter = self::PATH_DELIMITER_ARROW): string
{
if (!\is_array($this->full_path_strings)) {
if (! \is_array($this->full_path_strings)) {
$this->full_path_strings = [];
$this->full_path_strings[] = $this->getName();
$element = $this;
@ -233,7 +233,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
$tmp[] = $this;
//We only allow 20 levels depth
while (!end($tmp)->isRoot() && \count($tmp) < 20) {
while (! end($tmp)->isRoot() && \count($tmp) < 20) {
$tmp[] = end($tmp)->parent;
}
@ -243,8 +243,6 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
/**
* Get all sub elements of this element.
*
* @param bool $recursive if true, the search is recursive
*
* @return Collection<static> all subelements as an array of objects (sorted by their full path)
*/
public function getSubelements(): iterable

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*