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

@ -41,15 +41,8 @@ use SplFileInfo;
*/
class AttachmentDeleteListener
{
protected AttachmentReverseSearch $attachmentReverseSearch;
protected AttachmentManager $attachmentHelper;
protected AttachmentPathResolver $pathResolver;
public function __construct(AttachmentReverseSearch $attachmentReverseSearch, AttachmentManager $attachmentHelper, AttachmentPathResolver $pathResolver)
public function __construct(protected AttachmentReverseSearch $attachmentReverseSearch, protected AttachmentManager $attachmentHelper, protected AttachmentPathResolver $pathResolver)
{
$this->attachmentReverseSearch = $attachmentReverseSearch;
$this->attachmentHelper = $attachmentHelper;
$this->pathResolver = $pathResolver;
}
/**
@ -87,7 +80,7 @@ class AttachmentDeleteListener
//Ensure that the attachment that will be deleted, is not used as preview picture anymore...
$attachment_holder = $attachment->getElement();
if (null === $attachment_holder) {
if (!$attachment_holder instanceof \App\Entity\Attachments\AttachmentContainingDBElement) {
return;
}
@ -100,7 +93,7 @@ class AttachmentDeleteListener
if (!$em instanceof EntityManagerInterface) {
throw new \RuntimeException('Invalid EntityManagerInterface!');
}
$classMetadata = $em->getClassMetadata(get_class($attachment_holder));
$classMetadata = $em->getClassMetadata($attachment_holder::class);
$em->getUnitOfWork()->computeChangeSet($classMetadata, $attachment_holder);
}
}
@ -118,7 +111,7 @@ class AttachmentDeleteListener
$file = $this->attachmentHelper->attachmentToFile($attachment);
//Only delete if the attachment has a valid file.
if (null !== $file) {
if ($file instanceof \SplFileInfo) {
/* The original file has already been removed, so we have to decrease the threshold to zero,
as any remaining attachment depends on this attachment, and we must not delete this file! */
$this->attachmentReverseSearch->deleteIfNotUsed($file, 0);

View file

@ -35,13 +35,8 @@ use Symfony\Contracts\Cache\TagAwareCacheInterface;
class TreeCacheInvalidationListener
{
protected TagAwareCacheInterface $cache;
protected UserCacheKeyGenerator $keyGenerator;
public function __construct(TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator)
public function __construct(protected TagAwareCacheInterface $cache, protected UserCacheKeyGenerator $keyGenerator)
{
$this->cache = $treeCache;
$this->keyGenerator = $keyGenerator;
}
#[ORM\PostUpdate]
@ -51,7 +46,7 @@ class TreeCacheInvalidationListener
{
//If an element was changed, then invalidate all cached trees with this element class
if ($element instanceof AbstractStructuralDBElement || $element instanceof LabelProfile) {
$secure_class_name = str_replace('\\', '_', get_class($element));
$secure_class_name = str_replace('\\', '_', $element::class);
$this->cache->invalidateTags([$secure_class_name]);
//Trigger a sidebar reload for all users (see SidebarTreeUpdater service)
@ -62,7 +57,7 @@ class TreeCacheInvalidationListener
//If a user change, then invalidate all cached trees for him
if ($element instanceof User) {
$secure_class_name = str_replace('\\', '_', get_class($element));
$secure_class_name = str_replace('\\', '_', $element::class);
$tag = $this->keyGenerator->generateKey($element);
$this->cache->invalidateTags([$tag, $secure_class_name]);
}