Skip to content

Commit 73ecf23

Browse files
committed
minor #1064 [ci] use annotations when attributes are not supported (jrushlow)
This PR was merged into the 1.0-dev branch. Discussion ---------- [ci] use annotations when attributes are not supported `DoctrineBundle` `>=2.4`'s flex recipe uses attributes by default - regardless if you're using PHP < `8.0`. We need to use attributes in our tests by default unless doctrine and/or php does not support them. Commits ------- 00797b6 [ci] use annotations when attributes are not supported
2 parents 387c24d + 00797b6 commit 73ecf23

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/Maker/MakeEntityTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ private function createMakeEntityTest(bool $withDatabase = true): MakerTestDetai
3232
->preRun(function (MakerTestRunner $runner) use ($withDatabase) {
3333
$config = $runner->readYaml('config/packages/doctrine.yaml');
3434

35-
if (isset($config['doctrine']['orm']['mappings']['App']['type']) && $this->useAttributes($runner)) {
36-
// use attributes
37-
$runner->replaceInFile(
38-
'config/packages/doctrine.yaml',
39-
'type: annotation',
40-
'type: attribute'
41-
);
35+
/* @legacy Refactor when annotations are no longer supported. */
36+
if (isset($config['doctrine']['orm']['mappings']['App']) && !$this->useAttributes($runner)) {
37+
// Attributes are only supported w/ PHP 8, FrameworkBundle >=5.2,
38+
// ORM >=2.9, & DoctrineBundle >=2.4
39+
$runner->modifyYamlFile('config/packages/doctrine.yaml', function (array $data) {
40+
$data['doctrine']['orm']['mappings']['App']['type'] = 'annotation';
41+
42+
return $data;
43+
});
4244
}
4345

4446
if ($withDatabase) {

0 commit comments

Comments
 (0)