Invalid nullable property check for simple_array mapping type
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Read Doctrine DBAL's src/Types/SimpleArrayType.php around line 41, then locate the Doctrine ORM property type-mapping check in this repository. Confirm how nullable simple_array fields are represented before deciding the expected validation behavior. Done means the reported mismatch is handled correctly and a regression test covers a nullable database field with a non-nullable list property.
Written by the indexing model from the issue text.
Description
Doctrine DBAL always converts the database value to a PHP array, even when the field contains null. SimpleArrayType mapper converts the null value from DB to an empty PHP array.
However, when I put a not-nullable type hint for the simple_array mapping from the nullable DB field:
/**
* @var list<string>
* @ORM\Column(type="simple_array", nullable=true)
*/
private $simpleArrayFromNullableField;
PHPStan check produces an error:
Property PHPStan\Rules\Doctrine\ORM\MyEntity::$simpleArrayFromNullableField type mapping mismatch: database can contain list<string>|null but property expects list<string>.
- Dominant language
- PHP
- Stars
- 678
- Forks
- 122
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-doctrine
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
phpstan/phpstan-doctrine#785 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
phpstan/phpstan-doctrine#792 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
phpstan/phpstan-doctrine#788 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
phpstan/phpstan-doctrine#763 ·
All issues in phpstan/phpstan-doctrine
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100