Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ConstantsToBackedEnumValueRector migrates incorrectly #4473

Open
alexanderschnitzler opened this issue Jan 21, 2025 · 1 comment
Open
Labels

Comments

@alexanderschnitzler
Copy link

Minimal PHP Code Causing Issue

This rule migrates the following constants to enums:

TYPO3\CMS\Core\Resource\File::FILETYPE_*

Example:

- TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
+ TYPO3\CMS\Core\Resource\FileType::IMAGE => [

The problem is that those constants were integers and the replacement is an enum (object) with a corresponding integer value. This however breaks most, if not all code.

Applied rules

\Ssch\TYPO3Rector\General\Renaming\ConstantsToBackedEnumValueRector

Expected Behaviour

Expected behaviour would be to replace int constant usages with int enum values:

- TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
+ TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [

Package Version

2.0.7

PHP Version

8.2.0

TYPO3 Version

13.4.0

Notes

No response

@alexanderschnitzler
Copy link
Author

Another example outside of TCA, a comparison:

- if ($image->getOriginalResource()->getType() === \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE) {
+ if ($image->getOriginalResource()->getType() === \TYPO3\CMS\Core\Resource\FileType::IMAGE) {

This is also broken, as $image->getOriginalResource()->getType() still returns an integer in 13.4, not an enum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant