Type matching mismatch in child class with SINGLE TABLE INHERITANCE

Open
#493 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
32/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
databases

Research direction

Start with the Doctrine single-table-inheritance guidance quoted in the issue and trace where PHPStan Doctrine reports a type matching mismatch for child-class fields. Determine the expected behavior for non-nullable entity fields backed by nullable database columns, then add coverage showing that the mismatch is handled correctly.

Written by the indexing model from the issue text.

Description

Hi!

In the case of SINGLE TABLE INHERITANCE the doctrine documentation states that:

For Single-Table-Inheritance to work in scenarios where you are using either a legacy database schema or a self-written database schema you have to make sure that all columns that are not in the root entity but in any of the different sub-entities has to allow null values. Columns that have NOT NULL constraints have to be on the root entity of the single-table inheritance hierarchy.

So I think that the analysis shouldn't report an "type matching mismatch" for fields in child class that are not nullable even if the database field can be NULL.

What is your opinion on that matter?

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phpstan/phpstan-doctrine

All issues in phpstan/phpstan-doctrine

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.