You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
------ ----------------------------------------------------------------------------------------------------------
Line tests/database/FakerTest.php
------ ----------------------------------------------------------------------------------------------------------
49 Call to method PHPUnit\Framework\Assert::assertInstanceOf() with 'App\\Entities\\Dungeon' and array<int,
App\Entities\Dungeon> will always evaluate to false.
💡 Because the type is coming from a PHPDoc, you can turn off this check by setting
treatPhpDocTypesAsCertain: false in your phpstan.neon.dist.
------ ----------------------------------------------------------------------------------------------------------
Yes, because PHPStan does not know what really $monster is, the fetch of ->dungeon_id results in error.
A workaround is to add exhaustive tests.
publicfunctiontestMakesMonsterWithDungeon()
{
$monster = $this->fabricator->make();
$this->assertIsObject($monster);
$this->assertTrue(property_exists('dungeon_id', $monster));
$this->assertIsInt($monster->dungeon_id); // or assertIsString, whatever the case for this$dungeon = model(DungeonModel::class)->find($monster->dungeon_id);
$this->assertInstanceOf(Dungeon::class, $dungeon); // this should be fine, but if using strict-rules might still error
}
Activity
paulbalandan commentedon Feb 15, 2024
What is the dumped value of
\PHPStan\dumpType($monster->dungeon_id);kenjis commentedon Feb 15, 2024
This is an issue on
Fabricator::make(). It returnsarray|object.paulbalandan commentedon Feb 16, 2024
Yes, because PHPStan does not know what really
$monsteris, the fetch of->dungeon_idresults in error.A workaround is to add exhaustive tests.
paulbalandan commentedon Jun 15, 2026
Fixed in Fixed in https://github.com/CodeIgniter/phpstan-codeigniter/tree/v2.0.0