Skip to content

[CodeQuality] Fix TypedPropertyFromColumnTypeRector numeric default on decimal/bigint - #522

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-decimal-string-default-value
Sep 8, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix-decimal-string-default-value

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Doctrine decimal and bigint map to a PHP string (see Doctrine basic mapping).

When such a property has a numeric default, the rule set the string type but left the int default, producing a fatal error:

Cannot use int as default value for property ... of type string

Now the numeric default is converted to its string form:

-private $totalShippingCostDec = 0;
+private string $totalShippingCostDec = '0';

Fixes rectorphp/rector#9894

https://claude.ai/code/session_018nXn7xBmuX9jrY8zZqgAxp

…n decimal/bigint string type

Doctrine decimal and bigint map to a PHP string. A numeric default like 0 stays
an int, producing a fatal 'Cannot use int as default value for property of type string'.
Convert the numeric default to its string form, eg: 0 to '0'.

Fixes rectorphp/rector#9894

Claude-Session: https://claude.ai/code/session_018nXn7xBmuX9jrY8zZqgAxp
@TomasVotruba
TomasVotruba merged commit 737829e into main Sep 8, 2026
7 checks passed
@TomasVotruba
TomasVotruba deleted the fix-decimal-string-default-value branch September 8, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

TypedPropertyFromColumnTypeRector treats doctrine type "decimal" as string

1 participant