sabbelasichon / typo3-rector

Rector for TYPO3
MIT License
231 stars 63 forks source link

[BUG] ConstantsToBackedEnumValueRector with IconSize is triggering deprecation #4449

Closed wtfred closed 3 days ago

wtfred commented 5 days ago

Minimal PHP Code Causing Issue

->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));

Is leading to:

-            ->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
+            ->setIcon($this->iconFactory->getIcon('actions-refresh', IconSize::SMALL->value));

Applied rules

ConstantsToBackedEnumValueRector

Expected Behaviour

-            ->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
+            ->setIcon($this->iconFactory->getIcon('actions-refresh', IconSize::SMALL));

Package Version

2.11.0

PHP Version

8.3.12

TYPO3 Version

13.4.1

Notes

In vendor/typo3/cms-core/Classes/Imaging/IconFactory.php

There is this block that is triggering deprecation if code is migrated to IconSize::SMALL->value

if (is_string($size)) {
        $size = IconSize::from($size);
        $size->triggerDeprecation();
}

Relates: #3698

simonschaufi commented 3 days ago

Thank you, the migration in #3698 was indeed done wrong.