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

BackedEnum could not be converted to int #115

Closed
test789t opened this issue Oct 13, 2022 · 1 comment · Fixed by #117
Closed

BackedEnum could not be converted to int #115

test789t opened this issue Oct 13, 2022 · 1 comment · Fixed by #117
Labels
bug Something isn't working

Comments

@test789t
Copy link

test789t commented Oct 13, 2022

Q A
auditor version 2.0.5
PHP version 8.1.2
Database MySQL

Summary

ErrorException

Warning: Object of class App\Enum\ProductType could not be converted to int

Current behavior

vendor\damienharper\auditor\src\Provider\Doctrine\Auditing\Transaction\AuditTrait.php&line=89#line89)(line 89)

https://github.com/DamienHarper/auditor/blob/master/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php#L88

Current code

case DoctrineHelper::getDoctrineType('INTEGER'):
case DoctrineHelper::getDoctrineType('SMALLINT'):
$convertedValue = (int) $value; // @phpstan-ignore-line
break;

Bug fixed

case DoctrineHelper::getDoctrineType('INTEGER'):
case DoctrineHelper::getDoctrineType('SMALLINT'):
$convertedValue = (int) ($value instanceof \BackedEnum ? $value->value : $value) ; // @phpstan-ignore-line
break;
@test789t test789t added the bug Something isn't working label Oct 13, 2022
@DamienHarper
Copy link
Owner

@test789t Thanks for the report. I'll have a look at it asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants