8000 Fix detecting mapping with one line annotations · symfony/symfony@38c9b3a · GitHub
[go: up one dir, main page]

Skip to content

Commit 38c9b3a

Browse files
franmomujvmanji
authored andcommitted
Fix detecting mapping with one line annotations
1 parent 115588c commit 38c9b3a

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ private function detectMappingType(string $directory, ContainerBuilder $containe
318318
break;
319319
}
320320
if (
321-
preg_match('/^ \* @.*'.$quotedMappingObjectName.'\b/m', $content) ||
322-
preg_match('/^ \* @.*Embeddable\b/m', $content)
321+
preg_match('/^(?: \*|\/\*\*) @.*'.$quotedMappingObjectName.'\b/m', $content) ||
322+
preg_match('/^(?: \*|\/\*\*) @.*Embeddable\b/m', $content)
323323
) {
324324
$type = 'annotation';
325325
break;

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ public function testUnrecognizedCacheDriverException()
279279
public function providerBundles()
280280
{
281281
yield ['AnnotationsBundle', 'annotation', '/Entity'];
282+
yield ['AnnotationsOneLineBundle', 'annotation', '/Entity'];
282283
yield ['FullEmbeddableAnnotationsBundle', 'annotation', '/Entity'];
283284
if (\PHP_VERSION_ID >= 80000) {
284285
yield ['AttributesBundle', 'attribute', '/Entity'];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Fixtures\Bundles\AnnotationsOneLineBundle;
13+
14+
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
16+
class AnnotationsOneLineBundle extends Bundle
17+
{
18+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Fixtures\Bundles\AnnotationsOneLineBundle\Entity;
13+
14+
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Entity;
16+
use Doctrine\ORM\Mapping\Id;
17+
18+
/** @Entity */
19+
class Person
20+
{
21+
/** @Id @Column(type="integer") */
22+
protected $id;
23+
24+
/** @Column(type="string") */
25+
public $name;
26+
27+
public function __construct($id, $name)
28+
{
29+
$this->id = $id;
30+
$this->name = $name;
31+
}
32+
33+
public function __toString(): string
34+
{
35+
return (string) $this->name;
36+
}
37+
}

0 commit comments

Comments
 (0)
0