Add missing descriptors for SmallFloatType and EnumType#656
Conversation
2082cc3 to
2e8b2b6
Compare
| path: src/Type/Doctrine/Descriptors/SmallFloatType.php | ||
|
|
||
| - | ||
| message: '#^Class Doctrine\\DBAL\\Types\\EnumType not found\.$#' |
There was a problem hiding this comment.
At first, I tried adding new doctrine versions to composer.json, but it would require bigger effort to adjust this repo to support those everywhere, so I just referenced those not-yet-existing classes.
ondrejmirtes
left a comment
There was a problem hiding this comment.
- tests describing what this actually fixes would be nice
|
|
||
| namespace PHPStan\Type\Doctrine\Descriptors; | ||
|
|
||
| class SmallFloatType extends FloatType |
There was a problem hiding this comment.
Are you sure? I believe SmallFloatType IS FloatType in terms of type descriptor.
| use PHPStan\Type\StringType; | ||
| use PHPStan\Type\Type; | ||
|
|
||
| class EnumType implements DoctrineTypeDescriptor |
There was a problem hiding this comment.
Am I wrong or without this type the data is considered as mixed ?
Now with this, it will report error foo be 'A'|'B' but is string on level 8 because the values option is not considered in the following code
#[ORM\Column(name: 'foo', type: Types::ENUM, options: ['values' => ['A', 'B'])]
There was a problem hiding this comment.
Am I wrong or without this type the data is considered as mixed ?
You are correct.
It is pretty painful to test new doctrine here (due to all the compatibility hacks). But added. |
eca8f6c to
a59b33b
Compare
VincentLanglet
left a comment
There was a problem hiding this comment.
The enum type will introduce new false-positive.
Before
/**
* @Column(type="enum", options={"values"={"a", "b", "c"}})
* @var 'a'|'b'|'c'
*
public $enum;
Was reported level 9 (mixed is not 'a'|'b'|'c')
and now will be reported on a lower level (string is not 'a'|'b'|'c')
Would it be possible to read the options ?
Yes, implemented. |
Great. Could add a test for the EntityColumnRule too (I assume we just need to add an enum field in the BrokenEntity https://github.com/phpstan/phpstan-doctrine/blob/a1a9efb64708580a9d8b0d150340f7777d2b8aa0/tests/Rules/Doctrine/ORM/data/MyBrokenEntity.php) I assume that shouldn't be reported but should be reported |
|
Thank you. |
Uh oh!
There was an error while loading. Please reload this page.