Skip to content

Commit

Permalink
fix cs/stan
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Feb 9, 2023
1 parent c68624e commit 47a0474
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/ReferenceSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ public function testReferenceWithObjectId(): void
]);

$integerWrappedType = new class() extends DbalTypes\Type {
/**
* TODO: Remove once DBAL 3.x support is dropped.
*/
public function getName(): string
{
return self::class;
Expand Down Expand Up @@ -338,20 +341,21 @@ public function getValue(): int
};
}
};
$integerWrappedTypeName = $integerWrappedType->getName(); // @phpstan-ignore-line

DbalTypes\Type::addType($integerWrappedType->getName(), get_class($integerWrappedType));
DbalTypes\Type::addType($integerWrappedTypeName, get_class($integerWrappedType));
try {
$file = new Model($this->db, ['table' => 'file']);
$file->getField('id')->type = $integerWrappedType->getName();
$file->getField('id')->type = $integerWrappedTypeName;
$file->addField('name');
$file->hasOne('parentDirectory', [
'model' => $file,
'type' => $integerWrappedType->getName(), // TODO should be implied from their model
'type' => $integerWrappedTypeName, // TODO should be implied from their model
'ourField' => 'parentDirectoryId',
]);
$file->hasMany('childFiles', [
'model' => $file,
'theirField' => 'parentDirectoryId'
'theirField' => 'parentDirectoryId',
]);

$fileEntity = $file->loadBy('name', 'v')->ref('childFiles')->createEntity();
Expand Down Expand Up @@ -399,9 +403,9 @@ public function getValue(): int
['id' => $createWrappedIntegerFx(2), 'name' => 'u', 'parentDirectoryId' => null],
], $fileEntity->getModel()->export());
} finally {
\Closure::bind(function () use ($integerWrappedType) {
\Closure::bind(function () use ($integerWrappedTypeName) {
$dbalTypeRegistry = DbalTypes\Type::getTypeRegistry();
unset($dbalTypeRegistry->instances[$integerWrappedType->getName()]);
unset($dbalTypeRegistry->instances[$integerWrappedTypeName]);
}, null, DbalTypes\TypeRegistry::class)();
}
}
Expand Down

0 comments on commit 47a0474

Please sign in to comment.