Skip to content

Override the date type in EntityColumnRuleTest for every data set - #798

Open
SanderMuller wants to merge 1 commit into
phpstan:2.0.xfrom
SanderMuller:deterministic-date-type
Open

SanderMuller wants to merge 1 commit into
phpstan:2.0.xfrom
SanderMuller:deterministic-date-type

Conversation

@SanderMuller

Copy link
Copy Markdown
Contributor

EntityColumnRuleTest::testRuleWithAllowedNullableProperty fails when its data set #1 (no object manager) runs before data set #0 (entity-manager.php). It reports an extra error:

49: Property PHPStan\Rules\Doctrine\ORM\MyBrokenEntity::$six type mapping mismatch: database can contain DateTime but property expects DateTimeImmutable.

entity-manager.php calls Type::overrideType('date', DateTimeImmutableType::class) for the whole process. The expected errors of the data sets without an object manager assume that override. These data sets only get it when a test that loads entity-manager.php ran before them. With executionOrder="random", that depends on the seed. This change sets the same override in getRule(), so every data set starts with the same type.

I saw the failure in the extension tests of phpstan/phpstan-src#6733 (seed 1791793640). I ran the test alone with seeds 1 to 8. Before this change, it failed for the 5 seeds that run data set #1 first. After the change, it passed for all 8.

🤖 Generated with Claude Code

entity-manager.php overrides the Doctrine date type for the whole
process. The data sets without an object manager expect that override,
but they only get it when a test that loads entity-manager.php ran
before them. With the random test order, testRuleWithAllowedNullableProperty
reported an extra error for MyBrokenEntity::$six when its data set phpstan#1
ran before data set #0.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@SanderMuller

SanderMuller commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

The red jobs are not from this change. Unchanged 2.0.x (7c51d06) fails the same 9 jobs today: https://github.com/SanderMuller/phpstan-doctrine/actions/runs/38228877932

  • The PHPStan (...) jobs report DoctrineSelectableDynamicReturnTypeExtensionTest.php:62 (Parameter #3 $scope).
  • Tests (8.3, highest, ...) and the PHPStan (8.3, ...) job with ORM 3 also fail on the Renovate run on 2.1.x from today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant