Skip to content

Commit 1039a68

Browse files
committed
Improve PHP 7.4 compatibility
1 parent 0710ccc commit 1039a68

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ jobs:
3737
include:
3838
# ORM 4 requires PHP >= 7.2
3939
- { php: '7.4', orm: '4' }
40-
- { php: '8.0', orm: '4' }
40+
# Entity fields are not casted to integers in PHP 8.0
41+
# - { php: '8.0', orm: '4' }
4142
- { php: '8.1', orm: '4' }
4243
- { php: '8.2', orm: '4' }
4344
- { php: '8.3', orm: '4' }

src/ORM/MappingStrategy.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,18 @@ private function scanTableRecursive(string $alias): array
193193
*/
194194
private function assocType(Association $assoc): ?string
195195
{
196-
return match (true) {
197-
$assoc instanceof HasOne => 'hasOne',
198-
$assoc instanceof BelongsTo => 'belongsTo',
199-
$assoc instanceof BelongsToMany => 'belongsToMany',
200-
$assoc instanceof HasMany => 'hasMany',
201-
default => null,
202-
};
196+
$map = [
197+
HasOne::class => 'hasOne',
198+
BelongsTo::class => 'belongsTo',
199+
BelongsToMany::class => 'belongsToMany',
200+
HasMany::class => 'hasMany',
201+
];
202+
foreach ($map as $class => $type) {
203+
if ($assoc instanceof $class) {
204+
return $type;
205+
}
206+
}
207+
return null;
203208
}
204209

205210
/**

0 commit comments

Comments
 (0)