Skip to content

Commit

Permalink
more needs phpstan 7385
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jun 3, 2022
1 parent a401874 commit 2770d47
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tests/ModelPhpstanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ public function testVirtualInterfacesSimple(): void
$this->assertSamePhpstanType(Model::class, $entity->getModel());

if (PhpstanUtil::alwaysFalseAnalyseOnly()) {
$model->assertIsEntity();
$this->assertSamePhpstanType(Model::class . '&' . IsEntity::class, $model);
$model->assertIsModel();
$this->assertSamePhpstanType(Model::class, $model);

$entity = $model->load(1);
$this->assertSamePhpstanType(Model::class . '&' . IsLoaded::class, $entity);

$entity->unload();
// TODO must implement custom phpstan ext
// $this->assertSamePhpstanType(Model::class . '&' . IsEntity::class, $entity);
$this->assertSamePhpstanType(Model::class . '&' . IsEntity::class, $entity);
$entity->assertIsLoaded();
$this->assertSamePhpstanType(Model::class . '&' . IsLoaded::class, $entity);
$entity->assertIsEntity();
$this->assertSamePhpstanType(Model::class . '&' . IsLoaded::class, $entity);
}

// model and entity is mutually exclusive
Expand All @@ -50,12 +57,19 @@ public function testVirtualInterfacesUnion(): void
$this->assertSamePhpstanType(Female::class . '|' . Male::class, $entity->getModel());

if (PhpstanUtil::alwaysFalseAnalyseOnly()) {
$model->assertIsEntity();
$this->assertSamePhpstanType('(' . IsEntity::class . '&' . Female::class . ')|(' . IsEntity::class . '&' . Male::class . ')', $model);
$model->assertIsModel();
$this->assertSamePhpstanType(Female::class . '|' . Male::class, $model);

$entity = $model->load(1);
$this->assertSamePhpstanType('(' . IsLoaded::class . '&' . Female::class . ')|(' . IsLoaded::class . '&' . Male::class . ')', $entity);

$entity->unload();
// TODO must implement custom phpstan ext
// $this->assertSamePhpstanType('(' . IsEntity::class . '&' . Female::class . ')|(' . IsEntity::class . '&' . Male::class . ')', $entity);
$this->assertSamePhpstanType('(' . IsEntity::class . '&' . Female::class . ')|(' . IsEntity::class . '&' . Male::class . ')', $entity);
$entity->assertIsLoaded();
$this->assertSamePhpstanType('(' . IsLoaded::class . '&' . Female::class . ')|(' . IsLoaded::class . '&' . Male::class . ')', $entity);
$entity->assertIsEntity();
$this->assertSamePhpstanType('(' . IsLoaded::class . '&' . Female::class . ')|(' . IsLoaded::class . '&' . Male::class . ')', $entity);
}
}
}

0 comments on commit 2770d47

Please sign in to comment.