Skip to content

Commit

Permalink
Fix detecting mapping with one line annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Jan 6, 2023
1 parent c9c3141 commit 359ba96
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DependencyInjection/AbstractDoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ private function detectMappingType(string $directory, ContainerBuilder $containe
break;
}
if (
preg_match('/^ \* @.*'.$quotedMappingObjectName.'\b/m', $content) ||
preg_match('/^ \* @.*Embeddable\b/m', $content)
preg_match('/^(?: \*|\/\*\*) @.*'.$quotedMappingObjectName.'\b/m', $content) ||
preg_match('/^(?: \*|\/\*\*) @.*Embeddable\b/m', $content)
) {
$type = 'annotation';
break;
Expand Down
1 change: 1 addition & 0 deletions Tests/DependencyInjection/DoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ public function testUnrecognizedCacheDriverException()
public function providerBundles()
{
yield ['AnnotationsBundle', 'annotation', '/Entity'];
yield ['AnnotationsOneLineBundle', 'annotation', '/Entity'];
yield ['FullEmbeddableAnnotationsBundle', 'annotation', '/Entity'];
if (\PHP_VERSION_ID >= 80000) {
yield ['AttributesBundle', 'attribute', '/Entity'];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Fixtures\Bundles\AnnotationsOneLineBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AnnotationsOneLineBundle extends Bundle
{
}
37 changes: 37 additions & 0 deletions Tests/Fixtures/Bundles/AnnotationsOneLineBundle/Entity/Person.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Fixtures\Bundles\AnnotationsOneLineBundle\Entity;

use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;

/** @Entity */
class Person
{
/** @Id @Column(type="integer") */
protected $id;

/** @Column(type="string") */
public $name;

public function __construct($id, $name)
{
$this->id = $id;
$this->name = $name;
}

public function __toString(): string
{
return (string) $this->name;
}
}

0 comments on commit 359ba96

Please sign in to comment.