Skip to content

decimal column type no longer being declared as numeric #1738

@BrainStone

Description

@BrainStone

Versions:

  • ide-helper Version: 3.6.0
  • Laravel Version: 12.35.0
  • PHP Version: 8.4.13

Description:

Currently the decimal column type gets it's typehint as string instead of numeric as intended.

Compare with #1583 and #1582.

From what I understand decimal columns no longer have a cast associated with them but instead have a their own column type now.

So the check in the function

public function castPropertiesType($model)
no longer works (or no longer is enough) but instead/additionally the match statement here
$type = match ($column['type_name']) {
'tinyint', 'bit',
'integer', 'int', 'int4',
'smallint', 'int2',
'mediumint',
'bigint', 'int8' => 'int',
'boolean', 'bool' => 'bool',
'float', 'real', 'float4',
'double', 'float8' => 'float',
default => 'string',
};
needs and additional match for decimal, which then returns numeric.

I have locally tested adding the case 'decimal' => 'numeric' and now the generated type hints are working as intended.

Steps To Reproduce:

  • Get table with a decimal column
  • Generate model helpers
  • Check generated typehint (should be numeric, is string)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions