Applied rector with PHP8.1 migration rules

This commit is contained in:
Jan Böhmer 2023-06-11 14:15:46 +02:00
parent dc6a67c2f0
commit 7ee01d9a05
303 changed files with 1228 additions and 3465 deletions

View file

@ -46,8 +46,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
*
*/
#[UniqueEntity(fields: ['name', 'parent'], ignoreNull: false, message: 'structural.entity.unique_name')]
#[ORM\MappedSuperclass(repositoryClass: 'App\Repository\StructuralDBElementRepository')]
#[ORM\EntityListeners(['App\EntityListeners\TreeCacheInvalidationListener'])]
#[ORM\MappedSuperclass(repositoryClass: \App\Repository\StructuralDBElementRepository::class)]
#[ORM\EntityListeners([\App\EntityListeners\TreeCacheInvalidationListener::class])]
abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
{
use ParametersTrait;
@ -105,7 +105,6 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
parent::__construct();
$this->children = new ArrayCollection();
$this->parameters = new ArrayCollection();
$this->parent = null;
}
public function __clone()
@ -141,11 +140,11 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
//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 (!$another_element instanceof $class_name && !is_a($this, $another_element::class)) {
throw new InvalidArgumentException('isChildOf() only works for objects of the same type!');
}
if (null === $this->getParent()) { // this is the root node
if (!$this->getParent() instanceof \App\Entity\Base\AbstractStructuralDBElement) { // this is the root node
return false;
}
@ -170,7 +169,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
*/
public function isRoot(): bool
{
return null === $this->parent;
return !$this->parent instanceof \App\Entity\Base\AbstractStructuralDBElement;
}
/******************************************************************************
@ -213,9 +212,9 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
/*
* Only check for nodes that have a parent. In the other cases zero is correct.
*/
if (0 === $this->level && null !== $this->parent) {
if (0 === $this->level && $this->parent instanceof \App\Entity\Base\AbstractStructuralDBElement) {
$element = $this->parent;
while (null !== $element) {
while ($element instanceof \App\Entity\Base\AbstractStructuralDBElement) {
/** @var AbstractStructuralDBElement $element */
$element = $element->parent;
++$this->level;
@ -234,14 +233,14 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
*/
public function getFullPath(string $delimiter = self::PATH_DELIMITER_ARROW): string
{
if (empty($this->full_path_strings)) {
if ($this->full_path_strings === []) {
$this->full_path_strings = [];
$this->full_path_strings[] = $this->getName();
$element = $this;
$overflow = 20; //We only allow 20 levels depth
while (null !== $element->parent && $overflow >= 0) {
while ($element->parent instanceof \App\Entity\Base\AbstractStructuralDBElement && $overflow >= 0) {
$element = $element->parent;
$this->full_path_strings[] = $element->getName();
//Decrement to prevent mem overflow.
@ -328,7 +327,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
$this->parent = $new_parent;
//Add this element as child to the new parent
if (null !== $new_parent) {
if ($new_parent instanceof \App\Entity\Base\AbstractStructuralDBElement) {
$new_parent->getChildren()->add($this);
}