-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1025Labels
Milestone
Description
Bug report
When using a conditional path to build up the flags passed to json_encode, the JSON_THROW_ON_ERROR handling fails
Code snippet that reproduces the problem
https://phpstan.org/r/2c2248a1-cbf9-45b1-a346-85f0aca891fb
Expected output
string return value in both cases
Fix
Somewhere in https://github.com/phpstan/phpstan-src/blob/7667265bba564eb61711ad52376a6e7823708bda/src/Type/Php/JsonThrowOnErrorDynamicReturnTypeExtension.php#L85 it probably should handle the value as an int always, and simply check whether the int contains the bits from JSON_THROW_ON_ERROR, instead of checking for the constant's name.
mvorisek